Preferences: hide advanced settings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
7dae94976d
commit
c02dd9e040
@ -15,7 +15,6 @@ import androidx.preference.Preference
|
|||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import com.wireguard.android.Application
|
import com.wireguard.android.Application
|
||||||
import com.wireguard.android.R
|
import com.wireguard.android.R
|
||||||
import com.wireguard.android.backend.Backend
|
|
||||||
import com.wireguard.android.backend.WgQuickBackend
|
import com.wireguard.android.backend.WgQuickBackend
|
||||||
import com.wireguard.android.util.ModuleLoader
|
import com.wireguard.android.util.ModuleLoader
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
@ -77,9 +76,11 @@ class SettingsActivity : ThemeChangeAwareActivity() {
|
|||||||
class SettingsFragment : PreferenceFragmentCompat() {
|
class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, key: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, key: String?) {
|
||||||
addPreferencesFromResource(R.xml.preferences)
|
addPreferencesFromResource(R.xml.preferences)
|
||||||
|
preferenceScreen.initialExpandedChildrenCount = 4
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
val darkTheme = preferenceManager.findPreference<Preference>("dark_theme")
|
val darkTheme = preferenceManager.findPreference<Preference>("dark_theme")
|
||||||
darkTheme?.parent?.removePreference(darkTheme)
|
darkTheme?.parent?.removePreference(darkTheme)
|
||||||
|
--preferenceScreen.initialExpandedChildrenCount
|
||||||
}
|
}
|
||||||
val wgQuickOnlyPrefs = arrayOf(
|
val wgQuickOnlyPrefs = arrayOf(
|
||||||
preferenceManager.findPreference("tools_installer"),
|
preferenceManager.findPreference("tools_installer"),
|
||||||
@ -89,6 +90,7 @@ class SettingsActivity : ThemeChangeAwareActivity() {
|
|||||||
wgQuickOnlyPrefs.forEach { it.isVisible = false }
|
wgQuickOnlyPrefs.forEach { it.isVisible = false }
|
||||||
Application.getBackendAsync().thenAccept { backend ->
|
Application.getBackendAsync().thenAccept { backend ->
|
||||||
if (backend is WgQuickBackend) {
|
if (backend is WgQuickBackend) {
|
||||||
|
++preferenceScreen.initialExpandedChildrenCount
|
||||||
wgQuickOnlyPrefs.forEach { it.isVisible = true }
|
wgQuickOnlyPrefs.forEach { it.isVisible = true }
|
||||||
} else {
|
} else {
|
||||||
wgQuickOnlyPrefs.forEach { it.parent?.removePreference(it) }
|
wgQuickOnlyPrefs.forEach { it.parent?.removePreference(it) }
|
||||||
|
@ -7,14 +7,6 @@
|
|||||||
android:summaryOn="@string/restore_on_boot_summary_on"
|
android:summaryOn="@string/restore_on_boot_summary_on"
|
||||||
android:summaryOff="@string/restore_on_boot_summary_off"
|
android:summaryOff="@string/restore_on_boot_summary_off"
|
||||||
android:title="@string/restore_on_boot_title" />
|
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.ZipExporterPreference />
|
||||||
<com.wireguard.android.preference.LogExporterPreference />
|
<com.wireguard.android.preference.LogExporterPreference />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
@ -23,6 +15,14 @@
|
|||||||
android:summaryOff="@string/dark_theme_summary_off"
|
android:summaryOff="@string/dark_theme_summary_off"
|
||||||
android:summaryOn="@string/dark_theme_summary_on"
|
android:summaryOn="@string/dark_theme_summary_on"
|
||||||
android:title="@string/dark_theme_title" />
|
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" />
|
<com.wireguard.android.preference.KernelModuleDisablerPreference android:key="kernel_module_disabler" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
|
Loading…
Reference in New Issue
Block a user