am 33512668: am 5861b628: am a2a5c97f: am 8420a924: Merge "Fix bug #17521147 Settings activity looks terrible on Volantis" into lmp-dev

* commit '33512668429e480f0c80b3e60adae43230065184':
  Fix bug #17521147 Settings activity looks terrible on Volantis
This commit is contained in:
Fabrice Di Meglio
2014-09-26 21:53:00 +00:00
committed by Android Git Automerger
14 changed files with 374 additions and 15 deletions

View File

@@ -58,6 +58,8 @@ public class FragmentBreadCrumbs extends ViewGroup
private OnBreadCrumbClickListener mOnBreadCrumbClickListener;
private int mGravity;
private int mLayoutResId;
private int mTextColor;
private static final int DEFAULT_GRAVITY = Gravity.START | Gravity.CENTER_VERTICAL;
@@ -103,6 +105,12 @@ public class FragmentBreadCrumbs extends ViewGroup
mGravity = a.getInt(com.android.internal.R.styleable.FragmentBreadCrumbs_gravity,
DEFAULT_GRAVITY);
mLayoutResId = a.getResourceId(
com.android.internal.R.styleable.FragmentBreadCrumbs_itemLayout,
com.android.internal.R.layout.fragment_bread_crumb_item);
mTextColor = a.getColor(
com.android.internal.R.styleable.FragmentBreadCrumbs_itemColor,
0);
a.recycle();
}
@@ -311,12 +319,11 @@ public class FragmentBreadCrumbs extends ViewGroup
}
}
if (i >= numViews) {
final View item = mInflater.inflate(
com.android.internal.R.layout.fragment_bread_crumb_item,
this, false);
final View item = mInflater.inflate(mLayoutResId, this, false);
final TextView text = (TextView) item.findViewById(com.android.internal.R.id.title);
text.setText(bse.getBreadCrumbTitle());
text.setTag(bse);
text.setTextColor(mTextColor);
if (i == 0) {
item.findViewById(com.android.internal.R.id.left_icon).setVisibility(View.GONE);
}

View File

@@ -212,6 +212,9 @@ public abstract class PreferenceActivity extends ListActivity implements
private Button mNextButton;
private int mPreferenceHeaderItemResId = 0;
private boolean mPreferenceHeaderRemoveEmptyIcon = false;
/**
* The starting request code given out to preference framework.
*/
@@ -258,10 +261,15 @@ public abstract class PreferenceActivity extends ListActivity implements
}
private LayoutInflater mInflater;
private int mLayoutResId;
private boolean mRemoveIconIfEmpty;
public HeaderAdapter(Context context, List<Header> objects) {
public HeaderAdapter(Context context, List<Header> objects, int layoutResId,
boolean removeIconBehavior) {
super(context, 0, objects);
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mLayoutResId = layoutResId;
mRemoveIconIfEmpty = removeIconBehavior;
}
@Override
@@ -270,8 +278,7 @@ public abstract class PreferenceActivity extends ListActivity implements
View view;
if (convertView == null) {
view = mInflater.inflate(com.android.internal.R.layout.preference_header_item,
parent, false);
view = mInflater.inflate(mLayoutResId, parent, false);
holder = new HeaderViewHolder();
holder.icon = (ImageView) view.findViewById(com.android.internal.R.id.icon);
holder.title = (TextView) view.findViewById(com.android.internal.R.id.title);
@@ -284,7 +291,16 @@ public abstract class PreferenceActivity extends ListActivity implements
// All view fields must be updated every time, because the view may be recycled
Header header = getItem(position);
holder.icon.setImageResource(header.iconRes);
if (mRemoveIconIfEmpty) {
if (header.iconRes == 0) {
holder.icon.setVisibility(View.GONE);
} else {
holder.icon.setVisibility(View.VISIBLE);
holder.icon.setImageResource(header.iconRes);
}
} else {
holder.icon.setImageResource(header.iconRes);
}
holder.title.setText(header.getTitle(getContext().getResources()));
CharSequence summary = header.getSummary(getContext().getResources());
if (!TextUtils.isEmpty(summary)) {
@@ -512,7 +528,26 @@ public abstract class PreferenceActivity extends ListActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.android.internal.R.layout.preference_list_content);
// Theming for the PreferenceActivity layout and for the Preference Header(s) layout
TypedArray sa = obtainStyledAttributes(null,
com.android.internal.R.styleable.PreferenceActivity,
com.android.internal.R.attr.preferenceActivityStyle,
0);
final int layoutResId = sa.getResourceId(
com.android.internal.R.styleable.PreferenceActivity_layout,
com.android.internal.R.layout.preference_list_content);
mPreferenceHeaderItemResId = sa.getResourceId(
com.android.internal.R.styleable.PreferenceActivity_headerLayout,
com.android.internal.R.layout.preference_header_item);
mPreferenceHeaderRemoveEmptyIcon = sa.getBoolean(
com.android.internal.R.styleable.PreferenceActivity_headerRemoveIconIfEmpty,
false);
sa.recycle();
setContentView(layoutResId);
mListFooter = (FrameLayout)findViewById(com.android.internal.R.id.list_footer);
mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame);
@@ -582,7 +617,8 @@ public abstract class PreferenceActivity extends ListActivity implements
showBreadCrumbs(initialTitleStr, initialShortTitleStr);
}
} else if (mHeaders.size() > 0) {
setListAdapter(new HeaderAdapter(this, mHeaders));
setListAdapter(new HeaderAdapter(this, mHeaders, mPreferenceHeaderItemResId,
mPreferenceHeaderRemoveEmptyIcon));
if (!mSinglePane) {
// Multi-pane.
getListView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 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:id="@+android:id/breadcrumb_section"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginStart="@dimen/preference_breadcrumbs_padding_start_material"
android:layout_marginEnd="@dimen/preference_breadcrumbs_padding_end_material"
>
<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|start"
/>
</LinearLayout>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<ImageView
android:id="@android:id/left_icon"
android:src="?attr/dividerVertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:layout_marginTop="12dip"
android:layout_marginBottom="12dip"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingStart="8dip"
android:paddingEnd="8dip"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="?android:attr/selectableItemBackground"
/>
</LinearLayout>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 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.
-->
<!-- Layout of a header item in PreferenceActivity. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:paddingStart="24dip"
android:paddingEnd="?android:attr/scrollbarSize">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="0dip"
android:layout_marginEnd="8dip"
android:layout_gravity="center" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="0dip"
android:layout_marginEnd="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1">
<TextView android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<TextView android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:ellipsize="end"
android:maxLines="2" />
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/layout/list_content.xml
**
** Copyright 2014, 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="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
<LinearLayout
style="?attr/preferenceHeaderPanelStyle"
android:id="@+id/headers"
android:orientation="vertical"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="@integer/preferences_left_pane_weight"
android:background="?attr/windowBackground"
android:elevation="4dip" >
<ListView android:id="@android:id/list"
style="?attr/preferenceListStyle"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:clipToPadding="false"
android:drawSelectorOnTop="false"
android:cacheColorHint="@color/transparent"
android:listPreferredItemHeight="48dp"
android:scrollbarAlwaysDrawVerticalTrack="true" />
<FrameLayout android:id="@+id/list_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/prefs_frame"
style="?attr/preferencePanelStyle"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="@integer/preferences_right_pane_weight"
android:orientation="vertical"
android:visibility="gone" >
<!-- 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_material" />
<android.preference.PreferenceFrameLayout android:id="@+id/prefs"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="@+id/button_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="0"
android:visibility="gone">
<Button android:id="@+id/back_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentStart="true"
android:text="@string/back_button_label"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true">
<Button android:id="@+id/skip_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:text="@string/skip_button_label"
android:visibility="gone"
/>
<Button android:id="@+id/next_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:text="@string/next_button_label"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View File

@@ -836,6 +836,8 @@
<!-- Default style for PreferenceScreen. -->
<attr name="preferenceScreenStyle" format="reference" />
<!-- Default style for the PreferenceActivity. -->
<attr name="preferenceActivityStyle" format="reference" />
<!-- Default style for Headers pane in PreferenceActivity. -->
<attr name="preferenceFragmentStyle" format="reference" />
<!-- Default style for PreferenceCategory. -->
@@ -7265,10 +7267,21 @@
<!-- Base attributes available to PreferenceFragment. -->
<declare-styleable name="PreferenceFragment">
<!-- The layout for the PreferenceFragment. This should rarely need to be changed -->
<!-- The layout for the PreferenceFragment. This should rarely need to be changed. -->
<attr name="layout" />
</declare-styleable>
<!-- Base attributes available to PreferenceActivity. -->
<declare-styleable name="PreferenceActivity">
<!-- The layout for the Preference Activity. This should rarely need to be changed. -->
<attr name="layout" />
<!-- The layout for the Preference Header. This should rarely need to be changed. -->
<attr name="headerLayout" format="reference" />
<!-- true if the Icon view will be removed when there is none and thus not showing
the fixed margins. -->
<attr name="headerRemoveIconIfEmpty" format="boolean" />
</declare-styleable>
<!-- Use <code>tts-engine</code> as the root tag of the XML resource that
describes a text to speech engine implemented as a subclass of
{@link android.speech.tts.TextToSpeechService}.
@@ -7370,6 +7383,8 @@
tags. -->
<declare-styleable name="FragmentBreadCrumbs">
<attr name="gravity" />
<attr name="itemLayout" format="reference" />
<attr name="itemColor" format="color|reference" />
</declare-styleable>
<declare-styleable name="MultiPaneChallengeLayout">

View File

@@ -14,9 +14,22 @@
limitations under the License.
-->
<resources>
<!-- Preference activity, vertical padding for the header list -->
<dimen name="preference_screen_header_vertical_padding_material">8dp</dimen>
<!-- Preference activity side margins -->
<dimen name="preference_screen_side_margin_material">0dp</dimen>
<!-- Preference activity side margins negative-->
<dimen name="preference_screen_side_margin_negative_material">0dp</dimen>
<!-- Preference fragment padding, sides -->
<dimen name="preference_fragment_padding_side_material">0dp</dimen>
<dimen name="preference_fragment_padding_side_material">8dp</dimen>
<!-- Preference breadcrumbs padding, start padding -->
<dimen name="preference_breadcrumbs_padding_start_material">12dp</dimen>
<!-- Preference breadcrumbs padding, end padding -->
<dimen name="preference_breadcrumbs_padding_end_material">24dp</dimen>
<dimen name="preference_screen_header_padding_side_material">0dp</dimen>

View File

@@ -533,6 +533,8 @@ please see styles_device_defaults.xml.
<style name="Widget.FragmentBreadCrumbs">
<item name="padding">4dp</item>
<item name="animateLayoutChanges">true</item>
<item name="itemLayout">@layout/fragment_bread_crumb_item</item>
<item name="itemColor">@null</item>
</style>
<style name="Widget.ImageWell">
@@ -954,6 +956,12 @@ please see styles_device_defaults.xml.
<item name="paddingEnd">0dp</item>
</style>
<style name="PreferenceActivity">
<item name="layout">@layout/preference_list_content</item>
<item name="headerLayout">@layout/preference_header_item</item>
<item name="headerRemoveIconIfEmpty">false</item>
</style>
<style name="Preference.Information">
<item name="layout">@layout/preference_information</item>
<item name="enabled">false</item>

View File

@@ -42,6 +42,12 @@ please see styles_device_defaults.xml.
<item name="paddingEnd">@dimen/preference_fragment_padding_side_material</item>
</style>
<style name="PreferenceActivity.Material">
<item name="layout">@layout/preference_list_content_material</item>
<item name="headerLayout">@layout/preference_header_item_material</item>
<item name="headerRemoveIconIfEmpty">true</item>
</style>
<style name="Preference.Material.Information">
<item name="layout">@layout/preference_information_material</item>
<item name="enabled">false</item>
@@ -93,6 +99,8 @@ please see styles_device_defaults.xml.
<!-- No margins or background by default. Could be different for x-large screens -->
<style name="PreferencePanel.Material">
<item name="layout_marginStart">0dip</item>
<item name="layout_marginEnd">0dip</item>
</style>
<!-- The attributes are overridden here because the x-large or large resources may have
@@ -106,10 +114,10 @@ please see styles_device_defaults.xml.
</style>
<style name="PreferenceHeaderPanel.Material">
<item name="layout_marginStart">@dimen/preference_screen_side_margin</item>
<item name="layout_marginEnd">@dimen/preference_screen_side_margin_negative</item>
<item name="paddingTop">@dimen/preference_screen_header_vertical_padding</item>
<item name="paddingBottom">@dimen/preference_screen_header_vertical_padding</item>
<item name="layout_marginStart">@dimen/preference_screen_side_margin_material</item>
<item name="layout_marginEnd">@dimen/preference_screen_side_margin_negative_material</item>
<item name="paddingTop">@dimen/preference_screen_header_vertical_padding_material</item>
<item name="paddingBottom">@dimen/preference_screen_header_vertical_padding_material</item>
</style>
<style name="PreferenceHeaderList.Material">
@@ -585,6 +593,12 @@ please see styles_device_defaults.xml.
</style>
<style name="Widget.Material.ExpandableListView.White"/>
<style name="Widget.Material.FragmentBreadCrumbs" parent="Widget.FragmentBreadCrumbs">
<item name="itemLayout">@layout/fragment_bread_crumb_item_material</item>
<item name="itemColor">@color/primary_text_default_material_light</item>
</style>
<style name="Widget.Material.Gallery" parent="Widget.Gallery"/>
<style name="Widget.Material.GestureOverlayView" parent="Widget.GestureOverlayView"/>
@@ -972,6 +986,9 @@ please see styles_device_defaults.xml.
<style name="Widget.Material.Light.EditText" parent="Widget.Material.EditText"/>
<style name="Widget.Material.Light.ExpandableListView" parent="Widget.Material.ExpandableListView"/>
<style name="Widget.Material.Light.ExpandableListView.White" parent="Widget.Material.ExpandableListView.White"/>
<style name="Widget.Material.Light.FragmentBreadCrumbs" parent="Widget.Material.FragmentBreadCrumbs" >
<item name="itemColor">@color/primary_text_default_material_dark</item>
</style>
<style name="Widget.Material.Light.Gallery" parent="Widget.Material.Gallery"/>
<style name="Widget.Material.Light.GestureOverlayView" parent="Widget.Material.GestureOverlayView"/>
<style name="Widget.Material.Light.GridView" parent="Widget.Material.GridView"/>

View File

@@ -2022,6 +2022,7 @@
<java-symbol type="style" name="TextAppearance.Material.TimePicker.TimeLabel" />
<java-symbol type="attr" name="seekBarPreferenceStyle" />
<java-symbol type="style" name="Theme.DeviceDefault.Resolver" />
<java-symbol type="attr" name="preferenceActivityStyle" />
<java-symbol type="attr" name="preferenceFragmentStyle" />
<java-symbol type="bool" name="skipHoldBeforeMerge" />
<java-symbol type="bool" name="imsServiceAllowTurnOff" />

View File

@@ -317,6 +317,7 @@ please see themes_device_defaults.xml.
<!-- Preference styles -->
<item name="preferenceScreenStyle">@style/Preference.PreferenceScreen</item>
<item name="preferenceActivityStyle">@style/PreferenceActivity</item>
<item name="preferenceFragmentStyle">@style/PreferenceFragment</item>
<item name="preferenceCategoryStyle">@style/Preference.Category</item>
<item name="preferenceStyle">@style/Preference</item>

View File

@@ -308,6 +308,7 @@ please see themes_device_defaults.xml.
<!-- Preference styles -->
<item name="preferenceScreenStyle">@style/Preference.Holo.PreferenceScreen</item>
<item name="preferenceActivityStyle">@style/PreferenceActivity</item>
<item name="preferenceFragmentStyle">@style/PreferenceFragment.Holo</item>
<item name="preferenceCategoryStyle">@style/Preference.Holo.Category</item>
<item name="preferenceStyle">@style/Preference.Holo</item>
@@ -643,6 +644,7 @@ please see themes_device_defaults.xml.
<!-- Preference styles -->
<item name="preferenceScreenStyle">@style/Preference.Holo.PreferenceScreen</item>
<item name="preferenceActivityStyle">@style/PreferenceActivity</item>
<item name="preferenceFragmentStyle">@style/PreferenceFragment.Holo</item>
<item name="preferenceCategoryStyle">@style/Preference.Holo.Category</item>
<item name="preferenceStyle">@style/Preference.Holo</item>

View File

@@ -275,9 +275,11 @@ please see themes_device_defaults.xml.
<item name="popupMenuStyle">@style/Widget.Material.PopupMenu</item>
<item name="stackViewStyle">@style/Widget.Material.StackView</item>
<item name="activityChooserViewStyle">@style/Widget.Material.ActivityChooserView</item>
<item name="fragmentBreadCrumbsStyle">@style/Widget.Material.FragmentBreadCrumbs</item>
<!-- Preference styles -->
<item name="preferenceScreenStyle">@style/Preference.Material.PreferenceScreen</item>
<item name="preferenceActivityStyle">@style/PreferenceActivity.Material</item>
<item name="preferenceFragmentStyle">@style/PreferenceFragment.Material</item>
<item name="preferenceCategoryStyle">@style/Preference.Material.Category</item>
<item name="preferenceStyle">@style/Preference.Material</item>
@@ -622,9 +624,11 @@ please see themes_device_defaults.xml.
<item name="popupMenuStyle">@style/Widget.Material.Light.PopupMenu</item>
<item name="stackViewStyle">@style/Widget.Material.Light.StackView</item>
<item name="activityChooserViewStyle">@style/Widget.Material.Light.ActivityChooserView</item>
<item name="fragmentBreadCrumbsStyle">@style/Widget.Material.FragmentBreadCrumbs</item>
<!-- Preference styles -->
<item name="preferenceScreenStyle">@style/Preference.Material.PreferenceScreen</item>
<item name="preferenceActivityStyle">@style/PreferenceActivity.Material</item>
<item name="preferenceFragmentStyle">@style/PreferenceFragment.Material</item>
<item name="preferenceCategoryStyle">@style/Preference.Material.Category</item>
<item name="preferenceStyle">@style/Preference.Material</item>