From 55565ecd46ceef91abba8bda8eddb73e75300ca3 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 9 Apr 2014 16:52:54 -0700 Subject: [PATCH] Update list item text appearance Adds a new attribute for secondary list item text and points the Gingerbread and Holo themes to use TextAppearance.Small for compatibility's sake. Change-Id: I8e78a908b699baae6d1f5b3623fd7b5648b99b77 --- api/current.txt | 1 + core/java/android/preference/Preference.java | 10 ++- .../layout/preference_category_quantum.xml | 28 +++++++ .../res/layout/preference_child_quantum.xml | 73 ++++++++++++++++++ .../layout/preference_information_quantum.xml | 74 ++++++++++++++++++ core/res/res/layout/preference_quantum.xml | 77 +++++++++++++++++++ .../res/layout/preference_widget_checkbox.xml | 1 - .../res/layout/preference_widget_switch.xml | 1 - core/res/res/layout/simple_list_item_1.xml | 3 +- core/res/res/layout/simple_list_item_2.xml | 27 +++---- .../simple_list_item_2_single_choice.xml | 19 +++-- .../layout/simple_list_item_activated_1.xml | 3 +- .../layout/simple_list_item_activated_2.xml | 9 +-- .../res/layout/simple_list_item_checked.xml | 3 +- .../simple_list_item_multiple_choice.xml | 3 +- .../layout/simple_list_item_single_choice.xml | 3 +- core/res/res/values/attrs.xml | 2 + core/res/res/values/public.xml | 1 + core/res/res/values/styles_quantum.xml | 6 +- core/res/res/values/symbols.xml | 1 + core/res/res/values/themes.xml | 4 + core/res/res/values/themes_quantum.xml | 30 +++++--- 22 files changed, 320 insertions(+), 59 deletions(-) create mode 100644 core/res/res/layout/preference_category_quantum.xml create mode 100644 core/res/res/layout/preference_child_quantum.xml create mode 100644 core/res/res/layout/preference_information_quantum.xml create mode 100644 core/res/res/layout/preference_quantum.xml diff --git a/api/current.txt b/api/current.txt index 3230bd893b1a9..130a19b584302 100644 --- a/api/current.txt +++ b/api/current.txt @@ -1132,6 +1132,7 @@ package android { field public static final int textAppearanceLargeInverse = 16842819; // 0x1010043 field public static final int textAppearanceLargePopupMenu = 16843521; // 0x1010301 field public static final int textAppearanceListItem = 16843678; // 0x101039e + field public static final int textAppearanceListItemSecondary = 16843838; // 0x101043e field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f field public static final int textAppearanceMedium = 16842817; // 0x1010041 field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044 diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java index 144c90914a79c..56d5617a67125 100644 --- a/core/java/android/preference/Preference.java +++ b/core/java/android/preference/Preference.java @@ -533,8 +533,7 @@ public class Preference implements Comparable { * @see #onCreateView(ViewGroup) */ protected void onBindView(View view) { - final TextView titleView = (TextView) view.findViewById( - com.android.internal.R.id.title); + final TextView titleView = (TextView) view.findViewById(com.android.internal.R.id.title); if (titleView != null) { final CharSequence title = getTitle(); if (!TextUtils.isEmpty(title)) { @@ -557,7 +556,7 @@ public class Preference implements Comparable { } } - ImageView imageView = (ImageView) view.findViewById(com.android.internal.R.id.icon); + final ImageView imageView = (ImageView) view.findViewById(com.android.internal.R.id.icon); if (imageView != null) { if (mIconResId != 0 || mIcon != null) { if (mIcon == null) { @@ -570,6 +569,11 @@ public class Preference implements Comparable { imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE); } + final View imageFrame = view.findViewById(com.android.internal.R.id.icon_frame); + if (imageFrame != null) { + imageFrame.setVisibility(mIcon != null ? View.VISIBLE : View.GONE); + } + if (mShouldDisableView) { setEnabledStateOnViews(view, isEnabled()); } diff --git a/core/res/res/layout/preference_category_quantum.xml b/core/res/res/layout/preference_category_quantum.xml new file mode 100644 index 0000000000000..032e09d8af35f --- /dev/null +++ b/core/res/res/layout/preference_category_quantum.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/core/res/res/layout/preference_child_quantum.xml b/core/res/res/layout/preference_child_quantum.xml new file mode 100644 index 0000000000000..690d64a23db1e --- /dev/null +++ b/core/res/res/layout/preference_child_quantum.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/res/res/layout/preference_information_quantum.xml b/core/res/res/layout/preference_information_quantum.xml new file mode 100644 index 0000000000000..f21640fc0818f --- /dev/null +++ b/core/res/res/layout/preference_information_quantum.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/res/res/layout/preference_quantum.xml b/core/res/res/layout/preference_quantum.xml new file mode 100644 index 0000000000000..a4fe73d0cf608 --- /dev/null +++ b/core/res/res/layout/preference_quantum.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/res/res/layout/preference_widget_checkbox.xml b/core/res/res/layout/preference_widget_checkbox.xml index 33a43f455683e..bfd7f0aaf8cab 100644 --- a/core/res/res/layout/preference_widget_checkbox.xml +++ b/core/res/res/layout/preference_widget_checkbox.xml @@ -20,6 +20,5 @@ android:id="@+android:id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" android:focusable="false" android:clickable="false" /> diff --git a/core/res/res/layout/preference_widget_switch.xml b/core/res/res/layout/preference_widget_switch.xml index 83ef0975bcf48..534c7eca135e4 100644 --- a/core/res/res/layout/preference_widget_switch.xml +++ b/core/res/res/layout/preference_widget_switch.xml @@ -20,6 +20,5 @@ android:id="@+android:id/switchWidget" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" android:padding="16dip" android:focusable="false" /> diff --git a/core/res/res/layout/simple_list_item_1.xml b/core/res/res/layout/simple_list_item_1.xml index 4249d102b6ff9..43a5635feeca4 100644 --- a/core/res/res/layout/simple_list_item_1.xml +++ b/core/res/res/layout/simple_list_item_1.xml @@ -22,5 +22,4 @@ android:gravity="center_vertical" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" - android:minHeight="?android:attr/listPreferredItemHeightSmall" -/> + android:minHeight="?android:attr/listPreferredItemHeightSmall" /> diff --git a/core/res/res/layout/simple_list_item_2.xml b/core/res/res/layout/simple_list_item_2.xml index 63c542bbc3bbd..b47a34650bbde 100644 --- a/core/res/res/layout/simple_list_item_2.xml +++ b/core/res/res/layout/simple_list_item_2.xml @@ -20,22 +20,19 @@ android:minHeight="?android:attr/listPreferredItemHeight" android:mode="twoLine" android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" -> - + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> + - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dip" + android:textAppearance="?android:attr/textAppearanceListItem" /> + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@android:id/text1" + android:layout_alignStart="@android:id/text1" + android:textAppearance="?android:attr/textAppearanceListItemSecondary" /> diff --git a/core/res/res/layout/simple_list_item_2_single_choice.xml b/core/res/res/layout/simple_list_item_2_single_choice.xml index 562956740b1e2..65c58563f1126 100644 --- a/core/res/res/layout/simple_list_item_2_single_choice.xml +++ b/core/res/res/layout/simple_list_item_2_single_choice.xml @@ -22,31 +22,34 @@ android:paddingStart="16dip" android:paddingEnd="12dip" android:minHeight="?android:attr/listPreferredItemHeightSmall"> + + + android:ellipsize="marquee" /> + + android:ellipsize="marquee" /> + + + android:clickable="false" /> + diff --git a/core/res/res/layout/simple_list_item_activated_1.xml b/core/res/res/layout/simple_list_item_activated_1.xml index 41155e4018eab..9b778d7b9285b 100644 --- a/core/res/res/layout/simple_list_item_activated_1.xml +++ b/core/res/res/layout/simple_list_item_activated_1.xml @@ -23,5 +23,4 @@ android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:background="?android:attr/activatedBackgroundIndicator" - android:minHeight="?android:attr/listPreferredItemHeightSmall" -/> + android:minHeight="?android:attr/listPreferredItemHeightSmall" /> diff --git a/core/res/res/layout/simple_list_item_activated_2.xml b/core/res/res/layout/simple_list_item_activated_2.xml index 725697d4294e4..50368130f1d57 100644 --- a/core/res/res/layout/simple_list_item_activated_2.xml +++ b/core/res/res/layout/simple_list_item_activated_2.xml @@ -21,23 +21,20 @@ android:layout_height="wrap_content" android:background="?android:attr/activatedBackgroundIndicator" android:minHeight="?android:attr/listPreferredItemHeight" - android:mode="twoLine" -> + android:mode="twoLine"> + android:textAppearance="?android:attr/textAppearanceListItem" /> + android:textAppearance="?android:attr/textAppearanceListItemSecondary" /> diff --git a/core/res/res/layout/simple_list_item_checked.xml b/core/res/res/layout/simple_list_item_checked.xml index 0c497d6541dc1..4673e2797d803 100644 --- a/core/res/res/layout/simple_list_item_checked.xml +++ b/core/res/res/layout/simple_list_item_checked.xml @@ -22,5 +22,4 @@ android:gravity="center_vertical" android:checkMark="?android:attr/textCheckMark" android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" -/> + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" /> diff --git a/core/res/res/layout/simple_list_item_multiple_choice.xml b/core/res/res/layout/simple_list_item_multiple_choice.xml index 076d8c62aa3ff..440b6fd8e1b11 100644 --- a/core/res/res/layout/simple_list_item_multiple_choice.xml +++ b/core/res/res/layout/simple_list_item_multiple_choice.xml @@ -22,5 +22,4 @@ android:gravity="center_vertical" android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" -/> + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" /> diff --git a/core/res/res/layout/simple_list_item_single_choice.xml b/core/res/res/layout/simple_list_item_single_choice.xml index 4c1af09c2d2b3..02cb7f77645ce 100644 --- a/core/res/res/layout/simple_list_item_single_choice.xml +++ b/core/res/res/layout/simple_list_item_single_choice.xml @@ -22,5 +22,4 @@ android:gravity="center_vertical" android:checkMark="?android:attr/listChoiceIndicatorSingle" android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" -/> + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" /> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 46cb9b22728a2..2785ac3e3f544 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -245,6 +245,8 @@ + + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index acdf92683a358..d3bee288d2f4e 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2148,6 +2148,7 @@ + diff --git a/core/res/res/values/styles_quantum.xml b/core/res/res/values/styles_quantum.xml index dd148c4413634..2720d61532a54 100644 --- a/core/res/res/values/styles_quantum.xml +++ b/core/res/res/values/styles_quantum.xml @@ -33,7 +33,7 @@ please see styles_device_defaults.xml. 58dip @@ -269,6 +271,7 @@ please see themes_device_defaults.xml. @style/Preference.Quantum.PreferenceScreen @style/PreferenceFragment.Quantum + 0dip @style/Preference.Quantum.Category @style/Preference.Quantum @style/Preference.Quantum.Information @@ -278,7 +281,7 @@ please see themes_device_defaults.xml. @style/Preference.Quantum.DialogPreference @style/Preference.Quantum.DialogPreference.EditTextPreference @style/Preference.Quantum.RingtonePreference - @layout/preference_child_holo + @layout/preference_child_quantum ?attr/colorBackground @@ -442,11 +445,13 @@ please see themes_device_defaults.xml. 48dip 80dip ?attr/listPreferredItemHeightSmall - ?attr/textAppearanceMedium - 8dip - 8dip - 8dip - 8dip + @style/TextAppearance.Quantum.Subhead + @style/TextAppearance.Quantum.Subhead + @style/TextAppearance.Quantum.Body1 + 16dip + 16dip + 16dip + 16dip 58dip @@ -601,6 +606,7 @@ please see themes_device_defaults.xml. @style/Preference.Quantum.PreferenceScreen @style/PreferenceFragment.Quantum + 0dip @style/Preference.Quantum.Category @style/Preference.Quantum @style/Preference.Quantum.Information @@ -610,7 +616,7 @@ please see themes_device_defaults.xml. @style/Preference.Quantum.DialogPreference @style/Preference.Quantum.DialogPreference.EditTextPreference @style/Preference.Quantum.RingtonePreference - @layout/preference_child_holo + @layout/preference_child_quantum ?attr/colorBackground