diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt index 7c1ed9fab..8b0060f55 100644 --- a/app/src/main/java/com/github/libretube/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt @@ -37,6 +37,7 @@ import org.json.JSONTokener import retrofit2.HttpException private var isCurrentViewMainSettings = true +private var requireMainActivityRestart = false class SettingsActivity : AppCompatActivity(), @@ -243,11 +244,13 @@ class SettingsActivity : themeToggle?.setOnPreferenceChangeListener { _, _ -> val refresh = Intent(context, SettingsActivity::class.java) startActivity(refresh) + requireMainActivityRestart = true true } val accentColor = findPreference("accent_color") accentColor?.setOnPreferenceChangeListener { _, _ -> + requireMainActivityRestart = true val refresh = Intent(context, SettingsActivity::class.java) startActivity(refresh) true @@ -259,9 +262,9 @@ class SettingsActivity : true } - val changeLanguage = findPreference("language") - changeLanguage?.setOnPreferenceChangeListener { _, _ -> - restartMainActivity(requireContext()) + val gridColumns = findPreference("grid") + gridColumns?.setOnPreferenceChangeListener { _, _ -> + requireMainActivityRestart = true true } @@ -384,7 +387,13 @@ class SettingsActivity : if (isCurrentViewMainSettings) { PreferenceManager.getDefaultSharedPreferences(this) .unregisterOnSharedPreferenceChangeListener(this) - restartMainActivity(this) + if (requireMainActivityRestart) { + restartMainActivity(this) + finishAffinity() + } else { + super.onBackPressed() + } + finishAndRemoveTask() } else { isCurrentViewMainSettings = true supportFragmentManager