diff options
| author | d34d <clark@cyngn.com> | 2015-02-15 10:28:43 -0800 |
|---|---|---|
| committer | Clark Scheff <clark@cyngn.com> | 2015-10-27 10:40:06 -0700 |
| commit | 1efc14c608e0522640f4ccfd424628fd038721c0 (patch) | |
| tree | 3a248363924bc1a6b81a39d2a62434ca25fd82df /core/java | |
| parent | 6338f8d198756523e8fdd94a3223da68041bb875 (diff) | |
| download | frameworks_base-1efc14c608e0522640f4ccfd424628fd038721c0.zip frameworks_base-1efc14c608e0522640f4ccfd424628fd038721c0.tar.gz frameworks_base-1efc14c608e0522640f4ccfd424628fd038721c0.tar.bz2 | |
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
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/res/ThemeConfig.java | 22 |
1 files changed, 19 insertions, 3 deletions
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<ThemeConfi // Maps pkgname to theme (ex com.angry.birds -> red theme) protected final Map<String, AppTheme> mThemes = new HashMap<String, AppTheme>(); + // Theme change timestamp + private long mThemeChangeTimestamp; + public ThemeConfig(Map<String, AppTheme> appThemes) { mThemes.putAll(appThemes); } @@ -127,7 +130,8 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi Map<String, AppTheme> newThemes = (o.mThemes == null) ? new HashMap<String, AppTheme>() : 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<ThemeConfi public void writeToParcel(Parcel dest, int flags) { String json = JsonSerializer.toJson(this); dest.writeString(json); + dest.writeLong(mThemeChangeTimestamp); } public static final Parcelable.Creator<ThemeConfig> CREATOR = new Parcelable.Creator<ThemeConfig>() { 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<ThemeConfi private HashMap<String, String> mOverlays = new HashMap<String, String>(); private HashMap<String, String> mIcons = new HashMap<String, String>(); private HashMap<String, String> mFonts = new HashMap<String, String>(); + private long mThemeChangeTimestamp; public Builder() {} @@ -335,6 +343,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi mIcons.put(key, appTheme.getIconPackPkgName()); mOverlays.put(key, appTheme.getOverlayPkgName()); } + mThemeChangeTimestamp = theme.mThemeChangeTimestamp; } /** @@ -395,6 +404,11 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi return this; } + public Builder setThemeChangeTimestamp(long timestamp) { + mThemeChangeTimestamp = timestamp; + return this; + } + public ThemeConfig build() { HashSet<String> appPkgSet = new HashSet<String>(); appPkgSet.addAll(mOverlays.keySet()); @@ -410,7 +424,9 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi AppTheme appTheme = new AppTheme(overlay, icon, font); appThemes.put(appPkgName, appTheme); } - return new ThemeConfig(appThemes); + ThemeConfig themeConfig = new ThemeConfig(appThemes); + themeConfig.mThemeChangeTimestamp = mThemeChangeTimestamp; + return themeConfig; } } |
