summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-04 16:42:38 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-04 17:57:02 +0200
commite3a681446898ad43e63de1daaf74805f2041dd33 (patch)
tree566c786e6198f44e01d652c666790ce7da2cf5b4
parentdfab20136bcaaac77c9ce8910da19ad2ef88153e (diff)
BaseActivity: invalidate icon cache on Android P
-rw-r--r--app/src/main/java/com/wireguard/android/activity/BaseActivity.java27
-rw-r--r--app/src/main/java/com/wireguard/android/activity/SettingsActivity.java3
2 files changed, 15 insertions, 15 deletions
diff --git a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java
index 7b6923f9..3cce412d 100644
--- a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java
+++ b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java
@@ -121,21 +121,20 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Su
@Override
public void onTopicPublished(Topic topic) {
- try {
- Field f = getResources().getClass().getDeclaredField("mResourcesImpl");
- f.setAccessible(true);
- Object o = f.get(getResources());
- f = o.getClass().getDeclaredField("mDrawableCache");
- f.setAccessible(true);
- o = f.get(o);
- f = o.getClass().getSuperclass().getDeclaredField("mThemedEntries");
- f.setAccessible(true);
- o = f.get(o);
- o.getClass().getMethod("clear").invoke(o);
- } catch (Exception e) {
- Log.e(TAG, "Failed to flush icon cache", e);
+ if (topic == Application.getComponent().getThemeChangeTopic()) {
+ try {
+ Field f = getResources().getClass().getDeclaredField("mResourcesImpl");
+ f.setAccessible(true);
+ Object o = f.get(getResources());
+ f = o.getClass().getDeclaredField("mDrawableCache");
+ f.setAccessible(true);
+ o = f.get(o);
+ o.getClass().getMethod("onConfigurationChange", int.class).invoke(o, -1);
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to flush icon cache", e);
+ }
+ recreate();
}
- recreate();
}
@Override
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 ed7c5457..d7238b96 100644
--- a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java
+++ b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java
@@ -101,7 +101,8 @@ public class SettingsActivity extends AppCompatActivity implements Topic.Subscri
@Override
public void onTopicPublished(final Topic topic) {
- recreate();
+ if (topic == Application.getComponent().getThemeChangeTopic())
+ recreate();
}
@Override