Merge changes from topic "small_icons"
* changes: Use small icon in location and vpn settings UI Clean up: use AppPreference for PowerGaugePreference Switch to use small icon for most app related pages Update UI to use a smaller icon for ManageApplication page.
This commit is contained in:
committed by
Android (Google) Code Review
commit
40ebbf01a5
@@ -1,58 +0,0 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:background="@drawable/switchbar_background"
|
||||
android:gravity="center_vertical"
|
||||
android:theme="?attr/switchBarTheme" >
|
||||
|
||||
<ImageView android:id="@+id/app_icon"
|
||||
android:layout_width="@dimen/switchbar_subsettings_margin_start"
|
||||
android:layout_height="40dp"
|
||||
android:gravity="end"
|
||||
android:layout_centerVertical="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_name"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_toStartOf="@+id/app_settings"
|
||||
android:layout_marginStart="@dimen/switchbar_subsettings_margin_start"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textAppearance="@style/TextAppearance.Switch"
|
||||
android:textColor="@android:color/white"
|
||||
android:textAlignment="viewStart" />
|
||||
|
||||
<ImageView
|
||||
android:id="@id/app_settings"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/switchbar_subsettings_margin_end"
|
||||
android:layout_centerVertical="true"
|
||||
android:minHeight="0dp"
|
||||
android:minWidth="0dp"
|
||||
android:contentDescription="@string/notification_app_settings_button"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_settings_24dp"
|
||||
android:visibility="gone"
|
||||
style="?android:attr/borderlessButtonStyle" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
@@ -1,81 +0,0 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="72dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:gravity="top"
|
||||
android:columnCount="3"
|
||||
android:duplicateParentState="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:contentDescription="@null"
|
||||
android:duplicateParentState="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@android:id/icon"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAlignment="viewStart"
|
||||
android:duplicateParentState="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@android:id/title"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="6dip"
|
||||
android:gravity="end"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:duplicateParentState="true" />
|
||||
|
||||
<Switch
|
||||
android:id="@android:id/switch_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@null"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@android:id/icon"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_gravity="fill_horizontal|top"
|
||||
android:duplicateParentState="true" />
|
||||
|
||||
</RelativeLayout>
|
@@ -1,25 +0,0 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<include layout="@layout/app_item" />
|
||||
|
||||
</FrameLayout>
|
@@ -29,13 +29,17 @@
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
android:gravity="start|center_vertical"
|
||||
android:minWidth="60dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@android:dimen/app_icon_size"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:layout_width="@dimen/secondary_app_icon_size"
|
||||
android:layout_height="@dimen/secondary_app_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="8dip"
|
||||
android:contentDescription="@null" />
|
||||
@@ -70,7 +74,7 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<CheckBox
|
||||
<Switch
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2013 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.
|
||||
-->
|
||||
|
||||
<!-- text that appears when the recent app list is empty -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="?android:attr/scrollbarSize"
|
||||
android:background="?android:attr/selectableItemBackground" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dip"
|
||||
android:layout_marginEnd="6dip"
|
||||
android:layout_marginTop="6dip"
|
||||
android:layout_marginBottom="6dip"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView android:id="@android:id/title"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -13,13 +13,87 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<include layout="@layout/app_item" />
|
||||
<LinearLayout
|
||||
android:id="@+id/icon_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start|center_vertical"
|
||||
android:minWidth="60dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp">
|
||||
<android.support.v7.internal.widget.PreferenceImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
settings:maxWidth="@dimen/secondary_app_icon_size"
|
||||
settings:maxHeight="@dimen/secondary_app_icon_size" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.TileTitle"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/summary_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
<TextView android:id="@android:id/summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="@style/TextAppearance.Small"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
<TextView android:id="@+id/appendix"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.Small"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end" />
|
||||
</LinearLayout>
|
||||
<ProgressBar
|
||||
android:id="@android:id/progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:max="100"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<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>
|
||||
|
@@ -1,23 +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.
|
||||
-->
|
||||
|
||||
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:max="100"
|
||||
style="?android:attr/progressBarStyleHorizontal" />
|
@@ -22,6 +22,7 @@
|
||||
<dimen name="action_bar_switch_padding">16dip</dimen>
|
||||
|
||||
<dimen name="app_icon_size">40dip</dimen>
|
||||
<dimen name="secondary_app_icon_size">24dp</dimen>
|
||||
<dimen name="min_tap_target_size">48dp</dimen>
|
||||
<dimen name="screen_margin_sides">64dip</dimen>
|
||||
<dimen name="screen_margin_top">72dip</dimen>
|
||||
|
@@ -21,56 +21,56 @@
|
||||
android:key="app_default_settings_screen"
|
||||
android:title="@string/app_default_dashboard_title">
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="assist_and_voice_input"
|
||||
android:title="@string/assist_and_voice_input_title"
|
||||
android:fragment="com.android.settings.applications.assist.ManageAssist" />
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="default_browser"
|
||||
android:title="@string/default_browser_title"
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultBrowserPicker">
|
||||
<extra android:name="for_work" android:value="false" />
|
||||
</Preference>
|
||||
</com.android.settings.widget.AppPreference>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="default_home"
|
||||
android:title="@string/home_app"
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultHomePicker"
|
||||
settings:keywords="@string/keywords_home" />
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="default_phone_app"
|
||||
android:title="@string/default_phone_title"
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultPhonePicker"
|
||||
settings:keywords="@string/keywords_default_phone_app" />
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="default_sms_app"
|
||||
android:title="@string/sms_application_title"
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultSmsPicker"
|
||||
settings:keywords="@string/keywords_more_default_sms_app" />
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="default_payment_app"
|
||||
android:title="@string/nfc_payment_settings_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.nfc.PaymentSettings" />
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="default_emergency_app"
|
||||
android:title="@string/default_emergency_app"
|
||||
settings:keywords="@string/keywords_emergency_app" />
|
||||
|
||||
<!--
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="default_notification_asst_app"
|
||||
android:title="@string/default_notification_assistant"
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultNotificationAssistantPicker"
|
||||
/>
|
||||
-->
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="domain_urls"
|
||||
android:title="@string/domain_urls_title"
|
||||
android:fragment="com.android.settings.applications.ManageDomainUrls" />
|
||||
@@ -79,20 +79,20 @@
|
||||
android:key="work_app_defaults"
|
||||
android:title="@string/default_for_work">
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="work_default_browser"
|
||||
android:title="@string/default_browser_title"
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultBrowserPicker">
|
||||
<extra android:name="for_work" android:value="true" />
|
||||
</Preference>
|
||||
</com.android.settings.widget.AppPreference>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.AppPreference
|
||||
android:key="work_default_phone_app"
|
||||
android:title="@string/default_phone_title"
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultPhonePicker"
|
||||
settings:keywords="@string/keywords_default_phone_app">
|
||||
<extra android:name="for_work" android:value="true" />
|
||||
</Preference>
|
||||
</com.android.settings.widget.AppPreference>
|
||||
|
||||
</com.android.settings.widget.WorkOnlyCategory>
|
||||
|
||||
|
@@ -43,9 +43,9 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
@@ -205,7 +205,7 @@ public class DeviceAdminSettings extends ListFragment implements Instrumentable
|
||||
static class ViewHolder {
|
||||
ImageView icon;
|
||||
TextView name;
|
||||
CheckBox checkbox;
|
||||
Switch checkbox;
|
||||
TextView description;
|
||||
}
|
||||
|
||||
@@ -291,10 +291,10 @@ public class DeviceAdminSettings extends ListFragment implements Instrumentable
|
||||
private View newDeviceAdminView(ViewGroup parent) {
|
||||
View v = mInflater.inflate(R.layout.device_admin_item, parent, false);
|
||||
ViewHolder h = new ViewHolder();
|
||||
h.icon = (ImageView) v.findViewById(R.id.icon);
|
||||
h.name = (TextView) v.findViewById(R.id.name);
|
||||
h.checkbox = (CheckBox) v.findViewById(R.id.checkbox);
|
||||
h.description = (TextView) v.findViewById(R.id.description);
|
||||
h.icon = v.findViewById(R.id.icon);
|
||||
h.name = v.findViewById(R.id.name);
|
||||
h.checkbox = v.findViewById(R.id.checkbox);
|
||||
h.description = v.findViewById(R.id.description);
|
||||
v.setTag(h);
|
||||
return v;
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -25,12 +27,10 @@ import android.os.UserManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
public class AccountTypePreference extends Preference implements OnPreferenceClickListener {
|
||||
public class AccountTypePreference extends AppPreference implements OnPreferenceClickListener {
|
||||
/**
|
||||
* Title of the tile that is shown to the user.
|
||||
* @attr ref android.R.styleable#PreferenceHeader_title
|
||||
|
@@ -16,15 +16,14 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/**
|
||||
* ProviderPreference is used to display an image to the left of a provider name.
|
||||
* The preference ultimately calls AccountManager.addAccount() for the account type.
|
||||
@@ -35,6 +34,7 @@ public class ProviderPreference extends RestrictedPreference {
|
||||
public ProviderPreference(
|
||||
Context context, String accountType, Drawable icon, CharSequence providerName) {
|
||||
super(context);
|
||||
setUseSmallIcon(true);
|
||||
mAccountType = accountType;
|
||||
setIcon(icon);
|
||||
setPersistent(false);
|
||||
|
@@ -38,6 +38,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.notification.EmptyTextSettings;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settings.wrapper.ActivityInfoWrapper;
|
||||
import com.android.settings.wrapper.UserManagerWrapper;
|
||||
import com.android.settingslib.wrapper.PackageManagerWrapper;
|
||||
@@ -176,7 +177,7 @@ public class PictureInPictureSettings extends EmptyTextSettings {
|
||||
final String packageName = appInfo.packageName;
|
||||
final CharSequence label = appInfo.loadLabel(pm);
|
||||
|
||||
final Preference pref = new Preference(prefContext);
|
||||
final Preference pref = new AppPreference(prefContext);
|
||||
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appInfo, userId));
|
||||
pref.setTitle(pm.getUserBadgedLabel(label, user));
|
||||
pref.setSummary(PictureInPictureDetails.getPreferenceSummary(prefContext,
|
||||
|
@@ -18,14 +18,13 @@ package com.android.settings.applications;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
|
||||
import android.util.Log;
|
||||
import com.android.settings.AppProgressPreference;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
|
||||
public class ProcessStatsPreference extends AppProgressPreference {
|
||||
public class ProcessStatsPreference extends AppPreference {
|
||||
static final String TAG = "ProcessStatsPreference";
|
||||
|
||||
private ProcStatsPackageEntry mEntry;
|
||||
|
@@ -40,6 +40,7 @@ import android.util.Log;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.wrapper.PackageManagerWrapper;
|
||||
@@ -230,7 +231,7 @@ public class RecentAppsPreferenceController extends AbstractPreferenceController
|
||||
boolean rebindPref = true;
|
||||
Preference pref = appPreferences.remove(pkgName);
|
||||
if (pref == null) {
|
||||
pref = new Preference(prefContext);
|
||||
pref = new AppPreference(prefContext);
|
||||
rebindPref = false;
|
||||
}
|
||||
pref.setKey(pkgName);
|
||||
|
@@ -84,6 +84,11 @@ public abstract class DefaultAppPickerFragment extends RadioButtonPickerFragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRadioButtonPreferenceCustomLayoutResId() {
|
||||
return R.layout.preference_app;
|
||||
}
|
||||
|
||||
protected ConfirmationDialogFragment newConfirmationDialogFragment(String selectedKey,
|
||||
CharSequence confirmationMessage) {
|
||||
final ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();
|
||||
|
@@ -29,6 +29,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.GearPreference;
|
||||
import com.android.settingslib.TwoTargetPreference;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.wrapper.PackageManagerWrapper;
|
||||
|
||||
@@ -53,6 +54,12 @@ public abstract class DefaultAppPreferenceController extends AbstractPreferenceC
|
||||
public void updateState(Preference preference) {
|
||||
final DefaultAppInfo app = getDefaultAppInfo();
|
||||
CharSequence defaultAppLabel = getDefaultAppLabel();
|
||||
if (preference instanceof TwoTargetPreference) {
|
||||
// For use small icon because we are displaying an app preference.
|
||||
// We only need to do this for TwoTargetPreference because the other prefs are
|
||||
// already using AppPreference so their icon is already normalized.
|
||||
((TwoTargetPreference) preference).setUseSmallIcon(true);
|
||||
}
|
||||
if (!TextUtils.isEmpty(defaultAppLabel)) {
|
||||
preference.setSummary(defaultAppLabel);
|
||||
Utils.setSafeIcon(preference, getDefaultAppIcon());
|
||||
|
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -38,33 +39,39 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView mAppName;
|
||||
private final ImageView mAppIcon;
|
||||
|
||||
private final boolean mKeepStableHeight;
|
||||
|
||||
@VisibleForTesting
|
||||
View mSummaryContainer;
|
||||
@VisibleForTesting
|
||||
final TextView mSummary;
|
||||
@VisibleForTesting
|
||||
final TextView mDisabled;
|
||||
|
||||
ApplicationViewHolder(View itemView) {
|
||||
|
||||
ApplicationViewHolder(View itemView, boolean keepStableHeight) {
|
||||
super(itemView);
|
||||
mAppName = itemView.findViewById(android.R.id.title);
|
||||
mAppIcon = itemView.findViewById(android.R.id.icon);
|
||||
mSummary = itemView.findViewById(R.id.widget_text1);
|
||||
mDisabled = itemView.findViewById(R.id.widget_text2);
|
||||
mSummaryContainer = itemView.findViewById(R.id.summary_container);
|
||||
mSummary = itemView.findViewById(android.R.id.summary);
|
||||
mDisabled = itemView.findViewById(R.id.appendix);
|
||||
mKeepStableHeight = keepStableHeight;
|
||||
}
|
||||
|
||||
static View newView(LayoutInflater inflater, ViewGroup parent) {
|
||||
final View root = LayoutInflater.from(parent.getContext())
|
||||
static View newView(ViewGroup parent) {
|
||||
return LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.preference_app, parent, false);
|
||||
inflater.inflate(R.layout.widget_text_views,
|
||||
root.findViewById(android.R.id.widget_frame));
|
||||
return root;
|
||||
}
|
||||
|
||||
void setSummary(CharSequence summary) {
|
||||
mSummary.setText(summary);
|
||||
updateSummaryContainer();
|
||||
}
|
||||
|
||||
void setSummary(@StringRes int summary) {
|
||||
mSummary.setText(summary);
|
||||
updateSummaryContainer();
|
||||
}
|
||||
|
||||
void setEnabled(boolean isEnabled) {
|
||||
@@ -78,6 +85,10 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
||||
mAppName.setText(title);
|
||||
}
|
||||
|
||||
void setIcon(int drawableRes) {
|
||||
mAppIcon.setImageResource(drawableRes);
|
||||
}
|
||||
|
||||
void setIcon(Drawable icon) {
|
||||
if (icon == null) {
|
||||
return;
|
||||
@@ -96,6 +107,17 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
||||
} else {
|
||||
mDisabled.setVisibility(View.GONE);
|
||||
}
|
||||
updateSummaryContainer();
|
||||
}
|
||||
|
||||
void updateSummaryContainer() {
|
||||
if (mKeepStableHeight) {
|
||||
mSummaryContainer.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
final boolean hasContent =
|
||||
!TextUtils.isEmpty(mDisabled.getText()) || !TextUtils.isEmpty(mSummary.getText());
|
||||
mSummaryContainer.setVisibility(hasContent ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
void updateSizeText(AppEntry entry, CharSequence invalidSizeStr, int whichSize) {
|
||||
|
@@ -412,20 +412,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFastScrollEnabled() {
|
||||
switch (mListType) {
|
||||
case LIST_TYPE_MAIN:
|
||||
case LIST_TYPE_NOTIFICATION:
|
||||
case LIST_TYPE_STORAGE:
|
||||
case LIST_TYPE_GAMES:
|
||||
case LIST_TYPE_MOVIES:
|
||||
case LIST_TYPE_PHOTOGRAPHY:
|
||||
return mSortOrder == R.id.sort_order_alpha;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
switch (mListType) {
|
||||
@@ -924,9 +910,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
|
||||
@Override
|
||||
public ApplicationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
final View view = ApplicationViewHolder.newView(
|
||||
LayoutInflater.from(parent.getContext()), parent);
|
||||
return new ApplicationViewHolder(view);
|
||||
final View view = ApplicationViewHolder.newView(parent);
|
||||
return new ApplicationViewHolder(view,
|
||||
shouldUseStableItemHeight(mManageApplications.mListType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -994,7 +980,21 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
});
|
||||
}
|
||||
|
||||
static private boolean packageNameEquals(PackageItemInfo info1, PackageItemInfo info2) {
|
||||
@VisibleForTesting
|
||||
static boolean shouldUseStableItemHeight(int listType) {
|
||||
switch (listType) {
|
||||
case LIST_TYPE_NOTIFICATION:
|
||||
// Most entries in notification type has no summary. Don't use stable height
|
||||
// so height is short for most entries.
|
||||
return false;
|
||||
default:
|
||||
// Other types have non-empty summary, so keep the height as we expect summary
|
||||
// to fill in.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean packageNameEquals(PackageItemInfo info1, PackageItemInfo info2) {
|
||||
if (info1 == null || info2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.applications.manageapplications;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.support.annotation.WorkerThread;
|
||||
@@ -39,7 +38,6 @@ public class MusicViewHolderController implements FileViewHolderController {
|
||||
private static final String TAG = "MusicViewHolderCtrl";
|
||||
|
||||
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
||||
private static final int INSET_SIZE = 24; // dp
|
||||
|
||||
private Context mContext;
|
||||
private StorageStatsSource mSource;
|
||||
@@ -73,8 +71,7 @@ public class MusicViewHolderController implements FileViewHolderController {
|
||||
|
||||
@Override
|
||||
public void setupView(ApplicationViewHolder holder) {
|
||||
holder.setIcon(
|
||||
new InsetDrawable(mContext.getDrawable(R.drawable.ic_headset_24dp), INSET_SIZE));
|
||||
holder.setIcon(R.drawable.ic_headset_24dp);
|
||||
holder.setTitle(mContext.getText(R.string.audio_files_title));
|
||||
holder.setSummary(Formatter.formatFileSize(mContext, mMusicSize));
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.applications.manageapplications;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.os.UserHandle;
|
||||
import android.support.annotation.WorkerThread;
|
||||
import android.text.format.Formatter;
|
||||
@@ -36,7 +35,6 @@ public class PhotosViewHolderController implements FileViewHolderController {
|
||||
private static final String TAG = "PhotosViewHolderCtrl";
|
||||
|
||||
private static final String IMAGE_MIME_TYPE = "image/*";
|
||||
private static final int INSET_SIZE = 24; // dp
|
||||
|
||||
private Context mContext;
|
||||
private StorageStatsSource mSource;
|
||||
@@ -72,8 +70,7 @@ public class PhotosViewHolderController implements FileViewHolderController {
|
||||
|
||||
@Override
|
||||
public void setupView(ApplicationViewHolder holder) {
|
||||
holder.setIcon(
|
||||
new InsetDrawable(mContext.getDrawable(R.drawable.ic_photo_library), INSET_SIZE));
|
||||
holder.setIcon(R.drawable.ic_photo_library);
|
||||
holder.setTitle(mContext.getText(R.string.storage_detail_images));
|
||||
holder.setSummary(Formatter.formatFileSize(mContext, mFilesSize));
|
||||
}
|
||||
|
@@ -15,19 +15,18 @@
|
||||
package com.android.settings.datausage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.format.Formatter;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settingslib.AppItem;
|
||||
import com.android.settingslib.net.UidDetail;
|
||||
import com.android.settingslib.net.UidDetailProvider;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
public class AppDataUsagePreference extends Preference {
|
||||
public class AppDataUsagePreference extends AppPreference {
|
||||
|
||||
private final AppItem mItem;
|
||||
private final int mPercent;
|
||||
@@ -38,8 +37,6 @@ public class AppDataUsagePreference extends Preference {
|
||||
super(context);
|
||||
mItem = item;
|
||||
mPercent = percent;
|
||||
setLayoutResource(R.layout.data_usage_item);
|
||||
setWidgetLayoutResource(R.layout.widget_progress_bar);
|
||||
|
||||
if (item.restricted && item.total <= 0) {
|
||||
setSummary(com.android.settings.R.string.data_usage_app_restricted);
|
||||
@@ -60,7 +57,6 @@ public class AppDataUsagePreference extends Preference {
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
|
||||
final ProgressBar progress = (ProgressBar) holder.findViewById(
|
||||
android.R.id.progress);
|
||||
|
||||
|
@@ -18,7 +18,6 @@ import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.view.Menu;
|
||||
@@ -34,6 +33,7 @@ import com.android.settings.applications.AppStateBaseBridge;
|
||||
import com.android.settings.applications.InstalledAppDetails;
|
||||
import com.android.settings.datausage.AppStateDataUsageBridge.DataUsageState;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.AppSwitchPreference;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppFilter;
|
||||
@@ -59,11 +59,7 @@ public class UnrestrictedDataAccess extends SettingsPreferenceFragment
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
setAnimationAllowed(true);
|
||||
if (usePreferenceScreenTitle()) {
|
||||
addPreferencesFromResource(R.xml.unrestricted_data_access_settings);
|
||||
} else {
|
||||
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getContext()));
|
||||
}
|
||||
addPreferencesFromResource(R.xml.unrestricted_data_access_settings);
|
||||
mApplicationsState = ApplicationsState.getInstance(
|
||||
(Application) getContext().getApplicationContext());
|
||||
mDataSaverBackend = new DataSaverBackend(getContext());
|
||||
@@ -239,7 +235,8 @@ public class UnrestrictedDataAccess extends SettingsPreferenceFragment
|
||||
return app != null && UserHandle.isApp(app.info.uid);
|
||||
}
|
||||
|
||||
private class AccessPreference extends SwitchPreference implements DataSaverBackend.Listener {
|
||||
private class AccessPreference extends AppSwitchPreference
|
||||
implements DataSaverBackend.Listener {
|
||||
private final AppEntry mEntry;
|
||||
private final DataUsageState mState;
|
||||
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.development;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -37,23 +36,21 @@ public class AppViewHolder {
|
||||
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.preference_app, null);
|
||||
inflater.inflate(R.layout.widget_text_views,
|
||||
(ViewGroup) convertView.findViewById(android.R.id.widget_frame));
|
||||
|
||||
// Creates a ViewHolder and store references to the two children views
|
||||
// we want to bind data to.
|
||||
AppViewHolder holder = new AppViewHolder();
|
||||
holder.rootView = convertView;
|
||||
holder.appName = (TextView) convertView.findViewById(android.R.id.title);
|
||||
holder.appIcon = (ImageView) convertView.findViewById(android.R.id.icon);
|
||||
holder.summary = (TextView) convertView.findViewById(R.id.widget_text1);
|
||||
holder.disabled = (TextView) convertView.findViewById(R.id.widget_text2);
|
||||
holder.appName = convertView.findViewById(android.R.id.title);
|
||||
holder.appIcon = convertView.findViewById(android.R.id.icon);
|
||||
holder.summary = convertView.findViewById(android.R.id.summary);
|
||||
holder.disabled = convertView.findViewById(R.id.appendix);
|
||||
convertView.setTag(holder);
|
||||
return holder;
|
||||
} else {
|
||||
// Get the ViewHolder back to get fast access to the TextView
|
||||
// and the ImageView.
|
||||
return (AppViewHolder)convertView.getTag();
|
||||
return (AppViewHolder) convertView.getTag();
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,11 +22,11 @@ import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.util.IconDrawableFactory;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.UserAppInfo;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -68,8 +68,7 @@ public class ApplicationListPreferenceController extends AbstractPreferenceContr
|
||||
final Context prefContext = mParent.getPreferenceManager().getContext();
|
||||
for (int position = 0; position < result.size(); position++) {
|
||||
final UserAppInfo item = result.get(position);
|
||||
final Preference preference = new Preference(prefContext);
|
||||
preference.setLayoutResource(R.layout.preference_app);
|
||||
final Preference preference = new AppPreference(prefContext);
|
||||
preference.setTitle(item.appInfo.loadLabel(mPm));
|
||||
preference.setIcon(iconDrawableFactory.getBadgedIcon(item.appInfo));
|
||||
preference.setOrder(position);
|
||||
|
@@ -19,15 +19,13 @@ package com.android.settings.fuelgauge;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
|
||||
/**
|
||||
* Custom preference for displaying battery usage info as a bar and an icon on
|
||||
@@ -36,8 +34,7 @@ import com.android.settings.Utils;
|
||||
* The battery usage info could be usage percentage or usage time. The preference
|
||||
* won't show any icon if it is null.
|
||||
*/
|
||||
public class PowerGaugePreference extends Preference {
|
||||
private final int mIconSize;
|
||||
public class PowerGaugePreference extends AppPreference {
|
||||
|
||||
private BatteryEntry mInfo;
|
||||
private CharSequence mContentDescription;
|
||||
@@ -64,7 +61,6 @@ public class PowerGaugePreference extends Preference {
|
||||
setWidgetLayoutResource(R.layout.preference_widget_summary);
|
||||
mInfo = info;
|
||||
mContentDescription = contentDescription;
|
||||
mIconSize = context.getResources().getDimensionPixelSize(R.dimen.app_icon_size);
|
||||
mShowAnomalyIcon = false;
|
||||
}
|
||||
|
||||
@@ -107,8 +103,6 @@ public class PowerGaugePreference extends Preference {
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
|
||||
icon.setLayoutParams(new LinearLayout.LayoutParams(mIconSize, mIconSize));
|
||||
|
||||
final TextView subtitle = (TextView) view.findViewById(R.id.widget_summary);
|
||||
subtitle.setText(mProgress);
|
||||
|
@@ -43,9 +43,9 @@ import com.android.settings.applications.InstalledAppDetails;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
import com.android.settingslib.location.RecentLocationApps;
|
||||
|
||||
@@ -211,21 +211,19 @@ public class LocationSettings extends LocationSettingsBase
|
||||
|
||||
List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
|
||||
for (final RecentLocationApps.Request request : recentLocationRequests) {
|
||||
RestrictedPreference pref = new RestrictedPreference(getPrefContext());
|
||||
final AppPreference pref = new AppPreference(getPrefContext());
|
||||
pref.setSummary(request.contentDescription);
|
||||
pref.setIcon(request.icon);
|
||||
pref.setTitle(request.label);
|
||||
pref.setOnPreferenceClickListener(
|
||||
new PackageEntryClickedListener(request.packageName, request.userHandle));
|
||||
recentLocationPrefs.add(pref);
|
||||
|
||||
}
|
||||
if (recentLocationRequests.size() > 0) {
|
||||
addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
|
||||
} else {
|
||||
// If there's no item to display, add a "No recent apps" item.
|
||||
Preference banner = new Preference(getPrefContext());
|
||||
banner.setLayoutResource(R.layout.location_list_no_item);
|
||||
Preference banner = new AppPreference(getPrefContext());
|
||||
banner.setTitle(R.string.location_no_recent_apps);
|
||||
banner.setSelectable(false);
|
||||
mCategoryRecentLocationRequests.addPreference(banner);
|
||||
|
@@ -40,6 +40,8 @@ import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
|
||||
import com.android.settings.widget.AppPreference;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
@@ -268,7 +270,7 @@ class SettingsInjector {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
Drawable appIcon = pm.getDrawable(info.packageName, info.iconId, null);
|
||||
Drawable icon = pm.getUserBadgedIcon(appIcon, info.mUserHandle);
|
||||
Preference pref = new Preference(prefContext);
|
||||
Preference pref = new AppPreference(prefContext);
|
||||
pref.setTitle(info.title);
|
||||
pref.setSummary(null);
|
||||
pref.setIcon(icon);
|
||||
|
@@ -51,6 +51,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.AppSwitchPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -138,7 +139,7 @@ public class ZenAccessSettings extends EmptyTextSettings {
|
||||
for (ApplicationInfo app : apps) {
|
||||
final String pkg = app.packageName;
|
||||
final CharSequence label = app.loadLabel(mPkgMan);
|
||||
final SwitchPreference pref = new SwitchPreference(getPrefContext());
|
||||
final SwitchPreference pref = new AppSwitchPreference(getPrefContext());
|
||||
pref.setPersistent(false);
|
||||
pref.setIcon(app.loadIcon(mPkgMan));
|
||||
pref.setTitle(label);
|
||||
|
@@ -21,7 +21,6 @@ import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ComponentName;
|
||||
@@ -46,6 +45,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.notification.EmptyTextSettings;
|
||||
import com.android.settings.widget.AppSwitchPreference;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -127,7 +127,7 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings {
|
||||
Log.e(TAG, "can't find package name", e);
|
||||
}
|
||||
final String summary = service.loadLabel(mPm).toString();
|
||||
final SwitchPreference pref = new SwitchPreference(getPrefContext());
|
||||
final SwitchPreference pref = new AppSwitchPreference(getPrefContext());
|
||||
pref.setPersistent(false);
|
||||
pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo,
|
||||
UserHandle.getUserId(service.applicationInfo.uid)));
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.vpn2;
|
||||
|
||||
import static com.android.internal.net.LegacyVpnInfo.STATE_CONNECTED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
@@ -23,7 +25,6 @@ import android.view.View;
|
||||
|
||||
import com.android.internal.net.VpnProfile;
|
||||
import com.android.settings.R;
|
||||
import static com.android.internal.net.LegacyVpnInfo.STATE_CONNECTED;
|
||||
|
||||
/**
|
||||
* {@link android.support.v7.preference.Preference} tracks the underlying legacy vpn profile and
|
||||
@@ -35,6 +36,7 @@ public class LegacyVpnPreference extends ManageablePreference {
|
||||
LegacyVpnPreference(Context context) {
|
||||
super(context, null /* attrs */);
|
||||
setIcon(R.drawable.ic_vpn_key);
|
||||
setUseSmallIcon(true);
|
||||
}
|
||||
|
||||
public VpnProfile getProfile() {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -13,26 +13,36 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings;
|
||||
package com.android.settings.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
public class AppProgressPreference extends Preference {
|
||||
import com.android.settings.R;
|
||||
|
||||
public class AppPreference extends Preference {
|
||||
|
||||
private int mProgress;
|
||||
private boolean mProgressVisible;
|
||||
|
||||
public AppProgressPreference(Context context, AttributeSet attrs) {
|
||||
public AppPreference(Context context) {
|
||||
super(context);
|
||||
setLayoutResource(R.layout.preference_app);
|
||||
}
|
||||
|
||||
public AppPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setLayoutResource(R.layout.preference_app);
|
||||
setWidgetLayoutResource(R.layout.widget_progress_bar);
|
||||
}
|
||||
|
||||
public void setProgress(int amount) {
|
||||
mProgress = amount;
|
||||
mProgressVisible = true;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
@@ -40,7 +50,14 @@ public class AppProgressPreference extends Preference {
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
|
||||
view.findViewById(R.id.summary_container)
|
||||
.setVisibility(TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE);
|
||||
final ProgressBar progress = (ProgressBar) view.findViewById(android.R.id.progress);
|
||||
progress.setProgress(mProgress);
|
||||
if (mProgressVisible) {
|
||||
progress.setProgress(mProgress);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
progress.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
41
src/com/android/settings/widget/AppSwitchPreference.java
Normal file
41
src/com/android/settings/widget/AppSwitchPreference.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
public class AppSwitchPreference extends SwitchPreference {
|
||||
|
||||
public AppSwitchPreference(Context context) {
|
||||
super(context);
|
||||
setLayoutResource(R.layout.preference_app);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
|
||||
view.findViewById(R.id.summary_container)
|
||||
.setVisibility(TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
@@ -133,8 +134,13 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
final String systemDefaultKey = getSystemDefaultKey();
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
screen.removeAll();
|
||||
|
||||
final int customLayoutResId = getRadioButtonPreferenceCustomLayoutResId();
|
||||
if (shouldShowItemNone()) {
|
||||
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
|
||||
if (customLayoutResId > 0) {
|
||||
nonePref.setLayoutResource(customLayoutResId);
|
||||
}
|
||||
nonePref.setIcon(R.drawable.ic_remove_circle);
|
||||
nonePref.setTitle(R.string.app_list_preference_none);
|
||||
nonePref.setChecked(TextUtils.isEmpty(defaultKey));
|
||||
@@ -144,6 +150,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
if (candidateList != null) {
|
||||
for (CandidateInfo info : candidateList) {
|
||||
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
||||
if (customLayoutResId > 0) {
|
||||
pref.setLayoutResource(customLayoutResId);
|
||||
}
|
||||
bindPreference(pref, info.getKey(), info, defaultKey);
|
||||
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
|
||||
screen.addPreference(pref);
|
||||
@@ -206,6 +215,14 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a custom layout for each candidate row.
|
||||
*/
|
||||
@LayoutRes
|
||||
protected int getRadioButtonPreferenceCustomLayoutResId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static abstract class CandidateInfo {
|
||||
|
||||
public final boolean enabled;
|
||||
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class ProviderPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseSmallIcon() {
|
||||
final ProviderPreference providerPreference = new ProviderPreference(
|
||||
mContext, "account_type", null /* icon */, "provider_name");
|
||||
final boolean useSmallIcon =
|
||||
ReflectionHelpers.getField(providerPreference, "mUseSmallIcon");
|
||||
assertThat(useSmallIcon).isTrue();
|
||||
}
|
||||
}
|
@@ -17,6 +17,14 @@
|
||||
package com.android.settings.applications.defaultapps;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
@@ -24,9 +32,10 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.widget.RadioButtonPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -41,13 +50,6 @@ import org.robolectric.annotation.Config;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class DefaultAppPickerFragmentTest {
|
||||
@@ -97,6 +99,12 @@ public class DefaultAppPickerFragmentTest {
|
||||
any(Pair.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveAppPreferenceLayout() {
|
||||
assertThat(mFragment.getRadioButtonPreferenceCustomLayoutResId())
|
||||
.isEqualTo(R.layout.preference_app);
|
||||
}
|
||||
|
||||
public static class TestFragment extends DefaultAppPickerFragment {
|
||||
|
||||
boolean setDefaultAppKeyCalled;
|
||||
|
@@ -26,8 +26,9 @@ import android.os.UserManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.TwoTargetPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -79,6 +80,16 @@ public class DefaultAppPreferenceControllerTest {
|
||||
verify(mPreference).setSummary(R.string.app_list_preference_none);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_twoTargetPref_shouldUseSmallIcon() {
|
||||
final TwoTargetPreference pref = mock(TwoTargetPreference.class);
|
||||
mController = new TestPreferenceController(mContext);
|
||||
|
||||
mController.updateState(pref);
|
||||
|
||||
verify(pref).setUseSmallIcon(true);
|
||||
}
|
||||
|
||||
private static class TestPreferenceController extends DefaultAppPreferenceController {
|
||||
|
||||
private DefaultAppInfo mAppInfo;
|
||||
|
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@@ -48,9 +47,8 @@ public class ApplicationViewHolderTest {
|
||||
@Before
|
||||
public void seUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mView = ApplicationViewHolder.newView(LayoutInflater.from(mContext),
|
||||
new FrameLayout(mContext));
|
||||
mHolder = new ApplicationViewHolder(mView);
|
||||
mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
|
||||
mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,6 +69,10 @@ public class ApplicationViewHolderTest {
|
||||
|
||||
mHolder.setSummary(R.string.disabled);
|
||||
assertThat(mHolder.mSummary.getText()).isEqualTo(mContext.getText(R.string.disabled));
|
||||
assertThat(mHolder.mSummaryContainer.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
|
||||
mHolder.setSummary(null);
|
||||
assertThat(mHolder.mSummaryContainer.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -18,6 +18,10 @@ package com.android.settings.applications.manageapplications;
|
||||
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_ALL;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_MAIN;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_NOTIFICATION;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
@@ -102,7 +106,7 @@ public class ManageApplicationsTest {
|
||||
@Test
|
||||
public void updateMenu_mainListType_showAppReset() {
|
||||
setUpOptionMenus();
|
||||
ReflectionHelpers.setField(mFragment, "mListType", ManageApplications.LIST_TYPE_MAIN);
|
||||
ReflectionHelpers.setField(mFragment, "mListType", LIST_TYPE_MAIN);
|
||||
ReflectionHelpers.setField(mFragment, "mOptionsMenu", mMenu);
|
||||
|
||||
mFragment.updateOptionsMenu();
|
||||
@@ -182,6 +186,21 @@ public class ManageApplicationsTest {
|
||||
verify(loadingViewController).showLoadingViewDelayed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseStableItemHeight_mainType_yes() {
|
||||
assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
|
||||
LIST_TYPE_MAIN))
|
||||
.isTrue();
|
||||
assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
|
||||
LIST_TYPE_NOTIFICATION))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseStableItemHeight_notificationType_no() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRebuildComplete_shouldHideLoadingView() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
|
@@ -27,7 +27,6 @@ import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@@ -68,9 +67,8 @@ public class MusicViewHolderControllerTest {
|
||||
mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid,
|
||||
new UserHandle(0));
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
mView = ApplicationViewHolder.newView(inflater, new FrameLayout(mContext));
|
||||
mHolder = new ApplicationViewHolder(mView);
|
||||
mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
|
||||
mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -26,7 +26,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@@ -67,9 +66,8 @@ public class PhotosViewHolderControllerTest {
|
||||
new PhotosViewHolderController(
|
||||
mContext, mSource, mVolume.fsUuid, new UserHandle(0));
|
||||
|
||||
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
mView = ApplicationViewHolder.newView(inflater, new FrameLayout(mContext));
|
||||
mHolder = new ApplicationViewHolder(mView);
|
||||
mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
|
||||
mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -32,6 +32,7 @@ import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
@@ -41,6 +42,8 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
|
||||
import com.android.settings.widget.MasterSwitchPreference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -83,6 +86,10 @@ public class AutomaticStorageManagementSwitchPreferenceControllerTest {
|
||||
mContext, mMetricsFeature, mFragmentManager);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
}
|
||||
@After
|
||||
public void tearDown() {
|
||||
SettingsShadowSystemProperties.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_shouldReturnTrue_forHighRamDevice() {
|
||||
@@ -146,6 +153,9 @@ public class AutomaticStorageManagementSwitchPreferenceControllerTest {
|
||||
public void togglingOnShouldTriggerWarningFragment() {
|
||||
FragmentTransaction transaction = mock(FragmentTransaction.class);
|
||||
when (mFragmentManager.beginTransaction()).thenReturn(transaction);
|
||||
SettingsShadowSystemProperties.set(
|
||||
AutomaticStorageManagementSwitchPreferenceController
|
||||
.STORAGE_MANAGER_ENABLED_BY_DEFAULT_PROPERTY, "false");
|
||||
|
||||
mController.onSwitchToggled(true);
|
||||
|
||||
|
@@ -16,6 +16,16 @@
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
@@ -23,10 +33,10 @@ import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.UserAppInfo;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -43,16 +53,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class ApplicationListPreferenceControllerTest {
|
||||
@@ -120,7 +120,7 @@ public class ApplicationListPreferenceControllerTest {
|
||||
implements ApplicationListPreferenceController.ApplicationListBuilder {
|
||||
@Override
|
||||
public void buildApplicationList(Context context,
|
||||
ApplicationFeatureProvider.ListOfAppsCallback callback) {
|
||||
ApplicationFeatureProvider.ListOfAppsCallback callback) {
|
||||
final List<UserAppInfo> apps = new ArrayList<>();
|
||||
final UserInfo user = new UserInfo(MAIN_USER_ID, "main", UserInfo.FLAG_ADMIN);
|
||||
apps.add(new UserAppInfo(user, buildInfo(MAIN_USER_APP_UID, APP_1, 0, 0)));
|
||||
|
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
@@ -35,8 +37,6 @@ 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 {
|
||||
@@ -53,7 +53,7 @@ public class PowerGaugePreferenceTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mRootView = LayoutInflater.from(mContext).inflate(R.layout.preference,
|
||||
mRootView = LayoutInflater.from(mContext).inflate(R.layout.preference_app,
|
||||
null);
|
||||
mWidgetView = LayoutInflater.from(mContext).inflate(R.layout.preference_widget_summary,
|
||||
null);
|
||||
@@ -61,6 +61,7 @@ public class PowerGaugePreferenceTest {
|
||||
mPreferenceViewHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
|
||||
|
||||
mPowerGaugePreference = new PowerGaugePreference(mContext);
|
||||
assertThat(mPowerGaugePreference.getLayoutResource()).isEqualTo(R.layout.preference_app);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.widget;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AppPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
private View mRootView;
|
||||
private AppPreference mPref;
|
||||
private PreferenceViewHolder mHolder;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
|
||||
mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
|
||||
mPref = new AppPreference(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setProgress_showProgress() {
|
||||
mPref.setProgress(1);
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mHolder.findViewById(android.R.id.progress).getVisibility())
|
||||
.isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSummary_showSummaryContainer() {
|
||||
mPref.setSummary("test");
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSummary_hideSummaryContainer() {
|
||||
mPref.setSummary(null);
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.GONE);
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.widget;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AppSwitchPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
private View mRootView;
|
||||
private AppSwitchPreference mPref;
|
||||
private PreferenceViewHolder mHolder;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
|
||||
mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
|
||||
mPref = new AppSwitchPreference(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSummary_showSummaryContainer() {
|
||||
mPref.setSummary("test");
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSummary_hideSummaryContainer() {
|
||||
mPref.setSummary(null);
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.GONE);
|
||||
}
|
||||
}
|
@@ -16,15 +16,21 @@
|
||||
|
||||
package com.android.settings.widget;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.applications.defaultapps.DefaultAppInfo;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -38,12 +44,6 @@ import org.robolectric.annotation.Config;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class RadioButtonPickerFragmentTest {
|
||||
@@ -99,6 +99,11 @@ public class RadioButtonPickerFragmentTest {
|
||||
assertThat(mFragment.setDefaultKeyCalled).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveNoCustomPreferenceLayout() {
|
||||
assertThat(mFragment.getRadioButtonPreferenceCustomLayoutResId()).isEqualTo(0);
|
||||
}
|
||||
|
||||
public static class TestFragment extends RadioButtonPickerFragment {
|
||||
|
||||
boolean setDefaultKeyCalled;
|
||||
|
Reference in New Issue
Block a user