mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-02-18 12:30:38 +01:00
remove hidden icons with a fade animation
This commit is contained in:
parent
6833d5c9b3
commit
54b4b46da3
@ -56,6 +56,10 @@ class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName)
|
drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hiddenIcons.firstOrNull { it.packageName == applicationContext.packageName }?.apply {
|
||||||
|
drawable = getDrawableForPackageName(packageName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
|
@ -573,7 +573,10 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val hiddenIcon = HiddenIcon(null, item.packageName, item.activityName, item.title, null)
|
val hiddenIcon = HiddenIcon(null, item.packageName, item.activityName, item.title, null)
|
||||||
hiddenIconsDB.insert(hiddenIcon)
|
hiddenIconsDB.insert(hiddenIcon)
|
||||||
refetchLaunchers()
|
|
||||||
|
runOnUiThread {
|
||||||
|
(all_apps_fragment as AllAppsFragment).hideIcon(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ class HiddenIconsAdapter(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
calculateIconWidth()
|
calculateIconWidth()
|
||||||
|
setupDragListener(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getActionMenuId() = R.menu.cab_hidden_icons
|
override fun getActionMenuId() = R.menu.cab_hidden_icons
|
||||||
|
@ -17,6 +17,7 @@ import com.simplemobiletools.launcher.R
|
|||||||
import com.simplemobiletools.launcher.activities.SimpleActivity
|
import com.simplemobiletools.launcher.activities.SimpleActivity
|
||||||
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
||||||
import com.simplemobiletools.launcher.models.AppLauncher
|
import com.simplemobiletools.launcher.models.AppLauncher
|
||||||
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
||||||
|
|
||||||
class LaunchersAdapter(
|
class LaunchersAdapter(
|
||||||
@ -58,6 +59,15 @@ class LaunchersAdapter(
|
|||||||
iconPadding = (iconWidth * 0.1f).toInt()
|
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>) {
|
fun updateItems(newItems: ArrayList<AppLauncher>) {
|
||||||
val oldSum = launchers.sumOf { it.getHashToCompare() }
|
val oldSum = launchers.sumOf { it.getHashToCompare() }
|
||||||
val newSum = newItems.sumOf { it.getHashToCompare() }
|
val newSum = newItems.sumOf { it.getHashToCompare() }
|
||||||
|
@ -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) {
|
fun setupViews(addTopPadding: Boolean = hasTopPadding) {
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return
|
return
|
||||||
|
@ -44,4 +44,6 @@ data class HomeScreenGridItem(
|
|||||||
} else {
|
} else {
|
||||||
bottom - top + 1
|
bottom - top + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getItemIdentifier() = "$packageName/$activityName"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user