properly show the launcher icon when appropriate, whatever color it has
This commit is contained in:
parent
b4d6bcb2c2
commit
382b8abee0
|
@ -1,26 +1,31 @@
|
||||||
package com.simplemobiletools.thankyou.activities
|
package com.simplemobiletools.thankyou.activities
|
||||||
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.commons.extensions.getAppIconColors
|
||||||
|
import com.simplemobiletools.commons.extensions.toggleAppIconColor
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
|
import com.simplemobiletools.thankyou.BuildConfig
|
||||||
import com.simplemobiletools.thankyou.R
|
import com.simplemobiletools.thankyou.R
|
||||||
import com.simplemobiletools.thankyou.extensions.config
|
import com.simplemobiletools.thankyou.extensions.config
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
private var storedAppIconColor = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(R.layout.activity_settings)
|
||||||
|
storeStateVariables()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
|
checkAppIconColorChange(storedAppIconColor, BuildConfig.APPLICATION_ID)
|
||||||
|
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
setupUseEnglish()
|
setupUseEnglish()
|
||||||
setupAvoidWhatsNew()
|
setupAvoidWhatsNew()
|
||||||
|
@ -28,6 +33,17 @@ class SettingsActivity : SimpleActivity() {
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
storeStateVariables()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun storeStateVariables() {
|
||||||
|
config.apply {
|
||||||
|
storedAppIconColor = appIconColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
settings_customize_colors_holder.setOnClickListener {
|
settings_customize_colors_holder.setOnClickListener {
|
||||||
startCustomizationActivity()
|
startCustomizationActivity()
|
||||||
|
@ -69,8 +85,9 @@ class SettingsActivity : SimpleActivity() {
|
||||||
settings_hide_launcher_icon.toggle()
|
settings_hide_launcher_icon.toggle()
|
||||||
config.hideLauncherIcon = settings_hide_launcher_icon.isChecked
|
config.hideLauncherIcon = settings_hide_launcher_icon.isChecked
|
||||||
|
|
||||||
val componentName = ComponentName(this, SplashActivity::class.java)
|
val appId = BuildConfig.APPLICATION_ID
|
||||||
val state = if (config.hideLauncherIcon) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
getAppIconColors().forEachIndexed { index, color ->
|
||||||
packageManager.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP)
|
toggleAppIconColor(appId, index, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue