diff options
4 files changed, 46 insertions, 40 deletions
diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java index 9dabb4e..b8110e3 100644 --- a/core/java/com/android/internal/app/AlertController.java +++ b/core/java/com/android/internal/app/AlertController.java @@ -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); } } diff --git a/core/res/res/layout/select_dialog_multichoice_material.xml b/core/res/res/layout/select_dialog_multichoice_material.xml index 9cfbbb3..e21df73 100644 --- a/core/res/res/layout/select_dialog_multichoice_material.xml +++ b/core/res/res/layout/select_dialog_multichoice_material.xml @@ -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" /> diff --git a/core/res/res/layout/select_dialog_singlechoice_material.xml b/core/res/res/layout/select_dialog_singlechoice_material.xml index 4f8672f..3828317 100644 --- a/core/res/res/layout/select_dialog_singlechoice_material.xml +++ b/core/res/res/layout/select_dialog_singlechoice_material.xml @@ -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" /> diff --git a/core/res/res/values/dimens_material.xml b/core/res/res/values/dimens_material.xml index 6fd39f6..937e92ad 100644 --- a/core/res/res/values/dimens_material.xml +++ b/core/res/res/values/dimens_material.xml @@ -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> |