diff options
| author | 2010-10-08 17:10:24 -0700 | |
|---|---|---|
| committer | 2010-10-08 17:10:24 -0700 | |
| commit | 54ca811b29ceea6595b7e3d607a89ee625f0184c (patch) | |
| tree | e47d878e750449fd96c96b84323d2d81559aeafa | |
| parent | 7ff6f97f84b3df7d1f2c5e730189d26ba35bc688 (diff) | |
| parent | 4fb17b0490915d1c26663140c377037ea6af132e (diff) | |
Merge "Fix alert dialog layout size in landscape"
| -rw-r--r-- | core/java/com/android/internal/widget/WeightedLinearLayout.java | 31 | ||||
| -rw-r--r-- | core/res/res/layout-xlarge/alert_dialog.xml | 150 | ||||
| -rw-r--r-- | core/res/res/layout/alert_dialog.xml | 5 | ||||
| -rwxr-xr-x | core/res/res/values/attrs.xml | 6 |
4 files changed, 176 insertions, 16 deletions
diff --git a/core/java/com/android/internal/widget/WeightedLinearLayout.java b/core/java/com/android/internal/widget/WeightedLinearLayout.java index 3d09f08826f9..385a7c3ce566 100644 --- a/core/java/com/android/internal/widget/WeightedLinearLayout.java +++ b/core/java/com/android/internal/widget/WeightedLinearLayout.java @@ -30,8 +30,10 @@ import static com.android.internal.R.*; * the available space. */ public class WeightedLinearLayout extends LinearLayout { - private float mMajorWeight; - private float mMinorWeight; + private float mMajorWeightMin; + private float mMinorWeightMin; + private float mMajorWeightMax; + private float mMinorWeightMax; public WeightedLinearLayout(Context context) { super(context); @@ -43,8 +45,10 @@ public class WeightedLinearLayout extends LinearLayout { TypedArray a = context.obtainStyledAttributes(attrs, styleable.WeightedLinearLayout); - mMajorWeight = a.getFloat(styleable.WeightedLinearLayout_majorWeight, 0.0f); - mMinorWeight = a.getFloat(styleable.WeightedLinearLayout_minorWeight, 0.0f); + mMajorWeightMin = a.getFloat(styleable.WeightedLinearLayout_majorWeightMin, 0.0f); + mMinorWeightMin = a.getFloat(styleable.WeightedLinearLayout_minorWeightMin, 0.0f); + mMajorWeightMax = a.getFloat(styleable.WeightedLinearLayout_majorWeightMax, 0.0f); + mMinorWeightMax = a.getFloat(styleable.WeightedLinearLayout_minorWeightMax, 0.0f); a.recycle(); } @@ -60,17 +64,20 @@ public class WeightedLinearLayout extends LinearLayout { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = getMeasuredWidth(); - int height = getMeasuredHeight(); boolean measure = false; widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY); - heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, EXACTLY); - final float widthWeight = isPortrait ? mMinorWeight : mMajorWeight; - if (widthMode == AT_MOST && widthWeight > 0.0f) { - if (width < (screenWidth * widthWeight)) { - widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (screenWidth * widthWeight), - EXACTLY); + final float widthWeightMin = isPortrait ? mMinorWeightMin : mMajorWeightMin; + final float widthWeightMax = isPortrait ? mMinorWeightMax : mMajorWeightMax; + if (widthMode == AT_MOST) { + final int weightedMin = (int) (screenWidth * widthWeightMin); + final int weightedMax = (int) (screenWidth * widthWeightMin); + if (widthWeightMin > 0.0f && width < weightedMin) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(weightedMin, EXACTLY); + measure = true; + } else if (widthWeightMax > 0.0f && width > weightedMax) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(weightedMax, EXACTLY); measure = true; } } @@ -78,7 +85,7 @@ public class WeightedLinearLayout extends LinearLayout { // TODO: Support height? if (measure) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } } diff --git a/core/res/res/layout-xlarge/alert_dialog.xml b/core/res/res/layout-xlarge/alert_dialog.xml new file mode 100644 index 000000000000..5291e9dc44fb --- /dev/null +++ b/core/res/res/layout-xlarge/alert_dialog.xml @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* //device/apps/common/res/layout/alert_dialog.xml +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<com.android.internal.widget.WeightedLinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/parentPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="9dip" + android:paddingBottom="3dip" + android:paddingLeft="3dip" + android:paddingRight="1dip" + android:majorWeightMin="0.45" + android:minorWeightMin="0.72" + android:majorWeightMax="0.45" + android:minorWeightMax="0.72"> + + <LinearLayout android:id="@+id/topPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="54dip" + android:orientation="vertical"> + <LinearLayout android:id="@+id/title_template" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:gravity="center_vertical" + android:layout_marginTop="6dip" + android:layout_marginBottom="9dip" + android:layout_marginLeft="10dip" + android:layout_marginRight="10dip"> + <ImageView android:id="@+id/icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="top" + android:paddingTop="6dip" + android:paddingRight="10dip" + android:src="@drawable/ic_dialog_info" /> + <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle" + style="?android:attr/textAppearanceLarge" + android:singleLine="true" + android:ellipsize="end" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + </LinearLayout> + <ImageView android:id="@+id/titleDivider" + android:layout_width="match_parent" + android:layout_height="1dip" + android:visibility="gone" + android:scaleType="fitXY" + android:gravity="fill_horizontal" + android:src="@android:drawable/divider_horizontal_dark" /> + <!-- If the client uses a customTitle, it will be added here. --> + </LinearLayout> + + <LinearLayout android:id="@+id/contentPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical"> + <ScrollView android:id="@+id/scrollView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="2dip" + android:paddingBottom="12dip" + android:paddingLeft="14dip" + android:paddingRight="10dip"> + <TextView android:id="@+id/message" + style="?android:attr/textAppearanceMedium" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="5dip" /> + </ScrollView> + </LinearLayout> + + <FrameLayout android:id="@+id/customPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1"> + <FrameLayout android:id="@+android:id/custom" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="5dip" + android:paddingBottom="5dip" /> + </FrameLayout> + + <LinearLayout android:id="@+id/buttonPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="54dip" + android:orientation="vertical" > + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingTop="4dip" + android:paddingLeft="2dip" + android:paddingRight="2dip" + android:measureWithLargestChild="true"> + <LinearLayout android:id="@+id/leftSpacer" + android:layout_weight="0.25" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:visibility="gone" /> + <Button android:id="@+id/button1" + android:layout_width="0dip" + android:layout_gravity="left" + android:layout_weight="1" + android:maxLines="2" + android:layout_height="wrap_content" /> + <Button android:id="@+id/button3" + android:layout_width="0dip" + android:layout_gravity="center_horizontal" + android:layout_weight="1" + android:maxLines="2" + android:layout_height="wrap_content" /> + <Button android:id="@+id/button2" + android:layout_width="0dip" + android:layout_gravity="right" + android:layout_weight="1" + android:maxLines="2" + android:layout_height="wrap_content" /> + <LinearLayout android:id="@+id/rightSpacer" + android:layout_width="0dip" + android:layout_weight="0.25" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:visibility="gone" /> + </LinearLayout> + </LinearLayout> +</com.android.internal.widget.WeightedLinearLayout> diff --git a/core/res/res/layout/alert_dialog.xml b/core/res/res/layout/alert_dialog.xml index b746d289bb30..541d84d62edb 100644 --- a/core/res/res/layout/alert_dialog.xml +++ b/core/res/res/layout/alert_dialog.xml @@ -28,8 +28,9 @@ android:paddingBottom="3dip" android:paddingLeft="3dip" android:paddingRight="1dip" - android:majorWeight="0.65" - android:minorWeight="0.9"> + android:majorWeightMin="0.65" + android:minorWeightMin="0.9" + android:majorWeightMax="0.65"> <LinearLayout android:id="@+id/topPanel" android:layout_width="match_parent" diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 2a83b67ae378..d9f00394c004 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2609,8 +2609,10 @@ <!-- @hide --> <declare-styleable name="WeightedLinearLayout"> - <attr name="majorWeight" format="float" /> - <attr name="minorWeight" format="float" /> + <attr name="majorWeightMin" format="float" /> + <attr name="minorWeightMin" format="float" /> + <attr name="majorWeightMax" format="float" /> + <attr name="minorWeightMax" format="float" /> </declare-styleable> <!-- ========================= --> |