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 {
|
||||
private lateinit var binding: ActivitySettingsThemeBinding
|
||||
|
||||
private var reload = false
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
|
@ -41,16 +41,22 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi
|
|||
bottomMargin = navBarHeight
|
||||
}
|
||||
onBackPressedDispatcher.addCallback(context) {
|
||||
if (reload) {
|
||||
val packageName = context.packageName
|
||||
val mainIntent = Intent.makeRestartActivityTask(
|
||||
packageManager.getLaunchIntentForPackage(packageName)!!.component
|
||||
)
|
||||
val component = ComponentName(packageName, SettingsActivity::class.qualifiedName!!)
|
||||
try {
|
||||
startActivity(Intent().setComponent(component))
|
||||
} catch (anything: Exception) {
|
||||
} catch (e: Exception) {
|
||||
startActivity(mainIntent)
|
||||
}
|
||||
finishAndRemoveTask()
|
||||
reload = false
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
themeSettingsBack.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
|
@ -205,6 +211,7 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi
|
|||
fun reload() {
|
||||
PrefManager.setCustomVal("reload", true)
|
||||
restartApp()
|
||||
reload = true
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue