From c02dd9e040a5297c65677a80ca9a166b5e40b429 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 22 Mar 2020 01:50:58 -0600 Subject: Preferences: hide advanced settings Signed-off-by: Jason A. Donenfeld --- ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ui/src/main/java/com/wireguard') 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("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) } -- cgit v1.2.3