From 52060b65be47f1b18f15b8f20d95438c698cf060 Mon Sep 17 00:00:00 2001 From: Nicholas Tinsley Date: Wed, 24 May 2023 11:29:37 -0400 Subject: [PATCH] Disable all icons other than the active one. --- .../app/appearance/appicon/util/AppIconUtility.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/appearance/appicon/util/AppIconUtility.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/appearance/appicon/util/AppIconUtility.kt index 7598db44ba..a84c925f0d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/appearance/appicon/util/AppIconUtility.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/appearance/appicon/util/AppIconUtility.kt @@ -21,14 +21,20 @@ class AppIconUtility(context: Context) { } fun currentAppIconComponentName(): ComponentName { - return currentAppIcon.getComponentName(applicationContext) ?: AppIconPreset.DEFAULT.getComponentName(applicationContext) + return currentAppIcon.getComponentName(applicationContext) } fun setNewAppIcon(desiredAppIcon: AppIconPreset) { - currentAppIcon.let { - pm.setComponentEnabledSetting(it.getComponentName(applicationContext), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP) - } + Log.d(TAG, "Setting new app icon.") 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().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 {