aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-03-22 01:50:58 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-03-22 01:50:58 -0600
commitc02dd9e040a5297c65677a80ca9a166b5e40b429 (patch)
tree5eb852649f23f576210d60fc160222c3f106ebd7 /ui
parentSettingsActivity: remove from parent instead of fixed screen (diff)
downloadwireguard-android-c02dd9e040a5297c65677a80ca9a166b5e40b429.tar.xz
wireguard-android-c02dd9e040a5297c65677a80ca9a166b5e40b429.zip
Preferences: hide advanced settings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt4
-rw-r--r--ui/src/main/res/xml/preferences.xml16
2 files changed, 11 insertions, 9 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 bfbbf504..10f74f55 100644
--- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
@@ -15,7 +15,6 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.wireguard.android.Application
import com.wireguard.android.R
-import com.wireguard.android.backend.Backend
import com.wireguard.android.backend.WgQuickBackend
import com.wireguard.android.util.ModuleLoader
import java.util.ArrayList
@@ -77,9 +76,11 @@ class SettingsActivity : ThemeChangeAwareActivity() {
class SettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, key: String?) {
addPreferencesFromResource(R.xml.preferences)
+ preferenceScreen.initialExpandedChildrenCount = 4
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val darkTheme = preferenceManager.findPreference<Preference>("dark_theme")
darkTheme?.parent?.removePreference(darkTheme)
+ --preferenceScreen.initialExpandedChildrenCount
}
val wgQuickOnlyPrefs = arrayOf(
preferenceManager.findPreference("tools_installer"),
@@ -89,6 +90,7 @@ class SettingsActivity : ThemeChangeAwareActivity() {
wgQuickOnlyPrefs.forEach { it.isVisible = false }
Application.getBackendAsync().thenAccept { backend ->
if (backend is WgQuickBackend) {
+ ++preferenceScreen.initialExpandedChildrenCount
wgQuickOnlyPrefs.forEach { it.isVisible = true }
} else {
wgQuickOnlyPrefs.forEach { it.parent?.removePreference(it) }
diff --git a/ui/src/main/res/xml/preferences.xml b/ui/src/main/res/xml/preferences.xml
index 0f674108..4668fab4 100644
--- a/ui/src/main/res/xml/preferences.xml
+++ b/ui/src/main/res/xml/preferences.xml
@@ -7,14 +7,6 @@
android:summaryOn="@string/restore_on_boot_summary_on"
android:summaryOff="@string/restore_on_boot_summary_off"
android:title="@string/restore_on_boot_title" />
- <CheckBoxPreference
- android:defaultValue="false"
- android:key="multiple_tunnels"
- android:summaryOff="@string/multiple_tunnels_summary_off"
- android:summaryOn="@string/multiple_tunnels_summary_on"
- android:title="@string/multiple_tunnels_title" />
- <com.wireguard.android.preference.ModuleDownloaderPreference android:key="module_downloader" />
- <com.wireguard.android.preference.ToolsInstallerPreference android:key="tools_installer" />
<com.wireguard.android.preference.ZipExporterPreference />
<com.wireguard.android.preference.LogExporterPreference />
<CheckBoxPreference
@@ -23,6 +15,14 @@
android:summaryOff="@string/dark_theme_summary_off"
android:summaryOn="@string/dark_theme_summary_on"
android:title="@string/dark_theme_title" />
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:key="multiple_tunnels"
+ android:summaryOff="@string/multiple_tunnels_summary_off"
+ android:summaryOn="@string/multiple_tunnels_summary_on"
+ android:title="@string/multiple_tunnels_title" />
+ <com.wireguard.android.preference.ModuleDownloaderPreference android:key="module_downloader" />
+ <com.wireguard.android.preference.ToolsInstallerPreference android:key="tools_installer" />
<com.wireguard.android.preference.KernelModuleDisablerPreference android:key="kernel_module_disabler" />
<CheckBoxPreference
android:defaultValue="false"