From 1d2385d08a9e706243fdf9399b417ad7e24c19ba Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Fri, 20 May 2011 14:59:06 -0700 Subject: [PATCH] DO NOT MERGE. Preference activity changes to work on smaller tablet screens. Breadcrumbs move to the action bar on certain configs. Padding around fragments and to the left of preference items adjusted for different display sizes. Change-Id: Ie899f9742f4ebd7044f158b1c7db06df82ad2d75 --- core/java/android/preference/Preference.java | 2 + .../preference/PreferenceActivity.java | 24 ++++-------- .../preference_list_content_single.xml | 0 .../layout-xlarge/breadcrumbs_in_fragment.xml | 39 +++++++++++++++++++ .../res/layout/breadcrumbs_in_fragment.xml | 22 +++++++++++ .../res/layout/preference_category_holo.xml | 2 +- core/res/res/layout/preference_child_holo.xml | 3 +- core/res/res/layout/preference_holo.xml | 5 ++- .../layout/preference_information_holo.xml | 17 ++++++-- .../res/layout/preference_list_content.xml | 36 ++++++----------- .../res/layout/preference_list_fragment.xml | 6 +-- core/res/res/layout/search_view.xml | 4 +- core/res/res/values-h720dp/dimens.xml | 6 +++ core/res/res/values-land/dimens.xml | 4 +- core/res/res/values-large/styles.xml | 25 ++++++++++++ core/res/res/values-sw600dp/bools.xml | 19 +++++++++ core/res/res/values-w1280dp/dimens.xml | 32 +++++++++++++++ core/res/res/values-w720dp/dimens.xml | 14 +++++++ core/res/res/values-xlarge/styles.xml | 8 ---- core/res/res/values/bools.xml | 19 +++++++++ core/res/res/values/dimens.xml | 23 ++++++++++- core/res/res/values/styles.xml | 6 +-- 22 files changed, 248 insertions(+), 68 deletions(-) rename core/res/res/{layout-xlarge => layout-w600dp}/preference_list_content_single.xml (100%) create mode 100644 core/res/res/layout-xlarge/breadcrumbs_in_fragment.xml create mode 100644 core/res/res/layout/breadcrumbs_in_fragment.xml create mode 100644 core/res/res/values-large/styles.xml create mode 100644 core/res/res/values-sw600dp/bools.xml create mode 100644 core/res/res/values-w1280dp/dimens.xml create mode 100644 core/res/res/values/bools.xml diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java index 7d37e5bdf11d1..1584424a66240 100644 --- a/core/java/android/preference/Preference.java +++ b/core/java/android/preference/Preference.java @@ -519,6 +519,7 @@ public class Preference implements Comparable, OnDependencyChangeLis if (mIcon != null) { imageView.setImageDrawable(mIcon); } + imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE); } if (mShouldDisableView) { setEnabledStateOnViews(view, isEnabled()); @@ -618,6 +619,7 @@ public class Preference implements Comparable, OnDependencyChangeLis public void setIcon(Drawable icon) { if ((icon == null && mIcon != null) || (icon != null && mIcon != icon)) { mIcon = icon; + notifyChanged(); } } diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java index ad0bc84a40817..8535bd46116dd 100644 --- a/core/java/android/preference/PreferenceActivity.java +++ b/core/java/android/preference/PreferenceActivity.java @@ -18,9 +18,6 @@ package android.preference; import com.android.internal.util.XmlUtils; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.app.ActionBar; import android.app.Fragment; import android.app.FragmentBreadCrumbs; @@ -44,8 +41,8 @@ import android.util.TypedValue; import android.util.Xml; import android.view.LayoutInflater; import android.view.View; -import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.view.View.OnClickListener; import android.widget.AbsListView; import android.widget.ArrayAdapter; import android.widget.Button; @@ -58,6 +55,9 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + /** * This is the base class for an activity to show a hierarchy of preferences * to the user. Prior to {@link android.os.Build.VERSION_CODES#HONEYCOMB} @@ -641,17 +641,9 @@ public abstract class PreferenceActivity extends ListActivity implements * enough. */ public boolean onIsMultiPane() { - Configuration config = getResources().getConfiguration(); - if ((config.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) - == Configuration.SCREENLAYOUT_SIZE_XLARGE) { - return true; - } - if ((config.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) - == Configuration.SCREENLAYOUT_SIZE_LARGE - && config.orientation == Configuration.ORIENTATION_LANDSCAPE) { - return true; - } - return false; + boolean preferMultiPane = getResources().getBoolean( + com.android.internal.R.bool.preferences_prefer_dual_pane); + return preferMultiPane; } /** @@ -992,7 +984,7 @@ public abstract class PreferenceActivity extends ListActivity implements if (mFragmentBreadCrumbs == null) { View crumbs = findViewById(android.R.id.title); // For screens with a different kind of title, don't create breadcrumbs. - if (!(crumbs instanceof FragmentBreadCrumbs)) return; + if (crumbs != null && !(crumbs instanceof FragmentBreadCrumbs)) return; mFragmentBreadCrumbs = (FragmentBreadCrumbs) findViewById(android.R.id.title); if (mFragmentBreadCrumbs == null) { mFragmentBreadCrumbs = new FragmentBreadCrumbs(this); diff --git a/core/res/res/layout-xlarge/preference_list_content_single.xml b/core/res/res/layout-w600dp/preference_list_content_single.xml similarity index 100% rename from core/res/res/layout-xlarge/preference_list_content_single.xml rename to core/res/res/layout-w600dp/preference_list_content_single.xml diff --git a/core/res/res/layout-xlarge/breadcrumbs_in_fragment.xml b/core/res/res/layout-xlarge/breadcrumbs_in_fragment.xml new file mode 100644 index 0000000000000..9b814970f2565 --- /dev/null +++ b/core/res/res/layout-xlarge/breadcrumbs_in_fragment.xml @@ -0,0 +1,39 @@ + + + + + + + + \ No newline at end of file diff --git a/core/res/res/layout/breadcrumbs_in_fragment.xml b/core/res/res/layout/breadcrumbs_in_fragment.xml new file mode 100644 index 0000000000000..98fffb7c429ea --- /dev/null +++ b/core/res/res/layout/breadcrumbs_in_fragment.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/core/res/res/layout/preference_category_holo.xml b/core/res/res/layout/preference_category_holo.xml index 5fe8b28f18bcf..a4e20d2fd3dac 100644 --- a/core/res/res/layout/preference_category_holo.xml +++ b/core/res/res/layout/preference_category_holo.xml @@ -18,5 +18,5 @@ diff --git a/core/res/res/layout/preference_child_holo.xml b/core/res/res/layout/preference_child_holo.xml index 2e70d77cdc03e..06c846bd00a55 100644 --- a/core/res/res/layout/preference_child_holo.xml +++ b/core/res/res/layout/preference_child_holo.xml @@ -26,7 +26,7 @@ diff --git a/core/res/res/layout/preference_information_holo.xml b/core/res/res/layout/preference_information_holo.xml index d6cc063efa3e3..d15cd7b26d800 100644 --- a/core/res/res/layout/preference_information_holo.xml +++ b/core/res/res/layout/preference_information_holo.xml @@ -24,13 +24,24 @@ android:gravity="center_vertical" android:paddingRight="?android:attr/scrollbarSize"> - + + + + android:layout_weight="@integer/preferences_left_pane_weight"> - - + + - diff --git a/core/res/res/layout/preference_list_fragment.xml b/core/res/res/layout/preference_list_fragment.xml index 393cecf894b48..986536e498378 100644 --- a/core/res/res/layout/preference_list_fragment.xml +++ b/core/res/res/layout/preference_list_fragment.xml @@ -29,9 +29,9 @@ android:layout_height="0px" android:layout_weight="1" android:paddingTop="0dip" - android:paddingBottom="48dip" - android:paddingLeft="32dip" - android:paddingRight="32dip" + android:paddingBottom="@dimen/preference_fragment_padding_bottom" + android:paddingLeft="@dimen/preference_fragment_padding_side" + android:paddingRight="@dimen/preference_fragment_padding_side" android:clipToPadding="false" android:drawSelectorOnTop="false" android:cacheColorHint="@android:color/transparent" diff --git a/core/res/res/layout/search_view.xml b/core/res/res/layout/search_view.xml index face8b2857e28..99fdf5b3e9972 100644 --- a/core/res/res/layout/search_view.xml +++ b/core/res/res/layout/search_view.xml @@ -33,8 +33,8 @@ android:layout_gravity="center_vertical" android:layout_marginBottom="2dip" android:drawablePadding="0dip" - android:textAppearance="?android:attr/textAppearanceSmall" - android:textColor="?android:attr/textColorPrimaryInverse" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:attr/textColorPrimary" android:visibility="gone" /> diff --git a/core/res/res/values-h720dp/dimens.xml b/core/res/res/values-h720dp/dimens.xml index 7f4394619c300..c09cb5bd33a66 100644 --- a/core/res/res/values-h720dp/dimens.xml +++ b/core/res/res/values-h720dp/dimens.xml @@ -21,4 +21,10 @@ 54dip 54dip + + 16dp + + 16dp + + 16dp diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml index fbfc3bf6d1296..b0a11a6724d2a 100644 --- a/core/res/res/values-land/dimens.xml +++ b/core/res/res/values-land/dimens.xml @@ -21,7 +21,7 @@ 47dip 2dip - 96dp - -100dp + 16dp + -20dp 72dp diff --git a/core/res/res/values-large/styles.xml b/core/res/res/values-large/styles.xml new file mode 100644 index 0000000000000..79b524db0d623 --- /dev/null +++ b/core/res/res/values-large/styles.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/core/res/res/values-sw600dp/bools.xml b/core/res/res/values-sw600dp/bools.xml new file mode 100644 index 0000000000000..734031f2d93bc --- /dev/null +++ b/core/res/res/values-sw600dp/bools.xml @@ -0,0 +1,19 @@ + + + + + true + diff --git a/core/res/res/values-w1280dp/dimens.xml b/core/res/res/values-w1280dp/dimens.xml new file mode 100644 index 0000000000000..e67b3a9596bcb --- /dev/null +++ b/core/res/res/values-w1280dp/dimens.xml @@ -0,0 +1,32 @@ + + + + 96dp + -100dp + 64dp + + 48dp + + 48dp + + 48dp + + 48dp + + diff --git a/core/res/res/values-w720dp/dimens.xml b/core/res/res/values-w720dp/dimens.xml index a74c41c2b0aaa..45b5c25867a15 100644 --- a/core/res/res/values-w720dp/dimens.xml +++ b/core/res/res/values-w720dp/dimens.xml @@ -21,4 +21,18 @@ 16dip + + 32dp + + 32dp + + 32dp + + 1 + + 2 + + 48dp diff --git a/core/res/res/values-xlarge/styles.xml b/core/res/res/values-xlarge/styles.xml index dd789205667f0..9b2e126b29cd4 100644 --- a/core/res/res/values-xlarge/styles.xml +++ b/core/res/res/values-xlarge/styles.xml @@ -35,13 +35,5 @@ - - diff --git a/core/res/res/values/bools.xml b/core/res/res/values/bools.xml new file mode 100644 index 0000000000000..cd551227d33c1 --- /dev/null +++ b/core/res/res/values/bools.xml @@ -0,0 +1,19 @@ + + + + + false + diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 1782f02776fdb..77ba33ec508d4 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -54,9 +54,28 @@ 0dp 0dp + + 0dp + + 0dp - 56dp - + 48dp + + 0dp + + 0dp + + 4 + + 6 + + 0dp + + 0dp + + 0dp diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 08a3024c87d2d..74f0d6bfa7d40 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -2183,8 +2183,8 @@