Merge "Improve handling of AlertDialog padding between title and content" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f0f919f19a
@@ -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);
|
||||
|
||||
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) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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. -->
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -2556,4 +2556,7 @@
|
||||
|
||||
<!-- WallpaperManager config -->
|
||||
<java-symbol type="string" name="config_wallpaperCropperPackage" />
|
||||
|
||||
<java-symbol type="id" name="textSpacerNoTitle" />
|
||||
<java-symbol type="id" name="titleDividerNoCustom" />
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user