summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-07-29 14:41:21 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-28 20:44:43 -0700
commitd93bcf8d4a455e379aa32a76340dfbc1eefe23bc (patch)
tree9b3442c89f05e092d04503387393f5c041b2740a
parente43f46415b6c1a1b2a1a4cb7c24cd611afc2fb2c (diff)
downloadandroid_packages_apps_Messaging-d93bcf8d4a455e379aa32a76340dfbc1eefe23bc.tar.gz
android_packages_apps_Messaging-d93bcf8d4a455e379aa32a76340dfbc1eefe23bc.tar.bz2
android_packages_apps_Messaging-d93bcf8d4a455e379aa32a76340dfbc1eefe23bc.zip
Clear avatar media cache on theme change
Default avatars retained the previou;sly applied theme's colors due to the avatar images being cached. This patch checks if a theme change has occurred and if so destroys the avatar media cache so that it can be rebuilt with the newly applied theme's colors. Change-Id: Iab3d6e0171a949235da643fc80bf54d9375e42fb TICKET: CYNGNOS-3118
-rw-r--r--src/com/android/messaging/BugleApplication.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/com/android/messaging/BugleApplication.java b/src/com/android/messaging/BugleApplication.java
index c439700..b400fa4 100644
--- a/src/com/android/messaging/BugleApplication.java
+++ b/src/com/android/messaging/BugleApplication.java
@@ -21,6 +21,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.database.Cursor;
@@ -39,6 +40,9 @@ import com.android.messaging.datamodel.DatabaseWrapper;
import com.android.messaging.datamodel.MessagingContentProvider;
import com.android.messaging.datamodel.action.UpdateConversationArchiveStatusAction;
import com.android.messaging.datamodel.action.UpdateDestinationBlockedAction;
+import com.android.messaging.datamodel.media.BugleMediaCacheManager;
+import com.android.messaging.datamodel.media.MediaCache;
+import com.android.messaging.datamodel.media.MediaCacheManager;
import com.android.messaging.receiver.SmsReceiver;
import com.android.messaging.sms.ApnDatabase;
import com.android.messaging.sms.BugleApnSettingsLoader;
@@ -70,6 +74,8 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
private UncaughtExceptionHandler sSystemUncaughtExceptionHandler;
private static boolean sRunningTests = false;
+ private Configuration mCurrentConfig;
+
@VisibleForTesting
protected static void setTestsRunning() {
sRunningTests = true;
@@ -103,6 +109,8 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
BlacklistSync blacklistSync = new BlacklistSync(getApplicationContext());
blacklistSync.execute();
+ mCurrentConfig = new Configuration(getResources().getConfiguration());
+
sSystemUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(this);
@@ -118,6 +126,14 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
// Update conversation drawables when changing writing systems
// (Right-To-Left / Left-To-Right)
ConversationDrawables.get().updateDrawables();
+
+ // Clear avatar image cache on theme change
+ int changed = mCurrentConfig.updateFrom(newConfig);
+ if ((changed & ActivityInfo.CONFIG_THEME_RESOURCE) != 0) {
+ MediaCache<?> avatarCache = MediaCacheManager.get()
+ .getOrCreateMediaCacheById(BugleMediaCacheManager.AVATAR_IMAGE_CACHE);
+ avatarCache.destroy();
+ }
}
// Called by the "real" factory from FactoryImpl.register() (i.e. not run in tests)