summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-03-03 13:40:05 -0800
committerClark Scheff <clark@cyngn.com>2015-10-27 17:52:35 -0700
commitf3a1f050cbaa758656f862b42c328c2b1aeb6017 (patch)
tree80c4e94ed012750a302698c56f802a8f946409c1
parent05ce0a6f5651743add398556d557a5f4c40c2503 (diff)
downloadframeworks_base-f3a1f050cbaa758656f862b42c328c2b1aeb6017.zip
frameworks_base-f3a1f050cbaa758656f862b42c328c2b1aeb6017.tar.gz
frameworks_base-f3a1f050cbaa758656f862b42c328c2b1aeb6017.tar.bz2
Themes: Drop timestamp and add change request type
This patch ditches the hack where we keep track of the time a theme change occurs. Instead we keep track of the RequestType when a theme change occurs. This extra information is much more useful to apps that want to handle theme changes, i.e. SystemUI. If a new theme config is equal to an old theme config, the app can look at the request type and determine what action to take. Change-Id: Ie1d56060069d6645bf3212f4a70739d491cd0731
-rw-r--r--core/java/android/content/res/ThemeConfig.java26
-rw-r--r--services/core/java/com/android/server/ThemeService.java6
2 files changed, 16 insertions, 16 deletions
diff --git a/core/java/android/content/res/ThemeConfig.java b/core/java/android/content/res/ThemeConfig.java
index 1882211..052f694 100644
--- a/core/java/android/content/res/ThemeConfig.java
+++ b/core/java/android/content/res/ThemeConfig.java
@@ -17,6 +17,7 @@
package android.content.res;
import android.content.ContentResolver;
+import android.content.res.ThemeChangeRequest.RequestType;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.Settings;
@@ -61,8 +62,7 @@ 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;
+ private RequestType mLastThemeChangeRequestType = RequestType.USER_REQUEST;
public ThemeConfig(Map<String, AppTheme> appThemes) {
mThemes.putAll(appThemes);
@@ -110,6 +110,10 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
return Collections.unmodifiableMap(mThemes);
}
+ public RequestType getLastThemeChangeRequestType() {
+ return mLastThemeChangeRequestType;
+ }
+
private AppTheme getThemeFor(String pkgName) {
AppTheme theme = mThemes.get(pkgName);
if (theme == null) theme = getDefaultTheme();
@@ -136,7 +140,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
new HashMap<String, AppTheme>() : o.mThemes;
return (currThemes.equals(newThemes) &&
- mThemeChangeTimestamp == o.mThemeChangeTimestamp);
+ mLastThemeChangeRequestType.equals(o.mLastThemeChangeRequestType));
}
return false;
}
@@ -155,7 +159,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
public int hashCode() {
int hash = 17;
hash = 31 * hash + mThemes.hashCode();
- hash = 31 * hash + (int) mThemeChangeTimestamp;
+ hash = 31 * hash + mLastThemeChangeRequestType.ordinal();
return hash;
}
@@ -217,7 +221,7 @@ 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);
+ dest.writeInt(mLastThemeChangeRequestType.ordinal());
}
public static final Parcelable.Creator<ThemeConfig> CREATOR =
@@ -225,7 +229,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
public ThemeConfig createFromParcel(Parcel source) {
String json = source.readString();
ThemeConfig themeConfig = JsonSerializer.fromJson(json);
- themeConfig.mThemeChangeTimestamp = source.readLong();
+ themeConfig.mLastThemeChangeRequestType = RequestType.values()[source.readInt()];
return themeConfig;
}
@@ -344,7 +348,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;
+ private RequestType mLastThemeChangeRequestType = RequestType.USER_REQUEST;
public Builder() {}
@@ -356,7 +360,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
mIcons.put(key, appTheme.getIconPackPkgName());
mOverlays.put(key, appTheme.getOverlayPkgName());
}
- mThemeChangeTimestamp = theme.mThemeChangeTimestamp;
+ mLastThemeChangeRequestType = theme.mLastThemeChangeRequestType;
}
/**
@@ -417,8 +421,8 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
return this;
}
- public Builder setThemeChangeTimestamp(long timestamp) {
- mThemeChangeTimestamp = timestamp;
+ public Builder setLastThemeChangeRequestType(RequestType requestType) {
+ mLastThemeChangeRequestType = requestType;
return this;
}
@@ -445,7 +449,7 @@ public class ThemeConfig implements Cloneable, Parcelable, Comparable<ThemeConfi
}
}
ThemeConfig themeConfig = new ThemeConfig(appThemes);
- themeConfig.mThemeChangeTimestamp = mThemeChangeTimestamp;
+ themeConfig.mLastThemeChangeRequestType = mLastThemeChangeRequestType;
return themeConfig;
}
}
diff --git a/services/core/java/com/android/server/ThemeService.java b/services/core/java/com/android/server/ThemeService.java
index 86b5bfd..ad35099f 100644
--- a/services/core/java/com/android/server/ThemeService.java
+++ b/services/core/java/com/android/server/ThemeService.java
@@ -777,11 +777,7 @@ public class ThemeService extends IThemeService.Stub {
}
}
- // When a theme is being updated the new config equal the old config so in this case we
- // want to update the timestamp so they are no longer equal.
- if (request.getReqeustType() == ThemeChangeRequest.RequestType.THEME_UPDATED) {
- builder.setThemeChangeTimestamp(System.currentTimeMillis());
- }
+ builder.setLastThemeChangeRequestType(request.getReqeustType());
return builder;
}