mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Disable all icons other than the active one.
This commit is contained in:
committed by
Nicholas
parent
fd826749e4
commit
52060b65be
@@ -21,14 +21,20 @@ class AppIconUtility(context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun currentAppIconComponentName(): ComponentName {
|
fun currentAppIconComponentName(): ComponentName {
|
||||||
return currentAppIcon.getComponentName(applicationContext) ?: AppIconPreset.DEFAULT.getComponentName(applicationContext)
|
return currentAppIcon.getComponentName(applicationContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setNewAppIcon(desiredAppIcon: AppIconPreset) {
|
fun setNewAppIcon(desiredAppIcon: AppIconPreset) {
|
||||||
currentAppIcon.let {
|
Log.d(TAG, "Setting new app icon.")
|
||||||
pm.setComponentEnabledSetting(it.getComponentName(applicationContext), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
|
|
||||||
}
|
|
||||||
pm.setComponentEnabledSetting(desiredAppIcon.getComponentName(applicationContext), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP)
|
pm.setComponentEnabledSetting(desiredAppIcon.getComponentName(applicationContext), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP)
|
||||||
|
Log.d(TAG, "${desiredAppIcon.name} enabled.")
|
||||||
|
val previousAppIcon = currentAppIcon
|
||||||
|
pm.setComponentEnabledSetting(previousAppIcon.getComponentName(applicationContext), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
|
||||||
|
Log.d(TAG, "${previousAppIcon.name} disabled.")
|
||||||
|
enumValues<AppIconPreset>().filterNot { it == desiredAppIcon || it == previousAppIcon }.forEach {
|
||||||
|
pm.setComponentEnabledSetting(it.getComponentName(applicationContext), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
|
||||||
|
Log.d(TAG, "${it.name} disabled.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun readCurrentAppIconFromPackageManager(): AppIconPreset {
|
private fun readCurrentAppIconFromPackageManager(): AppIconPreset {
|
||||||
|
|||||||
Reference in New Issue
Block a user