summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-05-05 12:25:33 -0700
committerAlan Viverette <alanv@google.com>2014-05-05 12:26:03 -0700
commit5effd7e89f83824ac8982a6cbcebbf5cc331e436 (patch)
tree6e46eec8e5b7bee8ec967d32252f526a464a325b
parent5d039c458c67e8c08334e597a6a8781eda6aab13 (diff)
downloadframeworks_base-5effd7e89f83824ac8982a6cbcebbf5cc331e436.zip
frameworks_base-5effd7e89f83824ac8982a6cbcebbf5cc331e436.tar.gz
frameworks_base-5effd7e89f83824ac8982a6cbcebbf5cc331e436.tar.bz2
Partial revert "Load device default theme mapping from resources"
This reverts commit e4ab72d54cf41d16819b72e94d9b0d0d51289647. Change-Id: Id17170312c75993fc1f7859d52c7e050b2aeaf80
-rw-r--r--core/java/android/app/ContextImpl.java12
-rw-r--r--core/java/android/content/res/Resources.java49
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java12
-rw-r--r--core/java/android/view/ContextThemeWrapper.java2
-rw-r--r--core/res/res/values/arrays.xml39
-rw-r--r--core/res/res/values/symbols.xml4
6 files changed, 37 insertions, 81 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index a4b2651..fe532bf 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -473,14 +473,14 @@ class ContextImpl extends Context {
registerService(NOTIFICATION_SERVICE, new ServiceFetcher() {
public Object createService(ContextImpl ctx) {
final Context outerContext = ctx.getOuterContext();
- // TODO: Why are we not just using the theme attribute
- // that defines the dialog theme?
return new NotificationManager(
new ContextThemeWrapper(outerContext,
- outerContext.getResources().selectSystemTheme(0,
+ Resources.selectSystemTheme(0,
outerContext.getApplicationInfo().targetSdkVersion,
- com.android.internal.R.array.system_theme_sdks,
- com.android.internal.R.array.system_theme_dialog_styles)),
+ com.android.internal.R.style.Theme_Dialog,
+ com.android.internal.R.style.Theme_Holo_Dialog,
+ com.android.internal.R.style.Theme_DeviceDefault_Dialog,
+ com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog)),
ctx.mMainThread.getHandler());
}});
@@ -731,7 +731,7 @@ class ContextImpl extends Context {
@Override
public Resources.Theme getTheme() {
if (mTheme == null) {
- mThemeResource = mResources.selectDefaultTheme(mThemeResource,
+ mThemeResource = Resources.selectDefaultTheme(mThemeResource,
getOuterContext().getApplicationInfo().targetSdkVersion);
mTheme = mResources.newTheme();
mTheme.applyStyle(mThemeResource, true);
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 1331777..499de17 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -137,45 +137,42 @@ public class Resources {
/**
* Returns the most appropriate default theme for the specified target SDK version.
+ * <ul>
+ * <li>Below API 11: Gingerbread
+ * <li>APIs 11 thru 14: Holo
+ * <li>APIs 14 thru XX: Device default dark
+ * <li>API XX and above: Device default light with dark action bar
+ * </ul>
*
* @param curTheme The current theme, or 0 if not specified.
* @param targetSdkVersion The target SDK version.
* @return A theme resource identifier
* @hide
*/
- public int selectDefaultTheme(int curTheme, int targetSdkVersion) {
+ public static int selectDefaultTheme(int curTheme, int targetSdkVersion) {
return selectSystemTheme(curTheme, targetSdkVersion,
- com.android.internal.R.array.system_theme_sdks,
- com.android.internal.R.array.system_theme_styles);
+ com.android.internal.R.style.Theme,
+ com.android.internal.R.style.Theme_Holo,
+ com.android.internal.R.style.Theme_DeviceDefault,
+ com.android.internal.R.style.Theme_DeviceDefault_Light_DarkActionBar);
}
- /**
- * Returns the most appropriate default theme for the specified target SDK version.
- *
- * @param curTheme The current theme, or 0 if not specified.
- * @param targetSdkVersion The target SDK version.
- * @param sdkArrayId Identifier for integer array resource containing
- * sorted minimum SDK versions. First entry must be 0.
- * @param themeArrayId Identifier for array resource containing the
- * default themes that map to SDK versions.
- * @return A theme resource identifier
- * @hide
- */
- public int selectSystemTheme(
- int curTheme, int targetSdkVersion, int sdkArrayId, int themeArrayId) {
+ /** @hide */
+ public static int selectSystemTheme(int curTheme, int targetSdkVersion, int orig, int holo,
+ int dark, int deviceDefault) {
if (curTheme != 0) {
return curTheme;
}
-
- final int[] targetSdks = getIntArray(sdkArrayId);
- final TypedArray defaultThemes = obtainTypedArray(themeArrayId);
- for (int i = targetSdks.length - 1; i > 0; i--) {
- if (targetSdkVersion >= targetSdks[i]) {
- return defaultThemes.getResourceId(i, 0);
- }
+ if (targetSdkVersion < Build.VERSION_CODES.HONEYCOMB) {
+ return orig;
}
-
- return defaultThemes.getResourceId(0, 0);
+ if (targetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ return holo;
+ }
+ if (targetSdkVersion < Build.VERSION_CODES.CUR_DEVELOPMENT) {
+ return dark;
+ }
+ return deviceDefault;
}
/**
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 4160633..f6438b4 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -654,11 +654,13 @@ public class InputMethodService extends AbstractInputMethodService {
return false;
}
- @Override
- public void onCreate() {
- mTheme = getResources().selectSystemTheme(mTheme, getApplicationInfo().targetSdkVersion,
- com.android.internal.R.array.system_theme_sdks,
- com.android.internal.R.array.system_theme_ime_styles);
+ @Override public void onCreate() {
+ mTheme = Resources.selectSystemTheme(mTheme,
+ getApplicationInfo().targetSdkVersion,
+ android.R.style.Theme_InputMethod,
+ android.R.style.Theme_Holo_InputMethod,
+ android.R.style.Theme_DeviceDefault_InputMethod,
+ android.R.style.Theme_DeviceDefault_InputMethod);
super.setTheme(mTheme);
super.onCreate();
mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
diff --git a/core/java/android/view/ContextThemeWrapper.java b/core/java/android/view/ContextThemeWrapper.java
index ba1c4b6..0afbde9 100644
--- a/core/java/android/view/ContextThemeWrapper.java
+++ b/core/java/android/view/ContextThemeWrapper.java
@@ -96,7 +96,7 @@ public class ContextThemeWrapper extends ContextWrapper {
return mTheme;
}
- mThemeResource = getResources().selectDefaultTheme(mThemeResource,
+ mThemeResource = Resources.selectDefaultTheme(mThemeResource,
getApplicationInfo().targetSdkVersion);
initializeTheme();
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index 305ba28..f01f10e 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -348,43 +348,4 @@
<item>中文 (繁體)</item>
</string-array>
- <!-- Used by callers to Resources.selectSystemTheme(). Defines the minimum
- targetSdkVersion required for the theme style at a given index.
- NOTE: Must be sorted in ascending order. -->
- <integer-array name="system_theme_sdks">
- <item>0</item>
- <item>11</item>
- <item>14</item>
- <item>21</item>
- </integer-array>
-
- <!-- Used by Resources.selectDefaultTheme(). Defines the default theme style
- for the targetSdkVersion at a given index (see system_theme_sdks).
- NOTE: Must match number of entries in system_theme_sdks. -->
- <array name="system_theme_styles">
- <item>@style/Theme</item>
- <item>@style/Theme.Holo</item>
- <item>@style/Theme.DeviceDefault</item>
- <item>@style/Theme.DeviceDefault.Light.DarkActionBar</item>
- </array>
-
- <!-- Used by ContextImpl for notifications. Defines the default dialog theme
- style for the targetSdkVersion at a given index (see system_theme_sdks).
- NOTE: Must match number of entries in system_theme_sdks. -->
- <array name="system_theme_dialog_styles">
- <item>@style/Theme</item>
- <item>@style/Theme.Holo.Dialog</item>
- <item>@style/Theme.DeviceDefault.Dialog</item>
- <item>@style/Theme.DeviceDefault.Light.Dialog</item>
- </array>
-
- <!-- Used by InputMethodService.onCreate(). Defines the default IME theme
- style for the targetSdkVersion at a given index (see system_theme_sdks).
- NOTE: Must match number of entries in system_theme_sdks. -->
- <array name="system_theme_ime_styles">
- <item>@style/Theme.InputMethod</item>
- <item>@style/Theme.Holo.InputMethod</item>
- <item>@style/Theme.DeviceDefault.InputMethod</item>
- <item>@style/Theme.DeviceDefault.InputMethod</item>
- </array>
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 6bcbbce..a8a4b51 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1864,9 +1864,5 @@
<java-symbol type="id" name="icon_frame" />
<java-symbol type="style" name="Animation.VolumePanel" />
<java-symbol type="transition" name="no_transition" />
- <java-symbol type="array" name="system_theme_sdks" />
- <java-symbol type="array" name="system_theme_styles" />
- <java-symbol type="array" name="system_theme_dialog_styles" />
- <java-symbol type="array" name="system_theme_ime_styles" />
</resources>