summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-02-25 14:25:35 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-02-25 17:14:52 +0530
commit9c9463ac6850710a02b0119e522849d19819d877 (patch)
tree2a92491ff190c20bcc970abe156bbbd9c04e9b4f /app
parenta127fc816e16f0851cdd7429b1f1e1b4638ead6e (diff)
ThemeChangeAwareActivity: Remove drawable cache buster
Shouldn't be needed anymore. Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java35
1 files changed, 0 insertions, 35 deletions
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 977f64ea..602ad37c 100644
--- a/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
+++ b/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
@@ -20,38 +20,6 @@ import java.lang.reflect.Field;
public abstract class ThemeChangeAwareActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "WireGuard/" + ThemeChangeAwareActivity.class.getSimpleName();
- private static boolean lastDarkMode;
- @Nullable private static Resources lastResources;
-
- private static synchronized void invalidateDrawableCache(final Resources resources, final boolean darkMode) {
- if (resources == lastResources && darkMode == lastDarkMode)
- return;
-
- try {
- Field f;
- Object o = resources;
- try {
- f = o.getClass().getDeclaredField("mResourcesImpl");
- f.setAccessible(true);
- o = f.get(o);
- } catch (final Exception ignored) {
- }
- f = o.getClass().getDeclaredField("mDrawableCache");
- f.setAccessible(true);
- o = f.get(o);
- try {
- o.getClass().getMethod("onConfigurationChange", int.class).invoke(o, -1);
- } catch (final Exception ignored) {
- o.getClass().getMethod("clear").invoke(o);
- }
- } catch (final Exception e) {
- Log.e(TAG, "Failed to flush drawable cache", e);
- }
-
- lastResources = resources;
- lastDarkMode = darkMode;
- }
-
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
@@ -70,13 +38,10 @@ public abstract class ThemeChangeAwareActivity extends AppCompatActivity impleme
@Override
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) {
if ("dark_theme".equals(key)) {
- final boolean darkMode = sharedPreferences.getBoolean(key, false);
AppCompatDelegate.setDefaultNightMode(
sharedPreferences.getBoolean(key, false) ?
AppCompatDelegate.MODE_NIGHT_YES :
AppCompatDelegate.MODE_NIGHT_NO);
- invalidateDrawableCache(getResources(), darkMode);
- recreate();
}
}
}