mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-24 22:58:45 +02:00
Merge pull request #143 from Naveen3Singh/placeholder
Show a placeholder when no icons are shown
This commit is contained in:
commit
015d965660
@ -37,18 +37,14 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
|
setupEmptyView()
|
||||||
setupLaunchers()
|
setupLaunchers()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
setupGridLayoutManager()
|
setupGridLayoutManager()
|
||||||
|
|
||||||
fab.setOnClickListener {
|
fab.setOnClickListener {
|
||||||
if (allLaunchers != null) {
|
fabClicked()
|
||||||
val shownLaunchers = (launchers_grid.adapter as LaunchersAdapter).launchers
|
|
||||||
AddLaunchersDialog(this, allLaunchers!!, shownLaunchers) {
|
|
||||||
setupLaunchers()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +54,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
getGridAdapter()?.updateTextColor(getProperTextColor())
|
getGridAdapter()?.updateTextColor(getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStoredPrimaryColor != getProperPrimaryColor()) {
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
|
if (mStoredPrimaryColor != properPrimaryColor) {
|
||||||
getGridAdapter()?.apply {
|
getGridAdapter()?.apply {
|
||||||
updatePrimaryColor()
|
updatePrimaryColor()
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
@ -66,7 +63,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTextColors(coordinator_layout)
|
updateTextColors(coordinator_layout)
|
||||||
launchers_fastscroller.updateColors(getProperPrimaryColor())
|
add_icons_placeholder.setTextColor(properPrimaryColor)
|
||||||
|
launchers_fastscroller.updateColors(properPrimaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -126,13 +124,19 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
checkInvalidApps()
|
checkInvalidApps()
|
||||||
initZoomListener()
|
initZoomListener()
|
||||||
setupAdapter(displayedLaunchers)
|
setupAdapter(displayedLaunchers)
|
||||||
|
maybeShowEmptyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
||||||
AppLauncher.sorting = config.sorting
|
AppLauncher.sorting = config.sorting
|
||||||
launchers.sort()
|
launchers.sort()
|
||||||
|
|
||||||
LaunchersAdapter(this, launchers, this, launchers_grid) {
|
LaunchersAdapter(
|
||||||
|
activity = this,
|
||||||
|
launchers = launchers,
|
||||||
|
listener = this,
|
||||||
|
recyclerView = launchers_grid,
|
||||||
|
) {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName)
|
val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName)
|
||||||
if (launchIntent != null) {
|
if (launchIntent != null) {
|
||||||
@ -256,4 +260,33 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
checkWhatsNew(this, BuildConfig.VERSION_CODE)
|
checkWhatsNew(this, BuildConfig.VERSION_CODE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun fabClicked() {
|
||||||
|
if (allLaunchers != null) {
|
||||||
|
val shownLaunchers = (launchers_grid.adapter as LaunchersAdapter).launchers
|
||||||
|
AddLaunchersDialog(this, allLaunchers!!, shownLaunchers) {
|
||||||
|
setupLaunchers()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupEmptyView() {
|
||||||
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
|
add_icons_placeholder.underlineText()
|
||||||
|
add_icons_placeholder.setTextColor(properPrimaryColor)
|
||||||
|
add_icons_placeholder.setOnClickListener {
|
||||||
|
fabClicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun maybeShowEmptyView() {
|
||||||
|
val emptyViews = arrayOf(add_icons_placeholder, no_items_placeholder)
|
||||||
|
if (displayedLaunchers.isEmpty()) {
|
||||||
|
launchers_fastscroller.fadeOut()
|
||||||
|
emptyViews.forEach { it.fadeIn() }
|
||||||
|
} else {
|
||||||
|
emptyViews.forEach { it.fadeOut() }
|
||||||
|
launchers_fastscroller.fadeIn()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,11 @@ import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class LaunchersAdapter(
|
class LaunchersAdapter(
|
||||||
activity: SimpleActivity, val launchers: ArrayList<AppLauncher>, val listener: RefreshRecyclerViewListener?,
|
activity: SimpleActivity,
|
||||||
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
|
val launchers: ArrayList<AppLauncher>,
|
||||||
|
val listener: RefreshRecyclerViewListener,
|
||||||
|
recyclerView: MyRecyclerView,
|
||||||
|
itemClick: (Any) -> Unit
|
||||||
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate {
|
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||||
|
|
||||||
private var isChangingOrder = false
|
private var isChangingOrder = false
|
||||||
@ -125,7 +128,7 @@ class LaunchersAdapter(
|
|||||||
private fun showEditDialog() {
|
private fun showEditDialog() {
|
||||||
EditDialog(activity, getItemWithKey(selectedKeys.first())!!) {
|
EditDialog(activity, getItemWithKey(selectedKeys.first())!!) {
|
||||||
finishActMode()
|
finishActMode()
|
||||||
listener?.refreshItems()
|
listener.refreshItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,10 +174,13 @@ class LaunchersAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
launchers.removeAll(removeLaunchers)
|
launchers.removeAll(removeLaunchers.toSet())
|
||||||
activity.dbHelper.deleteLaunchers(removeIds)
|
activity.dbHelper.deleteLaunchers(removeIds)
|
||||||
positions.sortDescending()
|
positions.sortDescending()
|
||||||
removeSelectedItems(positions)
|
removeSelectedItems(positions)
|
||||||
|
if (launchers.isEmpty()) {
|
||||||
|
listener?.refreshItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, launcher: AppLauncher, holder: ViewHolder) {
|
private fun setupView(view: View, launcher: AppLauncher, holder: ViewHolder) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/coordinator_layout"
|
android:id="@+id/coordinator_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -10,6 +11,36 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/no_items_placeholder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:alpha="0.8"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingStart="@dimen/activity_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
android:paddingEnd="@dimen/activity_margin"
|
||||||
|
android:text="@string/no_items_found"
|
||||||
|
android:textSize="@dimen/bigger_text_size"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/add_icons_placeholder"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/no_items_placeholder"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:background="@drawable/ripple_all_corners"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="@dimen/activity_margin"
|
||||||
|
android:text="@string/manage_visible_app_icons"
|
||||||
|
android:textSize="@dimen/bigger_text_size"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
android:id="@+id/launchers_fastscroller"
|
android:id="@+id/launchers_fastscroller"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user