Snap for 4787078 from 0cf2e41bf8
to pi-release
Change-Id: I38c40e8f64da015784a9ad1907f7356f443b2737
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/suw_layout_title"
|
android:id="@+id/suw_layout_title"
|
||||||
style="@style/SuwGlifHeaderTitle"
|
style="@style/SuwGlifHeaderTitle"
|
||||||
|
android:accessibilityLiveRegion="polite"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
@@ -91,6 +91,30 @@
|
|||||||
<TextView android:id="@+id/roaming" style="@style/info_value" />
|
<TextView android:id="@+id/roaming" style="@style/info_value" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Link Bandwidth -->
|
||||||
|
<LinearLayout style="@style/entry_layout" android:orientation="horizontal">
|
||||||
|
<TextView android:text="@string/radio_info_dl_kbps" style="@style/info_label" />
|
||||||
|
<TextView android:id="@+id/dl_kbps" style="@style/info_value" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Link Bandwidth -->
|
||||||
|
<LinearLayout style="@style/entry_layout" android:orientation="horizontal">
|
||||||
|
<TextView android:text="@string/radio_info_ul_kbps" style="@style/info_label" />
|
||||||
|
<TextView android:id="@+id/ul_kbps" style="@style/info_value" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Physical Channel Config -->
|
||||||
|
<LinearLayout style="@style/entry_layout">
|
||||||
|
<TextView android:text="@string/radio_info_phy_chan_config" style="@style/info_label" />
|
||||||
|
<TextView android:id="@+id/phy_chan_config" style="@style/info_value" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Horizontal Rule -->
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:background="#000000" />
|
||||||
|
|
||||||
<!-- Preferred Network Type -->
|
<!-- Preferred Network Type -->
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -72,7 +72,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||||
android:textColor="?android:attr/textColorSecondaryNoDisable"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:maxLines="10"
|
android:maxLines="10"
|
||||||
android:layout_alignParentEnd="true"/>
|
android:layout_alignParentEnd="true"/>
|
||||||
|
|
||||||
|
@@ -17,40 +17,112 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="320dp"
|
android:layout_width="320dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" >
|
||||||
android:padding="20dp">
|
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:id="@+id/header"
|
android:id="@+id/zen_onboarding_choices"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/zen_onboarding_dnd_visual_disturbances_header"
|
android:paddingLeft="24dp"
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.DialogWindowTitle" />
|
android:paddingRight="24dp"
|
||||||
|
android:paddingTop="18dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/feature_description"
|
android:id="@+id/header"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/header"
|
android:text="@string/zen_onboarding_dnd_visual_disturbances_header"
|
||||||
android:layout_marginTop="24dp"
|
android:textAppearance="@android:style/TextAppearance.Material.DialogWindowTitle" />
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
|
||||||
android:text="@string/zen_onboarding_dnd_visual_disturbances_description" />
|
<LinearLayout
|
||||||
|
android:id="@+id/zen_onboarding_new_setting"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/header"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="22dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/zen_onboarding_new_setting_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="8dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/zen_onboarding_new_setting_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/zen_onboarding_new_setting_title"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItem" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/zen_onboarding_new_setting_summary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/zen_onboarding_new_setting_summary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/zen_onboarding_current_setting"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/zen_onboarding_new_setting"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/zen_onboarding_current_setting_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="8dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/zen_onboarding_current_setting_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/zen_onboarding_current_setting_title"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItem" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/zen_onboarding_current_setting_summary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/zen_onboarding_current_setting_summary" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/buttons"
|
android:id="@+id/buttons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/feature_description"
|
android:layout_below="@+id/zen_onboarding_choices"
|
||||||
android:layout_marginTop="35dp">
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_marginBottom="10dp">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/no"
|
android:id="@+id/settings"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/zen_onboarding_no_update"
|
android:text="@string/zen_onboarding_settings"
|
||||||
android:layout_toStartOf="@+id/ok"
|
android:layout_alignParentStart="true"
|
||||||
style="@style/TextAppearance.ZenOnboardingButton"
|
style="@style/TextAppearance.ZenOnboardingButton"
|
||||||
android:onClick="close" />
|
android:onClick="launchSettings" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/ok"
|
android:id="@+id/ok"
|
||||||
|
@@ -131,7 +131,4 @@
|
|||||||
<!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
|
<!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
|
||||||
<string-array name="config_settings_slices_accessibility_components" translatable="false"/>
|
<string-array name="config_settings_slices_accessibility_components" translatable="false"/>
|
||||||
|
|
||||||
<!-- Whether or not swipe up gesture's opt-in setting is available on this device -->
|
|
||||||
<bool name="config_swipe_up_gesture_setting_available">false</bool>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -471,11 +471,17 @@
|
|||||||
<!-- HTTP proxy settings. Title for Proxy-Auto Config URL. [CHAR LIMIT=25] -->
|
<!-- HTTP proxy settings. Title for Proxy-Auto Config URL. [CHAR LIMIT=25] -->
|
||||||
<string name="proxy_url_title">"PAC URL: "</string>
|
<string name="proxy_url_title">"PAC URL: "</string>
|
||||||
|
|
||||||
|
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
||||||
|
<string name="radio_info_dl_kbps">DL Bandwidth (kbps):</string>
|
||||||
|
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
||||||
|
<string name="radio_info_ul_kbps">UL Bandwidth (kbps):</string>
|
||||||
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
||||||
<string name="radio_info_signal_location_label">Cell Location Info (deprecated):</string>
|
<string name="radio_info_signal_location_label">Cell Location Info (deprecated):</string>
|
||||||
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
||||||
<string name="radio_info_neighboring_location_label">Neighbor Cell Info (deprecated):</string>
|
<string name="radio_info_neighboring_location_label">Neighbor Cell Info (deprecated):</string>
|
||||||
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
||||||
|
<string name="radio_info_phy_chan_config">LTE Physical Channel Configuration:</string>
|
||||||
|
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
||||||
<string name="radio_info_cell_info_refresh_rate">Cell Info Refresh Rate:</string>
|
<string name="radio_info_cell_info_refresh_rate">Cell Info Refresh Rate:</string>
|
||||||
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
|
||||||
<string name="radio_info_cellinfo_label">All Cell Measurement Info:</string>
|
<string name="radio_info_cellinfo_label">All Cell Measurement Info:</string>
|
||||||
@@ -7407,26 +7413,34 @@
|
|||||||
<string name="zen_msg_event_reminder_footer">When Do Not Disturb is on, messages, reminders, and events will muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you.</string>
|
<string name="zen_msg_event_reminder_footer">When Do Not Disturb is on, messages, reminders, and events will muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you.</string>
|
||||||
|
|
||||||
<!-- Do not disturb onboarding dialog, accept new settings [CHAR LIMIT=30]-->
|
<!-- Do not disturb onboarding dialog, accept new settings [CHAR LIMIT=30]-->
|
||||||
<string name="zen_onboarding_ok">Update</string>
|
<string name="zen_onboarding_ok">Done</string>
|
||||||
<!-- Do not disturb onboarding dialog, do not accept new settings [CHAR LIMIT=30]-->
|
<!-- Do not disturb onboarding dialog, on click user goes to dnd settings page [CHAR LIMIT=30]-->
|
||||||
<string name="zen_onboarding_no_update">Don\'t update</string>
|
|
||||||
<!-- Do not disturb onboarding dialog, description of new settings [CHAR LIMIT=NONE]-->
|
|
||||||
<string name="zen_onboarding_dnd_visual_disturbances_description">Your phone can do more to help you focus.\n\nUpdate settings to:\n\n- Hide notifications completely\n\n- Allow calls from starred contacts and repeat callers</string>
|
|
||||||
<!-- Do not disturb onboarding dialog, header prompt for settings [CHAR LIMIT=80]-->
|
|
||||||
<string name="zen_onboarding_dnd_visual_disturbances_header">Update Do Not Disturb?</string>
|
|
||||||
|
|
||||||
<!-- obsolete -->
|
|
||||||
<string name="zen_onboarding_settings">Settings</string>
|
<string name="zen_onboarding_settings">Settings</string>
|
||||||
<!-- obsolete -->
|
|
||||||
<string name="zen_onboarding_more_options">You can further customize this in Settings.</string>
|
<!-- Do not disturb onboarding dialog, title for radio button [CHAR LIMIT=80]-->
|
||||||
<!-- obsolete -->
|
<string name="zen_onboarding_new_setting_title">No visuals or sounds from notifications</string>
|
||||||
<string name="zen_onboarding_screen_on_title">Block when the screen is on</string>
|
<!-- Do not disturb onboarding dialog, title for radio button [CHAR LIMIT=80]-->
|
||||||
<!-- obsolete -->
|
<string name="zen_onboarding_current_setting_title">No sound from notifications</string>
|
||||||
<string name="zen_onboarding_screen_off_title">Block when the screen is off</string>
|
<!-- Do not disturb onboarding dialog, secondary text for radio button [CHAR LIMIT=NONE]-->
|
||||||
<!-- obsolete -->
|
<string name="zen_onboarding_new_setting_summary">You won\u2019t see or hear notifications. Calls from starred contacts and repeat callers are allowed.</string>
|
||||||
<string name="zen_onboarding_screen_off_summary">Don\'t turn on the screen or wake for notifications</string>
|
<!-- Do not disturb onboarding dialog, secondary text for radio button [CHAR LIMIT=NONE]-->
|
||||||
<!-- obsolete -->
|
<string name="zen_onboarding_current_setting_summary">(Current setting)</string>
|
||||||
<string name="zen_onboarding_screen_on_summary">Don\'t show notifications at all, except for basic phone activity and status</string>
|
|
||||||
|
<!-- Do not disturb onboarding dialog, header prompt for settings [CHAR LIMIT=80]-->
|
||||||
|
<string name="zen_onboarding_dnd_visual_disturbances_header">Change Do Not Disturb notification settings?</string>
|
||||||
|
|
||||||
|
<!-- DO NOT TRANSLATE obsolete [CHAR LIMIT=NONE]-->
|
||||||
|
<string name="zen_onboarding_dnd_visual_disturbances_description" translatable="false">Your phone can do more to help you focus.\n\nUpdate settings to:\n\n- Hide notifications completely\n\n- Allow calls from starred contacts and repeat callers</string>
|
||||||
|
<!-- DO NOT TRANSLATE obsolete -->
|
||||||
|
<string name="zen_onboarding_more_options" translatable="false">You can further customize this in Settings.</string>
|
||||||
|
<!-- DO NOT TRANSLATE obsolete -->
|
||||||
|
<string name="zen_onboarding_screen_on_title" translatable="false">Block when the screen is on</string>
|
||||||
|
<!-- DO NOT TRANSLATE obsolete -->
|
||||||
|
<string name="zen_onboarding_screen_off_title" translatable="false">Block when the screen is off</string>
|
||||||
|
<!-- DO NOT TRANSLATE obsolete -->
|
||||||
|
<string name="zen_onboarding_screen_off_summary" translatable="false">Don\'t turn on the screen or wake for notifications</string>
|
||||||
|
<!-- DO NOT TRANSLATE obsolete -->
|
||||||
|
<string name="zen_onboarding_screen_on_summary" translatable="false">Don\'t show notifications at all, except for basic phone activity and status</string>
|
||||||
|
|
||||||
<!-- Work Sounds: Work sound settings section header. [CHAR LIMIT=50] -->
|
<!-- Work Sounds: Work sound settings section header. [CHAR LIMIT=50] -->
|
||||||
<string name="sound_work_settings">Work profile sounds</string>
|
<string name="sound_work_settings">Work profile sounds</string>
|
||||||
@@ -9241,7 +9255,7 @@
|
|||||||
<!-- Informational text about update time only, without carrier. First argument intentionally skipped. [CHAR LIMIT=30] -->
|
<!-- Informational text about update time only, without carrier. First argument intentionally skipped. [CHAR LIMIT=30] -->
|
||||||
<string name="no_carrier_update_text">Updated <xliff:g name="time" example="3m">^2</xliff:g> ago</string>
|
<string name="no_carrier_update_text">Updated <xliff:g name="time" example="3m">^2</xliff:g> ago</string>
|
||||||
|
|
||||||
<!-- Informational text about a recent carrier and update time [CHAR LIMIT=30] -->
|
<!-- Informational text about a recent carrier and update time [CHAR LIMIT=34] -->
|
||||||
<string name="carrier_and_update_now_text">Updated by <xliff:g name="carrier" example="T-mobile">^1</xliff:g> just now</string>
|
<string name="carrier_and_update_now_text">Updated by <xliff:g name="carrier" example="T-mobile">^1</xliff:g> just now</string>
|
||||||
|
|
||||||
<!-- Informational text about recent update time only, without carrier [CHAR LIMIT=30] -->
|
<!-- Informational text about recent update time only, without carrier [CHAR LIMIT=30] -->
|
||||||
|
@@ -439,8 +439,7 @@
|
|||||||
<item name="android:background">@drawable/btn_borderless_rect</item>
|
<item name="android:background">@drawable/btn_borderless_rect</item>
|
||||||
<item name="android:gravity">center</item>
|
<item name="android:gravity">center</item>
|
||||||
<item name="android:focusable">true</item>
|
<item name="android:focusable">true</item>
|
||||||
<item name="android:paddingStart">8dp</item>
|
<item name="android:padding">8dp</item>
|
||||||
<item name="android:paddingEnd">8dp</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
|
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
|
||||||
|
@@ -161,10 +161,17 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="app_settings_link"
|
||||||
|
android:title="@string/app_settings_link"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppSettingPreferenceController"
|
||||||
|
settings:allowDividerAbove="true" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_version"
|
android:key="app_version"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
android:order="9999"
|
android:order="9999"
|
||||||
settings:controller="com.android.settings.applications.appinfo.AppVersionPreferenceController" />
|
settings:controller="com.android.settings.applications.appinfo.AppVersionPreferenceController"
|
||||||
|
settings:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="bluetooth_screen_add_bt_devices"
|
android:key="bluetooth_screen_add_bt_devices"
|
||||||
android:title="@string/connected_device_add_device_title"
|
android:title="@string/bluetooth_pairing_pref_title"
|
||||||
android:icon="@drawable/ic_menu_add"
|
android:icon="@drawable/ic_menu_add"
|
||||||
android:summary="@string/connected_device_add_device_summary"
|
android:summary="@string/connected_device_add_device_summary"
|
||||||
android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
|
android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
|
||||||
|
@@ -62,12 +62,6 @@
|
|||||||
android:order="-160"
|
android:order="-160"
|
||||||
settings:controller="com.android.settings.notification.RingVolumePreferenceController"/>
|
settings:controller="com.android.settings.notification.RingVolumePreferenceController"/>
|
||||||
|
|
||||||
<!-- Also vibrate for calls -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="vibrate_when_ringing"
|
|
||||||
android:title="@string/vibrate_when_ringing_title"
|
|
||||||
android:order="-155"/>
|
|
||||||
|
|
||||||
<!-- Alarm volume -->
|
<!-- Alarm volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
android:key="alarm_volume"
|
android:key="alarm_volume"
|
||||||
@@ -84,6 +78,13 @@
|
|||||||
android:order="-140"
|
android:order="-140"
|
||||||
settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>
|
settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>
|
||||||
|
|
||||||
|
<!-- Also vibrate for calls -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="vibrate_when_ringing"
|
||||||
|
android:title="@string/vibrate_when_ringing_title"
|
||||||
|
settings:controller="com.android.settings.notification.VibrateWhenRingPreferenceController"
|
||||||
|
android:order="-130"/>
|
||||||
|
|
||||||
<!-- Interruptions -->
|
<!-- Interruptions -->
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="zen_mode"
|
android:key="zen_mode"
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import static android.net.ConnectivityManager.NetworkCallback;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@@ -27,6 +29,10 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.NetworkRequest;
|
||||||
import android.net.TrafficStats;
|
import android.net.TrafficStats;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncResult;
|
import android.os.AsyncResult;
|
||||||
@@ -52,12 +58,14 @@ import android.telephony.DataConnectionRealTimeInfo;
|
|||||||
import android.telephony.NeighboringCellInfo;
|
import android.telephony.NeighboringCellInfo;
|
||||||
import android.telephony.PreciseCallState;
|
import android.telephony.PreciseCallState;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
|
import android.telephony.PhysicalChannelConfig;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.cdma.CdmaCellLocation;
|
import android.telephony.cdma.CdmaCellLocation;
|
||||||
import android.telephony.gsm.GsmCellLocation;
|
import android.telephony.gsm.GsmCellLocation;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -193,7 +201,10 @@ public class RadioInfo extends Activity {
|
|||||||
private TextView mPingHostnameV4;
|
private TextView mPingHostnameV4;
|
||||||
private TextView mPingHostnameV6;
|
private TextView mPingHostnameV6;
|
||||||
private TextView mHttpClientTest;
|
private TextView mHttpClientTest;
|
||||||
|
private TextView mPhyChanConfig;
|
||||||
private TextView dnsCheckState;
|
private TextView dnsCheckState;
|
||||||
|
private TextView mDownlinkKbps;
|
||||||
|
private TextView mUplinkKbps;
|
||||||
private EditText smsc;
|
private EditText smsc;
|
||||||
private Switch radioPowerOnSwitch;
|
private Switch radioPowerOnSwitch;
|
||||||
private Button cellInfoRefreshRateButton;
|
private Button cellInfoRefreshRateButton;
|
||||||
@@ -211,6 +222,7 @@ public class RadioInfo extends Activity {
|
|||||||
private Spinner preferredNetworkType;
|
private Spinner preferredNetworkType;
|
||||||
private Spinner cellInfoRefreshRateSpinner;
|
private Spinner cellInfoRefreshRateSpinner;
|
||||||
|
|
||||||
|
private ConnectivityManager mConnectivityManager;
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
private ImsManager mImsManager = null;
|
private ImsManager mImsManager = null;
|
||||||
private Phone phone = null;
|
private Phone phone = null;
|
||||||
@@ -228,6 +240,19 @@ public class RadioInfo extends Activity {
|
|||||||
private int mPreferredNetworkTypeResult;
|
private int mPreferredNetworkTypeResult;
|
||||||
private int mCellInfoRefreshRateIndex;
|
private int mCellInfoRefreshRateIndex;
|
||||||
|
|
||||||
|
private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||||
|
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private final NetworkCallback mNetworkCallback = new NetworkCallback() {
|
||||||
|
public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) {
|
||||||
|
int dlbw = nc.getLinkDownstreamBandwidthKbps();
|
||||||
|
int ulbw = nc.getLinkUpstreamBandwidthKbps();
|
||||||
|
updateBandwidths(dlbw, ulbw);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDataConnectionStateChanged(int state) {
|
public void onDataConnectionStateChanged(int state) {
|
||||||
@@ -295,8 +320,29 @@ public class RadioInfo extends Activity {
|
|||||||
updateNetworkType();
|
updateNetworkType();
|
||||||
updateImsProvisionedState();
|
updateImsProvisionedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPhysicalChannelConfigurationChanged(
|
||||||
|
List<PhysicalChannelConfig> configs) {
|
||||||
|
updatePhysicalChannelConfiguration(configs);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String div = "";
|
||||||
|
sb.append("{");
|
||||||
|
if (configs != null) {
|
||||||
|
for(PhysicalChannelConfig c : configs) {
|
||||||
|
sb.append(div).append(c);
|
||||||
|
div = ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
mPhyChanConfig.setText(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
private void updatePreferredNetworkType(int type) {
|
private void updatePreferredNetworkType(int type) {
|
||||||
if (type >= mPreferredNetworkLabels.length || type < 0) {
|
if (type >= mPreferredNetworkLabels.length || type < 0) {
|
||||||
log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
|
log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
|
||||||
@@ -365,6 +411,7 @@ public class RadioInfo extends Activity {
|
|||||||
log("Started onCreate");
|
log("Started onCreate");
|
||||||
|
|
||||||
mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
|
mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
|
||||||
|
mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
|
||||||
phone = PhoneFactory.getDefaultPhone();
|
phone = PhoneFactory.getDefaultPhone();
|
||||||
|
|
||||||
//TODO: Need to update this if the default phoneId changes?
|
//TODO: Need to update this if the default phoneId changes?
|
||||||
@@ -399,6 +446,8 @@ public class RadioInfo extends Activity {
|
|||||||
mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
|
mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
|
||||||
mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
|
mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
|
||||||
|
|
||||||
|
mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
|
||||||
|
|
||||||
preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
|
preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
|
ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
|
||||||
android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
|
android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
|
||||||
@@ -418,6 +467,10 @@ public class RadioInfo extends Activity {
|
|||||||
|
|
||||||
radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
|
radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
|
||||||
|
|
||||||
|
mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
|
||||||
|
mUplinkKbps = (TextView) findViewById(R.id.ul_kbps);
|
||||||
|
updateBandwidths(0, 0);
|
||||||
|
|
||||||
pingTestButton = (Button) findViewById(R.id.ping_test);
|
pingTestButton = (Button) findViewById(R.id.ping_test);
|
||||||
pingTestButton.setOnClickListener(mPingButtonHandler);
|
pingTestButton.setOnClickListener(mPingButtonHandler);
|
||||||
updateSmscButton = (Button) findViewById(R.id.update_smsc);
|
updateSmscButton = (Button) findViewById(R.id.update_smsc);
|
||||||
@@ -501,7 +554,10 @@ public class RadioInfo extends Activity {
|
|||||||
| PhoneStateListener.LISTEN_CELL_INFO
|
| PhoneStateListener.LISTEN_CELL_INFO
|
||||||
| PhoneStateListener.LISTEN_SERVICE_STATE
|
| PhoneStateListener.LISTEN_SERVICE_STATE
|
||||||
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
|
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
|
||||||
| PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO);
|
| PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
|
||||||
|
|
||||||
|
mConnectivityManager.registerNetworkCallback(
|
||||||
|
mDefaultNetworkRequest, mNetworkCallback, mHandler);
|
||||||
|
|
||||||
smsc.clearFocus();
|
smsc.clearFocus();
|
||||||
}
|
}
|
||||||
@@ -514,6 +570,8 @@ public class RadioInfo extends Activity {
|
|||||||
|
|
||||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
||||||
mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
|
mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
|
||||||
|
mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreFromBundle(Bundle b) {
|
private void restoreFromBundle(Bundle b) {
|
||||||
@@ -593,6 +651,14 @@ public class RadioInfo extends Activity {
|
|||||||
"0.0.0.0 allowed" :"0.0.0.0 not allowed");
|
"0.0.0.0 allowed" :"0.0.0.0 not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateBandwidths(int dlbw, int ulbw) {
|
||||||
|
dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw;
|
||||||
|
ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw;
|
||||||
|
mDownlinkKbps.setText(String.format("%-5d", dlbw));
|
||||||
|
mUplinkKbps.setText(String.format("%-5d", ulbw));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private final void
|
private final void
|
||||||
updateSignalStrength(SignalStrength signalStrength) {
|
updateSignalStrength(SignalStrength signalStrength) {
|
||||||
Resources r = getResources();
|
Resources r = getResources();
|
||||||
@@ -673,12 +739,34 @@ public class RadioInfo extends Activity {
|
|||||||
return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
|
return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final String getConnectionStatusString(CellInfo ci) {
|
||||||
|
String regStr = "";
|
||||||
|
String connStatStr = "";
|
||||||
|
String connector = "";
|
||||||
|
|
||||||
|
if (ci.isRegistered()) {
|
||||||
|
regStr = "R";
|
||||||
|
}
|
||||||
|
switch (ci.getCellConnectionStatus()) {
|
||||||
|
case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
|
||||||
|
case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
|
||||||
|
case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
|
||||||
|
case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
|
||||||
|
connector = "+";
|
||||||
|
}
|
||||||
|
|
||||||
|
return regStr + connector + connStatStr;
|
||||||
|
}
|
||||||
|
|
||||||
private final String buildCdmaInfoString(CellInfoCdma ci) {
|
private final String buildCdmaInfoString(CellInfoCdma ci) {
|
||||||
CellIdentityCdma cidCdma = ci.getCellIdentity();
|
CellIdentityCdma cidCdma = ci.getCellIdentity();
|
||||||
CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
|
CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
|
||||||
|
|
||||||
return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
|
return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
|
||||||
ci.isRegistered() ? "S " : " ",
|
getConnectionStatusString(ci),
|
||||||
getCellInfoDisplayString(cidCdma.getSystemId()),
|
getCellInfoDisplayString(cidCdma.getSystemId()),
|
||||||
getCellInfoDisplayString(cidCdma.getNetworkId()),
|
getCellInfoDisplayString(cidCdma.getNetworkId()),
|
||||||
getCellInfoDisplayString(cidCdma.getBasestationId()),
|
getCellInfoDisplayString(cidCdma.getBasestationId()),
|
||||||
@@ -694,7 +782,7 @@ public class RadioInfo extends Activity {
|
|||||||
CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
|
CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
|
||||||
|
|
||||||
return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
|
return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
|
||||||
ci.isRegistered() ? "S " : " ",
|
getConnectionStatusString(ci),
|
||||||
getCellInfoDisplayString(cidGsm.getMcc()),
|
getCellInfoDisplayString(cidGsm.getMcc()),
|
||||||
getCellInfoDisplayString(cidGsm.getMnc()),
|
getCellInfoDisplayString(cidGsm.getMnc()),
|
||||||
getCellInfoDisplayString(cidGsm.getLac()),
|
getCellInfoDisplayString(cidGsm.getLac()),
|
||||||
@@ -709,14 +797,15 @@ public class RadioInfo extends Activity {
|
|||||||
CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
|
CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
|
||||||
|
|
||||||
return String.format(
|
return String.format(
|
||||||
"%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n",
|
"%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
|
||||||
ci.isRegistered() ? "S " : " ",
|
getConnectionStatusString(ci),
|
||||||
getCellInfoDisplayString(cidLte.getMcc()),
|
getCellInfoDisplayString(cidLte.getMcc()),
|
||||||
getCellInfoDisplayString(cidLte.getMnc()),
|
getCellInfoDisplayString(cidLte.getMnc()),
|
||||||
getCellInfoDisplayString(cidLte.getTac()),
|
getCellInfoDisplayString(cidLte.getTac()),
|
||||||
getCellInfoDisplayString(cidLte.getCi()),
|
getCellInfoDisplayString(cidLte.getCi()),
|
||||||
getCellInfoDisplayString(cidLte.getPci()),
|
getCellInfoDisplayString(cidLte.getPci()),
|
||||||
getCellInfoDisplayString(cidLte.getEarfcn()),
|
getCellInfoDisplayString(cidLte.getEarfcn()),
|
||||||
|
getCellInfoDisplayString(cidLte.getBandwidth()),
|
||||||
getCellInfoDisplayString(ssLte.getDbm()),
|
getCellInfoDisplayString(ssLte.getDbm()),
|
||||||
getCellInfoDisplayString(ssLte.getRsrq()),
|
getCellInfoDisplayString(ssLte.getRsrq()),
|
||||||
getCellInfoDisplayString(ssLte.getTimingAdvance()));
|
getCellInfoDisplayString(ssLte.getTimingAdvance()));
|
||||||
@@ -727,7 +816,7 @@ public class RadioInfo extends Activity {
|
|||||||
CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
|
CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
|
||||||
|
|
||||||
return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
|
return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
|
||||||
ci.isRegistered() ? "S " : " ",
|
getConnectionStatusString(ci),
|
||||||
getCellInfoDisplayString(cidWcdma.getMcc()),
|
getCellInfoDisplayString(cidWcdma.getMcc()),
|
||||||
getCellInfoDisplayString(cidWcdma.getMnc()),
|
getCellInfoDisplayString(cidWcdma.getMnc()),
|
||||||
getCellInfoDisplayString(cidWcdma.getLac()),
|
getCellInfoDisplayString(cidWcdma.getLac()),
|
||||||
@@ -759,17 +848,21 @@ public class RadioInfo extends Activity {
|
|||||||
}
|
}
|
||||||
if (lteCells.length() != 0) {
|
if (lteCells.length() != 0) {
|
||||||
value += String.format(
|
value += String.format(
|
||||||
"LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n",
|
"LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
|
||||||
"SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA");
|
+ " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
|
||||||
|
"SRV", "MCC", "MNC", "TAC", "CID", "PCI",
|
||||||
|
"EARFCN", "BW", "RSRP", "RSRQ", "TA");
|
||||||
value += lteCells.toString();
|
value += lteCells.toString();
|
||||||
}
|
}
|
||||||
if (wcdmaCells.length() != 0) {
|
if (wcdmaCells.length() != 0) {
|
||||||
value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
|
value += String.format(
|
||||||
|
"WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
|
||||||
"SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
|
"SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
|
||||||
value += wcdmaCells.toString();
|
value += wcdmaCells.toString();
|
||||||
}
|
}
|
||||||
if (gsmCells.length() != 0) {
|
if (gsmCells.length() != 0) {
|
||||||
value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
|
value += String.format(
|
||||||
|
"GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
|
||||||
"SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
|
"SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
|
||||||
value += gsmCells.toString();
|
value += gsmCells.toString();
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,9 @@ import android.provider.Settings;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
|
||||||
public class MagnificationGesturesPreferenceController extends BasePreferenceController {
|
public class MagnificationGesturesPreferenceController extends TogglePreferenceController {
|
||||||
|
|
||||||
private boolean mIsFromSUW = false;
|
private boolean mIsFromSUW = false;
|
||||||
|
|
||||||
@@ -29,6 +29,18 @@ public class MagnificationGesturesPreferenceController extends BasePreferenceCon
|
|||||||
super(context, key);
|
super(context, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChecked() {
|
||||||
|
return MagnificationPreferenceFragment.isChecked(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
return MagnificationPreferenceFragment.setChecked(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, isChecked);
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsFromSUW(boolean fromSUW) {
|
public void setIsFromSUW(boolean fromSUW) {
|
||||||
mIsFromSUW = fromSUW;
|
mIsFromSUW = fromSUW;
|
||||||
}
|
}
|
||||||
@@ -38,6 +50,7 @@ public class MagnificationGesturesPreferenceController extends BasePreferenceCon
|
|||||||
if (getPreferenceKey().equals(preference.getKey())) {
|
if (getPreferenceKey().equals(preference.getKey())) {
|
||||||
Bundle extras = preference.getExtras();
|
Bundle extras = preference.getExtras();
|
||||||
populateMagnificationGesturesPreferenceExtras(extras, mContext);
|
populateMagnificationGesturesPreferenceExtras(extras, mContext);
|
||||||
|
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED, isChecked());
|
||||||
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
|
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -54,8 +67,7 @@ public class MagnificationGesturesPreferenceController extends BasePreferenceCon
|
|||||||
if (mIsFromSUW) {
|
if (mIsFromSUW) {
|
||||||
resId = R.string.accessibility_screen_magnification_short_summary;
|
resId = R.string.accessibility_screen_magnification_short_summary;
|
||||||
} else {
|
} else {
|
||||||
final boolean enabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
final boolean enabled = isChecked();
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1;
|
|
||||||
resId = (enabled ? R.string.accessibility_feature_state_on :
|
resId = (enabled ? R.string.accessibility_feature_state_on :
|
||||||
R.string.accessibility_feature_state_off);
|
R.string.accessibility_feature_state_off);
|
||||||
}
|
}
|
||||||
@@ -69,9 +81,6 @@ public class MagnificationGesturesPreferenceController extends BasePreferenceCon
|
|||||||
R.string.accessibility_screen_magnification_gestures_title);
|
R.string.accessibility_screen_magnification_gestures_title);
|
||||||
extras.putInt(AccessibilitySettings.EXTRA_SUMMARY_RES,
|
extras.putInt(AccessibilitySettings.EXTRA_SUMMARY_RES,
|
||||||
R.string.accessibility_screen_magnification_summary);
|
R.string.accessibility_screen_magnification_summary);
|
||||||
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
|
|
||||||
Settings.Secure.getInt(context.getContentResolver(),
|
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
|
|
||||||
extras.putInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID,
|
extras.putInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID,
|
||||||
R.raw.accessibility_screen_magnification);
|
R.raw.accessibility_screen_magnification);
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,9 @@ import android.provider.Settings;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
|
||||||
public class MagnificationNavbarPreferenceController extends BasePreferenceController {
|
public class MagnificationNavbarPreferenceController extends TogglePreferenceController {
|
||||||
|
|
||||||
private boolean mIsFromSUW = false;
|
private boolean mIsFromSUW = false;
|
||||||
|
|
||||||
@@ -29,6 +29,18 @@ public class MagnificationNavbarPreferenceController extends BasePreferenceContr
|
|||||||
super(context, key);
|
super(context, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChecked() {
|
||||||
|
return MagnificationPreferenceFragment.isChecked(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
return MagnificationPreferenceFragment.setChecked(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, isChecked);
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsFromSUW(boolean fromSUW) {
|
public void setIsFromSUW(boolean fromSUW) {
|
||||||
mIsFromSUW = fromSUW;
|
mIsFromSUW = fromSUW;
|
||||||
}
|
}
|
||||||
@@ -43,10 +55,7 @@ public class MagnificationNavbarPreferenceController extends BasePreferenceContr
|
|||||||
R.string.accessibility_screen_magnification_navbar_title);
|
R.string.accessibility_screen_magnification_navbar_title);
|
||||||
extras.putInt(AccessibilitySettings.EXTRA_SUMMARY_RES,
|
extras.putInt(AccessibilitySettings.EXTRA_SUMMARY_RES,
|
||||||
R.string.accessibility_screen_magnification_navbar_summary);
|
R.string.accessibility_screen_magnification_navbar_summary);
|
||||||
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
|
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED, isChecked());
|
||||||
Settings.Secure.getInt(mContext.getContentResolver(),
|
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0)
|
|
||||||
== 1);
|
|
||||||
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
|
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -65,8 +74,7 @@ public class MagnificationNavbarPreferenceController extends BasePreferenceContr
|
|||||||
if (mIsFromSUW) {
|
if (mIsFromSUW) {
|
||||||
resId = R.string.accessibility_screen_magnification_navbar_short_summary;
|
resId = R.string.accessibility_screen_magnification_navbar_short_summary;
|
||||||
} else {
|
} else {
|
||||||
final boolean enabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
final boolean enabled = isChecked();
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1;
|
|
||||||
resId = (enabled ? R.string.accessibility_feature_state_on :
|
resId = (enabled ? R.string.accessibility_feature_state_on :
|
||||||
R.string.accessibility_feature_state_off);
|
R.string.accessibility_feature_state_off);
|
||||||
}
|
}
|
||||||
|
@@ -18,11 +18,13 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.support.annotation.VisibleForTesting;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
@@ -39,6 +41,10 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class MagnificationPreferenceFragment extends DashboardFragment {
|
public final class MagnificationPreferenceFragment extends DashboardFragment {
|
||||||
|
@VisibleForTesting
|
||||||
|
static final int ON = 1;
|
||||||
|
@VisibleForTesting
|
||||||
|
static final int OFF = 0;
|
||||||
|
|
||||||
private static final String TAG = "MagnificationPreferenceFragment";
|
private static final String TAG = "MagnificationPreferenceFragment";
|
||||||
|
|
||||||
@@ -132,6 +138,15 @@ public final class MagnificationPreferenceFragment extends DashboardFragment {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean isChecked(ContentResolver contentResolver, String settingsKey) {
|
||||||
|
return Settings.Secure.getInt(contentResolver, settingsKey, OFF) == ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean setChecked(ContentResolver contentResolver, String settingsKey,
|
||||||
|
boolean isChecked) {
|
||||||
|
return Settings.Secure.putInt(contentResolver, settingsKey, isChecked ? ON : OFF);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@code true} if this fragment should be shown, {@code false} otherwise. This
|
* @return {@code true} if this fragment should be shown, {@code false} otherwise. This
|
||||||
* fragment is shown in the case that more than one magnification mode is available.
|
* fragment is shown in the case that more than one magnification mode is available.
|
||||||
|
@@ -25,7 +25,6 @@ import android.media.MediaPlayer;
|
|||||||
import android.media.MediaPlayer.OnPreparedListener;
|
import android.media.MediaPlayer.OnPreparedListener;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
@@ -174,7 +173,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||||
Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
|
MagnificationPreferenceFragment.setChecked(getContentResolver(), preferenceKey, enabled);
|
||||||
updateConfigurationWarningIfNeeded();
|
updateConfigurationWarningIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +182,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
super.onInstallSwitchBarToggleSwitch();
|
super.onInstallSwitchBarToggleSwitch();
|
||||||
|
|
||||||
mSwitchBar.setCheckedInternal(
|
mSwitchBar.setCheckedInternal(
|
||||||
Settings.Secure.getInt(getContentResolver(), mPreferenceKey, 0) == 1);
|
MagnificationPreferenceFragment.isChecked(getContentResolver(), mPreferenceKey));
|
||||||
mSwitchBar.addOnSwitchChangeListener(this);
|
mSwitchBar.addOnSwitchChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ public class AppHeaderViewPreferenceController extends BasePreferenceController
|
|||||||
mEntityHeaderController = EntityHeaderController
|
mEntityHeaderController = EntityHeaderController
|
||||||
.newInstance(activity, mParent, mHeader.findViewById(R.id.entity_header))
|
.newInstance(activity, mParent, mHeader.findViewById(R.id.entity_header))
|
||||||
.setPackageName(mPackageName)
|
.setPackageName(mPackageName)
|
||||||
.setButtonActions(EntityHeaderController.ActionType.ACTION_APP_PREFERENCE,
|
.setButtonActions(EntityHeaderController.ActionType.ACTION_NONE,
|
||||||
EntityHeaderController.ActionType.ACTION_NONE)
|
EntityHeaderController.ActionType.ACTION_NONE)
|
||||||
.bindHeaderButtons();
|
.bindHeaderButtons();
|
||||||
}
|
}
|
||||||
|
@@ -167,6 +167,9 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
use(AppOpenByDefaultPreferenceController.class).setParentFragment(this);
|
use(AppOpenByDefaultPreferenceController.class).setParentFragment(this);
|
||||||
use(AppPermissionPreferenceController.class).setParentFragment(this);
|
use(AppPermissionPreferenceController.class).setParentFragment(this);
|
||||||
use(AppPermissionPreferenceController.class).setPackageName(packageName);
|
use(AppPermissionPreferenceController.class).setPackageName(packageName);
|
||||||
|
use(AppSettingPreferenceController.class)
|
||||||
|
.setPackageName(packageName)
|
||||||
|
.setParentFragment(this);
|
||||||
use(AppStoragePreferenceController.class).setParentFragment(this);
|
use(AppStoragePreferenceController.class).setParentFragment(this);
|
||||||
use(AppVersionPreferenceController.class).setParentFragment(this);
|
use(AppVersionPreferenceController.class).setParentFragment(this);
|
||||||
use(InstantAppDomainsPreferenceController.class).setParentFragment(this);
|
use(InstantAppDomainsPreferenceController.class).setParentFragment(this);
|
||||||
|
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.applications.appinfo;
|
||||||
|
|
||||||
|
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_OPEN_APP_SETTING;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
|
||||||
|
public class AppSettingPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
|
private String mPackageName;
|
||||||
|
|
||||||
|
public AppSettingPreferenceController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppSettingPreferenceController setPackageName(String packageName) {
|
||||||
|
mPackageName = packageName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
if (TextUtils.isEmpty(mPackageName) || mParent == null) {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
final Intent intent = resolveIntent(
|
||||||
|
new Intent(Intent.ACTION_APPLICATION_PREFERENCES).setPackage(mPackageName));
|
||||||
|
return intent != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||||
|
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Intent intent = resolveIntent(
|
||||||
|
new Intent(Intent.ACTION_APPLICATION_PREFERENCES).setPackage(mPackageName));
|
||||||
|
if (intent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider()
|
||||||
|
.actionWithSource(mContext, mParent.getMetricsCategory(),
|
||||||
|
ACTION_OPEN_APP_SETTING);
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Intent resolveIntent(Intent i) {
|
||||||
|
ResolveInfo result = mContext.getPackageManager().resolveActivity(i, 0);
|
||||||
|
if (result != null) {
|
||||||
|
return new Intent(i.getAction())
|
||||||
|
.setClassName(result.activityInfo.packageName, result.activityInfo.name);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -51,8 +51,10 @@ public abstract class TogglePreferenceController extends BasePreferenceControlle
|
|||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
if (preference instanceof TwoStatePreference) {
|
if (preference instanceof TwoStatePreference) {
|
||||||
((TwoStatePreference) preference).setChecked(isChecked());
|
((TwoStatePreference) preference).setChecked(isChecked());
|
||||||
} if (preference instanceof MasterSwitchPreference) {
|
} else if (preference instanceof MasterSwitchPreference) {
|
||||||
((MasterSwitchPreference) preference).setChecked(isChecked());
|
((MasterSwitchPreference) preference).setChecked(isChecked());
|
||||||
|
} else {
|
||||||
|
refreshSummary(preference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -131,6 +131,7 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSmartBatterySupported() {
|
public boolean isSmartBatterySupported() {
|
||||||
return false;
|
return mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_smart_battery_available);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,9 +59,6 @@ public abstract class GesturePreferenceController extends TogglePreferenceContro
|
|||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
if (preference != null) {
|
if (preference != null) {
|
||||||
if (!(preference instanceof TwoStatePreference)) {
|
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
// Different meanings of "Enabled" for the Preference and Controller.
|
// Different meanings of "Enabled" for the Preference and Controller.
|
||||||
preference.setEnabled(canHandleClicks());
|
preference.setEnabled(canHandleClicks());
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ import android.os.UserManager;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import android.support.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.internal.R;
|
||||||
|
|
||||||
public class SwipeUpPreferenceController extends GesturePreferenceController {
|
public class SwipeUpPreferenceController extends GesturePreferenceController {
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class SwipeUpPreferenceController extends GesturePreferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final ComponentName recentsComponentName = ComponentName.unflattenFromString(
|
final ComponentName recentsComponentName = ComponentName.unflattenFromString(
|
||||||
context.getString(com.android.internal.R.string.config_recentsComponentName));
|
context.getString(R.string.config_recentsComponentName));
|
||||||
final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
|
final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
|
||||||
.setPackage(recentsComponentName.getPackageName());
|
.setPackage(recentsComponentName.getPackageName());
|
||||||
if (context.getPackageManager().resolveService(quickStepIntent,
|
if (context.getPackageManager().resolveService(quickStepIntent,
|
||||||
@@ -81,7 +81,7 @@ public class SwipeUpPreferenceController extends GesturePreferenceController {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
final int defaultValue = mContext.getResources()
|
final int defaultValue = mContext.getResources()
|
||||||
.getBoolean(com.android.internal.R.bool.config_swipe_up_gesture_default) ? ON : OFF;
|
.getBoolean(R.bool.config_swipe_up_gesture_default) ? ON : OFF;
|
||||||
final int swipeUpEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
final int swipeUpEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, defaultValue);
|
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, defaultValue);
|
||||||
return swipeUpEnabled != OFF;
|
return swipeUpEnabled != OFF;
|
||||||
|
@@ -131,7 +131,8 @@ public class TetherPreferenceController extends AbstractPreferenceController imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
if (mBluetoothAdapter != null) {
|
if (mBluetoothAdapter != null &&
|
||||||
|
mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
|
||||||
mBluetoothAdapter.getProfileProxy(mContext, mBtProfileServiceListener,
|
mBluetoothAdapter.getProfileProxy(mContext, mBtProfileServiceListener,
|
||||||
BluetoothProfile.PAN);
|
BluetoothProfile.PAN);
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,6 @@ public class SoundSettings extends DashboardFragment {
|
|||||||
private static final String SELECTED_PREFERENCE_KEY = "selected_preference";
|
private static final String SELECTED_PREFERENCE_KEY = "selected_preference";
|
||||||
private static final int REQUEST_CODE = 200;
|
private static final int REQUEST_CODE = 200;
|
||||||
private static final String KEY_ZEN_MODE = "zen_mode";
|
private static final String KEY_ZEN_MODE = "zen_mode";
|
||||||
|
|
||||||
private static final int SAMPLE_CUTOFF = 2000; // manually cap sample playback at 2 seconds
|
private static final int SAMPLE_CUTOFF = 2000; // manually cap sample playback at 2 seconds
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -195,7 +194,6 @@ public class SoundSettings extends DashboardFragment {
|
|||||||
SoundSettings fragment, Lifecycle lifecycle) {
|
SoundSettings fragment, Lifecycle lifecycle) {
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new ZenModePreferenceController(context, lifecycle, KEY_ZEN_MODE));
|
controllers.add(new ZenModePreferenceController(context, lifecycle, KEY_ZEN_MODE));
|
||||||
controllers.add(new VibrateWhenRingPreferenceController(context));
|
|
||||||
|
|
||||||
// Volumes are added via xml
|
// Volumes are added via xml
|
||||||
|
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@@ -24,26 +26,41 @@ import android.os.Handler;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.support.v7.preference.TwoStatePreference;
|
|
||||||
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
|
|
||||||
import static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
|
public class VibrateWhenRingPreferenceController extends TogglePreferenceController
|
||||||
|
implements LifecycleObserver, OnResume, OnPause {
|
||||||
public class VibrateWhenRingPreferenceController extends AbstractPreferenceController
|
|
||||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
|
|
||||||
LifecycleObserver, OnResume, OnPause {
|
|
||||||
|
|
||||||
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
||||||
|
private final int DEFAULT_VALUE = 0;
|
||||||
|
private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
|
||||||
private SettingObserver mSettingObserver;
|
private SettingObserver mSettingObserver;
|
||||||
|
|
||||||
public VibrateWhenRingPreferenceController(Context context) {
|
public VibrateWhenRingPreferenceController(Context context, String key) {
|
||||||
super(context);
|
super(context, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChecked() {
|
||||||
|
return Settings.System.getInt(mContext.getContentResolver(),
|
||||||
|
VIBRATE_WHEN_RINGING, DEFAULT_VALUE) != DEFAULT_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
return Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
|
||||||
|
isChecked ? NOTIFICATION_VIBRATE_WHEN_RINGING : DEFAULT_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AvailabilityStatus
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return Utils.isVoiceCapable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,38 +87,10 @@ public class VibrateWhenRingPreferenceController extends AbstractPreferenceContr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPreferenceKey() {
|
|
||||||
return KEY_VIBRATE_WHEN_RINGING;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAvailable() {
|
|
||||||
return Utils.isVoiceCapable(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
((TwoStatePreference) preference).setChecked(
|
|
||||||
Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 0) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
final boolean val = (Boolean) newValue;
|
|
||||||
return Settings.System.putInt(mContext.getContentResolver(),
|
|
||||||
VIBRATE_WHEN_RINGING, val ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class SettingObserver extends ContentObserver {
|
private final class SettingObserver extends ContentObserver {
|
||||||
|
|
||||||
private final Uri VIBRATE_WHEN_RINGING_URI =
|
private final Uri VIBRATE_WHEN_RINGING_URI =
|
||||||
Settings.System.getUriFor(VIBRATE_WHEN_RINGING);
|
Settings.System.getUriFor(VIBRATE_WHEN_RINGING);
|
||||||
|
|
||||||
private final Preference mPreference;
|
private final Preference mPreference;
|
||||||
|
|
||||||
@@ -127,5 +116,4 @@ public class VibrateWhenRingPreferenceController extends AbstractPreferenceContr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,12 +20,14 @@ import android.app.Activity;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.NotificationManager.Policy;
|
import android.app.NotificationManager.Policy;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
@@ -39,13 +41,16 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
private static final String TAG = "ZenOnboardingActivity";
|
private static final String TAG = "ZenOnboardingActivity";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String PREF_KEY_SUGGGESTION_FIRST_DISPLAY_TIME =
|
static final String PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME =
|
||||||
"pref_zen_suggestion_first_display_time_ms";
|
"pref_zen_suggestion_first_display_time_ms";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String PREF_KEY_SUGGESTION_VIEWED = "pref_zen_suggestion_viewed";
|
|
||||||
@VisibleForTesting
|
|
||||||
static final long ALWAYS_SHOW_THRESHOLD = DateUtils.DAY_IN_MILLIS * 14;
|
static final long ALWAYS_SHOW_THRESHOLD = DateUtils.DAY_IN_MILLIS * 14;
|
||||||
|
|
||||||
|
View mNewSetting;
|
||||||
|
View mKeepCurrentSetting;
|
||||||
|
RadioButton mNewSettingButton;
|
||||||
|
RadioButton mKeepCurrentSettingButton;
|
||||||
|
|
||||||
private NotificationManager mNm;
|
private NotificationManager mNm;
|
||||||
private MetricsLogger mMetrics;
|
private MetricsLogger mMetrics;
|
||||||
|
|
||||||
@@ -66,6 +71,34 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
protected void setupUI() {
|
protected void setupUI() {
|
||||||
setContentView(R.layout.zen_onboarding);
|
setContentView(R.layout.zen_onboarding);
|
||||||
|
|
||||||
|
mNewSetting = findViewById(R.id.zen_onboarding_new_setting);
|
||||||
|
mKeepCurrentSetting = findViewById(R.id.zen_onboarding_current_setting);
|
||||||
|
mNewSettingButton = findViewById(R.id.zen_onboarding_new_setting_button);
|
||||||
|
mKeepCurrentSettingButton = findViewById(R.id.zen_onboarding_current_setting_button);
|
||||||
|
|
||||||
|
View.OnClickListener newSettingClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mKeepCurrentSettingButton.setChecked(false);
|
||||||
|
mNewSettingButton.setChecked(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
View.OnClickListener currentSettingClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mKeepCurrentSettingButton.setChecked(true);
|
||||||
|
mNewSettingButton.setChecked(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mNewSetting.setOnClickListener(newSettingClickListener);
|
||||||
|
mNewSettingButton.setOnClickListener(newSettingClickListener);
|
||||||
|
|
||||||
|
mKeepCurrentSetting.setOnClickListener(currentSettingClickListener);
|
||||||
|
mKeepCurrentSettingButton.setOnClickListener(currentSettingClickListener);
|
||||||
|
|
||||||
|
mKeepCurrentSettingButton.setChecked(true);
|
||||||
mMetrics.visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING);
|
mMetrics.visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,25 +112,27 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
mMetrics = ml;
|
mMetrics = ml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close(View button) {
|
public void launchSettings(View button) {
|
||||||
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
|
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_SETTINGS);
|
||||||
|
Intent settings = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
|
||||||
Settings.Global.putInt(getApplicationContext().getContentResolver(),
|
settings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
Settings.Global.ZEN_SETTINGS_UPDATED, 1);
|
startActivity(settings);
|
||||||
|
|
||||||
finishAndRemoveTask();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(View button) {
|
public void save(View button) {
|
||||||
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
|
||||||
NotificationManager.Policy policy = mNm.getNotificationPolicy();
|
NotificationManager.Policy policy = mNm.getNotificationPolicy();
|
||||||
|
|
||||||
NotificationManager.Policy newPolicy = new NotificationManager.Policy(
|
if (mNewSettingButton.isChecked()) {
|
||||||
Policy.PRIORITY_CATEGORY_REPEAT_CALLERS | policy.priorityCategories,
|
NotificationManager.Policy newPolicy = new NotificationManager.Policy(
|
||||||
Policy.PRIORITY_SENDERS_STARRED,
|
Policy.PRIORITY_CATEGORY_REPEAT_CALLERS | policy.priorityCategories,
|
||||||
policy.priorityMessageSenders,
|
Policy.PRIORITY_SENDERS_STARRED,
|
||||||
NotificationManager.Policy.getAllSuppressedVisualEffects());
|
policy.priorityMessageSenders,
|
||||||
mNm.setNotificationPolicy(newPolicy);
|
NotificationManager.Policy.getAllSuppressedVisualEffects());
|
||||||
|
mNm.setNotificationPolicy(newPolicy);
|
||||||
|
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
||||||
|
} else {
|
||||||
|
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
|
||||||
|
}
|
||||||
|
|
||||||
Settings.Global.putInt(getApplicationContext().getContentResolver(),
|
Settings.Global.putInt(getApplicationContext().getContentResolver(),
|
||||||
Settings.Global.ZEN_SETTINGS_UPDATED, 1);
|
Settings.Global.ZEN_SETTINGS_UPDATED, 1);
|
||||||
@@ -143,11 +178,11 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
final long currentTimeMs = System.currentTimeMillis();
|
final long currentTimeMs = System.currentTimeMillis();
|
||||||
final long firstDisplayTimeMs;
|
final long firstDisplayTimeMs;
|
||||||
|
|
||||||
if (!prefs.contains(PREF_KEY_SUGGGESTION_FIRST_DISPLAY_TIME)) {
|
if (!prefs.contains(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME)) {
|
||||||
firstDisplayTimeMs = currentTimeMs;
|
firstDisplayTimeMs = currentTimeMs;
|
||||||
prefs.edit().putLong(PREF_KEY_SUGGGESTION_FIRST_DISPLAY_TIME, currentTimeMs).commit();
|
prefs.edit().putLong(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME, currentTimeMs).commit();
|
||||||
} else {
|
} else {
|
||||||
firstDisplayTimeMs = prefs.getLong(PREF_KEY_SUGGGESTION_FIRST_DISPLAY_TIME, -1);
|
firstDisplayTimeMs = prefs.getLong(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
final long showTimeMs = firstDisplayTimeMs + ALWAYS_SHOW_THRESHOLD;
|
final long showTimeMs = firstDisplayTimeMs + ALWAYS_SHOW_THRESHOLD;
|
||||||
|
@@ -24,11 +24,11 @@ import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_
|
|||||||
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_KEY;
|
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_KEY;
|
||||||
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_PLATFORM_DEFINED;
|
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_PLATFORM_DEFINED;
|
||||||
|
|
||||||
|
import android.annotation.ColorInt;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.SettingsSlicesContract;
|
import android.provider.SettingsSlicesContract;
|
||||||
@@ -41,6 +41,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.SubSettings;
|
import com.android.settings.SubSettings;
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.SliderPreferenceController;
|
import com.android.settings.core.SliderPreferenceController;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
@@ -67,9 +68,6 @@ public class SliceBuilderUtils {
|
|||||||
|
|
||||||
private static final String TAG = "SliceBuilder";
|
private static final String TAG = "SliceBuilder";
|
||||||
|
|
||||||
// A Slice should not be store for longer than 60,000 milliseconds / 1 minute.
|
|
||||||
public static final long SLICE_TTL_MILLIS = 60000;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a Slice from {@link SliceData}.
|
* Build a Slice from {@link SliceData}.
|
||||||
*
|
*
|
||||||
@@ -190,7 +188,12 @@ public class SliceBuilderUtils {
|
|||||||
*/
|
*/
|
||||||
public static CharSequence getSubtitleText(Context context,
|
public static CharSequence getSubtitleText(Context context,
|
||||||
AbstractPreferenceController controller, SliceData sliceData) {
|
AbstractPreferenceController controller, SliceData sliceData) {
|
||||||
CharSequence summaryText;
|
CharSequence summaryText = sliceData.getScreenTitle();
|
||||||
|
if (isValidSummary(context, summaryText) && !TextUtils.equals(summaryText,
|
||||||
|
sliceData.getTitle())) {
|
||||||
|
return summaryText;
|
||||||
|
}
|
||||||
|
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
summaryText = controller.getSummary();
|
summaryText = controller.getSummary();
|
||||||
|
|
||||||
@@ -234,13 +237,15 @@ public class SliceBuilderUtils {
|
|||||||
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
|
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
|
||||||
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
||||||
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
|
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
|
||||||
|
@ColorInt final int color = Utils.getColorAccent(context);
|
||||||
final TogglePreferenceController toggleController =
|
final TogglePreferenceController toggleController =
|
||||||
(TogglePreferenceController) controller;
|
(TogglePreferenceController) controller;
|
||||||
final SliceAction sliceAction = getToggleAction(context, sliceData,
|
final SliceAction sliceAction = getToggleAction(context, sliceData,
|
||||||
toggleController.isChecked());
|
toggleController.isChecked());
|
||||||
final List<String> keywords = buildSliceKeywords(sliceData);
|
final List<String> keywords = buildSliceKeywords(sliceData);
|
||||||
|
|
||||||
return new ListBuilder(context, sliceData.getUri(), SLICE_TTL_MILLIS)
|
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
|
||||||
|
.setAccentColor(color)
|
||||||
.addRow(rowBuilder -> rowBuilder
|
.addRow(rowBuilder -> rowBuilder
|
||||||
.setTitle(sliceData.getTitle())
|
.setTitle(sliceData.getTitle())
|
||||||
.setSubtitle(subtitleText)
|
.setSubtitle(subtitleText)
|
||||||
@@ -256,9 +261,11 @@ public class SliceBuilderUtils {
|
|||||||
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
|
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
|
||||||
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
||||||
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
|
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
|
||||||
|
@ColorInt final int color = Utils.getColorAccent(context);
|
||||||
final List<String> keywords = buildSliceKeywords(sliceData);
|
final List<String> keywords = buildSliceKeywords(sliceData);
|
||||||
|
|
||||||
return new ListBuilder(context, sliceData.getUri(), SLICE_TTL_MILLIS)
|
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
|
||||||
|
.setAccentColor(color)
|
||||||
.addRow(rowBuilder -> rowBuilder
|
.addRow(rowBuilder -> rowBuilder
|
||||||
.setTitle(sliceData.getTitle())
|
.setTitle(sliceData.getTitle())
|
||||||
.setSubtitle(subtitleText)
|
.setSubtitle(subtitleText)
|
||||||
@@ -274,11 +281,13 @@ public class SliceBuilderUtils {
|
|||||||
final PendingIntent actionIntent = getSliderAction(context, sliceData);
|
final PendingIntent actionIntent = getSliderAction(context, sliceData);
|
||||||
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
|
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
|
||||||
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
||||||
|
@ColorInt final int color = Utils.getColorAccent(context);
|
||||||
final SliceAction primaryAction = new SliceAction(contentIntent, icon,
|
final SliceAction primaryAction = new SliceAction(contentIntent, icon,
|
||||||
sliceData.getTitle());
|
sliceData.getTitle());
|
||||||
final List<String> keywords = buildSliceKeywords(sliceData);
|
final List<String> keywords = buildSliceKeywords(sliceData);
|
||||||
|
|
||||||
return new ListBuilder(context, sliceData.getUri(), SLICE_TTL_MILLIS)
|
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
|
||||||
|
.setAccentColor(color)
|
||||||
.addInputRange(builder -> builder
|
.addInputRange(builder -> builder
|
||||||
.setTitle(sliceData.getTitle())
|
.setTitle(sliceData.getTitle())
|
||||||
.setMax(sliderController.getMaxSteps())
|
.setMax(sliderController.getMaxSteps())
|
||||||
@@ -346,6 +355,7 @@ public class SliceBuilderUtils {
|
|||||||
BasePreferenceController controller) {
|
BasePreferenceController controller) {
|
||||||
final String title = data.getTitle();
|
final String title = data.getTitle();
|
||||||
final List<String> keywords = buildSliceKeywords(data);
|
final List<String> keywords = buildSliceKeywords(data);
|
||||||
|
@ColorInt final int color = Utils.getColorAccent(context);
|
||||||
final String summary;
|
final String summary;
|
||||||
final SliceAction primaryAction;
|
final SliceAction primaryAction;
|
||||||
final IconCompat icon = IconCompat.createWithResource(context, data.getIconResource());
|
final IconCompat icon = IconCompat.createWithResource(context, data.getIconResource());
|
||||||
@@ -371,7 +381,8 @@ public class SliceBuilderUtils {
|
|||||||
primaryAction = new SliceAction(getSettingsIntent(context), icon, title);
|
primaryAction = new SliceAction(getSettingsIntent(context), icon, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ListBuilder(context, data.getUri(), SLICE_TTL_MILLIS)
|
return new ListBuilder(context, data.getUri(), ListBuilder.INFINITY)
|
||||||
|
.setAccentColor(color)
|
||||||
.addRow(builder -> builder
|
.addRow(builder -> builder
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setSubtitle(summary)
|
.setSubtitle(summary)
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings.widget;
|
|||||||
|
|
||||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent
|
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent
|
||||||
.ACTION_OPEN_APP_NOTIFICATION_SETTING;
|
.ACTION_OPEN_APP_NOTIFICATION_SETTING;
|
||||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_OPEN_APP_SETTING;
|
|
||||||
|
|
||||||
import android.annotation.IdRes;
|
import android.annotation.IdRes;
|
||||||
import android.annotation.UserIdInt;
|
import android.annotation.UserIdInt;
|
||||||
@@ -28,7 +27,6 @@ import android.app.Fragment;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -59,15 +57,13 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
public class EntityHeaderController {
|
public class EntityHeaderController {
|
||||||
|
|
||||||
@IntDef({ActionType.ACTION_NONE,
|
@IntDef({ActionType.ACTION_NONE,
|
||||||
ActionType.ACTION_APP_PREFERENCE,
|
|
||||||
ActionType.ACTION_NOTIF_PREFERENCE,
|
ActionType.ACTION_NOTIF_PREFERENCE,
|
||||||
ActionType.ACTION_DND_RULE_PREFERENCE,})
|
ActionType.ACTION_DND_RULE_PREFERENCE,})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface ActionType {
|
public @interface ActionType {
|
||||||
int ACTION_NONE = 0;
|
int ACTION_NONE = 0;
|
||||||
int ACTION_APP_PREFERENCE = 1;
|
int ACTION_NOTIF_PREFERENCE = 1;
|
||||||
int ACTION_NOTIF_PREFERENCE = 2;
|
int ACTION_DND_RULE_PREFERENCE = 2;
|
||||||
int ACTION_DND_RULE_PREFERENCE = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String PREF_KEY_APP_HEADER = "pref_app_header";
|
public static final String PREF_KEY_APP_HEADER = "pref_app_header";
|
||||||
@@ -298,9 +294,9 @@ public class EntityHeaderController {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AppInfoBase.startAppInfoFragment(
|
AppInfoBase.startAppInfoFragment(
|
||||||
AppInfoDashboardFragment.class, R.string.application_info_label,
|
AppInfoDashboardFragment.class, R.string.application_info_label,
|
||||||
mPackageName, mUid, mFragment, 0 /* request */,
|
mPackageName, mUid, mFragment, 0 /* request */,
|
||||||
mMetricsCategory);
|
mMetricsCategory);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -371,27 +367,6 @@ public class EntityHeaderController {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case ActionType.ACTION_APP_PREFERENCE: {
|
|
||||||
final Intent intent = resolveIntent(
|
|
||||||
new Intent(Intent.ACTION_APPLICATION_PREFERENCES).setPackage(mPackageName));
|
|
||||||
if (intent == null) {
|
|
||||||
button.setImageDrawable(null);
|
|
||||||
button.setVisibility(View.GONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
FeatureFactory.getFactory(mAppContext).getMetricsFeatureProvider()
|
|
||||||
.actionWithSource(mAppContext, mMetricsCategory,
|
|
||||||
ACTION_OPEN_APP_SETTING);
|
|
||||||
mFragment.startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
button.setImageResource(R.drawable.ic_settings_24dp);
|
|
||||||
button.setVisibility(View.VISIBLE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case ActionType.ACTION_NONE: {
|
case ActionType.ACTION_NONE: {
|
||||||
button.setVisibility(View.GONE);
|
button.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
@@ -399,14 +374,6 @@ public class EntityHeaderController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent resolveIntent(Intent i) {
|
|
||||||
ResolveInfo result = mAppContext.getPackageManager().resolveActivity(i, 0);
|
|
||||||
if (result != null) {
|
|
||||||
return new Intent(i.getAction())
|
|
||||||
.setClassName(result.activityInfo.packageName, result.activityInfo.name);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setText(@IdRes int id, CharSequence text) {
|
private void setText(@IdRes int id, CharSequence text) {
|
||||||
TextView textView = mHeader.findViewById(id);
|
TextView textView = mHeader.findViewById(id);
|
||||||
|
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
|
import static com.android.settings.accessibility.MagnificationPreferenceFragment.OFF;
|
||||||
|
import static com.android.settings.accessibility.MagnificationPreferenceFragment.ON;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -57,13 +60,13 @@ public class MagnificationGesturesPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateState_shouldRefreshSummary() {
|
public void updateState_shouldRefreshSummary() {
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 1);
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_on));
|
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_on));
|
||||||
|
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0);
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
|
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
|
||||||
@@ -77,4 +80,38 @@ public class MagnificationGesturesPreferenceControllerTest {
|
|||||||
.isEqualTo(mContext.getString(R.string.
|
.isEqualTo(mContext.getString(R.string.
|
||||||
accessibility_screen_magnification_short_summary));
|
accessibility_screen_magnification_short_summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isChecked_enabled() {
|
||||||
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isChecked_disabled() {
|
||||||
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_enabled() {
|
||||||
|
mController.setChecked(true);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, -1))
|
||||||
|
.isEqualTo(ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_disabled() {
|
||||||
|
mController.setChecked(false);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, -1))
|
||||||
|
.isEqualTo(OFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,12 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
|
import static com.android.settings.accessibility.MagnificationPreferenceFragment.OFF;
|
||||||
|
import static com.android.settings.accessibility.MagnificationPreferenceFragment.ON;
|
||||||
import static com.android.settings.search.ResultPayload.Availability.AVAILABLE;
|
import static com.android.settings.search.ResultPayload.Availability.AVAILABLE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -81,13 +85,13 @@ public class MagnificationNavbarPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateState_shouldRefreshSummary() {
|
public void updateState_shouldRefreshSummary() {
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 1);
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, ON);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_on));
|
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_on));
|
||||||
|
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0);
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, OFF);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
|
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
|
||||||
@@ -102,6 +106,40 @@ public class MagnificationNavbarPreferenceControllerTest {
|
|||||||
accessibility_screen_magnification_navbar_short_summary));
|
accessibility_screen_magnification_navbar_short_summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isChecked_enabled() {
|
||||||
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, ON);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isChecked_disabled() {
|
||||||
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, OFF);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_enabled() {
|
||||||
|
mController.setChecked(true);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, -1))
|
||||||
|
.isEqualTo(ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_disabled() {
|
||||||
|
mController.setChecked(false);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, -1))
|
||||||
|
.isEqualTo(OFF);
|
||||||
|
}
|
||||||
|
|
||||||
@Implements(MagnificationPreferenceFragment.class)
|
@Implements(MagnificationPreferenceFragment.class)
|
||||||
public static class ShadowMagnificationPreferenceFragment {
|
public static class ShadowMagnificationPreferenceFragment {
|
||||||
private static boolean sIsApplicable;
|
private static boolean sIsApplicable;
|
||||||
|
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.applications.appinfo;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.doNothing;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
import static org.robolectric.Shadows.shadowOf;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.shadows.ShadowPackageManager;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
public class AppSettingPreferenceControllerTest {
|
||||||
|
|
||||||
|
private static final String TEST_PKG_NAME = "test_pkg";
|
||||||
|
private static final String TEST_CLASS_NAME = "name";
|
||||||
|
private static final Intent TEST_INTENT =
|
||||||
|
new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
|
||||||
|
.setClassName(TEST_PKG_NAME, TEST_CLASS_NAME);
|
||||||
|
private static final Intent RESOLVED_INTENT =
|
||||||
|
new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
|
||||||
|
.setPackage(TEST_PKG_NAME);
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AppInfoDashboardFragment mParent;
|
||||||
|
private Application mApplication;
|
||||||
|
private ShadowPackageManager mPackageManager;
|
||||||
|
private AppSettingPreferenceController mController;
|
||||||
|
private Preference mPreference;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mApplication = RuntimeEnvironment.application;
|
||||||
|
mPackageManager = shadowOf(mApplication.getPackageManager());
|
||||||
|
mController = new AppSettingPreferenceController(mApplication, "test_key");
|
||||||
|
mController.setPackageName(TEST_PKG_NAME).setParentFragment(mParent);
|
||||||
|
mPreference = new Preference(mApplication);
|
||||||
|
mPreference.setKey(mController.getPreferenceKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_noAppSetting_shouldNotBeAvailable() {
|
||||||
|
assertThat(mController.isAvailable())
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_noPackageName_shouldNotBeAvailable() {
|
||||||
|
mController.setPackageName(null);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable())
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_hasAppSetting_shouldBeAvailable() {
|
||||||
|
final ResolveInfo info = new ResolveInfo();
|
||||||
|
info.activityInfo = new ActivityInfo();
|
||||||
|
info.activityInfo.packageName = TEST_PKG_NAME;
|
||||||
|
info.activityInfo.name = TEST_CLASS_NAME;
|
||||||
|
|
||||||
|
mPackageManager.addResolveInfoForIntent(RESOLVED_INTENT, info);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable())
|
||||||
|
.isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void clickPreference_noAppSetting_shouldDoNothing() {
|
||||||
|
assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void clickPreference_hasAppSetting_shouldLaunchIntent() {
|
||||||
|
final ResolveInfo info = new ResolveInfo();
|
||||||
|
info.activityInfo = new ActivityInfo();
|
||||||
|
info.activityInfo.packageName = TEST_PKG_NAME;
|
||||||
|
info.activityInfo.name = TEST_CLASS_NAME;
|
||||||
|
|
||||||
|
mPackageManager.addResolveInfoForIntent(RESOLVED_INTENT, info);
|
||||||
|
|
||||||
|
assertThat(mController.handlePreferenceTreeClick(mPreference)).isTrue();
|
||||||
|
assertThat(shadowOf(mApplication).getNextStartedActivity().getComponent())
|
||||||
|
.isEqualTo(TEST_INTENT.getComponent());
|
||||||
|
}
|
||||||
|
}
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.fuelgauge;
|
package com.android.settings.fuelgauge;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -29,6 +30,7 @@ import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Answers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ public class PowerUsageFeatureProviderImplTest {
|
|||||||
private static final String[] PACKAGES_MEDIA = {"com.android.providers.media"};
|
private static final String[] PACKAGES_MEDIA = {"com.android.providers.media"};
|
||||||
private static final String[] PACKAGES_SYSTEMUI = {"com.android.systemui"};
|
private static final String[] PACKAGES_SYSTEMUI = {"com.android.systemui"};
|
||||||
|
|
||||||
@Mock
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@Mock
|
@Mock
|
||||||
private BatterySipper mBatterySipper;
|
private BatterySipper mBatterySipper;
|
||||||
@@ -55,6 +57,7 @@ public class PowerUsageFeatureProviderImplTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||||
mPowerFeatureProvider = new PowerUsageFeatureProviderImpl(mContext);
|
mPowerFeatureProvider = new PowerUsageFeatureProviderImpl(mContext);
|
||||||
when(mPackageManager.getPackagesForUid(UID_CALENDAR)).thenReturn(PACKAGES_CALENDAR);
|
when(mPackageManager.getPackagesForUid(UID_CALENDAR)).thenReturn(PACKAGES_CALENDAR);
|
||||||
when(mPackageManager.getPackagesForUid(UID_MEDIA)).thenReturn(PACKAGES_MEDIA);
|
when(mPackageManager.getPackagesForUid(UID_MEDIA)).thenReturn(PACKAGES_MEDIA);
|
||||||
@@ -138,7 +141,18 @@ public class PowerUsageFeatureProviderImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsSmartBatterySupported_returnFalse() {
|
public void testIsSmartBatterySupported_smartBatterySupported_returnTrue() {
|
||||||
|
when(mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_smart_battery_available)).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mPowerFeatureProvider.isSmartBatterySupported()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsSmartBatterySupported_smartBatteryNotSupported_returnFalse() {
|
||||||
|
when(mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_smart_battery_available)).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mPowerFeatureProvider.isSmartBatterySupported()).isFalse();
|
assertThat(mPowerFeatureProvider.isSmartBatterySupported()).isFalse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ import android.content.pm.ResolveInfo;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.internal.R;
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
|
|
||||||
@@ -57,8 +57,7 @@ public class SwipeUpPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
||||||
true);
|
true);
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, true);
|
||||||
com.android.internal.R.bool.config_swipe_up_gesture_default, true);
|
|
||||||
|
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
||||||
@@ -107,8 +106,7 @@ public class SwipeUpPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_defaultIsFalse_shouldReturnFalse() {
|
public void testIsChecked_defaultIsFalse_shouldReturnFalse() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, false);
|
||||||
com.android.internal.R.bool.config_swipe_up_gesture_default, false);
|
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,10 +75,21 @@ public class TetherPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lifeCycle_onCreate_shouldInitBluetoothPan() {
|
public void lifeCycle_onCreate_shouldInitBluetoothPan() {
|
||||||
|
when(mBluetoothAdapter.getState()).thenReturn(BluetoothAdapter.STATE_ON);
|
||||||
mController.onCreate(null);
|
mController.onCreate(null);
|
||||||
|
|
||||||
verify(mBluetoothAdapter)
|
verify(mBluetoothAdapter).getState();
|
||||||
.getProfileProxy(mContext, mController.mBtProfileServiceListener, BluetoothProfile.PAN);
|
verify(mBluetoothAdapter).getProfileProxy(mContext, mController.mBtProfileServiceListener,
|
||||||
|
BluetoothProfile.PAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void lifeCycle_onCreate_shouldNotInitBluetoothPanWhenBluetoothOff() {
|
||||||
|
when(mBluetoothAdapter.getState()).thenReturn(BluetoothAdapter.STATE_OFF);
|
||||||
|
mController.onCreate(null);
|
||||||
|
|
||||||
|
verify(mBluetoothAdapter).getState();
|
||||||
|
verifyNoMoreInteractions(mBluetoothAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -17,11 +17,17 @@
|
|||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
|
import static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
@@ -37,26 +43,32 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.shadow.api.Shadow;
|
||||||
|
import org.robolectric.shadows.ShadowContentResolver;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
public class VibrateWhenRingPreferenceControllerTest {
|
public class VibrateWhenRingPreferenceControllerTest {
|
||||||
|
|
||||||
@Mock
|
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
||||||
|
private final int DEFAULT_VALUE = 0;
|
||||||
|
private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private ContentResolver mContentResolver;
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
|
|
||||||
private VibrateWhenRingPreferenceController mController;
|
private VibrateWhenRingPreferenceController mController;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
mContentResolver = mContext.getContentResolver();
|
||||||
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
||||||
mController = new VibrateWhenRingPreferenceController(mContext);
|
mController = new VibrateWhenRingPreferenceController(mContext, KEY_VIBRATE_WHEN_RINGING);
|
||||||
mPreference = new Preference(RuntimeEnvironment.application);
|
mPreference = new Preference(mContext);
|
||||||
mPreference.setKey(mController.getPreferenceKey());
|
mPreference.setKey(mController.getPreferenceKey());
|
||||||
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
@@ -79,27 +91,96 @@ public class VibrateWhenRingPreferenceControllerTest {
|
|||||||
assertThat(mPreference.isVisible()).isFalse();
|
assertThat(mPreference.isVisible()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnPreferenceChange_turnOn_returnOn() {
|
||||||
|
mController.onPreferenceChange(null, true);
|
||||||
|
final int mode = Settings.System.getInt(mContext.getContentResolver(),
|
||||||
|
VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
|
||||||
|
|
||||||
|
assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnPreferenceChange_turnOff_returnOff() {
|
||||||
|
mController.onPreferenceChange(null, false);
|
||||||
|
final int mode = Settings.System.getInt(mContext.getContentResolver(),
|
||||||
|
VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
|
||||||
|
|
||||||
|
assertThat(mode).isEqualTo(DEFAULT_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void voiceCapable_availabled() {
|
||||||
|
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void voiceCapable_notAvailabled() {
|
||||||
|
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingIsOn_preferenceShouldBeChecked() {
|
public void updateState_settingIsOn_preferenceShouldBeChecked() {
|
||||||
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
||||||
final Context context = RuntimeEnvironment.application;
|
Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 1);
|
||||||
Settings.System.putInt(context.getContentResolver(), VIBRATE_WHEN_RINGING, 1);
|
|
||||||
|
|
||||||
mController = new VibrateWhenRingPreferenceController(context);
|
|
||||||
mController.updateState(preference);
|
mController.updateState(preference);
|
||||||
|
|
||||||
verify(preference).setChecked(true);
|
assertThat(mController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
|
public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
|
||||||
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
||||||
final Context context = RuntimeEnvironment.application;
|
Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
|
||||||
Settings.System.putInt(context.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
|
|
||||||
|
|
||||||
mController = new VibrateWhenRingPreferenceController(context);
|
|
||||||
mController.updateState(preference);
|
mController.updateState(preference);
|
||||||
|
|
||||||
verify(preference).setChecked(false);
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_settingsIsOn() {
|
||||||
|
mController.setChecked(true);
|
||||||
|
final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setChecked_settingsIsOff() {
|
||||||
|
mController.setChecked(false);
|
||||||
|
final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
assertThat(mode).isEqualTo(DEFAULT_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testObserver_onResume_shouldRegisterObserver() {
|
||||||
|
final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
mController.onResume();
|
||||||
|
|
||||||
|
assertThat(shadowContentResolver.getContentObservers(
|
||||||
|
Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testObserver_onPause_shouldUnregisterObserver() {
|
||||||
|
final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
mController.onResume();
|
||||||
|
mController.onPause();
|
||||||
|
|
||||||
|
assertThat(shadowContentResolver.getContentObservers(
|
||||||
|
Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,21 +18,11 @@ package com.android.settings.notification;
|
|||||||
|
|
||||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS;
|
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS;
|
||||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS;
|
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS;
|
||||||
import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF;
|
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
|
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
|
||||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR;
|
|
||||||
|
|
||||||
import static com.android.settings.notification.ZenOnboardingActivity.ALWAYS_SHOW_THRESHOLD;
|
import static com.android.settings.notification.ZenOnboardingActivity.ALWAYS_SHOW_THRESHOLD;
|
||||||
import static com.android.settings.notification.ZenOnboardingActivity.PREF_KEY_SUGGESTION_VIEWED;
|
|
||||||
import static com.android.settings.notification.ZenOnboardingActivity
|
import static com.android.settings.notification.ZenOnboardingActivity
|
||||||
.PREF_KEY_SUGGGESTION_FIRST_DISPLAY_TIME;
|
.PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME;
|
||||||
import static com.android.settings.notification.ZenOnboardingActivity.isSuggestionComplete;
|
import static com.android.settings.notification.ZenOnboardingActivity.isSuggestionComplete;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@@ -99,10 +89,11 @@ public class ZenOnboardingActivityTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void save() {
|
public void saveNewSetting() {
|
||||||
Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON);
|
Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON);
|
||||||
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
||||||
|
|
||||||
|
mActivity.mNewSetting.performClick();
|
||||||
mActivity.save(null);
|
mActivity.save(null);
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
||||||
@@ -120,24 +111,14 @@ public class ZenOnboardingActivityTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void close() {
|
public void keepCurrentSetting() {
|
||||||
Policy policy = new Policy(
|
Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON);
|
||||||
PRIORITY_CATEGORY_ALARMS, PRIORITY_SENDERS_ANY, 0,
|
|
||||||
SUPPRESSED_EFFECT_SCREEN_ON
|
|
||||||
| SUPPRESSED_EFFECT_SCREEN_OFF
|
|
||||||
| SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
|
|
||||||
| SUPPRESSED_EFFECT_LIGHTS
|
|
||||||
| SUPPRESSED_EFFECT_PEEK
|
|
||||||
| SUPPRESSED_EFFECT_STATUS_BAR
|
|
||||||
| SUPPRESSED_EFFECT_BADGE
|
|
||||||
| SUPPRESSED_EFFECT_AMBIENT
|
|
||||||
| SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
|
||||||
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
||||||
|
|
||||||
mActivity.close(null);
|
mActivity.mKeepCurrentSetting.performClick();
|
||||||
|
mActivity.save(null);
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
|
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
|
||||||
|
|
||||||
verify(mNm, never()).setNotificationPolicy(any());
|
verify(mNm, never()).setNotificationPolicy(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +173,7 @@ public class ZenOnboardingActivityTest {
|
|||||||
firstTime -= ALWAYS_SHOW_THRESHOLD * 2;
|
firstTime -= ALWAYS_SHOW_THRESHOLD * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSharedPreferences().edit().putLong(PREF_KEY_SUGGGESTION_FIRST_DISPLAY_TIME,
|
getSharedPreferences().edit().putLong(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME,
|
||||||
firstTime).commit();
|
firstTime).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -204,18 +204,18 @@ public class SliceBuilderUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDynamicSummary_returnsSliceSummary() {
|
public void getDynamicSummary_returnsScreenTitle() {
|
||||||
final SliceData data = getDummyData();
|
final SliceData data = getDummyData();
|
||||||
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
||||||
|
|
||||||
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
assertThat(summary).isEqualTo(data.getSummary());
|
assertThat(summary).isEqualTo(data.getScreenTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDynamicSummary_returnsFragmentSummary() {
|
public void getDynamicSummary_noScreenTitle_returnsPrefControllerSummary() {
|
||||||
final SliceData data = getDummyData(null);
|
final SliceData data = getDummyData("", "");
|
||||||
final FakePreferenceController controller = spy(
|
final FakePreferenceController controller = spy(
|
||||||
new FakePreferenceController(mContext, KEY));
|
new FakePreferenceController(mContext, KEY));
|
||||||
final String controllerSummary = "new_Summary";
|
final String controllerSummary = "new_Summary";
|
||||||
@@ -227,8 +227,21 @@ public class SliceBuilderUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDynamicSummary_returnsSliceEmptyString() {
|
public void getDynamicSummary_screenTitleMatchesTitle_returnsPrefControllerSummary() {
|
||||||
final SliceData data = getDummyData(null);
|
final SliceData data = getDummyData("", TITLE);
|
||||||
|
final FakePreferenceController controller = spy(
|
||||||
|
new FakePreferenceController(mContext, KEY));
|
||||||
|
final String controllerSummary = "new_Summary";
|
||||||
|
doReturn(controllerSummary).when(controller).getSummary();
|
||||||
|
|
||||||
|
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
|
assertThat(summary).isEqualTo(controllerSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDynamicSummary_emptyScreenTitle_emptyControllerSummary_returnsEmptyString() {
|
||||||
|
final SliceData data = getDummyData(null, null);
|
||||||
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
||||||
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
@@ -236,8 +249,9 @@ public class SliceBuilderUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDynamicSummary_placeHolderString_returnsEmptyString() {
|
public void
|
||||||
final SliceData data = getDummyData(mContext.getString(R.string.summary_placeholder));
|
getDynamicSummary_emptyScreenTitle_placeHolderControllerSummary_returnsEmptyString() {
|
||||||
|
final SliceData data = getDummyData(mContext.getString(R.string.summary_placeholder), null);
|
||||||
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
||||||
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
@@ -245,9 +259,9 @@ public class SliceBuilderUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDynamicSummary_sliceDataAndFragmentPlaceholder_returnsSliceEmptyString() {
|
public void getDynamicSummary_screenTitleAndControllerPlaceholder_returnsSliceEmptyString() {
|
||||||
final String summaryPlaceholder = mContext.getString(R.string.summary_placeholder);
|
final String summaryPlaceholder = mContext.getString(R.string.summary_placeholder);
|
||||||
final SliceData data = getDummyData(summaryPlaceholder);
|
final SliceData data = getDummyData(summaryPlaceholder, summaryPlaceholder);
|
||||||
final FakePreferenceController controller = spy(
|
final FakePreferenceController controller = spy(
|
||||||
new FakePreferenceController(mContext, KEY));
|
new FakePreferenceController(mContext, KEY));
|
||||||
doReturn(summaryPlaceholder).when(controller).getSummary();
|
doReturn(summaryPlaceholder).when(controller).getSummary();
|
||||||
@@ -257,18 +271,6 @@ public class SliceBuilderUtilsTest {
|
|||||||
assertThat(summary).isEqualTo("");
|
assertThat(summary).isEqualTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void summaryText_bothDynamicAndStaticSummary_dynamicSummaryReturned() {
|
|
||||||
SliceData data = getDummyData("bad_summary");
|
|
||||||
FakePreferenceController controller = spy(new FakePreferenceController(mContext, KEY));
|
|
||||||
String controllerSummary = "new_Summary";
|
|
||||||
doReturn(controllerSummary).when(controller).getSummary();
|
|
||||||
|
|
||||||
CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
|
||||||
|
|
||||||
assertThat(summary).isEqualTo(controllerSummary);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPathData_splitsIntentUri() {
|
public void getPathData_splitsIntentUri() {
|
||||||
final Uri uri = new Uri.Builder()
|
final Uri uri = new Uri.Builder()
|
||||||
@@ -417,23 +419,24 @@ public class SliceBuilderUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SliceData getDummyData() {
|
private SliceData getDummyData() {
|
||||||
return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH);
|
return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SliceData getDummyData(String summary) {
|
private SliceData getDummyData(String summary, String screenTitle) {
|
||||||
return getDummyData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH);
|
return getDummyData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH, screenTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SliceData getDummyData(Class prefController, int sliceType) {
|
private SliceData getDummyData(Class prefController, int sliceType) {
|
||||||
return getDummyData(prefController, SUMMARY, sliceType);
|
return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SliceData getDummyData(Class prefController, String summary, int sliceType) {
|
private SliceData getDummyData(Class prefController, String summary, int sliceType,
|
||||||
|
String screenTitle) {
|
||||||
return new SliceData.Builder()
|
return new SliceData.Builder()
|
||||||
.setKey(KEY)
|
.setKey(KEY)
|
||||||
.setTitle(TITLE)
|
.setTitle(TITLE)
|
||||||
.setSummary(summary)
|
.setSummary(summary)
|
||||||
.setScreenTitle(SCREEN_TITLE)
|
.setScreenTitle(screenTitle)
|
||||||
.setKeywords(KEYWORDS)
|
.setKeywords(KEYWORDS)
|
||||||
.setIcon(ICON)
|
.setIcon(ICON)
|
||||||
.setFragmentName(FRAGMENT_NAME)
|
.setFragmentName(FRAGMENT_NAME)
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
package com.android.settings.testutils;
|
package com.android.settings.testutils;
|
||||||
|
|
||||||
import static android.app.slice.Slice.HINT_TITLE;
|
import static android.app.slice.Slice.HINT_TITLE;
|
||||||
|
import static android.app.slice.Slice.SUBTYPE_COLOR;
|
||||||
|
import static android.app.slice.SliceItem.FORMAT_INT;
|
||||||
import static android.app.slice.SliceItem.FORMAT_TEXT;
|
import static android.app.slice.SliceItem.FORMAT_TEXT;
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||||
@@ -37,11 +39,13 @@ import java.util.Set;
|
|||||||
import androidx.slice.Slice;
|
import androidx.slice.Slice;
|
||||||
import androidx.slice.SliceItem;
|
import androidx.slice.SliceItem;
|
||||||
import androidx.slice.SliceMetadata;
|
import androidx.slice.SliceMetadata;
|
||||||
|
import androidx.slice.builders.ListBuilder;
|
||||||
import androidx.slice.core.SliceAction;
|
import androidx.slice.core.SliceAction;
|
||||||
import androidx.slice.core.SliceQuery;
|
import androidx.slice.core.SliceQuery;
|
||||||
|
|
||||||
import android.support.v4.graphics.drawable.IconCompat;
|
import android.support.v4.graphics.drawable.IconCompat;
|
||||||
|
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.slices.SettingsSliceProvider;
|
import com.android.settings.slices.SettingsSliceProvider;
|
||||||
import com.android.settings.slices.SliceBuilderUtils;
|
import com.android.settings.slices.SliceBuilderUtils;
|
||||||
import com.android.settings.slices.SliceData;
|
import com.android.settings.slices.SliceData;
|
||||||
@@ -59,10 +63,19 @@ public class SliceTester {
|
|||||||
* - Correct intent
|
* - Correct intent
|
||||||
* - Correct title
|
* - Correct title
|
||||||
* - Correct keywords
|
* - Correct keywords
|
||||||
|
* - TTL
|
||||||
|
* - Color
|
||||||
*/
|
*/
|
||||||
public static void testSettingsIntentSlice(Context context, Slice slice, SliceData sliceData) {
|
public static void testSettingsIntentSlice(Context context, Slice slice, SliceData sliceData) {
|
||||||
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
||||||
|
|
||||||
|
final long sliceTTL = metadata.getExpiry();
|
||||||
|
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
|
||||||
|
|
||||||
|
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
|
||||||
|
final int color = colorItem.getInt();
|
||||||
|
assertThat(color).isEqualTo(Utils.getColorAccent(context));
|
||||||
|
|
||||||
final List<SliceAction> toggles = metadata.getToggles();
|
final List<SliceAction> toggles = metadata.getToggles();
|
||||||
assertThat(toggles).isEmpty();
|
assertThat(toggles).isEmpty();
|
||||||
|
|
||||||
@@ -83,13 +96,22 @@ public class SliceTester {
|
|||||||
* - Correct content intent
|
* - Correct content intent
|
||||||
* - Correct title
|
* - Correct title
|
||||||
* - Correct keywords
|
* - Correct keywords
|
||||||
|
* - TTL
|
||||||
|
* - Color
|
||||||
*/
|
*/
|
||||||
public static void testSettingsToggleSlice(Context context, Slice slice, SliceData sliceData) {
|
public static void testSettingsToggleSlice(Context context, Slice slice, SliceData sliceData) {
|
||||||
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
||||||
|
|
||||||
|
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
|
||||||
|
final int color = colorItem.getInt();
|
||||||
|
assertThat(color).isEqualTo(Utils.getColorAccent(context));
|
||||||
|
|
||||||
final List<SliceAction> toggles = metadata.getToggles();
|
final List<SliceAction> toggles = metadata.getToggles();
|
||||||
assertThat(toggles).hasSize(1);
|
assertThat(toggles).hasSize(1);
|
||||||
|
|
||||||
|
final long sliceTTL = metadata.getExpiry();
|
||||||
|
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
|
||||||
|
|
||||||
final SliceAction mainToggleAction = toggles.get(0);
|
final SliceAction mainToggleAction = toggles.get(0);
|
||||||
|
|
||||||
final IconCompat expectedToggleIcon = IconCompat.createWithResource(context,
|
final IconCompat expectedToggleIcon = IconCompat.createWithResource(context,
|
||||||
@@ -117,13 +139,22 @@ public class SliceTester {
|
|||||||
* - No intent
|
* - No intent
|
||||||
* - Correct title
|
* - Correct title
|
||||||
* - Correct keywords
|
* - Correct keywords
|
||||||
|
* - TTL
|
||||||
|
* - Color
|
||||||
*/
|
*/
|
||||||
public static void testSettingsSliderSlice(Context context, Slice slice, SliceData sliceData) {
|
public static void testSettingsSliderSlice(Context context, Slice slice, SliceData sliceData) {
|
||||||
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
||||||
|
|
||||||
|
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
|
||||||
|
final int color = colorItem.getInt();
|
||||||
|
assertThat(color).isEqualTo(Utils.getColorAccent(context));
|
||||||
|
|
||||||
final IconCompat expectedToggleIcon = IconCompat.createWithResource(context,
|
final IconCompat expectedToggleIcon = IconCompat.createWithResource(context,
|
||||||
sliceData.getIconResource());
|
sliceData.getIconResource());
|
||||||
|
|
||||||
|
final long sliceTTL = metadata.getExpiry();
|
||||||
|
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
|
||||||
|
|
||||||
// Check primary intent
|
// Check primary intent
|
||||||
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
|
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
|
||||||
assertThat(primaryPendingIntent).isEqualTo(
|
assertThat(primaryPendingIntent).isEqualTo(
|
||||||
@@ -141,11 +172,20 @@ public class SliceTester {
|
|||||||
* - Correct title
|
* - Correct title
|
||||||
* - Correct intent
|
* - Correct intent
|
||||||
* - Correct keywords
|
* - Correct keywords
|
||||||
|
* - Color
|
||||||
|
* - TTL
|
||||||
*/
|
*/
|
||||||
public static void testSettingsUnavailableSlice(Context context, Slice slice,
|
public static void testSettingsUnavailableSlice(Context context, Slice slice,
|
||||||
SliceData sliceData) {
|
SliceData sliceData) {
|
||||||
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
final SliceMetadata metadata = SliceMetadata.from(context, slice);
|
||||||
|
|
||||||
|
final long sliceTTL = metadata.getExpiry();
|
||||||
|
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
|
||||||
|
|
||||||
|
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
|
||||||
|
final int color = colorItem.getInt();
|
||||||
|
assertThat(color).isEqualTo(Utils.getColorAccent(context));
|
||||||
|
|
||||||
final List<SliceAction> toggles = metadata.getToggles();
|
final List<SliceAction> toggles = metadata.getToggles();
|
||||||
assertThat(toggles).isEmpty();
|
assertThat(toggles).isEmpty();
|
||||||
|
|
||||||
|
@@ -41,7 +41,6 @@ import android.view.View;
|
|||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.applications.LayoutPreference;
|
import com.android.settings.applications.LayoutPreference;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
@@ -113,7 +112,7 @@ public class EntityHeaderControllerTest {
|
|||||||
public void bindViews_shouldBindAllData() {
|
public void bindViews_shouldBindAllData() {
|
||||||
final String testString = "test";
|
final String testString = "test";
|
||||||
final View header =
|
final View header =
|
||||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||||
final TextView label = header.findViewById(R.id.entity_header_title);
|
final TextView label = header.findViewById(R.id.entity_header_title);
|
||||||
final TextView summary = header.findViewById(R.id.entity_header_summary);
|
final TextView summary = header.findViewById(R.id.entity_header_summary);
|
||||||
final TextView secondSummary = header.findViewById(R.id.entity_header_second_summary);
|
final TextView secondSummary = header.findViewById(R.id.entity_header_second_summary);
|
||||||
@@ -133,41 +132,6 @@ public class EntityHeaderControllerTest {
|
|||||||
assertThat(secondSummary.getText()).isEqualTo(testString);
|
assertThat(secondSummary.getText()).isEqualTo(testString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void bindButton_hasAppPref_shouldShowButton() {
|
|
||||||
final ResolveInfo info = new ResolveInfo();
|
|
||||||
info.activityInfo = new ActivityInfo();
|
|
||||||
info.activityInfo.packageName = "123";
|
|
||||||
info.activityInfo.name = "321";
|
|
||||||
final View appLinks =
|
|
||||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
|
||||||
when(mActivity.getApplicationContext()).thenReturn(mContext);
|
|
||||||
when(mContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
|
|
||||||
.thenReturn(info);
|
|
||||||
|
|
||||||
mController = EntityHeaderController.newInstance(mActivity, mFragment, appLinks);
|
|
||||||
mController.setButtonActions(
|
|
||||||
EntityHeaderController.ActionType.ACTION_APP_PREFERENCE,
|
|
||||||
EntityHeaderController.ActionType.ACTION_NONE);
|
|
||||||
mController.done(mActivity);
|
|
||||||
|
|
||||||
final ImageButton button1 = appLinks.findViewById(android.R.id.button1);
|
|
||||||
assertThat(button1).isNotNull();
|
|
||||||
assertThat(button1.getVisibility()).isEqualTo(View.VISIBLE);
|
|
||||||
assertThat(button1.getDrawable()).isNotNull();
|
|
||||||
assertThat(appLinks.findViewById(android.R.id.button2).getVisibility())
|
|
||||||
.isEqualTo(View.GONE);
|
|
||||||
try {
|
|
||||||
appLinks.findViewById(android.R.id.button1).performClick();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Ignore exception because the launching intent is fake.
|
|
||||||
}
|
|
||||||
verify(mFeatureFactory.metricsFeatureProvider).actionWithSource(mContext,
|
|
||||||
MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
|
||||||
MetricsProto.MetricsEvent.ACTION_OPEN_APP_SETTING);
|
|
||||||
verify(mFragment).startActivity(any(Intent.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindButton_hasEditRuleNameClickListener_shouldShowButton() {
|
public void bindButton_hasEditRuleNameClickListener_shouldShowButton() {
|
||||||
final ResolveInfo info = new ResolveInfo();
|
final ResolveInfo info = new ResolveInfo();
|
||||||
@@ -216,31 +180,10 @@ public class EntityHeaderControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void bindButton_noAppPref_shouldNotShowButton() {
|
|
||||||
final View appLinks =
|
|
||||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
|
||||||
when(mContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
|
|
||||||
.thenReturn(null);
|
|
||||||
|
|
||||||
mController = EntityHeaderController.newInstance(mActivity, mFragment, appLinks);
|
|
||||||
mController.setButtonActions(
|
|
||||||
EntityHeaderController.ActionType.ACTION_APP_PREFERENCE,
|
|
||||||
EntityHeaderController.ActionType.ACTION_NONE);
|
|
||||||
mController.done(mActivity);
|
|
||||||
|
|
||||||
final ImageButton button1 = appLinks.findViewById(android.R.id.button1);
|
|
||||||
assertThat(button1).isNotNull();
|
|
||||||
assertThat(button1.getVisibility()).isEqualTo(View.GONE);
|
|
||||||
assertThat(button1.getDrawable()).isNull();
|
|
||||||
assertThat(appLinks.findViewById(android.R.id.button2).getVisibility())
|
|
||||||
.isEqualTo(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindButton_noAppInfo_shouldNotAttachClickListener() {
|
public void bindButton_noAppInfo_shouldNotAttachClickListener() {
|
||||||
final View appLinks =
|
final View appLinks =
|
||||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||||
final Activity activity = mock(Activity.class);
|
final Activity activity = mock(Activity.class);
|
||||||
when(mFragment.getActivity()).thenReturn(activity);
|
when(mFragment.getActivity()).thenReturn(activity);
|
||||||
|
|
||||||
@@ -265,7 +208,7 @@ public class EntityHeaderControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void bindButton_hasAppInfo_shouldAttachClickListener() {
|
public void bindButton_hasAppInfo_shouldAttachClickListener() {
|
||||||
final View appLinks =
|
final View appLinks =
|
||||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||||
final Activity activity = mock(Activity.class);
|
final Activity activity = mock(Activity.class);
|
||||||
when(mFragment.getActivity()).thenReturn(activity);
|
when(mFragment.getActivity()).thenReturn(activity);
|
||||||
when(mContext.getString(eq(R.string.application_info_label))).thenReturn("App Info");
|
when(mContext.getString(eq(R.string.application_info_label))).thenReturn("App Info");
|
||||||
@@ -281,13 +224,13 @@ public class EntityHeaderControllerTest {
|
|||||||
|
|
||||||
appLinks.findViewById(R.id.entity_header_content).performClick();
|
appLinks.findViewById(R.id.entity_header_content).performClick();
|
||||||
verify(activity)
|
verify(activity)
|
||||||
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
|
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void iconContentDescription_shouldWorkWithSetIcon() {
|
public void iconContentDescription_shouldWorkWithSetIcon() {
|
||||||
final View view =
|
final View view =
|
||||||
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
mLayoutInflater.inflate(R.layout.settings_entity_header, null /* root */);
|
||||||
when(mFragment.getActivity()).thenReturn(mock(Activity.class));
|
when(mFragment.getActivity()).thenReturn(mock(Activity.class));
|
||||||
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
|
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
|
||||||
String description = "Fake Description";
|
String description = "Fake Description";
|
||||||
|
Reference in New Issue
Block a user