diff options
author | Tobias Haamel <haamel@google.com> | 2010-02-09 23:09:17 +0100 |
---|---|---|
committer | Tobias Haamel <haamel@google.com> | 2010-02-11 21:25:58 +0100 |
commit | 27b28b3f62bd3b54fa13acd5d035940b9be464f3 (patch) | |
tree | d1f44096f7071bbc53e5bc979117be8e0f4aa55c /core/java/android/content/res | |
parent | d5663a108760de672b130ffabd4f6632982f75e5 (diff) | |
download | frameworks_base-27b28b3f62bd3b54fa13acd5d035940b9be464f3.zip frameworks_base-27b28b3f62bd3b54fa13acd5d035940b9be464f3.tar.gz frameworks_base-27b28b3f62bd3b54fa13acd5d035940b9be464f3.tar.bz2 |
Introduce special UI modes for night and car usage.
The device mode is now called ui mode. Furthermore is the order of
precedence for the resources now in such a way that the ui mode needs
to be specified after the orientation and before the density.
The ui mode can be set, like it is done for the locale, as follows:
IActivityManager am = ActivityManagerNative.getDefault();
Configuration config = am.getConfiguration();
config.uiMode = Configuration.UI_MODE_TYPE_CAR | Configuration.UI_MODE_NIGHT_ANY;
am.updateConfiguration(config);
To allow users to disable the car mode and set the night mode the IUiModeManager
interface is used.
The automatic night mode switching will be added in a separate change.
Diffstat (limited to 'core/java/android/content/res')
-rw-r--r-- | core/java/android/content/res/AssetManager.java | 2 | ||||
-rw-r--r-- | core/java/android/content/res/Configuration.java | 51 | ||||
-rw-r--r-- | core/java/android/content/res/Resources.java | 2 |
3 files changed, 51 insertions, 4 deletions
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 23a408b..7f9a5c6 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -619,7 +619,7 @@ public final class AssetManager { public native final void setConfiguration(int mcc, int mnc, String locale, int orientation, int touchscreen, int density, int keyboard, int keyboardHidden, int navigation, int screenWidth, int screenHeight, - int screenLayout, int majorVersion); + int screenLayout, int uiMode, int majorVersion); /** * Retrieve the resource identifier for the given resource name. diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java index 1fe34b5..aa5f128 100644 --- a/core/java/android/content/res/Configuration.java +++ b/core/java/android/content/res/Configuration.java @@ -161,7 +161,37 @@ public final class Configuration implements Parcelable, Comparable<Configuration * or {@link #ORIENTATION_SQUARE}. */ public int orientation; - + + /** @hide (UIMODE) Pending API council approval */ + public static final int UI_MODE_TYPE_MASK = 0x0f; + /** @hide (UIMODE) Pending API council approval */ + public static final int UI_MODE_TYPE_NORMAL = 0x00; + /** @hide (UIMODE) Pending API council approval */ + public static final int UI_MODE_TYPE_CAR = 0x01; + + /** @hide (UIMODE) Pending API council approval */ + public static final int UI_MODE_NIGHT_MASK = 0x30; + /** @hide (UIMODE) Pending API council approval */ + public static final int UI_MODE_NIGHT_UNDEFINED = 0x00; + /** @hide (UIMODE) Pending API council approval */ + public static final int UI_MODE_NIGHT_NO = 0x10; + /** @hide (UIMODE) Pending API council approval */ + public static final int UI_MODE_NIGHT_YES = 0x20; + + /** + * Bit mask of the ui mode. Currently there are two fields: + * <p>The {@link #UI_MODE_TYPE_MASK} bits define the overall ui mode of the + * device. They may be one of + * {@link #UI_MODE_TYPE_NORMAL} or {@link #UI_MODE_TYPE_CAR}. + * + * <p>The {@link #UI_MODE_NIGHT_MASK} defines whether the screen + * is in a special mode. They may be one of + * {@link #UI_MODE_NIGHT_NO} or {@link #UI_MODE_NIGHT_YES}. + * + * @hide (UIMODE) Pending API council approval + */ + public int uiMode; + /** * Construct an invalid Configuration. You must call {@link #setToDefaults} * for this object to be valid. {@more} @@ -189,6 +219,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration navigationHidden = o.navigationHidden; orientation = o.orientation; screenLayout = o.screenLayout; + uiMode = o.uiMode; } public String toString() { @@ -217,6 +248,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration sb.append(orientation); sb.append(" layout="); sb.append(screenLayout); + sb.append(" uiMode="); + sb.append(uiMode); sb.append('}'); return sb.toString(); } @@ -237,6 +270,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration navigationHidden = NAVIGATIONHIDDEN_UNDEFINED; orientation = ORIENTATION_UNDEFINED; screenLayout = SCREENLAYOUT_SIZE_UNDEFINED; + uiMode = UI_MODE_TYPE_NORMAL; } /** {@hide} */ @@ -317,6 +351,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT; screenLayout = delta.screenLayout; } + if (delta.uiMode != UI_MODE_TYPE_NORMAL + && uiMode != delta.uiMode) { + changed |= ActivityInfo.CONFIG_UI_MODE; + uiMode = delta.uiMode; + } return changed; } @@ -393,6 +432,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration && screenLayout != delta.screenLayout) { changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT; } + if (delta.uiMode != UI_MODE_TYPE_NORMAL + && uiMode != delta.uiMode) { + changed |= ActivityInfo.CONFIG_UI_MODE; + } return changed; } @@ -444,6 +487,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration dest.writeInt(navigationHidden); dest.writeInt(orientation); dest.writeInt(screenLayout); + dest.writeInt(uiMode); } public static final Parcelable.Creator<Configuration> CREATOR @@ -477,6 +521,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration navigationHidden = source.readInt(); orientation = source.readInt(); screenLayout = source.readInt(); + uiMode = source.readInt(); } public int compareTo(Configuration that) { @@ -510,6 +555,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration n = this.orientation - that.orientation; if (n != 0) return n; n = this.screenLayout - that.screenLayout; + if (n != 0) return n; + n = this.uiMode - that.uiMode; //if (n != 0) return n; return n; } @@ -533,6 +580,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration + this.locale.hashCode() + this.touchscreen + this.keyboard + this.keyboardHidden + this.hardKeyboardHidden + this.navigation + this.navigationHidden - + this.orientation + this.screenLayout; + + this.orientation + this.screenLayout + this.uiMode; } } diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index e4fc259..ae8e297 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -1294,7 +1294,7 @@ public class Resources { mConfiguration.touchscreen, (int)(mMetrics.density*160), mConfiguration.keyboard, keyboardHidden, mConfiguration.navigation, width, height, - mConfiguration.screenLayout, sSdkVersion); + mConfiguration.screenLayout, mConfiguration.uiMode, sSdkVersion); int N = mDrawableCache.size(); if (DEBUG_CONFIG) { Log.d(TAG, "Cleaning up drawables config changes: 0x" |