Merge "DO NOT MERGE. Preference activity changes to work on smaller tablet screens." into honeycomb-mr2

This commit is contained in:
Amith Yamasani
2011-05-23 17:05:47 -07:00
committed by Android (Google) Code Review
22 changed files with 248 additions and 68 deletions

View File

@@ -519,6 +519,7 @@ public class Preference implements Comparable<Preference>, 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<Preference>, OnDependencyChangeLis
public void setIcon(Drawable icon) {
if ((icon == null && mIcon != null) || (icon != null && mIcon != icon)) {
mIcon = icon;
notifyChanged();
}
}

View File

@@ -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);

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<android.app.FragmentBreadCrumbs
android:id="@android:id/title"
android:layout_height="72dip"
android:layout_width="match_parent"
android:paddingTop="16dip"
android:paddingBottom="8dip"
android:gravity="center_vertical|left"
android:layout_marginLeft="@dimen/preference_breadcrumb_paddingLeft"
android:layout_marginRight="@dimen/preference_breadcrumb_paddingRight"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="1dip"
android:paddingLeft="@dimen/preference_breadcrumb_paddingLeft"
android:paddingRight="@dimen/preference_breadcrumb_paddingRight"
android:src="#404040"
/>
</LinearLayout>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This layout disables breadcrumbs in the fragment area and causes PreferenceActivity to
put the breadcrumbs in the action bar. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="@dimen/preference_fragment_padding_side"
android:layout_width="match_parent">
</LinearLayout>

View File

@@ -18,5 +18,5 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/listSeparatorTextViewStyle"
android:id="@+android:id/title"
android:paddingLeft="32dp"
android:paddingLeft="16dp"
/>

View File

@@ -26,7 +26,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/preference_widget_width"
android:minWidth="@dimen/preference_icon_minWidth"
android:gravity="center"
android:orientation="horizontal">
<ImageView
@@ -40,6 +40,7 @@
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"

View File

@@ -27,8 +27,8 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/preference_widget_width"
android:gravity="center"
android:minWidth="@dimen/preference_icon_minWidth"
android:orientation="horizontal">
<ImageView
android:id="@+android:id/icon"
@@ -41,7 +41,8 @@
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="8dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1">

View File

@@ -24,13 +24,24 @@
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize">
<View
android:layout_width="@dimen/preference_widget_width"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/preference_icon_minWidth"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginRight="6sp"
android:layout_marginTop="6sp"
android:layout_marginBottom="6sp"

View File

@@ -27,6 +27,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_marginTop="@dimen/preference_screen_top_margin"
android:layout_marginBottom="@dimen/preference_screen_bottom_margin"
android:layout_weight="1">
<LinearLayout
@@ -36,14 +38,15 @@
android:layout_height="match_parent"
android:layout_marginRight="@dimen/preference_screen_side_margin_negative"
android:layout_marginLeft="@dimen/preference_screen_side_margin"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
android:layout_weight="10">
android:layout_weight="@integer/preferences_left_pane_weight">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
android:listPreferredItemHeight="48dp"
@@ -60,39 +63,22 @@
android:id="@+id/prefs_frame"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="20"
android:layout_weight="@integer/preferences_right_pane_weight"
android:layout_marginLeft="@dimen/preference_screen_side_margin"
android:layout_marginRight="@dimen/preference_screen_side_margin"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:background="?attr/detailsElementBackground"
android:orientation="vertical"
android:visibility="gone" >
<!-- Breadcrumb inserted here -->
<android.app.FragmentBreadCrumbs
android:id="@android:id/title"
android:layout_height="72dip"
android:layout_width="match_parent"
android:paddingTop="16dip"
android:paddingBottom="8dip"
android:gravity="center_vertical|left"
android:layout_marginLeft="48dip"
android:layout_marginRight="48dip"
/>
<!-- Breadcrumb inserted here, in certain screen sizes. In others, it will be an
empty layout or just padding, and PreferenceActivity will put the breadcrumbs in
the action bar. -->
<include layout="@layout/breadcrumbs_in_fragment" />
<ImageView
android:layout_width="match_parent"
android:layout_height="1dip"
android:paddingLeft="32dip"
android:paddingRight="32dip"
android:src="#404040"
/>
<android.preference.PreferenceFrameLayout android:id="@+id/prefs"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:layout_marginTop="-1dip"
/>
</LinearLayout>
</LinearLayout>

View File

@@ -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"

View File

@@ -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"
/>

View File

@@ -21,4 +21,10 @@
<dimen name="alert_dialog_title_height">54dip</dimen>
<!-- Dialog button bar height -->
<dimen name="alert_dialog_button_bar_height">54dip</dimen>
<!-- Preference fragment padding, bottom -->
<dimen name="preference_fragment_padding_bottom">16dp</dimen>
<!-- Preference activity top margin -->
<dimen name="preference_screen_top_margin">16dp</dimen>
<!-- Preference activity bottom margin -->
<dimen name="preference_screen_bottom_margin">16dp</dimen>
</resources>

View File

