fix: double setting page in theme settings
This commit is contained in:
parent
3fd01d582a
commit
d2127f92a1
1 changed files with 17 additions and 10 deletions
|
@ -27,7 +27,7 @@ import eltos.simpledialogfragment.color.SimpleColorDialog
|
||||||
|
|
||||||
class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListener {
|
class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListener {
|
||||||
private lateinit var binding: ActivitySettingsThemeBinding
|
private lateinit var binding: ActivitySettingsThemeBinding
|
||||||
|
private var reload = false
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
ThemeManager(this).applyTheme()
|
ThemeManager(this).applyTheme()
|
||||||
|
@ -41,16 +41,22 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi
|
||||||
bottomMargin = navBarHeight
|
bottomMargin = navBarHeight
|
||||||
}
|
}
|
||||||
onBackPressedDispatcher.addCallback(context) {
|
onBackPressedDispatcher.addCallback(context) {
|
||||||
val mainIntent = Intent.makeRestartActivityTask(
|
if (reload) {
|
||||||
packageManager.getLaunchIntentForPackage(packageName)!!.component
|
val packageName = context.packageName
|
||||||
)
|
val mainIntent = Intent.makeRestartActivityTask(
|
||||||
val component = ComponentName(packageName, SettingsActivity::class.qualifiedName!!)
|
packageManager.getLaunchIntentForPackage(packageName)!!.component
|
||||||
try {
|
)
|
||||||
startActivity(Intent().setComponent(component))
|
val component = ComponentName(packageName, SettingsActivity::class.qualifiedName!!)
|
||||||
} catch (anything: Exception) {
|
try {
|
||||||
startActivity(mainIntent)
|
startActivity(Intent().setComponent(component))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
startActivity(mainIntent)
|
||||||
|
}
|
||||||
|
finishAndRemoveTask()
|
||||||
|
reload = false
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
finishAndRemoveTask()
|
|
||||||
}
|
}
|
||||||
themeSettingsBack.setOnClickListener {
|
themeSettingsBack.setOnClickListener {
|
||||||
onBackPressedDispatcher.onBackPressed()
|
onBackPressedDispatcher.onBackPressed()
|
||||||
|
@ -205,6 +211,7 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi
|
||||||
fun reload() {
|
fun reload() {
|
||||||
PrefManager.setCustomVal("reload", true)
|
PrefManager.setCustomVal("reload", true)
|
||||||
restartApp()
|
restartApp()
|
||||||
|
reload = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue