-
-
Save KatieBarnett/cdc519a486db12fb2416a0cba696086a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class IconStatus { | |
DEFAULT, DARK | |
} | |
fun updateAppIcon(packageManager: PackageManager, status: IconStatus) { | |
for (value in IconStatus.values()) { | |
val action = if (value == status) { | |
PackageManager.COMPONENT_ENABLED_STATE_ENABLED | |
} else { | |
PackageManager.COMPONENT_ENABLED_STATE_DISABLED | |
} | |
packageManager.setComponentEnabledSetting( | |
ComponentName(BuildConfig.APPLICATION_ID, "${BuildConfig.APPLICATION_ID}.${value.name}"), | |
action, PackageManager.DONT_KILL_APP | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment