Use preference theme from SettingsLib
Bug: 36663882 Test: rerun robotests Change-Id: I9f0f51a9d070191f5bf8f3315fef4d997d6213c3
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 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.
|
||||
-->
|
||||
|
||||
<!-- Based off frameworks/base/core/res/res/layout/preference_category_material.xml
|
||||
except that this supports icon -->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/icon_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<com.android.internal.widget.PreferenceImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:tint="?android:attr/textColorPrimary"
|
||||
android:maxWidth="18dp"
|
||||
android:maxHeight="18dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="56dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Body2"
|
||||
android:textColor="?android:attr/colorAccent"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"/>
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
@@ -30,6 +30,6 @@
|
||||
android:layout_marginStart="@dimen/preference_no_icon_padding_start"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<include layout="@layout/preference_material_settings"/>
|
||||
<include layout="@layout/preference_material"/>
|
||||
|
||||
</FrameLayout>
|
@@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<!-- Based off frameworks/base/core/res/res/layout/preference_material.xml
|
||||
except that this has the negative margin on the image removed. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/icon_frame"
|
||||
style="@style/preference_icon_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start|center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp">
|
||||
<com.android.internal.widget.PreferenceImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="48dp"
|
||||
android:maxHeight="48dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="24dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:ellipsize="marquee"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="24dp"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- Preference should place its actual preference widget here. -->
|
||||
<LinearLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="end|center_vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</LinearLayout>
|
@@ -26,6 +26,6 @@
|
||||
android:visibility="invisible"
|
||||
android:layout_marginStart="@dimen/preference_no_icon_padding_start"/>
|
||||
|
||||
<include layout="@layout/preference_material_settings" />
|
||||
<include layout="@layout/preference_material" />
|
||||
|
||||
</FrameLayout>
|
@@ -19,64 +19,21 @@
|
||||
<!-- Things unrelated to preference framework UI customization should go to other styles files -->
|
||||
<resources>
|
||||
|
||||
<dimen name="preference_no_icon_padding_start">72dp</dimen>
|
||||
|
||||
<!-- Fragment style -->
|
||||
<style name="PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
|
||||
<style name="SettingsPreferenceFragmentStyle" parent="@style/PreferenceFragmentStyle.SettingsBase">
|
||||
<item name="android:layout">@layout/preference_list_fragment</item>
|
||||
<item name="allowDividerAfterLastItem">false</item>
|
||||
</style>
|
||||
|
||||
<!-- Preferences -->
|
||||
<style name="SettingsPreference" parent="@style/Preference.Material">
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">true</item>
|
||||
<item name="singleLineTitle">false</item>
|
||||
<item name="iconSpaceReserved">true</item>
|
||||
</style>
|
||||
|
||||
<style name="ApnPreference" parent="SettingsPreference">
|
||||
<style name="ApnPreference" parent="Preference.SettingsBase">
|
||||
<item name="android:layout">@layout/apn_preference_layout</item>
|
||||
</style>
|
||||
|
||||
<style name="FooterPreference" parent="SettingsPreference">
|
||||
<item name="android:layout">@layout/preference_footer</item>
|
||||
<item name="allowDividerAbove">true</item>
|
||||
</style>
|
||||
|
||||
<style name="EditTextPreference"
|
||||
parent="@style/Preference.DialogPreference.EditTextPreference.Material">
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">true</item>
|
||||
<item name="iconSpaceReserved">true</item>
|
||||
<item name="singleLineTitle">false</item>
|
||||
<item name="android:dialogLayout">@layout/preference_dialog_edittext</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsDropdownPreference" parent="SettingsPreference">
|
||||
<item name="android:layout">@layout/preference_dropdown_material_settings</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsDialogPreference" parent="SettingsPreference" />
|
||||
|
||||
<style name="SettingsPreferenceCategory" parent="@style/Preference.Category.Material">
|
||||
<item name="allowDividerAbove">true</item>
|
||||
<item name="allowDividerBelow">true</item>
|
||||
<item name="android:layout">@layout/preference_category_material_settings</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsSeekBarPreference" parent="SettingsPreference">
|
||||
<style name="SettingsSeekBarPreference" parent="Preference.SettingsBase">
|
||||
<item name="android:layout">@layout/preference_widget_seekbar_settings</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsSwitchPreference" parent="@style/Preference.SwitchPreference.Material">
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">true</item>
|
||||
<item name="iconSpaceReserved">true</item>
|
||||
<item name="singleLineTitle">false</item>
|
||||
</style>
|
||||
|
||||
<style name="SyncSwitchPreference" parent="SettingsPreference">
|
||||
<style name="SyncSwitchPreference" parent="Preference.SettingsBase">
|
||||
<item name="android:widgetLayout">@layout/preference_widget_sync_toggle</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@@ -122,19 +122,10 @@
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>
|
||||
</style>
|
||||
|
||||
<style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.v14.Material">
|
||||
<!-- Parent path frameworks/support/v14/preference/res/values/themes.xml -->
|
||||
<item name="android:scrollbars">vertical</item>
|
||||
<style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.SettingsBase">
|
||||
<item name="preferenceFragmentStyle">@style/SettingsPreferenceFragmentStyle</item>
|
||||
<item name="apnPreferenceStyle">@style/ApnPreference</item>
|
||||
<item name="footerPreferenceStyle">@style/FooterPreference</item>
|
||||
<item name="dialogPreferenceStyle">@style/SettingsDialogPreference</item>
|
||||
<item name="dropdownPreferenceStyle">@style/SettingsDropdownPreference</item>
|
||||
<item name="editTextPreferenceStyle">@style/EditTextPreference</item>
|
||||
<item name="preferenceCategoryStyle">@style/SettingsPreferenceCategory</item>
|
||||
<item name="preferenceFragmentStyle">@style/PreferenceFragmentStyle</item>
|
||||
<item name="preferenceStyle">@style/SettingsPreference</item>
|
||||
<item name="seekBarPreferenceStyle">@style/SettingsSeekBarPreference</item>
|
||||
<item name="switchPreferenceStyle">@style/SettingsSwitchPreference</item>
|
||||
</style>
|
||||
|
||||
<style name="PreferenceTheme.SetupWizard" parent="PreferenceTheme">
|
||||
|
58
tests/robotests/res/layout/preference.xml
Normal file
58
tests/robotests/res/layout/preference.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 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.
|
||||
-->
|
||||
|
||||
<!-- A test preference layout containing all required widgets -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
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:visibility="gone"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="58dip"
|
||||
android:gravity="end|center_vertical"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
@@ -29,8 +25,8 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -39,6 +35,8 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class PowerGaugePreferenceTest {
|
||||
@@ -55,7 +53,7 @@ public class PowerGaugePreferenceTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mRootView = LayoutInflater.from(mContext).inflate(R.layout.preference_material_settings,
|
||||
mRootView = LayoutInflater.from(mContext).inflate(R.layout.preference,
|
||||
null);
|
||||
mWidgetView = LayoutInflater.from(mContext).inflate(R.layout.preference_widget_summary,
|
||||
null);
|
||||
|
Reference in New Issue
Block a user