diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-12 14:58:47 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-12 18:55:28 +0200 |
commit | 96b44c1771c528264cc1e83b725bfc8a96e7cc73 (patch) | |
tree | 6c32284e431471ef10b96f96cb1f314f32f7079e /app/src/main/java/com/wireguard/android/activity | |
parent | 4a1d07b36430af788a7d65e880a077d6685eba13 (diff) |
Activity: make dark/night theme follow system on Q
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/activity')
-rw-r--r-- | app/src/main/java/com/wireguard/android/activity/SettingsActivity.java | 6 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java | 7 |
2 files changed, 10 insertions, 3 deletions
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(); } |