diff options
author | d34d <clark@cyngn.com> | 2016-07-29 14:41:21 -0700 |
---|---|---|
committer | Abhisek Devkota <ciwrl@cyanogenmod.com> | 2016-08-09 14:10:09 -0700 |
commit | b4ef59bc6fb77851132caadc748eeef5a94e03b2 (patch) | |
tree | 91eb1f471f8bc7ecb9ce47442cdb418e94b04ec8 | |
parent | f958ca0e887279eb636ef87959173df4a074fe08 (diff) | |
download | android_packages_apps_Messaging-b4ef59bc6fb77851132caadc748eeef5a94e03b2.tar.gz android_packages_apps_Messaging-b4ef59bc6fb77851132caadc748eeef5a94e03b2.tar.bz2 android_packages_apps_Messaging-b4ef59bc6fb77851132caadc748eeef5a94e03b2.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
(cherry picked from commit 84d9f8271c2d6d5a65944d3b499d5f87e3839090)
-rw-r--r-- | src/com/android/messaging/BugleApplication.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/com/android/messaging/BugleApplication.java b/src/com/android/messaging/BugleApplication.java index b5adab2..571fa70 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.net.Uri; import android.os.Handler; @@ -30,6 +31,9 @@ import android.support.v7.mms.MmsManager; import android.telephony.CarrierConfigManager; import com.android.messaging.datamodel.DataModel; +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; @@ -66,6 +70,8 @@ public class BugleApplication extends Application implements UncaughtExceptionHa // Lookup provider members private static LookupProviderManager sLookupProviderManager; + private Configuration mCurrentConfig; + @VisibleForTesting protected static void setTestsRunning() { sRunningTests = true; @@ -99,6 +105,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); @@ -115,6 +123,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) |