remove hidden icons with a fade animation

This commit is contained in:
tibbi 2022-10-26 16:56:13 +02:00
parent 6833d5c9b3
commit 54b4b46da3
6 changed files with 25 additions and 1 deletions

View File

@ -56,6 +56,10 @@ class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName)
}
}
hiddenIcons.firstOrNull { it.packageName == applicationContext.packageName }?.apply {
drawable = getDrawableForPackageName(packageName)
}
}
runOnUiThread {

View File

@ -573,7 +573,10 @@ class MainActivity : SimpleActivity(), FlingListener {
ensureBackgroundThread {
val hiddenIcon = HiddenIcon(null, item.packageName, item.activityName, item.title, null)
hiddenIconsDB.insert(hiddenIcon)
refetchLaunchers()
runOnUiThread {
(all_apps_fragment as AllAppsFragment).hideIcon(item)
}
}
}

View File

@ -31,6 +31,7 @@ class HiddenIconsAdapter(
init {
calculateIconWidth()
setupDragListener(true)
}
override fun getActionMenuId() = R.menu.cab_hidden_icons

View File

@ -17,6 +17,7 @@ import com.simplemobiletools.launcher.R
import com.simplemobiletools.launcher.activities.SimpleActivity
import com.simplemobiletools.launcher.interfaces.AllAppsListener
import com.simplemobiletools.launcher.models.AppLauncher
import com.simplemobiletools.launcher.models.HomeScreenGridItem
import kotlinx.android.synthetic.main.item_launcher_label.view.*
class LaunchersAdapter(
@ -58,6 +59,15 @@ class LaunchersAdapter(
iconPadding = (iconWidth * 0.1f).toInt()
}
fun hideIcon(item: HomeScreenGridItem) {
val itemToRemove = launchers.firstOrNull { it.getLauncherIdentifier() == item.getItemIdentifier() }
if (itemToRemove != null) {
val position = launchers.indexOf(itemToRemove)
launchers.remove(itemToRemove)
notifyItemRemoved(position)
}
}
fun updateItems(newItems: ArrayList<AppLauncher>) {
val oldSum = launchers.sumOf { it.getHashToCompare() }
val newSum = newItems.sumOf { it.getHashToCompare() }

View File

@ -117,6 +117,10 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
}
}
fun hideIcon(item: HomeScreenGridItem) {
(all_apps_grid.adapter as? LaunchersAdapter)?.hideIcon(item)
}
fun setupViews(addTopPadding: Boolean = hasTopPadding) {
if (activity == null) {
return

View File

@ -44,4 +44,6 @@ data class HomeScreenGridItem(
} else {
bottom - top + 1
}
fun getItemIdentifier() = "$packageName/$activityName"
}