diff options
| -rw-r--r-- | core/java/com/android/internal/app/AlertController.java | 46 | ||||
| -rw-r--r-- | core/res/res/layout/alert_dialog_material.xml | 9 | ||||
| -rw-r--r-- | core/res/res/layout/alert_dialog_title_material.xml | 8 | ||||
| -rw-r--r-- | core/res/res/layout/app_anr_dialog.xml | 2 | ||||
| -rw-r--r-- | core/res/res/layout/app_error_dialog.xml | 2 | ||||
| -rw-r--r-- | core/res/res/layout/select_dialog_material.xml | 6 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 7 | ||||
| -rw-r--r-- | core/res/res/values/dimens.xml | 1 | ||||
| -rw-r--r-- | core/res/res/values/dimens_material.xml | 6 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 3 |
10 files changed, 70 insertions, 20 deletions
diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java index 753c0691222e..b7ac6008a1fd 100644 --- a/core/java/com/android/internal/app/AlertController.java +++ b/core/java/com/android/internal/app/AlertController.java @@ -516,9 +516,15 @@ public class AlertController { } // Only show the divider if we have a title. - final View divider; + View divider = null; if (mMessage != null || mListView != null || hasCustomPanel) { - divider = topPanel.findViewById(R.id.titleDivider); + if (!hasCustomPanel) { + divider = topPanel.findViewById(R.id.titleDividerNoCustom); + } + if (divider == null) { + divider = topPanel.findViewById(R.id.titleDivider); + } + } else { divider = topPanel.findViewById(R.id.titleDividerTop); } @@ -526,6 +532,17 @@ public class AlertController { if (divider != null) { divider.setVisibility(View.VISIBLE); } + } else { + if (contentPanel != null) { + final View spacer = contentPanel.findViewById(R.id.textSpacerNoTitle); + if (spacer != null) { + spacer.setVisibility(View.VISIBLE); + } + } + } + + if (mListView instanceof RecycleListView) { + ((RecycleListView) mListView).setHasDecor(hasTopPanel, hasButtonPanel); } // Update scroll indicators as needed. @@ -861,23 +878,34 @@ public class AlertController { } public static class RecycleListView extends ListView { + private final int mPaddingTopNoTitle; + private final int mPaddingBottomNoButtons; + boolean mRecycleOnMeasure = true; public RecycleListView(Context context) { - super(context); + this(context, null); } public RecycleListView(Context context, AttributeSet attrs) { super(context, attrs); - } - public RecycleListView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); + final TypedArray ta = context.obtainStyledAttributes( + attrs, R.styleable.RecycleListView); + mPaddingBottomNoButtons = ta.getDimensionPixelOffset( + R.styleable.RecycleListView_paddingBottomNoButtons, -1); + mPaddingTopNoTitle = ta.getDimensionPixelOffset( + R.styleable.RecycleListView_paddingTopNoTitle, -1); } - public RecycleListView( - Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); + public void setHasDecor(boolean hasTitle, boolean hasButtons) { + if (!hasButtons || !hasTitle) { + final int paddingLeft = getPaddingLeft(); + final int paddingTop = hasTitle ? getPaddingTop() : mPaddingTopNoTitle; + final int paddingRight = getPaddingRight(); + final int paddingBottom = hasButtons ? getPaddingBottom() : mPaddingBottomNoButtons; + setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); + } } @Override diff --git a/core/res/res/layout/alert_dialog_material.xml b/core/res/res/layout/alert_dialog_material.xml index 9f5093799cd9..6d33de6ca307 100644 --- a/core/res/res/layout/alert_dialog_material.xml +++ b/core/res/res/layout/alert_dialog_material.xml @@ -34,7 +34,6 @@ android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="@dimen/dialog_padding_top_material" android:clipToPadding="false"> <LinearLayout @@ -42,6 +41,12 @@ android:layout_height="wrap_content" android:orientation="vertical"> + <Space + android:id="@+id/textSpacerNoTitle" + android:visibility="gone" + android:layout_width="match_parent" + android:layout_height="@dimen/dialog_padding_top_material" /> + <TextView android:id="@+id/message" android:layout_width="match_parent" @@ -53,7 +58,7 @@ <Space android:id="@+id/textSpacerNoButtons" android:visibility="gone" - android:layout_width="0dp" + android:layout_width="match_parent" android:layout_height="@dimen/dialog_padding_top_material" /> </LinearLayout> </ScrollView> diff --git a/core/res/res/layout/alert_dialog_title_material.xml b/core/res/res/layout/alert_dialog_title_material.xml index 738a6373b338..eef95859cab6 100644 --- a/core/res/res/layout/alert_dialog_title_material.xml +++ b/core/res/res/layout/alert_dialog_title_material.xml @@ -21,6 +21,8 @@ android:layout_height="wrap_content" android:orientation="vertical"> + <!-- If the client uses a customTitle, it will be added here. --> + <LinearLayout android:id="@+id/title_template" android:layout_width="match_parent" @@ -49,5 +51,9 @@ style="?attr/windowTitleStyle" /> </LinearLayout> - <!-- If the client uses a customTitle, it will be added here. --> + <Space + android:id="@+id/titleDividerNoCustom" + android:visibility="gone" + android:layout_width="match_parent" + android:layout_height="@dimen/dialog_title_divider_material" /> </LinearLayout> diff --git a/core/res/res/layout/app_anr_dialog.xml b/core/res/res/layout/app_anr_dialog.xml index 8bef116fa89e..5ad0f4c0f6cc 100644 --- a/core/res/res/layout/app_anr_dialog.xml +++ b/core/res/res/layout/app_anr_dialog.xml @@ -19,7 +19,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="@dimen/aerr_padding_list_top" - android:paddingBottom="@dimen/dialog_list_padding_vertical_material"> + android:paddingBottom="@dimen/aerr_padding_list_bottom"> <Button android:id="@+id/aerr_close" diff --git a/core/res/res/layout/app_error_dialog.xml b/core/res/res/layout/app_error_dialog.xml index b9531f46e275..7147ea24ee5d 100644 --- a/core/res/res/layout/app_error_dialog.xml +++ b/core/res/res/layout/app_error_dialog.xml @@ -22,7 +22,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="@dimen/aerr_padding_list_top" - android:paddingBottom="@dimen/dialog_list_padding_vertical_material"> + android:paddingBottom="@dimen/aerr_padding_list_bottom"> <Button diff --git a/core/res/res/layout/select_dialog_material.xml b/core/res/res/layout/select_dialog_material.xml index 19ad407d7a96..9a068f9adaec 100644 --- a/core/res/res/layout/select_dialog_material.xml +++ b/core/res/res/layout/select_dialog_material.xml @@ -30,6 +30,6 @@ android:scrollbars="vertical" android:overScrollMode="ifContentScrolls" android:textAlignment="viewStart" - android:paddingTop="@dimen/dialog_list_padding_vertical_material" - android:paddingBottom="@dimen/dialog_list_padding_vertical_material" - android:clipToPadding="false" /> + android:clipToPadding="false" + android:paddingBottomNoButtons="@dimen/dialog_list_padding_bottom_no_buttons" + android:paddingTopNoTitle="@dimen/dialog_list_padding_top_no_title" /> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 44290010b746..0ed1f133c627 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3528,6 +3528,13 @@ i This setting implies fastScrollEnabled. --> <attr name="fastScrollAlwaysVisible" format="boolean" /> </declare-styleable> + <!-- @hide --> + <declare-styleable name="RecycleListView"> + <!-- Bottom padding to use when no buttons are present. --> + <attr name="paddingBottomNoButtons" format="dimension" /> + <!-- Top padding to use when no title is present. --> + <attr name="paddingTopNoTitle" format="dimension" /> + </declare-styleable> <declare-styleable name="AbsSpinner"> <!-- Reference to an array resource that will populate the Spinner. For static content, this is simpler than populating the Spinner programmatically. --> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 71d9a1f6c6ef..a21f276873e8 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -450,6 +450,7 @@ <item type="dimen" format="integer" name="time_picker_column_end_material">1</item> <item type="dimen" name="aerr_padding_list_top">15dp</item> + <item type="dimen" name="aerr_padding_list_bottom">8dp</item> <item type="fraction" name="docked_stack_divider_fixed_ratio">34.15%</item> diff --git a/core/res/res/values/dimens_material.xml b/core/res/res/values/dimens_material.xml index ad2b335de5bb..00e48a0eb6e9 100644 --- a/core/res/res/values/dimens_material.xml +++ b/core/res/res/values/dimens_material.xml @@ -117,13 +117,13 @@ <dimen name="dialog_padding_material">24dp</dimen> <dimen name="dialog_padding_top_material">18dp</dimen> + <dimen name="dialog_title_divider_material">8dp</dimen> + <dimen name="dialog_list_padding_top_no_title">8dp</dimen> + <dimen name="dialog_list_padding_bottom_no_buttons">8dp</dimen> <!-- Dialog padding minus control padding, used to fix alignment. --> <dimen name="select_dialog_padding_start_material">20dp</dimen> - <!-- Padding above and below selection dialog lists. --> - <dimen name="dialog_list_padding_vertical_material">8dp</dimen> - <dimen name="seekbar_track_background_height_material">2dp</dimen> <dimen name="seekbar_track_progress_height_material">2dp</dimen> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 694e9342000d..4ee174e3a4c2 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2557,4 +2557,7 @@ <!-- WallpaperManager config --> <java-symbol type="string" name="config_wallpaperCropperPackage" /> + + <java-symbol type="id" name="textSpacerNoTitle" /> + <java-symbol type="id" name="titleDividerNoCustom" /> </resources> |