From 1efc14c608e0522640f4ccfd424628fd038721c0 Mon Sep 17 00:00:00 2001 From: d34d Date: Sun, 15 Feb 2015 10:28:43 -0800 Subject: Themes: Add theme change timestamp to ThemeConfig Rather than perform two configuration changes when an applied theme is upadted, this patch adds an additional member to the ThemeConfig which tracks the time at which the theme is applied. This allows us to only perform one configuration change since the new config should differ from the previous one if the time stamp changes. The case where this is needed is when a currently applied theme is updated and needs to be re-applied so that apps pick up the new resources. Change-Id: I0036fd6465428bb8e972e294a99839e55203cfaf --- core/java/android/content/res/ThemeConfig.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'core/java/android/content/res') diff --git a/core/java/android/content/res/ThemeConfig.java b/core/java/android/content/res/ThemeConfig.java index 1b1837d..a10151d 100644 --- a/core/java/android/content/res/ThemeConfig.java +++ b/core/java/android/content/res/ThemeConfig.java @@ -60,6 +60,9 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable red theme) protected final Map mThemes = new HashMap(); + // Theme change timestamp + private long mThemeChangeTimestamp; + public ThemeConfig(Map appThemes) { mThemes.putAll(appThemes); } @@ -127,7 +130,8 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable newThemes = (o.mThemes == null) ? new HashMap() : o.mThemes; - return (currThemes.equals(newThemes)); + return (currThemes.equals(newThemes) && + mThemeChangeTimestamp == o.mThemeChangeTimestamp); } return false; } @@ -200,13 +204,16 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable CREATOR = new Parcelable.Creator() { public ThemeConfig createFromParcel(Parcel source) { String json = source.readString(); - return JsonSerializer.fromJson(json); + ThemeConfig themeConfig = JsonSerializer.fromJson(json); + themeConfig.mThemeChangeTimestamp = source.readLong(); + return themeConfig; } public ThemeConfig[] newArray(int size) { @@ -324,6 +331,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable mOverlays = new HashMap(); private HashMap mIcons = new HashMap(); private HashMap mFonts = new HashMap(); + private long mThemeChangeTimestamp; public Builder() {} @@ -335,6 +343,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable appPkgSet = new HashSet(); appPkgSet.addAll(mOverlays.keySet()); @@ -410,7 +424,9 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable