diff options
Diffstat (limited to 'app/src/main/java/com/wireguard/android')
3 files changed, 17 insertions, 6 deletions
diff --git a/app/src/main/java/com/wireguard/android/Application.java b/app/src/main/java/com/wireguard/android/Application.java index 7bc07d6b..1ffaa250 100644 --- a/app/src/main/java/com/wireguard/android/Application.java +++ b/app/src/main/java/com/wireguard/android/Application.java @@ -115,9 +115,13 @@ public class Application extends android.app.Application { toolsInstaller = new ToolsInstaller(getApplicationContext()); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); - AppCompatDelegate.setDefaultNightMode( - sharedPreferences.getBoolean("dark_theme", false) ? - AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + AppCompatDelegate.setDefaultNightMode( + sharedPreferences.getBoolean("dark_theme", false) ? + AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); + } else { + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); + } tunnelManager = new TunnelManager(new FileConfigStore(getApplicationContext())); tunnelManager.onCreate(); diff --git a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java index 475c579e..89ba0c12 100644 --- a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java @@ -6,6 +6,7 @@ package com.wireguard.android.activity; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import androidx.annotation.Nullable; import androidx.core.app.ActivityCompat; @@ -91,13 +92,16 @@ public class SettingsActivity extends ThemeChangeAwareActivity { @Override public void onCreatePreferences(final Bundle savedInstanceState, final String key) { addPreferencesFromResource(R.xml.preferences); + final PreferenceScreen screen = getPreferenceScreen(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) + screen.removePreference(getPreferenceManager().findPreference("dark_theme")); + final Preference wgQuickOnlyPrefs[] = { getPreferenceManager().findPreference("tools_installer"), getPreferenceManager().findPreference("restore_on_boot") }; for (final Preference pref : wgQuickOnlyPrefs) pref.setVisible(false); - final PreferenceScreen screen = getPreferenceScreen(); Application.getBackendAsync().thenAccept(backend -> { for (final Preference pref : wgQuickOnlyPrefs) { if (backend instanceof WgQuickBackend) diff --git a/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java b/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java index 0309722c..977f64ea 100644 --- a/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java @@ -7,6 +7,7 @@ package com.wireguard.android.activity; import android.content.SharedPreferences; import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -55,12 +56,14 @@ public abstract class ThemeChangeAwareActivity extends AppCompatActivity impleme @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Application.getSharedPreferences().registerOnSharedPreferenceChangeListener(this); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) + Application.getSharedPreferences().registerOnSharedPreferenceChangeListener(this); } @Override protected void onDestroy() { - Application.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) + Application.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); super.onDestroy(); } |