diff options
| author | 2011-08-14 16:48:32 -0700 | |
|---|---|---|
| committer | 2011-08-14 16:49:22 -0700 | |
| commit | 6e90a362bc66cc67b1beae27b21d3f0148403b08 (patch) | |
| tree | 0ebfe4ce91bbeaa0c6c275106682a0cb79685dce | |
| parent | 52727fc38aaf6821bac6adf33235f154139638d0 (diff) | |
Fix bug 5159736 - Make DeviceDefault the default
Have the framework refer to the DeviceDefault themes for ICS apps that
don't explicitly request another theme.
Change-Id: I27dd0bbaa60f71df4f36e47d260f556d923ba075
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/app/AlertDialog.java | 16 | ||||
| -rw-r--r-- | core/java/android/app/ContextImpl.java | 3 | ||||
| -rw-r--r-- | core/java/android/app/DialogFragment.java | 2 | ||||
| -rwxr-xr-x | core/java/android/content/res/Resources.java | 12 | ||||
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 4 | ||||
| -rw-r--r-- | core/java/android/os/Build.java | 9 | ||||
| -rw-r--r-- | core/res/res/values/themes_device_defaults.xml | 4 |
8 files changed, 46 insertions, 6 deletions
diff --git a/api/current.txt b/api/current.txt index 08cd44f982f5..6dc3bfe6471d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -2853,6 +2853,8 @@ package android.app { method public void setMessage(java.lang.CharSequence); method public void setView(android.view.View); method public void setView(android.view.View, int, int, int, int); + field public static final int THEME_DEVICE_DEFAULT_DARK = 4; // 0x4 + field public static final int THEME_DEVICE_DEFAULT_LIGHT = 5; // 0x5 field public static final int THEME_HOLO_DARK = 2; // 0x2 field public static final int THEME_HOLO_LIGHT = 3; // 0x3 field public static final int THEME_TRADITIONAL = 1; // 0x1 diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index 491fcfea7991..c09e87fc0f9a 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -75,6 +75,18 @@ public class AlertDialog extends Dialog implements DialogInterface { * the holographic alert theme with a light background. */ public static final int THEME_HOLO_LIGHT = 3; + + /** + * Special theme constant for {@link #AlertDialog(Context, int)}: use + * the device's default alert theme with a dark background. + */ + public static final int THEME_DEVICE_DEFAULT_DARK = 4; + + /** + * Special theme constant for {@link #AlertDialog(Context, int)}: use + * the device's default alert theme with a dark background. + */ + public static final int THEME_DEVICE_DEFAULT_LIGHT = 5; protected AlertDialog(Context context) { this(context, resolveDialogTheme(context, 0), true); @@ -113,6 +125,10 @@ public class AlertDialog extends Dialog implements DialogInterface { return com.android.internal.R.style.Theme_Holo_Dialog_Alert; } else if (resid == THEME_HOLO_LIGHT) { return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert; + } else if (resid == THEME_DEVICE_DEFAULT_DARK) { + return com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert; + } else if (resid == THEME_DEVICE_DEFAULT_LIGHT) { + return com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog_Alert; } else if (resid >= 0x01000000) { // start of real resource IDs. return resid; } else { diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index b4bdb2fc39dd..21397040357f 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -364,7 +364,8 @@ class ContextImpl extends Context { Resources.selectSystemTheme(0, outerContext.getApplicationInfo().targetSdkVersion, com.android.internal.R.style.Theme_Dialog, - com.android.internal.R.style.Theme_Holo_Dialog)), + com.android.internal.R.style.Theme_Holo_Dialog, + com.android.internal.R.style.Theme_DeviceDefault_Dialog)), ctx.mMainThread.getHandler()); }}); diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java index cce7cd6bd8fe..892157895bc1 100644 --- a/core/java/android/app/DialogFragment.java +++ b/core/java/android/app/DialogFragment.java @@ -204,7 +204,7 @@ public class DialogFragment extends Fragment public void setStyle(int style, int theme) { mStyle = style; if (mStyle == STYLE_NO_FRAME || mStyle == STYLE_NO_INPUT) { - mTheme = com.android.internal.R.style.Theme_Holo_Dialog_NoFrame; + mTheme = com.android.internal.R.style.Theme_DeviceDefault_Dialog_NoFrame; } if (theme != 0) { mTheme = theme; diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index f52692324177..24f8319c9080 100755 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -134,18 +134,24 @@ public class Resources { /** @hide */ public static int selectDefaultTheme(int curTheme, int targetSdkVersion) { return selectSystemTheme(curTheme, targetSdkVersion, - com.android.internal.R.style.Theme, com.android.internal.R.style.Theme_Holo); + com.android.internal.R.style.Theme, + com.android.internal.R.style.Theme_Holo, + com.android.internal.R.style.Theme_DeviceDefault); } /** @hide */ - public static int selectSystemTheme(int curTheme, int targetSdkVersion, int orig, int holo) { + public static int selectSystemTheme(int curTheme, int targetSdkVersion, + int orig, int holo, int deviceDefault) { if (curTheme != 0) { return curTheme; } if (targetSdkVersion < Build.VERSION_CODES.HONEYCOMB) { return orig; } - return holo; + if (targetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + return holo; + } + return deviceDefault; } /** diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 9481a880fb08..370e22a0f84c 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -617,7 +617,9 @@ public class InputMethodService extends AbstractInputMethodService { @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_InputMethod, + android.R.style.Theme_Holo, + android.R.style.Theme_DeviceDefault_InputMethod); super.setTheme(mTheme); super.onCreate(); mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 6c7c58dc85af..1e9ee7c6544c 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -287,6 +287,15 @@ public class Build { * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} * to turn it off if needed, although this is strongly discouraged since * it will result in poor performance on larger screen devices. + * <li> The default theme for applications is now the "device default" theme: + * {@link android.R.style#Theme_DeviceDefault}. This may be the + * holo dark theme or a different dark theme defined by the specific device. + * The {@link android.R.style#Theme_Holo} family must not be modified + * for a device to be considered compatible. Applications that explicitly + * request a theme from the Holo family will be guaranteed that these themes + * will not change character within the same platform version. Applications + * that wish to blend in with the device should use a theme from the + * {@link android.R.style#Theme_DeviceDefault} family. * </ul> */ public static final int ICE_CREAM_SANDWICH = CUR_DEVELOPMENT; diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml index bf6329d6a1ca..94d2c381349d 100644 --- a/core/res/res/values/themes_device_defaults.xml +++ b/core/res/res/values/themes_device_defaults.xml @@ -420,4 +420,8 @@ easier. <style name="Theme.DeviceDefault.Light.SearchBar" parent="Theme.DeviceDefault.Light.SearchBar"> </style> + + <style name="Theme.DeviceDefault.Dialog.NoFrame" parent="Theme.Holo.Dialog.NoFrame"> + </style> + </resources> |