summaryrefslogtreecommitdiffstats
path: root/policy/src
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2012-02-15 17:10:58 -0800
committerAdam Powell <adamp@google.com>2012-02-21 15:32:26 -0800
commit40eec4c0f1392665dbfcd9ca9ea4a9519a71c34a (patch)
tree81f21bb20aa50f8074e45dad513bef09c6074f57 /policy/src
parent30167542cb23726a0d28c2eeb280f16f3101e97f (diff)
downloadframeworks_base-40eec4c0f1392665dbfcd9ca9ea4a9519a71c34a.zip
frameworks_base-40eec4c0f1392665dbfcd9ca9ea4a9519a71c34a.tar.gz
frameworks_base-40eec4c0f1392665dbfcd9ca9ea4a9519a71c34a.tar.bz2
Fix the size of DialogWhenLarge windows
Change-Id: I8c9588e958d8fb9c45b1cdb235cced48ba508dd3
Diffstat (limited to 'policy/src')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java91
1 files changed, 77 insertions, 14 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index b87b8c3..301dbf5 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -115,6 +115,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
final TypedValue mMinWidthMajor = new TypedValue();
final TypedValue mMinWidthMinor = new TypedValue();
+ TypedValue mFixedWidthMajor;
+ TypedValue mFixedWidthMinor;
+ TypedValue mFixedHeightMajor;
+ TypedValue mFixedHeightMinor;
// This is the top-level view of the window, containing the window decor.
private DecorView mDecor;
@@ -2088,6 +2092,44 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;
final int widthMode = getMode(widthMeasureSpec);
+ final int heightMode = getMode(heightMeasureSpec);
+
+ boolean fixedWidth = false;
+ if (widthMode == AT_MOST) {
+ final TypedValue tvw = isPortrait ? mFixedWidthMinor : mFixedWidthMajor;
+ if (tvw != null && tvw.type != TypedValue.TYPE_NULL) {
+ fixedWidth = true;
+ final int w;
+ if (tvw.type == TypedValue.TYPE_DIMENSION) {
+ w = (int) tvw.getDimension(metrics);
+ } else if (tvw.type == TypedValue.TYPE_FRACTION) {
+ w = (int) tvw.getFraction(metrics.widthPixels, metrics.widthPixels);
+ } else {
+ w = 0;
+ }
+
+ final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(Math.min(w, widthSize), EXACTLY);
+ }
+ }
+
+ if (heightMode == AT_MOST) {
+ final TypedValue tvh = isPortrait ? mFixedHeightMajor : mFixedHeightMinor;
+ if (tvh != null && tvh.type != TypedValue.TYPE_NULL) {
+ final int h;
+ if (tvh.type == TypedValue.TYPE_DIMENSION) {
+ h = (int) tvh.getDimension(metrics);
+ } else if (tvh.type == TypedValue.TYPE_FRACTION) {
+ h = (int) tvh.getFraction(metrics.heightPixels, metrics.heightPixels);
+ } else {
+ h = 0;
+ }
+
+ final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+ heightMeasureSpec =
+ MeasureSpec.makeMeasureSpec(Math.min(h, heightSize), EXACTLY);
+ }
+ }
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
@@ -2096,21 +2138,22 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY);
- final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor;
-
- if (widthMode == AT_MOST && tv.type != TypedValue.TYPE_NULL) {
- final int min;
- if (tv.type == TypedValue.TYPE_DIMENSION) {
- min = (int)tv.getDimension(metrics);
- } else if (tv.type == TypedValue.TYPE_FRACTION) {
- min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels);
- } else {
- min = 0;
- }
+ if (!fixedWidth && widthMode == AT_MOST) {
+ final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor;
+ if (tv.type != TypedValue.TYPE_NULL) {
+ final int min;
+ if (tv.type == TypedValue.TYPE_DIMENSION) {
+ min = (int)tv.getDimension(metrics);
+ } else if (tv.type == TypedValue.TYPE_FRACTION) {
+ min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels);
+ } else {
+ min = 0;
+ }
- if (width < min) {
- widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
- measure = true;
+ if (width < min) {
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
+ measure = true;
+ }
}
}
@@ -2571,6 +2614,26 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
a.getValue(com.android.internal.R.styleable.Window_windowMinWidthMajor, mMinWidthMajor);
a.getValue(com.android.internal.R.styleable.Window_windowMinWidthMinor, mMinWidthMinor);
+ if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedWidthMajor)) {
+ if (mFixedWidthMajor == null) mFixedWidthMajor = new TypedValue();
+ a.getValue(com.android.internal.R.styleable.Window_windowFixedWidthMajor,
+ mFixedWidthMajor);
+ }
+ if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedWidthMinor)) {
+ if (mFixedWidthMinor == null) mFixedWidthMinor = new TypedValue();
+ a.getValue(com.android.internal.R.styleable.Window_windowFixedWidthMinor,
+ mFixedWidthMinor);
+ }
+ if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedHeightMajor)) {
+ if (mFixedHeightMajor == null) mFixedHeightMajor = new TypedValue();
+ a.getValue(com.android.internal.R.styleable.Window_windowFixedHeightMajor,
+ mFixedHeightMajor);
+ }
+ if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedHeightMinor)) {
+ if (mFixedHeightMinor == null) mFixedHeightMinor = new TypedValue();
+ a.getValue(com.android.internal.R.styleable.Window_windowFixedHeightMinor,
+ mFixedHeightMinor);
+ }
final Context context = getContext();
final int targetSdk = context.getApplicationInfo().targetSdkVersion;