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

Commit 8990083b authored by Alan Viverette's avatar Alan Viverette
Browse files

Fix control alignment for single- and multi-select dialogs

Clean up some code in AlertController.

Change-Id: I0e4978c4c14dd838188cb23565eb231903c82afe
parent a323e3f3
Loading
Loading
Loading
Loading
+31 −28
Original line number Diff line number Diff line
@@ -170,9 +170,8 @@ public class AlertController {
    }

    private static boolean shouldCenterSingleButton(Context context) {
        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogCenterButtons,
                outValue, true);
        final TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(R.attr.alertDialogCenterButtons, outValue, true);
        return outValue.data != 0;
    }

@@ -182,27 +181,25 @@ public class AlertController {
        mWindow = window;
        mHandler = new ButtonHandler(di);

        TypedArray a = context.obtainStyledAttributes(null,
                com.android.internal.R.styleable.AlertDialog,
                com.android.internal.R.attr.alertDialogStyle, 0);
        final TypedArray a = context.obtainStyledAttributes(null,
                R.styleable.AlertDialog, R.attr.alertDialogStyle, 0);

        mAlertDialogLayout = a.getResourceId(com.android.internal.R.styleable.AlertDialog_layout,
                com.android.internal.R.layout.alert_dialog);
        mAlertDialogLayout = a.getResourceId(
                R.styleable.AlertDialog_layout, R.layout.alert_dialog);
        mButtonPanelSideLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_buttonPanelSideLayout, 0);

                R.styleable.AlertDialog_buttonPanelSideLayout, 0);
        mListLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_listLayout,
                com.android.internal.R.layout.select_dialog);
                R.styleable.AlertDialog_listLayout, R.layout.select_dialog);

        mMultiChoiceItemLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_multiChoiceItemLayout,
                com.android.internal.R.layout.select_dialog_multichoice);
                R.styleable.AlertDialog_multiChoiceItemLayout,
                R.layout.select_dialog_multichoice);
        mSingleChoiceItemLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_singleChoiceItemLayout,
                com.android.internal.R.layout.select_dialog_singlechoice);
                R.styleable.AlertDialog_singleChoiceItemLayout,
                R.layout.select_dialog_singlechoice);
        mListItemLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_listItemLayout,
                com.android.internal.R.layout.select_dialog_item);
                R.styleable.AlertDialog_listItemLayout,
                R.layout.select_dialog_item);

        a.recycle();
    }
@@ -1067,9 +1064,9 @@ public class AlertController {
        }

        private void createListView(final AlertController dialog) {
            final RecycleListView listView = (RecycleListView)
                    mInflater.inflate(dialog.mListLayout, null);
            ListAdapter adapter;
            final RecycleListView listView =
                    (RecycleListView) mInflater.inflate(dialog.mListLayout, null);
            final ListAdapter adapter;

            if (mIsMultiChoice) {
                if (mCursor == null) {
@@ -1115,14 +1112,20 @@ public class AlertController {
                    };
                }
            } else {
                int layout = mIsSingleChoice
                        ? dialog.mSingleChoiceItemLayout : dialog.mListItemLayout;
                if (mCursor == null) {
                    adapter = (mAdapter != null) ? mAdapter
                            : new CheckedItemAdapter(mContext, layout, R.id.text1, mItems);
                final int layout;
                if (mIsSingleChoice) {
                    layout = dialog.mSingleChoiceItemLayout;
                } else {
                    layout = dialog.mListItemLayout;
                }

                if (mCursor != null) {
                    adapter = new SimpleCursorAdapter(mContext, layout, mCursor,
                            new String[] { mLabelColumn }, new int[] { R.id.text1 });
                } else if (mAdapter != null) {
                    adapter = mAdapter;
                } else {
                    adapter = new SimpleCursorAdapter(mContext, layout,
                            mCursor, new String[]{mLabelColumn}, new int[]{R.id.text1});
                    adapter = new CheckedItemAdapter(mContext, layout, R.id.text1, mItems);
                }
            }

+6 −6
Original line number Diff line number Diff line
@@ -16,15 +16,15 @@
-->

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:id="@id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="?android:attr/textColorAlertDialogListItem"
    android:minHeight="?attr/listPreferredItemHeightSmall"
    android:textAppearance="?attr/textAppearanceMedium"
    android:textColor="?attr/textColorAlertDialogListItem"
    android:gravity="center_vertical"
    android:paddingStart="?attr/dialogPreferredPadding"
    android:paddingStart="@dimen/select_dialog_padding_start_material"
    android:paddingEnd="?attr/dialogPreferredPadding"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
    android:checkMark="?attr/listChoiceIndicatorMultiple"
    android:checkMarkGravity="start"
    android:ellipsize="marquee" />
+6 −6
Original line number Diff line number Diff line
@@ -16,15 +16,15 @@
-->

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:id="@id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="?android:attr/textColorAlertDialogListItem"
    android:minHeight="?attr/listPreferredItemHeightSmall"
    android:textAppearance="?attr/textAppearanceMedium"
    android:textColor="?attr/textColorAlertDialogListItem"
    android:gravity="center_vertical"
    android:paddingStart="?attr/dialogPreferredPadding"
    android:paddingStart="@dimen/select_dialog_padding_start_material"
    android:paddingEnd="?attr/dialogPreferredPadding"
    android:checkMark="?android:attr/listChoiceIndicatorSingle"
    android:checkMark="?attr/listChoiceIndicatorSingle"
    android:checkMarkGravity="start"
    android:ellipsize="marquee" />
+3 −0
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@
    <dimen name="dialog_padding_material">24dp</dimen>
    <dimen name="dialog_padding_top_material">18dp</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>