Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6bfb82d authored by Alan Viverette's avatar Alan Viverette
Browse files

Improve handling of AlertDialog padding between title and content

Very slight improvements all-around. There is now greater separation
between the list's top edge and the title and less separation between
the list's bottom edge and the buttons.

Bug: 27535708
Change-Id: Ia0d0dfa5ea6d34597104885dd2c773144dcf446e
parent 2ea367d8
Loading
Loading
Loading
Loading
+37 −9
Original line number Diff line number Diff line
@@ -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) {
                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
+7 −2
Original line number Diff line number Diff line
@@ -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>
+7 −1
Original line number Diff line number Diff line
@@ -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>
+1 −1
Original line number Diff line number Diff line
@@ -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"
+1 −1
Original line number Diff line number Diff line
@@ -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
Loading