@@ -21,7 +21,7 @@
<resources>
<dimen name="password_keyboard_key_height">47dip</dimen>
<dimen name="password_keyboard_spacebar_vertical_correction">2dip</dimen>
<dimen name="preference_screen_side_margin">96dp</dimen>
<dimen name="preference_screen_side_margin_negative">-100dp</dimen>
<dimen name="preference_screen_side_margin">16dp</dimen>
<dimen name="preference_screen_side_margin_negative">-20dp</dimen>
<dimen name="preference_widget_width">72dp</dimen>
</resources>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="PreferencePanel">
<item name="android:layout_marginLeft">@dimen/preference_screen_side_margin</item>
<item name="android:layout_marginRight">@dimen/preference_screen_side_margin</item>
<item name="android:layout_marginTop">48dip</item>
<item name="android:layout_marginBottom">48dip</item>
<item name="android:background">?attr/detailsElementBackground</item>
</style>
</resources>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<bool name="preferences_prefer_dual_pane">true</bool>
</resources>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
<dimen name="preference_screen_side_margin">96dp</dimen>
<dimen name="preference_screen_side_margin_negative">-100dp</dimen>
<dimen name="preference_widget_width">64dp</dimen>
<!-- Preference fragment padding, bottom -->
<dimen name="preference_fragment_padding_bottom">48dp</dimen>
<!-- Preference fragment padding, sides -->
<dimen name="preference_fragment_padding_side">48dp</dimen>
<!-- Padding to the left of the preference panel breadcrumb -->
<dimen name="preference_breadcrumb_paddingLeft">48dp</dimen>
<!-- Padding to the right of the preference panel breadcrumb -->
<dimen name="preference_breadcrumb_paddingRight">48dp</dimen>
</resources>

View File

@@ -21,4 +21,18 @@
<!-- Size of the padding on either side of the app-supplied image
in the action bar home section. -->
<dimen name="action_bar_home_image_padding">16dip</dimen>
<!-- Preference fragment padding, sides -->
<dimen name="preference_fragment_padding_side">32dp</dimen>
<!-- Padding to the left of the preference panel breadcrumb -->
<dimen name="preference_breadcrumb_paddingLeft">32dp</dimen>
<!-- Padding to the right of the preference panel breadcrumb -->
<dimen name="preference_breadcrumb_paddingRight">32dp</dimen>
<!-- Weight of the left pane in a multi-pane preference layout. -->
<integer name="preferences_left_pane_weight">1</integer>
<!-- Weight of the right pane in a multi-pane preference layout. So the split is 1:2 -->
<integer name="preferences_right_pane_weight">2</integer>
<!-- Minimum space to allocate to the left of a preference item for an icon.
This helps in aligning titles when some items have icons and some don't. When space is
at a premium, we don't pre-allocate any space. -->
<dimen name="preference_icon_minWidth">48dp</dimen>
</resources>

View File

@@ -35,13 +35,5 @@
<style name="TextAppearance.StatusBar.EventContent.Title">
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="PreferencePanel">
<item name="android:layout_marginLeft">@dimen/preference_screen_side_margin</item>
<item name="android:layout_marginRight">@dimen/preference_screen_side_margin</item>
<item name="android:layout_marginTop">48dip</item>
<item name="android:layout_marginBottom">48dip</item>
<item name="android:background">?attr/detailsElementBackground</item>
</style>
</resources>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<bool name="preferences_prefer_dual_pane">false</bool>
</resources>

View File

@@ -54,9 +54,28 @@
<dimen name="preference_screen_side_margin">0dp</dimen>
<!-- Preference activity side margins negative-->
<dimen name="preference_screen_side_margin_negative">0dp</dimen>
<!-- Preference activity top margin -->
<dimen name="preference_screen_top_margin">0dp</dimen>
<!-- Preference activity bottom margin -->
<dimen name="preference_screen_bottom_margin">0dp</dimen>
<!-- Preference widget area width (to the left of the text) -->
<dimen name="preference_widget_width">56dp</dimen>
<dimen name="preference_widget_width">48dp</dimen>
<!-- Preference fragment padding, bottom -->
<dimen name="preference_fragment_padding_bottom">0dp</dimen>
<!-- Preference fragment padding, sides -->
<dimen name="preference_fragment_padding_side">0dp</dimen>
<!-- Weight of the left pane in a multi-pane preference layout. -->
<integer name="preferences_left_pane_weight">4</integer>
<!-- Weight of the right pane in a multi-pane preference layout. So the split is 40:60 -->
<integer name="preferences_right_pane_weight">6</integer>
<!-- Padding to the left of the preference panel breadcrumb -->
<dimen name="preference_breadcrumb_paddingLeft">0dp</dimen>
<!-- Padding to the right of the preference panel breadcrumb -->
<dimen name="preference_breadcrumb_paddingRight">0dp</dimen>
<!-- Minimum space to allocate to the left of a preference item for an icon.
This helps in aligning titles when some items have icons and some don't. When space is
at a premium, we don't pre-allocate any space. -->
<dimen name="preference_icon_minWidth">0dp</dimen>
<!-- The platform's desired minimum size for a dialog's width when it
is along the major axis (that is the screen is landscape). This may
be either a fraction or a dimension. -->

View File

@@ -2183,8 +2183,8 @@
<style name="Widget.Holo.PreferenceFrameLayout">
<item name="android:borderTop">0dip</item>
<item name="android:borderBottom">48dip</item>
<item name="android:borderLeft">32dip</item>
<item name="android:borderRight">32dip</item>
<item name="android:borderBottom">@dimen/preference_fragment_padding_side</item>
<item name="android:borderLeft">@dimen/preference_fragment_padding_side</item>
<item name="android:borderRight">@dimen/preference_fragment_padding_side</item>
</style>
</resources>