summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-03-22 01:23:23 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-03-22 01:23:23 -0600
commit7dae94976d2b9d70c2d3ce8e75641d790b4af70e (patch)
treec74bbee0b9461bfa91748e0edbf2f48ca86d2422 /ui/src/main/java/com/wireguard
parent38c360cb742d0688456cff1da7a37426dba80cc5 (diff)
SettingsActivity: remove from parent instead of fixed screen
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt14
1 files changed, 8 insertions, 6 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
index a6bdb187..bfbbf504 100644
--- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
@@ -77,8 +77,10 @@ class SettingsActivity : ThemeChangeAwareActivity() {
class SettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, key: String?) {
addPreferencesFromResource(R.xml.preferences)
- val screen = preferenceScreen
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) screen.removePreference(preferenceManager.findPreference("dark_theme"))
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val darkTheme = preferenceManager.findPreference<Preference>("dark_theme")
+ darkTheme?.parent?.removePreference(darkTheme)
+ }
val wgQuickOnlyPrefs = arrayOf(
preferenceManager.findPreference("tools_installer"),
preferenceManager.findPreference("restore_on_boot"),
@@ -89,21 +91,21 @@ class SettingsActivity : ThemeChangeAwareActivity() {
if (backend is WgQuickBackend) {
wgQuickOnlyPrefs.forEach { it.isVisible = true }
} else {
- wgQuickOnlyPrefs.forEach { screen.removePreference(it) }
+ wgQuickOnlyPrefs.forEach { it.parent?.removePreference(it) }
}
}
val moduleInstaller = preferenceManager.findPreference<Preference>("module_downloader")
val kernelModuleDisabler = preferenceManager.findPreference<Preference>("kernel_module_disabler")
moduleInstaller?.isVisible = false
if (ModuleLoader.isModuleLoaded()) {
- screen.removePreference(moduleInstaller)
+ moduleInstaller?.parent?.removePreference(moduleInstaller)
} else {
- screen.removePreference(kernelModuleDisabler)
+ kernelModuleDisabler?.parent?.removePreference(kernelModuleDisabler)
Application.getAsyncWorker().runAsync(Application.getRootShell()::start).whenComplete { _, e ->
if (e == null)
moduleInstaller?.isVisible = true
else
- screen.removePreference(moduleInstaller)
+ moduleInstaller?.parent?.removePreference(moduleInstaller)
}
}
}