show the placeholder if no icons are hidden
This commit is contained in:
parent
68cf94bd74
commit
6833d5c9b3
|
@ -3,9 +3,11 @@ package com.simplemobiletools.launcher.activities
|
|||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.normalizeString
|
||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||
import com.simplemobiletools.launcher.R
|
||||
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
|
||||
|
@ -15,7 +17,7 @@ import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
|||
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||
import kotlinx.android.synthetic.main.activity_hidden_icons.*
|
||||
|
||||
class HiddenIconsActivity : SimpleActivity() {
|
||||
class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_hidden_icons)
|
||||
|
@ -40,25 +42,32 @@ class HiddenIconsActivity : SimpleActivity() {
|
|||
})
|
||||
).toMutableList() as ArrayList<HiddenIcon>
|
||||
|
||||
val intent = Intent(Intent.ACTION_MAIN, null)
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
manage_hidden_icons_placeholder.beVisibleIf(hiddenIcons.isEmpty())
|
||||
if (hiddenIcons.isNotEmpty()) {
|
||||
val intent = Intent(Intent.ACTION_MAIN, null)
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
|
||||
val list = packageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)
|
||||
for (info in list) {
|
||||
val componentInfo = info.activityInfo.applicationInfo
|
||||
val packageName = componentInfo.packageName
|
||||
val activityName = info.activityInfo.name
|
||||
hiddenIcons.firstOrNull { it.getIconIdentifier() == "$packageName/$activityName" }?.apply {
|
||||
drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName)
|
||||
val list = packageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)
|
||||
for (info in list) {
|
||||
val componentInfo = info.activityInfo.applicationInfo
|
||||
val packageName = componentInfo.packageName
|
||||
val activityName = info.activityInfo.name
|
||||
hiddenIcons.firstOrNull { it.getIconIdentifier() == "$packageName/$activityName" }?.apply {
|
||||
drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
HiddenIconsAdapter(this, hiddenIcons, manage_hidden_icons_list) {
|
||||
HiddenIconsAdapter(this, hiddenIcons, this, manage_hidden_icons_list) {
|
||||
}.apply {
|
||||
manage_hidden_icons_list.adapter = this
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun refreshItems() {
|
||||
updateIcons()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||
import com.simplemobiletools.commons.extensions.portrait
|
||||
import com.simplemobiletools.commons.extensions.realScreenSize
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.launcher.R
|
||||
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
||||
|
@ -21,6 +22,7 @@ import kotlinx.android.synthetic.main.item_hidden_icon.view.*
|
|||
class HiddenIconsAdapter(
|
||||
activity: BaseSimpleActivity,
|
||||
var hiddenIcons: ArrayList<HiddenIcon>,
|
||||
val listener: RefreshRecyclerViewListener,
|
||||
recyclerView: MyRecyclerView,
|
||||
itemClick: (Any) -> Unit
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
|
@ -77,6 +79,9 @@ class HiddenIconsAdapter(
|
|||
|
||||
activity.runOnUiThread {
|
||||
removeSelectedItems(positions)
|
||||
if (hiddenIcons.isEmpty()) {
|
||||
listener.refreshItems()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue