+++ /dev/null
-<?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>
\ No newline at end of file
android:layout_marginStart="@dimen/preference_no_icon_padding_start"
android:visibility="invisible" />
- <include layout="@layout/preference_material_settings"/>
+ <include layout="@layout/preference_material"/>
</FrameLayout>
\ No newline at end of file
+++ /dev/null
-<?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>
android:visibility="invisible"
android:layout_marginStart="@dimen/preference_no_icon_padding_start"/>
- <include layout="@layout/preference_material_settings" />
+ <include layout="@layout/preference_material" />
</FrameLayout>
\ No newline at end of file
<!-- 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>
\ No newline at end of file
<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">
--- /dev/null
+<?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>
*/
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;
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;
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 {
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);