Merge "Import translations. DO NOT MERGE"
diff --git a/res/layout/preference_category_material_settings.xml b/res/layout/preference_category_material_settings.xml
index 2a25bbc..233f54a 100644
--- a/res/layout/preference_category_material_settings.xml
+++ b/res/layout/preference_category_material_settings.xml
@@ -40,13 +40,26 @@
android:maxHeight="18dp"/>
</LinearLayout>
- <TextView
- android:id="@android:id/title"
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"
- android:textColor="?android:attr/textColorPrimary"
android:paddingStart="60dp"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"/>
+ android:orientation="vertical">
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textColor="?android:attr/textColorPrimary"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"/>
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary"
+ android:ellipsize="end"
+ android:singleLine="true" />
+ </LinearLayout>
</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/restricted_preference_dropdown.xml b/res/layout/restricted_preference_dropdown.xml
index 1a1e191..fd0d07d 100644
--- a/res/layout/restricted_preference_dropdown.xml
+++ b/res/layout/restricted_preference_dropdown.xml
@@ -25,6 +25,6 @@
android:layout_height="wrap_content"
android:visibility="invisible" />
- <include layout="@layout/preference_material" />
+ <include layout="@layout/preference_material_settings" />
</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/search_inline_switch_item.xml b/res/layout/search_inline_switch_item.xml
new file mode 100644
index 0000000..998c09c
--- /dev/null
+++ b/res/layout/search_inline_switch_item.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:background="?android:attr/selectableItemBackground"
+ android:clipToPadding="false">
+
+ <LinearLayout
+ android:id="@+id/icon_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="60dp"
+ android:gravity="start|center_vertical"
+ android:orientation="horizontal"
+ android:paddingEnd="12dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp">
+ <com.android.internal.widget.PreferenceImageView
+ android:id="@android:id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:maxWidth="48dp"
+ android:maxHeight="48dp"/>
+ </LinearLayout>
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp">
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceListItem"
+ android:ellipsize="marquee"/>
+
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_alignStart="@android:id/title"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLength="60"
+ android:maxLines="10"/>
+
+ </RelativeLayout>
+
+ <Switch
+ android:id="@+id/switchView"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="end|center_vertical"
+ android:paddingStart="16dp"
+ android:orientation="vertical"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/search_intent_item.xml b/res/layout/search_intent_item.xml
index b68f65b..fcb5532 100644
--- a/res/layout/search_intent_item.xml
+++ b/res/layout/search_intent_item.xml
@@ -14,50 +14,59 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:paddingEnd="?android:attr/scrollbarSize"
- android:orientation="horizontal">
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:background="?android:attr/selectableItemBackground"
+ android:clipToPadding="false">
<LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:gravity="center"
- android:orientation="horizontal">
-
- <ImageView
- android:id="@+id/icon"
- android:layout_width="@dimen/search_result_item_image_size"
- android:layout_height="@dimen/search_result_item_image_size"
- android:layout_marginStart="@dimen/search_result_item_image_margin_start"
- android:layout_marginEnd="@dimen/search_result_item_image_margin_end"
- android:scaleType="centerInside"/>
- </LinearLayout>
-
- <LinearLayout
+ android:id="@+id/icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingTop="10dp"
- android:orientation="vertical">
-
- <TextView android:id="@+id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
-
- <TextView android:id="@+id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
-
+ android:minWidth="60dp"
+ android:gravity="start|center_vertical"
+ android:orientation="horizontal"
+ android:paddingEnd="12dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp">
+ <com.android.internal.widget.PreferenceImageView
+ android:id="@android:id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:maxWidth="48dp"
+ android:maxHeight="48dp"/>
</LinearLayout>
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp">
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceListItem"
+ android:ellipsize="marquee"/>
+
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_alignStart="@android:id/title"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLines="10"/>
+
+ </RelativeLayout>
</LinearLayout>
diff --git a/res/layout/storage_item.xml b/res/layout/storage_item.xml
index 636a4c2..de73543 100644
--- a/res/layout/storage_item.xml
+++ b/res/layout/storage_item.xml
@@ -20,7 +20,7 @@
android:orientation="vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingStart="@dimen/preference_no_icon_padding_start"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="16dip"
android:paddingBottom="16dip"
diff --git a/res/layout/storage_summary.xml b/res/layout/storage_summary.xml
index 7cd5b06..1beb49f 100644
--- a/res/layout/storage_summary.xml
+++ b/res/layout/storage_summary.xml
@@ -20,7 +20,7 @@
android:orientation="vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingStart="@dimen/preference_no_icon_padding_start"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="16dip"
android:paddingBottom="16dip"
diff --git a/res/layout/work_profile_category.xml b/res/layout/work_profile_category.xml
deleted file mode 100644
index 8ca99f1..0000000
--- a/res/layout/work_profile_category.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Layout used for "Work" preference group in Accounts. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="16dip"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="16dip"
- android:orientation="vertical">
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"
- android:textColor="?android:attr/colorAccent" />
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceListItemSecondary"
- android:textColor="?android:attr/textColorSecondary"
- android:ellipsize="end"
- android:singleLine="true" />
-</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ef9cbc4..c1a76b3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3568,11 +3568,11 @@
<!-- [CHAR LIMIT=30] Manage applications, label for option to disable app -->
<string name="app_disable_dlg_positive">Disable app</string>
<!-- [CHAR LIMIT=200] Manage applications, text for dialog when disabling apps -->
- <string name="app_disable_dlg_text">If you disable this app, other apps may no longer function as intended.</string>
+ <string name="app_disable_dlg_text">If you disable this app, Android and other apps may no longer function as intended.</string>
<!-- [CHAR LIMIT=NONE] Manage applications, title for dialog when disabling updated apps -->
<string name="app_special_disable_dlg_title">Delete data and disable app?</string>
<!-- [CHAR LIMIT=NONE] Manage applications, text for dialog when disabling update apps -->
- <string name="app_special_disable_dlg_text">If you disable this app, other apps may no longer function as intended. Your data will also be deleted.</string>
+ <string name="app_special_disable_dlg_text">If you disable this app, Android and other apps may no longer function as intended. Your data will also be deleted.</string>
<!-- [CHAR LIMIT=30] Manage applications, title for dialog when disabling notifications for an app -->
<string name="app_disable_notifications_dlg_title">Turn off notifications?</string>
<!-- [CHAR LIMIT=200] Manage applications, text for dialog when disabling notifications for an app -->
@@ -5929,7 +5929,7 @@
</plurals>
<!-- Title for setting tile leading to network and Internet settings [CHAR LIMIT=40]-->
- <string name="network_dashboard_title">Network & Internet</string>
+ <string name="network_dashboard_title">Network & internet</string>
<!-- Title for setting tile leading to Connected devices settings [CHAR LIMIT=40]-->
<string name="connected_devices_dashboard_title">Connected devices</string>
<!-- Title for setting tile leading to Apps & Notification settings [CHAR LIMIT=40]-->
@@ -6226,25 +6226,19 @@
<string name="notification_importance_none">Not set</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
- <string name="notification_importance_blocked">Never show notifications from this app</string>
+ <string name="notification_importance_blocked">Never show notifications</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: min importance level description -->
- <string name="notification_importance_min">No full screen interruption, peeking, sound, or vibration. Show at the bottom of the notification list. Hide from lock screen and status bar.</string>
+ <string name="notification_importance_min">No sound or visual interruption</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: low importance level description -->
- <string name="notification_importance_low">No full screen interruption, peeking, sound, or vibration.</string>
+ <string name="notification_importance_low">Show silently</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: normal importance level description -->
- <string name="notification_importance_default">No full screen interruption or peeking.</string>
+ <string name="notification_importance_default">Make sound</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
- <string name="notification_importance_high">Always peek. No full screen interruption.</string>
-
- <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
- <string name="notification_importance_max">Always peek, and allow full screen interruption. Show at the top of the notification list.</string>
-
- <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
- <string name="notification_importance_unspecified">App determines importance for each notification</string>
+ <string name="notification_importance_high">Make sound and pop on screen</string>
<!-- [CHAR LIMIT=60] Notification importance reset button -->
<string name="importance_reset">Reset</string>
@@ -6335,13 +6329,19 @@
<string name="app_notification_block_title">Block all</string>
<!-- [CHAR LIMIT=NONE] App notification settings: Block option description-->
- <string name="app_notification_block_summary">Never show notifications from this app</string>
+ <string name="app_notification_block_summary">Never show these notifications</string>
<!-- [CHAR LIMIT=NONE] Channel notification settings: Block option title -->
- <string name="channel_notification_block_title">Block all</string>
+ <string name="notification_content_block_title">Show notifications</string>
<!-- [CHAR LIMIT=NONE] Channel notification settings: Block option description-->
- <string name="channel_notification_block_summary">Never show notifications from this channel</string>
+ <string name="notification_content_block_summary">Never show notifications in the shade or on peripheral devices</string>
+
+ <!-- [CHAR LIMIT=NONE] Channel notification settings: Badging option title -->
+ <string name="notification_badge_title">Show badge</string>
+
+ <!-- [CHAR LIMIT=NONE] Channel notification settings: Badge option description-->
+ <string name="notification_badge_summary">Show notifications as badges on the Home app, if supported.</string>
<!-- [CHAR LIMIT=NONE] App notification settings: Override DND option title -->
<string name="app_notification_override_dnd_title">Override Do Not Disturb</string>
@@ -6352,7 +6352,7 @@
<!-- [CHAR LIMIT=NONE] App notification settings: Visibility override option title -->
<string name="app_notification_visibility_override_title">On the lock screen</string>
- <!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when banned -->
+ <!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when allowed -->
<string name="app_notification_row_banned">Blocked</string>
<!-- [CHAR LIMIT=40] Notification settings: App notifications row summary when high priority -->
@@ -6794,14 +6794,6 @@
<string name="filter_notif_blocked_apps">Blocked</string>
<!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
<string name="filter_with_domain_urls_apps">With domain URLs</string>
- <!-- Label for showing apps with priority notifications in list [CHAR LIMIT=50] -->
- <string name="filter_notif_priority_apps">Overrides Do Not Disturb</string>
- <!-- Label for showing apps redacting sensitive notifications in list [CHAR LIMIT=50] -->
- <string name="filter_notif_sensitive_apps">No sensitive content on lock screen</string>
- <!-- Label for showing apps hiding notifications from lockscreen [CHAR LIMIT=50] -->
- <string name="filter_notif_hide_notifications_apps">Never shown on lock screen</string>
- <!-- Filter label for apps that the user has silenced [CHAR LIMIT=40] -->
- <string name="filter_notif_silent">Shown silently</string>
<!-- Title for advanced application management settings [CHAR LIMIT=30] -->
<string name="advanced_apps">Advanced</string>
@@ -7787,6 +7779,9 @@
<!-- Spinner dropdown text, when selected will try to add account [CHAR LIMIT=60] -->
<string name="support_account_picker_add_account">Add account</string>
+ <!-- Title for the dialog containing system information shown [CHAR LIMIT=30] -->
+ <string name="support_system_information_title">System information</string>
+
<!-- [CHAR LIMIT=60] Title of work profile setting page -->
<string name="managed_profile_settings_title">Work profile settings</string>
<!-- [CHAR LIMIT=60] The preference title for enabling cross-profile remote contact search -->
diff --git a/res/xml/advanced_apps.xml b/res/xml/advanced_apps.xml
index c17da05..0f9f82b 100644
--- a/res/xml/advanced_apps.xml
+++ b/res/xml/advanced_apps.xml
@@ -92,7 +92,7 @@
<PreferenceCategory
android:title="@string/advanced_apps">
- <PreferenceScreen
+ <Preference
android:key="special_access"
android:fragment="com.android.settings.applications.SpecialAccessSettings"
android:title="@string/special_access" />
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 2b2fc31..82660dc 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -18,46 +18,18 @@
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/app_notifications_title"
android:key="app_notification_settings">
-
- <!-- Importance -->
<!-- Block -->
<com.android.settingslib.RestrictedSwitchPreference
- android:key="block"
- android:title="@string/app_notification_block_title"
- android:summary="@string/app_notification_block_summary"
- android:order="2"
- settings:useAdditionalSummary="true"
- settings:restrictedSwitchSummary="@string/enabled_by_admin" />
- <!-- Silent -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="silent"
- android:title="@string/show_silently"
- android:summary="@string/show_silently_summary"
- android:order="3"
- settings:useAdditionalSummary="true" />
- <!-- Slider -->
- <com.android.settings.notification.ImportanceSeekBarPreference
- android:key="importance"
- android:title="@string/notification_importance_title"
- android:order="4"/>
-
- <!-- Visibility Override -->
- <com.android.settings.notification.RestrictedDropDownPreference
- android:key="visibility_override"
- android:title="@string/app_notification_visibility_override_title"
- android:order="5" />
-
- <!-- Bypass DND -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="bypass_dnd"
- android:title="@string/app_notification_override_dnd_title"
- android:summary="@string/app_notification_override_dnd_summary"
- android:order="6"
- settings:useAdditionalSummary="true" />
+ android:key="block"
+ android:title="@string/app_notification_block_title"
+ android:summary="@string/app_notification_block_summary"
+ android:order="2"
+ settings:useAdditionalSummary="true"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin" />
<PreferenceCategory
android:key="channels"
android:title="@string/notification_channels"
- android:order="7" />
+ android:order="3" />
</PreferenceScreen>
diff --git a/res/xml/application_settings.xml b/res/xml/application_settings.xml
index 1afe243..9987fc2 100644
--- a/res/xml/application_settings.xml
+++ b/res/xml/application_settings.xml
@@ -26,26 +26,26 @@
android:summary="@string/applications_settings_summary"
android:key="applications_settings">
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.applications.ManageApplications"
android:title="@string/manageapplications_settings_title"
android:summary="@string/manageapplications_settings_summary">
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.applications.ManageApplications"
android:title="@string/runningservices_settings_title"
android:summary="@string/runningservices_settings_summary">
<extra android:name="classname" android:value="com.android.settings.Settings$RunningServicesActivity" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.applications.ManageApplications"
android:title="@string/storageuse_settings_title"
android:summary="@string/storageuse_settings_summary">
<extra android:name="classname"
android:value="com.android.settings.Settings$StorageUseActivity" />
- </PreferenceScreen>
+ </Preference>
<CheckBoxPreference
android:key="toggle_advanced_settings"
diff --git a/res/xml/automatic_storage_management_settings.xml b/res/xml/automatic_storage_management_settings.xml
index c597cc8..af79396 100644
--- a/res/xml/automatic_storage_management_settings.xml
+++ b/res/xml/automatic_storage_management_settings.xml
@@ -32,12 +32,10 @@
android:title="@string/downloads_backup_preference_title"
android:summary="@string/downloads_backup_text"/>
- <com.android.settings.fuelgauge.WallOfTextPreference
+ <Preference
android:key="freed_bytes"
android:persistent="false"
- android:selectable="false"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="true" />
+ android:selectable="false" />
<DropDownPreference
android:key="days"
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 630016f..1720c73 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -15,7 +15,6 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/battery_saver"
android:key="battery_saver">
@@ -25,12 +24,4 @@
android:title="@string/battery_saver_turn_on_automatically_title"
android:summary="%s" />
- <!-- Feature description text -->
- <com.android.settings.fuelgauge.WallOfTextPreference
- android:key="description"
- android:summary="@*android:string/battery_saver_description"
- android:persistent="false"
- android:selectable="false"
- settings:allowDividerAbove="true" />
-
</PreferenceScreen>
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index de0b9c7..c2d1f73 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -20,21 +20,33 @@
<!-- Importance -->
<!-- Block -->
<com.android.settingslib.RestrictedSwitchPreference
- android:key="block"
- android:title="@string/channel_notification_block_title"
- android:summary="@string/app_notification_block_summary"
- android:order="2"
- settings:useAdditionalSummary="true"
- settings:restrictedSwitchSummary="@string/enabled_by_admin" />
- <!-- Silent -->
+ android:key="block"
+ android:title="@string/app_notification_block_title"
+ android:summary="@string/app_notification_block_summary"
+ android:order="1"
+ settings:useAdditionalSummary="true"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin" />
+
+ <!-- Show notification -->
<com.android.settingslib.RestrictedSwitchPreference
- android:key="silent"
- android:title="@string/show_silently"
- android:summary="@string/show_silently_summary"
- android:order="3"
- settings:useAdditionalSummary="true" />
- <!-- Slider -->
- <com.android.settings.notification.ImportanceSeekBarPreference
+ android:key="show"
+ android:title="@string/notification_content_block_title"
+ android:summary="@string/notification_content_block_summary"
+ android:order="2"
+ settings:useAdditionalSummary="true"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin" />
+
+ <!-- Show badge -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="badge"
+ android:title="@string/notification_badge_title"
+ android:summary="@string/notification_badge_summary"
+ android:order="3"
+ settings:useAdditionalSummary="true"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin" />
+
+ <!-- Importance -->
+ <com.android.settings.notification.RestrictedDropDownPreference
android:key="importance"
android:title="@string/notification_importance_title"
android:order="4"/>
diff --git a/res/xml/data_saver.xml b/res/xml/data_saver.xml
index 20ce5c8..0244030 100644
--- a/res/xml/data_saver.xml
+++ b/res/xml/data_saver.xml
@@ -15,7 +15,6 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/data_saver_title">
<Preference
@@ -23,12 +22,4 @@
android:title="@string/unrestricted_data_saver"
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess" />
- <!-- Feature description text -->
- <com.android.settings.fuelgauge.WallOfTextPreference
- android:key="description"
- android:summary="@*android:string/data_saver_description"
- android:persistent="false"
- android:selectable="false"
- settings:allowDividerAbove="true" />
-
</PreferenceScreen>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 1440c3f..2632c78 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -19,12 +19,12 @@
android:title="@string/display_settings"
settings:keywords="@string/keywords_display">
- <PreferenceScreen
+ <Preference
android:key="brightness"
android:title="@string/brightness"
settings:keywords="@string/keywords_display_brightness_level">
<intent android:action="android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
- </PreferenceScreen>
+ </Preference>
<SwitchPreference
android:key="auto_brightness"
@@ -70,7 +70,7 @@
android:title="@string/camera_gesture_title"
android:summary="@string/camera_gesture_desc" />
- <PreferenceScreen
+ <Preference
android:key="screensaver"
android:title="@string/screensaver_settings_title"
android:fragment="com.android.settings.DreamSettings" />
@@ -89,7 +89,7 @@
android:title="@string/tap_to_wake"
android:summary="@string/tap_to_wake_summary" />
- <PreferenceScreen
+ <Preference
android:key="font_size"
android:title="@string/title_font_size"
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
@@ -105,7 +105,7 @@
android:summary="%s"
android:title="@string/display_auto_rotate_title" />
- <PreferenceScreen
+ <Preference
android:key="wifi_display"
android:title="@string/wifi_display_settings_title"
settings:keywords="@string/keywords_display_cast_screen"
diff --git a/res/xml/language_settings.xml b/res/xml/language_settings.xml
index 992af92..8aa105b 100644
--- a/res/xml/language_settings.xml
+++ b/res/xml/language_settings.xml
@@ -18,7 +18,7 @@
android:key="language_keyboard_settings"
android:title="@string/language_keyboard_settings_title">
- <PreferenceScreen
+ <Preference
android:key="phone_language"
android:title="@string/phone_language"
android:fragment="com.android.settings.localepicker.LocaleListEditor"
@@ -34,17 +34,17 @@
android:persistent="false"/>
<!-- User dictionary preference title and fragment will be set programmatically. -->
- <PreferenceScreen
+ <Preference
android:key="key_user_dictionary_settings"
android:title="@string/user_dict_settings_title"
/>
<PreferenceCategory
android:title="@string/keyboard_and_input_methods_category">
- <PreferenceScreen
+ <Preference
android:title="@string/virtual_keyboard_category"
android:fragment="com.android.settings.inputmethod.VirtualKeyboardFragment" />
- <PreferenceScreen
+ <Preference
android:title="@string/physical_keyboard_title"
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment" />
</PreferenceCategory>
@@ -53,7 +53,7 @@
android:key="voice_category"
android:title="@string/voice_category" >
- <PreferenceScreen
+ <Preference
android:key="tts_settings"
android:title="@string/tts_settings_title"
android:fragment="com.android.settings.tts.TextToSpeechSettings"
diff --git a/res/xml/night_display_settings.xml b/res/xml/night_display_settings.xml
index 76b9323..c0b91ae 100644
--- a/res/xml/night_display_settings.xml
+++ b/res/xml/night_display_settings.xml
@@ -46,9 +46,4 @@
</PreferenceCategory>
- <com.android.settings.fuelgauge.WallOfTextPreference
- android:summary="@string/night_display_text"
- android:selectable="false"
- settings:allowDividerAbove="true" />
-
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/privacy_settings.xml b/res/xml/privacy_settings.xml
index f2af8f3..eeef64c 100644
--- a/res/xml/privacy_settings.xml
+++ b/res/xml/privacy_settings.xml
@@ -19,24 +19,24 @@
android:title="@string/privacy_settings_title">
<!-- Backup settings -->
- <PreferenceScreen
+ <Preference
android:key="backup_data"
android:title="@string/backup_data_title"
android:persistent="false"
android:fragment="com.android.settings.backup.ToggleBackupSettingFragment"/>
- <PreferenceScreen
+ <Preference
android:key="configure_account"
android:title="@string/backup_configure_account_title"
android:persistent="false">
<!-- the Intent declared here is always overwritten by a real one -->
<intent android:action="dummy" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:key="data_management"
android:persistent="false">
- </PreferenceScreen>
+ </Preference>
<SwitchPreference
android:key="auto_restore"
diff --git a/res/xml/security_settings_unencrypted.xml b/res/xml/security_settings_unencrypted.xml
index ee87705..7c51d25 100644
--- a/res/xml/security_settings_unencrypted.xml
+++ b/res/xml/security_settings_unencrypted.xml
@@ -21,7 +21,7 @@
android:key="security_category"
android:title="@string/crypt_keeper_settings_title">
- <PreferenceScreen
+ <Preference
android:key="encryption"
android:title="@string/crypt_keeper_encrypt_title"
android:fragment="com.android.settings.CryptKeeperSettings" />
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index 31789fb..4de167a 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
- <PreferenceScreen
+ <Preference
android:key="high_power_apps"
android:title="@string/high_power_apps"
android:fragment="com.android.settings.applications.ManageApplications"
@@ -26,19 +26,19 @@
<extra
android:name="classname"
android:value="com.android.settings.Settings$HighPowerApplicationsActivity" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:key="device_administrators"
android:title="@string/manage_device_admin"
android:fragment="com.android.settings.DeviceAdminSettings" />
- <PreferenceScreen
+ <Preference
android:key="zen_access"
android:title="@string/manage_zen_access_title"
android:fragment="com.android.settings.notification.ZenAccessSettings" />
- <PreferenceScreen
+ <Preference
android:key="system_alert_window"
android:title="@string/system_alert_window_settings"
android:fragment="com.android.settings.applications.ManageApplications"
@@ -46,9 +46,9 @@
<extra
android:name="classname"
android:value="com.android.settings.Settings$OverlaySettingsActivity" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:key="enabled_vr_listeners"
android:title="@string/vr_listeners_title"
android:fragment="com.android.settings.applications.VrListenerSettings"
@@ -56,9 +56,9 @@
<extra
android:name="classname"
android:value="com.android.settings.Settings$VrListenersSettingsActivity" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:key="write_settings_apps"
android:title="@string/write_settings"
android:fragment="com.android.settings.applications.ManageApplications"
@@ -66,24 +66,24 @@
<extra
android:name="classname"
android:value="com.android.settings.Settings$WriteSettingsActivity" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:key="notification_access"
android:title="@string/manage_notification_access_title"
android:fragment="com.android.settings.notification.NotificationAccessSettings" />
- <PreferenceScreen
+ <Preference
android:key="premium_sms"
android:title="@string/premium_sms_access"
android:fragment="com.android.settings.applications.PremiumSmsAccess" />
- <PreferenceScreen
+ <Preference
android:key="data_saver"
android:title="@string/unrestricted_data_saver"
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess" />
- <PreferenceScreen
+ <Preference
android:key="usage_access"
android:title="@string/usage_access"
android:fragment="com.android.settings.applications.ManageApplications"
@@ -91,5 +91,5 @@
<extra
android:name="classname"
android:value="com.android.settings.Settings$UsageAccessSettingsActivity" />
- </PreferenceScreen>
+ </Preference>
</PreferenceScreen>
diff --git a/res/xml/virtual_keyboard_settings.xml b/res/xml/virtual_keyboard_settings.xml
index e5a5f38..d5f0496 100644
--- a/res/xml/virtual_keyboard_settings.xml
+++ b/res/xml/virtual_keyboard_settings.xml
@@ -16,7 +16,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/virtual_keyboard_category">
<!-- Enabled input method list will be populated programmatically here. -->
- <PreferenceScreen
+ <Preference
android:key="add_virtual_keyboard_screen"
android:title="@string/add_virtual_keyboard"
android:fragment="com.android.settings.inputmethod.AvailableVirtualKeyboardFragment" />
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index d8ad10d..b22ad6a 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -20,19 +20,19 @@
android:title="@string/zen_mode_settings_title" >
<!-- Priority only allows -->
- <PreferenceScreen
+ <Preference
android:key="priority_settings"
android:title="@string/zen_mode_priority_settings_title"
android:fragment="com.android.settings.notification.ZenModePrioritySettings" />
<!-- Automated rules -->
- <PreferenceScreen
+ <Preference
android:key="automation_settings"
android:title="@string/zen_mode_automation_settings_title"
android:fragment="com.android.settings.notification.ZenModeAutomationSettings" />
<!-- Visual interruptions -->
- <PreferenceScreen
+ <Preference
android:key="visual_interruptions_settings"
android:title="@string/zen_mode_visual_interruptions_settings_title"
android:fragment="com.android.settings.notification.ZenModeVisualInterruptionSettings" />
diff --git a/src/com/android/settings/BandMode.java b/src/com/android/settings/BandMode.java
index 6f83fbc..b130295 100644
--- a/src/com/android/settings/BandMode.java
+++ b/src/com/android/settings/BandMode.java
@@ -164,7 +164,12 @@
int size = bands[0];
if (size > 0) {
+ mBandListAdapter.add(
+ new BandListItem(Phone.BM_UNSPECIFIED)); //Always include AUTOMATIC
for (int i=1; i<=size; i++) {
+ if (bands[i] == Phone.BM_UNSPECIFIED) {
+ continue;
+ }
item = new BandListItem(bands[i]);
mBandListAdapter.add(item);
if (DBG) log("Add " + item.toString());
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index 560b160..e9d810a 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -16,7 +16,6 @@
package com.android.settings;
-import android.app.Activity;
import android.app.backup.IBackupManager;
import android.content.ContentResolver;
import android.content.Context;
@@ -30,6 +29,7 @@
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
@@ -37,11 +37,9 @@
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.RestrictedPreference;
import java.util.ArrayList;
import java.util.Collection;
@@ -56,18 +54,22 @@
// Vendor specific
private static final String GSETTINGS_PROVIDER = "com.google.settings";
- private static final String BACKUP_DATA = "backup_data";
- private static final String AUTO_RESTORE = "auto_restore";
- private static final String CONFIGURE_ACCOUNT = "configure_account";
- private static final String DATA_MANAGEMENT = "data_management";
+ @VisibleForTesting
+ static final String BACKUP_DATA = "backup_data";
+ @VisibleForTesting
+ static final String AUTO_RESTORE = "auto_restore";
+ @VisibleForTesting
+ static final String CONFIGURE_ACCOUNT = "configure_account";
+ @VisibleForTesting
+ static final String DATA_MANAGEMENT = "data_management";
private static final String BACKUP_INACTIVE = "backup_inactive";
private static final String FACTORY_RESET = "factory_reset";
private static final String TAG = "PrivacySettings";
private IBackupManager mBackupManager;
- private PreferenceScreen mBackup;
+ private Preference mBackup;
private SwitchPreference mAutoRestore;
- private PreferenceScreen mConfigure;
- private PreferenceScreen mManageData;
+ private Preference mConfigure;
+ private Preference mManageData;
private boolean mEnabled;
@Override
@@ -90,13 +92,7 @@
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
- mBackup = (PreferenceScreen) screen.findPreference(BACKUP_DATA);
-
- mAutoRestore = (SwitchPreference) screen.findPreference(AUTO_RESTORE);
- mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
-
- mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
- mManageData = (PreferenceScreen) screen.findPreference(DATA_MANAGEMENT);
+ setPreferenceReferences(screen);
Set<String> keysToRemove = new HashSet<>();
getNonVisibleKeys(getActivity(), keysToRemove);
@@ -121,6 +117,17 @@
}
}
+ @VisibleForTesting
+ void setPreferenceReferences(PreferenceScreen screen) {
+ mBackup = screen.findPreference(BACKUP_DATA);
+
+ mAutoRestore = (SwitchPreference) screen.findPreference(AUTO_RESTORE);
+ mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
+
+ mConfigure = screen.findPreference(CONFIGURE_ACCOUNT);
+ mManageData = screen.findPreference(DATA_MANAGEMENT);
+ }
+
private OnPreferenceChangeListener preferenceChangeListener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
diff --git a/src/com/android/settings/WallOfTextPreference.java b/src/com/android/settings/WallOfTextPreference.java
deleted file mode 100644
index 4cc2f67..0000000
--- a/src/com/android/settings/WallOfTextPreference.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.util.AttributeSet;
-import android.widget.TextView;
-import com.android.settings.DividerPreference;
-
-public class WallOfTextPreference extends DividerPreference {
-
- public WallOfTextPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder view) {
- super.onBindViewHolder(view);
- final TextView summary = (TextView) view.findViewById(android.R.id.summary);
- summary.setMaxLines(20);
- }
-}
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 219dd3a..723a1ec 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -271,7 +271,6 @@
} else {
List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
final int profilesCount = profiles.size();
- final boolean addCategory = profilesCount > 1;
for (int i = 0; i < profilesCount; i++) {
updateProfileUi(profiles.get(i));
}
@@ -298,7 +297,6 @@
preferenceGroup.setContentDescription(
mContext.getString(R.string.account_settings));
} else if (userInfo.isManagedProfile()) {
- preferenceGroup.setLayoutResource(R.layout.work_profile_category);
preferenceGroup.setTitle(R.string.category_work);
String workGroupSummary = getWorkGroupSummary(context, userInfo);
preferenceGroup.setSummary(workGroupSummary);
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index 45b472a..5942897 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -35,7 +36,7 @@
@Override
public int getMetricsCategory() {
- return APP_AND_NOTIFICATION_CATEGORY_FRAGMENT;
+ return MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY;
}
@Override
diff --git a/src/com/android/settings/applications/AppStateNotificationBridge.java b/src/com/android/settings/applications/AppStateNotificationBridge.java
index 5fff175..b0c065a 100644
--- a/src/com/android/settings/applications/AppStateNotificationBridge.java
+++ b/src/com/android/settings/applications/AppStateNotificationBridge.java
@@ -81,64 +81,4 @@
return false;
}
};
-
- public static final AppFilter FILTER_APP_NOTIFICATION_SILENCED = new AppFilter() {
- @Override
- public void init() {
- }
-
- @Override
- public boolean filterApp(AppEntry info) {
- if (info == null || info.extraInfo == null) {
- return false;
- }
- AppRow row = (AppRow) info.extraInfo;
- return row.appImportance > NotificationManager.IMPORTANCE_NONE
- && row.appImportance < NotificationManager.IMPORTANCE_DEFAULT;
- }
- };
-
- public static final AppFilter FILTER_APP_NOTIFICATION_PRIORITY = new AppFilter() {
- @Override
- public void init() {
- }
-
- @Override
- public boolean filterApp(AppEntry info) {
- if (info == null || info.extraInfo == null) {
- return false;
- }
- return ((AppRow) info.extraInfo).appBypassDnd;
- }
- };
-
- public static final AppFilter FILTER_APP_NOTIFICATION_HIDE_SENSITIVE = new AppFilter() {
- @Override
- public void init() {
- }
-
- @Override
- public boolean filterApp(AppEntry info) {
- if (info == null || info.extraInfo == null) {
- return false;
- }
- return ((AppRow) info.extraInfo).lockScreenSecure
- && ((AppRow) info.extraInfo).appVisOverride == Notification.VISIBILITY_PRIVATE;
- }
- };
-
- public static final AppFilter FILTER_APP_NOTIFICATION_HIDE_ALL = new AppFilter() {
- @Override
- public void init() {
- }
-
- @Override
- public boolean filterApp(AppEntry info) {
- if (info == null || info.extraInfo == null) {
- return false;
- }
- return ((AppRow) info.extraInfo).lockScreenSecure
- && ((AppRow) info.extraInfo).appVisOverride == Notification.VISIBILITY_SECRET;
- }
- };
}
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 2569eac..d689ee4 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -1088,10 +1088,6 @@
return NetworkTemplate.buildTemplateEthernet();
}
- public static CharSequence getNotificationSummary(AppEntry appEntry, Context context) {
- return getNotificationSummary(appEntry, context, new NotificationBackend());
- }
-
public static CharSequence getNotificationSummary(AppEntry appEntry, Context context,
NotificationBackend backend) {
AppRow appRow = backend.loadAppRow(context, context.getPackageManager(), appEntry.info);
@@ -1099,43 +1095,8 @@
}
public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
- boolean showSlider = Settings.Secure.getInt(
- context.getContentResolver(), NOTIFICATION_TUNER_SETTING, 0) == 1;
- List<String> summaryAttributes = new ArrayList<>();
- StringBuffer summary = new StringBuffer();
- if (showSlider) {
- if (appRow.appImportance != NotificationManager.IMPORTANCE_UNSPECIFIED) {
- summaryAttributes.add(context.getString(
- R.string.notification_summary_level, appRow.appImportance));
- }
- } else {
- if (appRow.banned) {
- summaryAttributes.add(context.getString(R.string.notifications_disabled));
- } else if (appRow.appImportance > NotificationManager.IMPORTANCE_NONE
- && appRow.appImportance < NotificationManager.IMPORTANCE_DEFAULT) {
- summaryAttributes.add(context.getString(R.string.notifications_silenced));
- }
- }
- final boolean lockscreenSecure = new LockPatternUtils(context).isSecure(
- UserHandle.myUserId());
- if (lockscreenSecure) {
- if (appRow.appVisOverride == Notification.VISIBILITY_PRIVATE) {
- summaryAttributes.add(context.getString(R.string.notifications_redacted));
- } else if (appRow.appVisOverride == Notification.VISIBILITY_SECRET) {
- summaryAttributes.add(context.getString(R.string.notifications_hidden));
- }
- }
- if (appRow.appBypassDnd) {
- summaryAttributes.add(context.getString(R.string.notifications_priority));
- }
- final int N = summaryAttributes.size();
- for (int i = 0; i < N; i++) {
- if (i > 0) {
- summary.append(context.getString(R.string.notifications_summary_divider));
- }
- summary.append(summaryAttributes.get(i));
- }
- return summary.toString();
+ // TODO: implement summary when it is known what it should say
+ return "";
}
@Override
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 099d30e..d8ee6b7 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -131,15 +131,11 @@
public static final int FILTER_APPS_ENABLED = 3;
public static final int FILTER_APPS_DISABLED = 4;
public static final int FILTER_APPS_BLOCKED = 5;
- public static final int FILTER_APPS_SILENT = 6;
- public static final int FILTER_APPS_SENSITIVE = 7;
- public static final int FILTER_APPS_HIDE_NOTIFICATIONS = 8;
- public static final int FILTER_APPS_PRIORITY = 9;
- public static final int FILTER_APPS_PERSONAL = 10;
- public static final int FILTER_APPS_WORK = 11;
- public static final int FILTER_APPS_USAGE_ACCESS = 13;
- public static final int FILTER_APPS_WITH_OVERLAY = 14;
- public static final int FILTER_APPS_WRITE_SETTINGS = 15;
+ public static final int FILTER_APPS_PERSONAL = 6;
+ public static final int FILTER_APPS_WORK = 7;
+ public static final int FILTER_APPS_USAGE_ACCESS = 8;
+ public static final int FILTER_APPS_WITH_OVERLAY = 9;
+ public static final int FILTER_APPS_WRITE_SETTINGS = 10;
// This is the string labels for the filter modes above, the order must be kept in sync.
public static final int[] FILTER_LABELS = new int[]{
@@ -149,10 +145,6 @@
R.string.filter_enabled_apps, // Enabled
R.string.filter_apps_disabled, // Disabled
R.string.filter_notif_blocked_apps, // Blocked Notifications
- R.string.filter_notif_silent, // Silenced Notifications
- R.string.filter_notif_sensitive_apps, // Sensitive Notifications
- R.string.filter_notif_hide_notifications_apps, // Sensitive Notifications
- R.string.filter_notif_priority_apps, // Priority Notifications
R.string.filter_personal_apps, // Personal
R.string.filter_work_apps, // Work
R.string.filter_with_domain_urls_apps, // Domain URLs
@@ -171,10 +163,6 @@
ApplicationsState.FILTER_ALL_ENABLED, // Enabled
ApplicationsState.FILTER_DISABLED, // Disabled
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED, // Blocked Notifications
- AppStateNotificationBridge.FILTER_APP_NOTIFICATION_SILENCED, // Silenced Notifications
- AppStateNotificationBridge.FILTER_APP_NOTIFICATION_HIDE_SENSITIVE, // Sensitive Notifications
- AppStateNotificationBridge.FILTER_APP_NOTIFICATION_HIDE_ALL, // Hide all Notifications
- AppStateNotificationBridge.FILTER_APP_NOTIFICATION_PRIORITY, // Priority Notifications
ApplicationsState.FILTER_PERSONAL, // Personal
ApplicationsState.FILTER_WORK, // Work
ApplicationsState.FILTER_WITH_DOMAIN_URLS, // Apps with Domain URLs
@@ -356,10 +344,6 @@
}
if (mListType == LIST_TYPE_NOTIFICATION) {
mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
- mFilterAdapter.enableFilter(FILTER_APPS_SILENT);
- mFilterAdapter.enableFilter(FILTER_APPS_SENSITIVE);
- mFilterAdapter.enableFilter(FILTER_APPS_HIDE_NOTIFICATIONS);
- mFilterAdapter.enableFilter(FILTER_APPS_PRIORITY);
}
if (mListType == LIST_TYPE_HIGH_POWER) {
mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index db541d5..b8ee1ff 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -39,7 +40,7 @@
@Override
public int getMetricsCategory() {
- return CONNECTED_DEVICE_CATEGORY_FRAGMENT;
+ return MetricsProto.MetricsEvent.SETTINGS_CONNECTED_DEVICE_CATEGORY;
}
@Override
diff --git a/src/com/android/settings/core/InstrumentedPreferenceFragment.java b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
index 3a4d0c2..29ba287 100644
--- a/src/com/android/settings/core/InstrumentedPreferenceFragment.java
+++ b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
@@ -43,18 +43,6 @@
// metrics placeholder value. Only use this for development.
protected final int PLACEHOLDER_METRIC = 10000;
- protected final int SYSTEM_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 1;
- protected final int STORAGE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 2;
- protected final int NETWORK_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 3;
- protected final int CONNECTED_DEVICE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 4;
- protected final int APP_AND_NOTIFICATION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 5;
- protected final int INPUT_AND_GESTURE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 6;
- protected final int LANGUAGE_AND_REGION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 7;
- protected final int GESTURE_SWIPE_TO_NOTIFICATION = PLACEHOLDER_METRIC + 8;
- protected final int GESTURE_DOUBLE_TAP_POWER = PLACEHOLDER_METRIC + 9;
- protected final int GESTURE_PICKUP = PLACEHOLDER_METRIC + 10;
- protected final int GESTURE_DOUBLE_TAP_SCREEN = PLACEHOLDER_METRIC + 11;
- protected final int GESTURE_DOUBLE_TWIST = PLACEHOLDER_METRIC + 12;
private final PreferenceDividerDecoration mDividerDecoration =
new PreferenceDividerDecoration();
diff --git a/src/com/android/settings/datausage/DataSaverSummary.java b/src/com/android/settings/datausage/DataSaverSummary.java
index b0304fc..b424fa2 100644
--- a/src/com/android/settings/datausage/DataSaverSummary.java
+++ b/src/com/android/settings/datausage/DataSaverSummary.java
@@ -54,6 +54,8 @@
super.onCreate(icicle);
addPreferencesFromResource(R.xml.data_saver);
+ mFooterPreferenceMixin.createFooterPreference()
+ .setTitle(com.android.internal.R.string.data_saver_description);
mUnrestrictedAccess = findPreference(KEY_UNRESTRICTED_ACCESS);
mApplicationsState = ApplicationsState.getInstance(
(Application) getContext().getApplicationContext());
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index b0685cf..e63a1df 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -18,7 +18,6 @@
import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
import android.app.Fragment;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -37,7 +36,6 @@
import android.os.storage.VolumeInfo;
import android.os.storage.VolumeRecord;
import android.provider.DocumentsContract;
-import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceGroup;
@@ -65,9 +63,9 @@
import com.android.settingslib.deviceinfo.StorageMeasurement;
import com.android.settingslib.deviceinfo.StorageMeasurement.MeasurementDetails;
import com.android.settingslib.deviceinfo.StorageMeasurement.MeasurementReceiver;
+
import com.google.android.collect.Lists;
-import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
@@ -107,9 +105,6 @@
R.string.storage_detail_other,
};
- private static final int DELETION_HELPER_SETTINGS = 1;
- private static final int DELETION_HELPER_CLEAR = 1;
-
private StorageManager mStorageManager;
private UserManager mUserManager;
@@ -285,8 +280,7 @@
if (mHeaderPoolIndex < mHeaderPreferencePool.size()) {
category = mHeaderPreferencePool.get(mHeaderPoolIndex);
} else {
- category = new PreferenceCategory(getPrefContext(), null,
- com.android.internal.R.attr.preferenceCategoryStyle);
+ category = new PreferenceCategory(getPrefContext());
mHeaderPreferencePool.add(category);
}
category.setTitle(title);
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index aa4d834..8992830 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -37,7 +38,7 @@
@Override
public int getMetricsCategory() {
- return STORAGE_CATEGORY_FRAGMENT;
+ return MetricsProto.MetricsEvent.SETTINGS_STORAGE_CATEGORY;
}
@Override
diff --git a/src/com/android/settings/display/NightDisplaySettings.java b/src/com/android/settings/display/NightDisplaySettings.java
index 1ff4297..619c0d4 100644
--- a/src/com/android/settings/display/NightDisplaySettings.java
+++ b/src/com/android/settings/display/NightDisplaySettings.java
@@ -73,7 +73,7 @@
// Load the preferences from xml.
addPreferencesFromResource(R.xml.night_display_settings);
-
+ mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.night_display_text);
mAutoModePreference = (DropDownPreference) findPreference(KEY_NIGHT_DISPLAY_AUTO_MODE);
mStartTimePreference = findPreference(KEY_NIGHT_DISPLAY_START_TIME);
mEndTimePreference = findPreference(KEY_NIGHT_DISPLAY_END_TIME);
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
index 4dc8f87..6b7ddf9 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
@@ -78,7 +78,8 @@
}
mCreated = true;
addPreferencesFromResource(R.xml.battery_saver_settings);
-
+ mFooterPreferenceMixin.createFooterPreference()
+ .setTitle(com.android.internal.R.string.battery_saver_description);
mContext = getActivity();
mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
mSwitch = mSwitchBar.getSwitch();
diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
index 2219e33..de16fe5 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
@@ -16,6 +16,8 @@
package com.android.settings.fuelgauge;
+import android.content.Intent;
+
/**
* Feature Provider used in power usage
*/
@@ -25,5 +27,13 @@
*/
boolean isLocationSettingEnabled(String[] packages);
+ /**
+ * Check whether additional battery info feature is enabled.
+ */
boolean isAdditionalBatteryInfoEnabled();
+
+ /**
+ * Gets an {@link Intent} to show additional battery info.
+ */
+ Intent getAdditionalBatteryInfoIntent();
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 1100a2c..14e6693 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -175,6 +175,11 @@
sa.startPreferencePanel(ManageApplications.class.getName(), args,
R.string.high_power_apps, null, null, 0);
return true;
+ case MENU_ADDITIONAL_BATTERY_INFO:
+ startActivity(FeatureFactory.getFactory(getContext())
+ .getPowerUsageFeatureProvider(getContext())
+ .getAdditionalBatteryInfoIntent());
+ return true;
default:
return super.onOptionsItemSelected(item);
}
diff --git a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
index cb36879..213259b 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
@@ -20,7 +20,10 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
+import android.util.ArrayMap;
import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
public class DoubleTapPowerPreferenceController extends GesturePreferenceController {
@@ -61,4 +64,14 @@
Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
return cameraDisabled == 0;
}
+
+ @Override
+ public ResultPayload getResultPayload() {
+ ArrayMap<Integer, Boolean> valueMap = new ArrayMap<>();
+ valueMap.put(0, true);
+ valueMap.put(1, false);
+
+ return new InlineSwitchPayload(Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
+ ResultPayload.SettingsSource.SECURE, valueMap);
+ }
}
diff --git a/src/com/android/settings/gestures/DoubleTapPowerSettings.java b/src/com/android/settings/gestures/DoubleTapPowerSettings.java
index b4319f1..c31e999 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerSettings.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerSettings.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -35,7 +36,7 @@
@Override
public int getMetricsCategory() {
- return GESTURE_DOUBLE_TAP_POWER;
+ return MetricsProto.MetricsEvent.SETTINGS_GESTURE_DOUBLE_TAP_POWER;
}
@Override
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 722d66a..02d8dd7 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -21,8 +21,11 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
+import android.util.ArrayMap;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
public class DoubleTapScreenPreferenceController extends GesturePreferenceController {
@@ -67,4 +70,14 @@
protected boolean isSwitchPrefEnabled() {
return mAmbientConfig.pulseOnDoubleTapEnabled(mUserId);
}
+
+ @Override
+ public ResultPayload getResultPayload() {
+ ArrayMap<Integer, Boolean> valueMap = new ArrayMap<>();
+ valueMap.put(1, true);
+ valueMap.put(0, false);
+
+ return new InlineSwitchPayload(Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
+ ResultPayload.SettingsSource.SECURE, valueMap);
+ }
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenSettings.java b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
index c10fbb7..d203fbc 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenSettings.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
@@ -21,6 +21,7 @@
import android.provider.SearchIndexableResource;
import com.android.internal.hardware.AmbientDisplayConfiguration;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -37,7 +38,7 @@
@Override
public int getMetricsCategory() {
- return GESTURE_DOUBLE_TAP_SCREEN;
+ return MetricsProto.MetricsEvent.SETTINGS_GESTURE_DOUBLE_TAP_SCREEN;
}
@Override
diff --git a/src/com/android/settings/gestures/DoubleTwistGestureSettings.java b/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
index c11f4a5..1303ca1 100644
--- a/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
+++ b/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -35,7 +36,7 @@
@Override
public int getMetricsCategory() {
- return GESTURE_DOUBLE_TWIST;
+ return MetricsProto.MetricsEvent.SETTINGS_GESTURE_DOUBLE_TWIST;
}
@Override
diff --git a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
index 5192484..fea1c9d 100644
--- a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
@@ -24,8 +24,11 @@
import android.support.v7.preference.Preference;
import android.text.TextUtils;
+import android.util.ArrayMap;
import com.android.settings.R;
import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
public class DoubleTwistPreferenceController extends GesturePreferenceController {
@@ -82,4 +85,14 @@
}
return false;
}
+
+ @Override
+ public ResultPayload getResultPayload() {
+ ArrayMap<Integer, Boolean> valueMap = new ArrayMap<>();
+ valueMap.put(1, true);
+ valueMap.put(0, false);
+
+ return new InlineSwitchPayload(Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
+ ResultPayload.SettingsSource.SECURE, valueMap);
+ }
}
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index 98ed5fb..9b71b96 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -167,21 +167,32 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
ArrayList<String> result = new ArrayList<String>();
+
+ List<PreferenceController> preferenceControllers =
+ getPreferenceControllers(context);
+ for(PreferenceController controller : preferenceControllers) {
+ controller.updateNonIndexableKeys(result);
+ }
+ return result;
+ }
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ List<PreferenceController> controllers = new ArrayList<>();
AmbientDisplayConfiguration ambientConfig
= new AmbientDisplayConfiguration(context);
- new DoubleTapPowerPreferenceController(context, null /* lifecycle */)
- .updateNonIndexableKeys(result);
- new PickupGesturePreferenceController(
- context, null /* lifecycle */, ambientConfig, UserHandle.myUserId())
- .updateNonIndexableKeys(result);
- new DoubleTapScreenPreferenceController(
- context, null /* lifecycle */, ambientConfig, UserHandle.myUserId())
- .updateNonIndexableKeys(result);
- new SwipeToNotificationPreferenceController(context, null /* lifecycle */)
- .updateNonIndexableKeys(result);
- new DoubleTwistPreferenceController(context, null /* lifecycle */)
- .updateNonIndexableKeys(result);
- return result;
+
+ controllers.add(new DoubleTapPowerPreferenceController(context,
+ null /* lifecycle */));
+ controllers.add(new PickupGesturePreferenceController(context,
+ null /* lifecycle */, ambientConfig, UserHandle.myUserId()));
+ controllers.add(new DoubleTapScreenPreferenceController(context,
+ null /* lifecycle */, ambientConfig, UserHandle.myUserId()));
+ controllers.add(new SwipeToNotificationPreferenceController(context,
+ null /* lifecycle */));
+ controllers.add(new DoubleTwistPreferenceController(context,
+ null /* lifecycle */));
+ return controllers;
}
};
}
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index 225e1d0..f48551e 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -21,8 +21,11 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
+import android.util.ArrayMap;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
public class PickupGesturePreferenceController extends GesturePreferenceController {
@@ -68,4 +71,13 @@
return true;
}
+ @Override
+ public ResultPayload getResultPayload() {
+ ArrayMap<Integer, Boolean> valueMap = new ArrayMap<>();
+ valueMap.put(1, true);
+ valueMap.put(0, false);
+
+ return new InlineSwitchPayload(Settings.Secure.DOZE_PULSE_ON_PICK_UP,
+ ResultPayload.SettingsSource.SECURE, valueMap);
+ }
}
diff --git a/src/com/android/settings/gestures/PickupGestureSettings.java b/src/com/android/settings/gestures/PickupGestureSettings.java
index 63d3968..8c0f74c 100644
--- a/src/com/android/settings/gestures/PickupGestureSettings.java
+++ b/src/com/android/settings/gestures/PickupGestureSettings.java
@@ -21,6 +21,7 @@
import android.provider.SearchIndexableResource;
import com.android.internal.hardware.AmbientDisplayConfiguration;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -37,7 +38,7 @@
@Override
public int getMetricsCategory() {
- return GESTURE_PICKUP;
+ return MetricsProto.MetricsEvent.SETTINGS_GESTURE_PICKUP;
}
@Override
diff --git a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
index 08dc614..67c8e14 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
@@ -20,7 +20,10 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
+import android.util.ArrayMap;
import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
public class SwipeToNotificationPreferenceController extends GesturePreferenceController {
@@ -60,4 +63,14 @@
Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0)
== 1;
}
+
+ @Override
+ public ResultPayload getResultPayload() {
+ ArrayMap<Integer, Boolean> valueMap = new ArrayMap<>();
+ valueMap.put(1, true);
+ valueMap.put(0, false);
+
+ return new InlineSwitchPayload(Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED,
+ ResultPayload.SettingsSource.SECURE, valueMap);
+ }
}
diff --git a/src/com/android/settings/gestures/SwipeToNotificationSettings.java b/src/com/android/settings/gestures/SwipeToNotificationSettings.java
index 57796a6..fba074e 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationSettings.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationSettings.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -35,7 +36,7 @@
@Override
public int getMetricsCategory() {
- return GESTURE_SWIPE_TO_NOTIFICATION;
+ return MetricsProto.MetricsEvent.SETTINGS_GESTURE_SWIPE_TO_NOTIFICATION;
}
@Override
diff --git a/src/com/android/settings/inputmethod/InputAndGestureSettings.java b/src/com/android/settings/inputmethod/InputAndGestureSettings.java
index eecfd31..43d8b230b 100644
--- a/src/com/android/settings/inputmethod/InputAndGestureSettings.java
+++ b/src/com/android/settings/inputmethod/InputAndGestureSettings.java
@@ -21,6 +21,7 @@
import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.lifecycle.Lifecycle;
@@ -43,7 +44,7 @@
@Override
public int getMetricsCategory() {
- return INPUT_AND_GESTURE_CATEGORY_FRAGMENT;
+ return MetricsProto.MetricsEvent.SETTINGS_INPUT_CATEGORY;
}
@Override
diff --git a/src/com/android/settings/language/LanguageAndRegionSettings.java b/src/com/android/settings/language/LanguageAndRegionSettings.java
index 5741255..7e92e05 100644
--- a/src/com/android/settings/language/LanguageAndRegionSettings.java
+++ b/src/com/android/settings/language/LanguageAndRegionSettings.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.speech.tts.TtsEngines;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -34,7 +35,7 @@
@Override
public int getMetricsCategory() {
- return LANGUAGE_AND_REGION_CATEGORY_FRAGMENT;
+ return MetricsProto.MetricsEvent.SETTINGS_LANGUAGE_CATEGORY;
}
@Override
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index a58a879..89dfa02 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -43,7 +43,7 @@
@Override
public int getMetricsCategory() {
- return NETWORK_CATEGORY_FRAGMENT;
+ return MetricsProto.MetricsEvent.SETTINGS_NETWORK_CATEGORY;
}
@Override
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index c38a72f..c720bb5 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -54,12 +54,12 @@
.addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
private static final String KEY_CHANNELS = "channels";
+ private static final String KEY_BLOCK = "block";
private DashboardFeatureProvider mDashboardFeatureProvider;
private PreferenceCategory mChannels;
private List<NotificationChannel> mChannelList;
-
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -84,28 +84,17 @@
addPreferencesFromResource(R.xml.app_notification_settings);
- mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
- mPriority =
- (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
- mVisibilityOverride =
- (RestrictedDropDownPreference) getPreferenceScreen().findPreference(
- KEY_VISIBILITY_OVERRIDE);
mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
- mSilent = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SILENT);
mChannels = (PreferenceCategory) findPreference(KEY_CHANNELS);
if (mPkgInfo != null) {
+ setupBlock(mAppRow.systemApp, mAppRow.banned);
// load settings intent
ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
rows.put(mAppRow.pkg, mAppRow);
collectConfigActivities(rows);
mChannelList = mBackend.getChannels(mPkg, mUid).getList();
- setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance, mAppRow.banned,
- NotificationManager.IMPORTANCE_HIGH);
- setupPriorityPref(mAppRow.appBypassDnd);
- setupVisOverridePref(mAppRow.appVisOverride);
-
if (mChannelList.isEmpty()) {
setVisible(mChannels, false);
} else {
@@ -129,7 +118,7 @@
mChannels.addPreference(channelPref);
}
}
- updateDependents(mAppRow.appImportance);
+ updateDependents(mAppRow.banned);
}
if (mDashboardFeatureProvider.isEnabled()) {
final Preference pref = FeatureFactory.getFactory(activity)
@@ -148,10 +137,40 @@
}
@Override
- protected void updateDependents(int importance) {
- super.updateDependents(importance);
- setVisible(mChannels,
- !(mChannelList.isEmpty() || importance == NotificationManager.IMPORTANCE_NONE));
+ public void onResume() {
+ super.onResume();
+ if ((mUid != -1 && getPackageManager().getPackagesForUid(mUid) == null)) {
+ // App isn't around anymore, must have been removed.
+ finish();
+ return;
+ }
+ if (mBlock != null) {
+ mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+ }
+ }
+
+ private void setupBlock(boolean notBlockable, boolean banned) {
+ if (notBlockable) {
+ setVisible(mBlock, false);
+ } else {
+ mBlock.setChecked(banned);
+ mBlock.setOnPreferenceChangeListener(
+ new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference,
+ Object newValue) {
+ final boolean blocked = (Boolean) newValue;
+ mBackend.setNotificationsEnabledForPackage(mPkgInfo.packageName, mUid,
+ !blocked);
+ updateDependents(blocked);
+ return true;
+ }
+ });
+ }
+ }
+
+ private void updateDependents(boolean banned) {
+ setVisible(mChannels, !(mChannelList.isEmpty() || banned));
}
private List<ResolveInfo> queryNotificationConfigActivities() {
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 02cc436..77bf6be 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -16,17 +16,27 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+import static android.app.NotificationManager.IMPORTANCE_MIN;
+import static android.app.NotificationManager.IMPORTANCE_NONE;
+
import android.app.Activity;
+import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
+import android.app.admin.DevicePolicyManager;
import android.content.Intent;
+import android.content.pm.UserInfo;
import android.net.Uri;
import android.os.Bundle;
+import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.Ranking;
import android.support.v7.preference.Preference;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.widget.LockPatternUtils;
import com.android.settings.AppHeader;
import com.android.settings.R;
import com.android.settings.RingtonePreference;
@@ -36,17 +46,26 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
+import java.util.ArrayList;
+
public class ChannelNotificationSettings extends NotificationSettingsBase {
+ protected static final String KEY_BYPASS_DND = "bypass_dnd";
+ protected static final String KEY_VISIBILITY_OVERRIDE = "visibility_override";
+ protected static final String KEY_IMPORTANCE = "importance";
protected static final String KEY_LIGHTS = "lights";
protected static final String KEY_VIBRATE = "vibrate";
protected static final String KEY_RINGTONE = "ringtone";
+ protected static final String KEY_SHOW = "show";
+ protected static final String KEY_BADGE = "badge";
protected RestrictedSwitchPreference mLights;
protected RestrictedSwitchPreference mVibrate;
protected DefaultNotificationTonePreference mRingtone;
+ protected RestrictedDropDownPreference mImportance;
+ protected RestrictedSwitchPreference mPriority;
+ protected RestrictedDropDownPreference mVisibilityOverride;
private DashboardFeatureProvider mDashboardFeatureProvider;
- private int mMaxImportance;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -71,34 +90,26 @@
FeatureFactory.getFactory(activity).getDashboardFeatureProvider(activity);
addPreferencesFromResource(R.xml.channel_notification_settings);
- mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
+ mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
+ mShow = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SHOW);
+ mBadge = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BADGE);
+ mImportance = (RestrictedDropDownPreference) findPreference(KEY_IMPORTANCE);
mPriority =
(RestrictedSwitchPreference) findPreference(KEY_BYPASS_DND);
mVisibilityOverride =
(RestrictedDropDownPreference) findPreference(KEY_VISIBILITY_OVERRIDE);
- mBlock = (RestrictedSwitchPreference) findPreference(KEY_BLOCK);
- mSilent = (RestrictedSwitchPreference) findPreference(KEY_SILENT);
mLights = (RestrictedSwitchPreference) findPreference(KEY_LIGHTS);
mVibrate = (RestrictedSwitchPreference) findPreference(KEY_VIBRATE);
mRingtone = (DefaultNotificationTonePreference) findPreference(KEY_RINGTONE);
if (mPkgInfo != null) {
setupPriorityPref(mChannel.canBypassDnd());
- if (mAppRow.appBypassDnd) {
- mPriority.setShouldDisableView(true);
- }
setupVisOverridePref(mChannel.getLockscreenVisibility());
- if (mAppRow.appVisOverride != Ranking.VISIBILITY_NO_OVERRIDE) {
- mVisibilityOverride.setShouldDisableView(true);
- }
setupLights();
setupVibrate();
setupRingtone();
- mMaxImportance = mAppRow.appImportance == NotificationManager.IMPORTANCE_UNSPECIFIED
- ? NotificationManager.IMPORTANCE_HIGH : mAppRow.appImportance;
- setupImportancePrefs(false, mChannel.getImportance(),
- mChannel.getImportance() == NotificationManager.IMPORTANCE_NONE,
- mMaxImportance);
+ setupBlockAndImportance();
+ updateDependents();
}
if (mDashboardFeatureProvider.isEnabled()) {
final Preference pref = FeatureFactory.getFactory(activity)
@@ -124,14 +135,14 @@
finish();
return;
}
- mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
- mContext, mPkg, mUserId);
- if (mLights != null) {
- mLights.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- if (mVibrate != null) {
- mVibrate.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
+ mLights.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mVibrate.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mShow.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
}
private void setupLights() {
@@ -179,6 +190,209 @@
});
}
+ protected void setupBlockAndImportance() {
+ mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mBlock.setChecked(!mChannel.isAllowed());
+ mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean value = (Boolean) newValue;
+ mChannel.setAllowed(!value);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_ALLOWED);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ updateDependents();
+ return true;
+ }
+ });
+
+ mShow.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mShow.setChecked(mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE);
+ mShow.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean value = (Boolean) newValue;
+ int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
+ mImportance.setValue(String.valueOf(importance));
+ mChannel.setImportance(importance);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ updateDependents();
+ return true;
+ }
+ });
+ mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mBadge.setChecked(mChannel.canShowBadge());
+ mBadge.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean value = (Boolean) newValue;
+ mChannel.setShowBadge(value);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_SHOW_BADGE);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ return true;
+ }
+ });
+
+ mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
+ final int numImportances = IMPORTANCE_HIGH - IMPORTANCE_MIN + 1;
+ String[] summaries = new String[numImportances];
+ String[] values = new String[numImportances];
+ for (int i = 0; i < numImportances; i++) {
+ int importance = i + 1;
+ summaries[i] = getSummary(importance);
+ values[i] = String.valueOf(importance);
+ }
+ mImportance.setEntryValues(values);
+ mImportance.setEntries(summaries);
+ mImportance.setValue(String.valueOf(mChannel.getImportance()));
+ mImportance.setSummary("%s");
+
+ mImportance.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ int importance = Integer.parseInt((String) newValue);
+ mChannel.setImportance(importance);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ updateDependents();
+ return true;
+ }
+ });
+ }
+
+ private String getSummary(int importance) {
+ switch (importance) {
+ case NotificationManager.IMPORTANCE_NONE:
+ return getContext().getString(R.string.notification_importance_blocked);
+ case NotificationManager.IMPORTANCE_MIN:
+ return getContext().getString(R.string.notification_importance_min);
+ case NotificationManager.IMPORTANCE_LOW:
+ return getContext().getString(R.string.notification_importance_low);
+ case NotificationManager.IMPORTANCE_DEFAULT:
+ return getContext().getString(R.string.notification_importance_default);
+ case NotificationManager.IMPORTANCE_HIGH:
+ case NotificationManager.IMPORTANCE_MAX:
+ default:
+ return getContext().getString(R.string.notification_importance_high);
+ }
+ }
+
+ protected void setupPriorityPref(boolean priority) {
+ mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mPriority.setChecked(priority);
+ mPriority.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean bypassZenMode = (Boolean) newValue;
+ mChannel.setBypassDnd(bypassZenMode);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_PRIORITY);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ return true;
+ }
+ });
+ }
+
+ protected void setupVisOverridePref(int sensitive) {
+ ArrayList<CharSequence> entries = new ArrayList<>();
+ ArrayList<CharSequence> values = new ArrayList<>();
+
+ mVisibilityOverride.clearRestrictedItems();
+ if (getLockscreenNotificationsEnabled() && getLockscreenAllowPrivateNotifications()) {
+ final String summaryShowEntry =
+ getString(R.string.lock_screen_notifications_summary_show);
+ final String summaryShowEntryValue =
+ Integer.toString(NotificationManager.VISIBILITY_NO_OVERRIDE);
+ entries.add(summaryShowEntry);
+ values.add(summaryShowEntryValue);
+ setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue,
+ DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
+ | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
+ }
+
+ final String summaryHideEntry = getString(R.string.lock_screen_notifications_summary_hide);
+ final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
+ entries.add(summaryHideEntry);
+ values.add(summaryHideEntryValue);
+ setRestrictedIfNotificationFeaturesDisabled(summaryHideEntry, summaryHideEntryValue,
+ DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
+ entries.add(getString(R.string.lock_screen_notifications_summary_disable));
+ values.add(Integer.toString(Notification.VISIBILITY_SECRET));
+ mVisibilityOverride.setEntries(entries.toArray(new CharSequence[entries.size()]));
+ mVisibilityOverride.setEntryValues(values.toArray(new CharSequence[values.size()]));
+
+ if (sensitive == Ranking.VISIBILITY_NO_OVERRIDE) {
+ mVisibilityOverride.setValue(Integer.toString(getGlobalVisibility()));
+ } else {
+ mVisibilityOverride.setValue(Integer.toString(sensitive));
+ }
+ mVisibilityOverride.setSummary("%s");
+
+ mVisibilityOverride.setOnPreferenceChangeListener(
+ new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ int sensitive = Integer.parseInt((String) newValue);
+ if (sensitive == getGlobalVisibility()) {
+ sensitive = Ranking.VISIBILITY_NO_OVERRIDE;
+ }
+ mChannel.setLockscreenVisibility(sensitive);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ return true;
+ }
+ });
+ }
+
+ private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
+ CharSequence entryValue, int keyguardNotificationFeatures) {
+ RestrictedLockUtils.EnforcedAdmin admin =
+ RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
+ mContext, keyguardNotificationFeatures, mUserId);
+ if (admin != null) {
+ RestrictedDropDownPreference.RestrictedItem item =
+ new RestrictedDropDownPreference.RestrictedItem(entry, entryValue, admin);
+ mVisibilityOverride.addRestrictedItem(item);
+ }
+ }
+
+ private int getGlobalVisibility() {
+ int globalVis = Ranking.VISIBILITY_NO_OVERRIDE;
+ if (!getLockscreenNotificationsEnabled()) {
+ globalVis = Notification.VISIBILITY_SECRET;
+ } else if (!getLockscreenAllowPrivateNotifications()) {
+ globalVis = Notification.VISIBILITY_PRIVATE;
+ }
+ return globalVis;
+ }
+
+ private boolean getLockscreenNotificationsEnabled() {
+ return Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
+ }
+
+ private boolean getLockscreenAllowPrivateNotifications() {
+ return Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
+ }
+
+ private boolean isLockScreenSecure() {
+ LockPatternUtils utils = new LockPatternUtils(getActivity());
+ boolean lockscreenSecure = utils.isSecure(UserHandle.myUserId());
+ UserInfo parentUser = mUm.getProfileParent(UserHandle.myUserId());
+ if (parentUser != null){
+ lockscreenSecure |= utils.isSecure(parentUser.id);
+ }
+
+ return lockscreenSecure;
+ }
+
+ protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
+ if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) {
+ return true;
+ }
+ return importance >= minImportanceVisible;
+ }
+
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference instanceof RingtonePreference) {
@@ -205,22 +419,24 @@
Settings.System.NOTIFICATION_LIGHT_PULSE, 0) == 1;
}
- @Override
- protected void updateDependents(int importance) {
- if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) {
- importance = mMaxImportance;
- }
- importance = Math.min(mMaxImportance, importance);
-
- super.updateDependents(importance);
- setVisible(mLights, checkCanBeVisible(
+ private void updateDependents() {
+ boolean allowed = mChannel.isAllowed();
+ int importance = mChannel.getImportance();
+ setVisible(mShow, allowed);
+ setVisible(mBadge, allowed);
+ setVisible(mImportance, allowed && importance != NotificationManager.IMPORTANCE_NONE);
+ setVisible(mLights, allowed && checkCanBeVisible(
NotificationManager.IMPORTANCE_LOW, importance) && canPulseLight());
- setVisible(mVibrate, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance));
- setVisible(mRingtone, checkCanBeVisible(
+ setVisible(mVibrate, allowed
+ && checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance));
+ setVisible(mRingtone, allowed && checkCanBeVisible(
NotificationManager.IMPORTANCE_DEFAULT, importance));
- if (mMaxImportance == NotificationManager.IMPORTANCE_LOW
- && getPreferenceScreen().findPreference(mBlock.getKey()) != null) {
- setVisible(mSilent, false);
- }
+ setVisible(mPriority, allowed
+ && (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance)
+ || (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW, importance)
+ && mDndVisualEffectsSuppressed)));
+ setVisible(mVisibilityOverride, allowed
+ && checkCanBeVisible(NotificationManager.IMPORTANCE_MIN, importance)
+ && isLockScreenSecure());
}
}
diff --git a/src/com/android/settings/notification/ImportanceSeekBarPreference.java b/src/com/android/settings/notification/ImportanceSeekBarPreference.java
deleted file mode 100644
index 568dc1c..0000000
--- a/src/com/android/settings/notification/ImportanceSeekBarPreference.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import com.android.settings.R;
-import com.android.settings.SeekBarPreference;
-
-import android.app.NotificationManager;
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.service.notification.NotificationListenerService;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import com.android.settings.Utils;
-
-/**
- * A slider preference that controls notification importance.
- **/
-public class ImportanceSeekBarPreference extends SeekBarPreference implements
- SeekBar.OnSeekBarChangeListener {
- private static final String TAG = "ImportanceSeekBarPref";
-
- private Callback mCallback;
- private int mMinProgress;
- private TextView mSummaryTextView;
- private String mSummary;
- private SeekBar mSeekBar;
- private ColorStateList mActiveSliderTint;
- private ColorStateList mInactiveSliderTint;
- private float mActiveSliderAlpha = 1.0f;
- private float mInactiveSliderAlpha;
- private boolean mAutoOn;
- private Handler mHandler;
-
- public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
- int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- setLayoutResource(R.layout.preference_importance_slider);
- mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(context));
- mInactiveSliderTint = ColorStateList.valueOf(
- context.getColor(R.color.importance_disabled_slider_color));
- mHandler = new Handler();
- final TypedArray ta =
- context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Theme, 0, 0);
- mInactiveSliderAlpha =
- ta.getFloat(com.android.internal.R.styleable.Theme_disabledAlpha, 0.5f);
- ta.recycle();
- }
-
- public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
- this(context, attrs, defStyleAttr, 0);
- }
-
- public ImportanceSeekBarPreference(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public ImportanceSeekBarPreference(Context context) {
- this(context, null);
- }
-
- public void setCallback(Callback callback) {
- mCallback = callback;
- }
-
- public void setMinimumProgress(int minProgress) {
- mMinProgress = minProgress;
- notifyChanged();
- }
-
- @Override
- public void setProgress(int progress) {
- mSummary = getProgressSummary(progress);
- super.setProgress(progress);
- }
-
- public void setAutoOn(boolean autoOn) {
- mAutoOn = autoOn;
- notifyChanged();
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder view) {
- super.onBindViewHolder(view);
- mSummaryTextView = (TextView) view.findViewById(com.android.internal.R.id.summary);
- mSeekBar = (SeekBar) view.findViewById(
- com.android.internal.R.id.seekbar);
-
- final ImageView autoButton = (ImageView) view.findViewById(R.id.auto_importance);
- applyAutoUi(autoButton);
- autoButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- applyAuto(autoButton);
- }
- });
- }
-
- private void applyAuto(ImageView autoButton) {
- mAutoOn = !mAutoOn;
- if (!mAutoOn) {
- setProgress(NotificationManager.IMPORTANCE_DEFAULT);
- mCallback.onImportanceChanged(NotificationManager.IMPORTANCE_DEFAULT, true);
- } else {
- mCallback.onImportanceChanged(NotificationManager.IMPORTANCE_UNSPECIFIED, true);
- }
- applyAutoUi(autoButton);
- }
-
- private void applyAutoUi(ImageView autoButton) {
- mSeekBar.setEnabled(!mAutoOn);
-
- final float alpha = mAutoOn ? mInactiveSliderAlpha : mActiveSliderAlpha;
- final ColorStateList starTint = mAutoOn ? mActiveSliderTint : mInactiveSliderTint;
- Drawable icon = autoButton.getDrawable().mutate();
- icon.setTintList(starTint);
- autoButton.setImageDrawable(icon);
- mSeekBar.setAlpha(alpha);
-
- if (mAutoOn) {
- setProgress(NotificationManager.IMPORTANCE_DEFAULT);
- mSummary = getProgressSummary(NotificationManager.IMPORTANCE_UNSPECIFIED);
- }
- mSummaryTextView.setText(mSummary);
- }
-
- @Override
- public CharSequence getSummary() {
- return mSummary;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
- super.onProgressChanged(seekBar, progress, fromTouch);
- if (progress < mMinProgress) {
- seekBar.setProgress(mMinProgress);
- progress = mMinProgress;
- }
- if (mSummaryTextView != null) {
- mSummary = getProgressSummary(progress);
- mSummaryTextView.setText(mSummary);
- }
- mCallback.onImportanceChanged(progress, fromTouch);
- }
-
- private String getProgressSummary(int progress) {
- switch (progress) {
- case NotificationManager.IMPORTANCE_NONE:
- return getContext().getString(R.string.notification_importance_blocked);
- case NotificationManager.IMPORTANCE_MIN:
- return getContext().getString(R.string.notification_importance_min);
- case NotificationManager.IMPORTANCE_LOW:
- return getContext().getString(R.string.notification_importance_low);
- case NotificationManager.IMPORTANCE_DEFAULT:
- return getContext().getString(R.string.notification_importance_default);
- case NotificationManager.IMPORTANCE_HIGH:
- case NotificationManager.IMPORTANCE_MAX:
- return getContext().getString(R.string.notification_importance_high);
- default:
- return getContext().getString(R.string.notification_importance_unspecified);
- }
- }
-
- @Override
- protected void notifyChanged() {
- mHandler.post(mNotifyChanged);
- }
-
- private void postNotifyChanged() {
- super.notifyChanged();
- }
-
- private final Runnable mNotifyChanged = new Runnable() {
- @Override
- public void run() {
- postNotifyChanged();
- }
- };
-
- public interface Callback {
- void onImportanceChanged(int progress, boolean fromTouch);
- }
-}
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 5d69203..4013971 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -16,7 +16,6 @@
package com.android.settings.notification;
import android.app.INotificationManager;
-import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
@@ -27,11 +26,8 @@
import android.content.pm.ParceledListSlice;
import android.graphics.drawable.Drawable;
import android.os.ServiceManager;
-import android.os.UserHandle;
-import android.service.notification.NotificationListenerService;
import android.util.Log;
-import com.android.internal.widget.LockPatternUtils;
import com.android.settingslib.Utils;
public class NotificationBackend {
@@ -52,11 +48,6 @@
}
row.icon = app.loadIcon(pm);
row.banned = getNotificationsBanned(row.pkg, row.uid);
- row.appImportance = getImportance(row.pkg, row.uid);
- row.appBypassDnd = getBypassZenMode(row.pkg, row.uid);
- row.appVisOverride = getVisibilityOverride(row.pkg, row.uid);
- row.lockScreenSecure = new LockPatternUtils(context).isSecure(
- UserHandle.myUserId());
return row;
}
@@ -86,19 +77,9 @@
}
}
- public boolean getBypassZenMode(String pkg, int uid) {
+ public boolean setNotificationsEnabledForPackage(String pkg, int uid, boolean enabled) {
try {
- return sINM.getPriority(pkg, uid) == Notification.PRIORITY_MAX;
- } catch (Exception e) {
- Log.w(TAG, "Error calling NoMan", e);
- return false;
- }
- }
-
- public boolean setBypassZenMode(String pkg, int uid, boolean bypassZen) {
- try {
- sINM.setPriority(pkg, uid,
- bypassZen ? Notification.PRIORITY_MAX : Notification.PRIORITY_DEFAULT);
+ sINM.setNotificationsEnabledForPackage(pkg, uid, enabled);
return true;
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
@@ -106,44 +87,6 @@
}
}
- public int getVisibilityOverride(String pkg, int uid) {
- try {
- return sINM.getVisibilityOverride(pkg, uid);
- } catch (Exception e) {
- Log.w(TAG, "Error calling NoMan", e);
- return NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE;
- }
- }
-
- public boolean setVisibilityOverride(String pkg, int uid, int override) {
- try {
- sINM.setVisibilityOverride(pkg, uid, override);
- return true;
- } catch (Exception e) {
- Log.w(TAG, "Error calling NoMan", e);
- return false;
- }
- }
-
- public boolean setImportance(String pkg, int uid, int importance) {
- try {
- sINM.setImportance(pkg, uid, importance);
- return true;
- } catch (Exception e) {
- Log.w(TAG, "Error calling NoMan", e);
- return false;
- }
- }
-
- public int getImportance(String pkg, int uid) {
- try {
- return sINM.getImportance(pkg, uid);
- } catch (Exception e) {
- Log.w(TAG, "Error calling NoMan", e);
- return NotificationManager.IMPORTANCE_UNSPECIFIED;
- }
- }
-
public NotificationChannel getChannel(String pkg, int uid, String channelId) {
if (channelId == null) {
return null;
@@ -186,10 +129,6 @@
public boolean banned;
public boolean first; // first app in section
public boolean systemApp;
- public int appImportance;
- public boolean appBypassDnd;
- public int appVisOverride;
- public boolean lockScreenSecure;
}
public static class ChannelRow extends AppRow {
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 5d6f598..046c5e6 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -51,15 +51,10 @@
abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
private static final String TAG = "NotifiSettingsBase";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- private static final String TUNER_SETTING = "show_importance_slider";
protected static final String ARG_CHANNEL = "channel";
- protected static final String KEY_BYPASS_DND = "bypass_dnd";
- protected static final String KEY_VISIBILITY_OVERRIDE = "visibility_override";
- protected static final String KEY_IMPORTANCE = "importance";
protected static final String KEY_BLOCK = "block";
- protected static final String KEY_SILENT = "silent";
protected PackageManager mPm;
protected UserManager mUm;
@@ -70,13 +65,10 @@
protected int mUserId;
protected String mPkg;
protected PackageInfo mPkgInfo;
- protected ImportanceSeekBarPreference mImportance;
- protected RestrictedSwitchPreference mPriority;
- protected RestrictedDropDownPreference mVisibilityOverride;
protected RestrictedSwitchPreference mBlock;
- protected RestrictedSwitchPreference mSilent;
+ protected RestrictedSwitchPreference mShow;
+ protected RestrictedSwitchPreference mBadge;
protected EnforcedAdmin mSuspendedAppsAdmin;
- protected boolean mShowSlider = false;
protected boolean mDndVisualEffectsSuppressed;
protected NotificationChannel mChannel;
@@ -138,7 +130,6 @@
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
mContext, mPkg, mUserId);
- mShowSlider = Settings.Secure.getInt(getContentResolver(), TUNER_SETTING, 0) == 1;
NotificationManager.Policy policy =
NotificationManager.from(mContext).getNotificationPolicy();
mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
@@ -154,237 +145,7 @@
}
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
mContext, mPkg, mUserId);
- if (mImportance != null) {
- mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- if (mPriority != null) {
- mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- if (mBlock != null) {
- mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- if (mSilent != null) {
- mSilent.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- if (mVisibilityOverride != null) {
- mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- }
-
- protected void setupImportancePrefs(boolean notBlockable, int importance, boolean banned,
- int maxImportance) {
- if (mShowSlider) {
- setVisible(mBlock, false);
- setVisible(mSilent, false);
- mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
- mImportance.setMinimumProgress(
- notBlockable ? NotificationManager.IMPORTANCE_MIN
- : NotificationManager.IMPORTANCE_NONE);
- mImportance.setMax(maxImportance);
- mImportance.setProgress(Math.min(importance, maxImportance));
- mImportance.setAutoOn(importance == NotificationManager.IMPORTANCE_UNSPECIFIED);
- mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
- @Override
- public void onImportanceChanged(int progress, boolean fromUser) {
- if (fromUser) {
- if (mChannel != null) {
- mChannel.setImportance(progress);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- } else {
- mBackend.setImportance(mPkg, mUid, progress);
- }
- }
- updateDependents(progress);
- }
- });
- } else {
- setVisible(mImportance, false);
- if (notBlockable) {
- setVisible(mBlock, false);
- } else {
- mBlock.setChecked(banned);
- mBlock.setOnPreferenceChangeListener(
- new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference,
- Object newValue) {
- final boolean blocked = (Boolean) newValue;
- final int importance = blocked
- ? NotificationManager.IMPORTANCE_NONE
- : NotificationManager.IMPORTANCE_UNSPECIFIED;
- if (mChannel != null) {
- mChannel.setImportance(importance);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- } else {
- mBackend.setImportance(mPkgInfo.packageName, mUid,
- importance);
- }
- updateDependents(importance);
- return true;
- }
- });
- }
- // app silenced; cannot un-silence a channel
- if (maxImportance == NotificationManager.IMPORTANCE_LOW) {
- setVisible(mSilent, false);
- updateDependents(banned ? NotificationManager.IMPORTANCE_NONE
- : NotificationManager.IMPORTANCE_LOW);
- } else {
- mSilent.setChecked(importance == NotificationManager.IMPORTANCE_LOW);
- mSilent.setOnPreferenceChangeListener(
- new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference,
- Object newValue) {
- final boolean silenced = (Boolean) newValue;
- final int importance = silenced
- ? NotificationManager.IMPORTANCE_LOW
- : NotificationManager.IMPORTANCE_UNSPECIFIED;
- if (mChannel != null) {
- mChannel.setImportance(importance);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- } else {
- mBackend.setImportance(mPkgInfo.packageName, mUid,
- importance);
- }
- updateDependents(importance);
- return true;
- }
- });
- updateDependents(banned ? NotificationManager.IMPORTANCE_NONE : importance);
- }
- }
- }
-
- protected void setupPriorityPref(boolean priority) {
- mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
- mPriority.setChecked(priority);
- mPriority.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- final boolean bypassZenMode = (Boolean) newValue;
- if (mChannel != null) {
- mChannel.setBypassDnd(bypassZenMode);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_PRIORITY);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- return true;
- } else {
- return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, bypassZenMode);
- }
- }
- });
- }
-
- protected void setupVisOverridePref(int sensitive) {
- ArrayList<CharSequence> entries = new ArrayList<>();
- ArrayList<CharSequence> values = new ArrayList<>();
-
- mVisibilityOverride.clearRestrictedItems();
- if (getLockscreenNotificationsEnabled() && getLockscreenAllowPrivateNotifications()) {
- final String summaryShowEntry =
- getString(R.string.lock_screen_notifications_summary_show);
- final String summaryShowEntryValue =
- Integer.toString(NotificationManager.VISIBILITY_NO_OVERRIDE);
- entries.add(summaryShowEntry);
- values.add(summaryShowEntryValue);
- setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue,
- DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
- | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
- }
-
- final String summaryHideEntry = getString(R.string.lock_screen_notifications_summary_hide);
- final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
- entries.add(summaryHideEntry);
- values.add(summaryHideEntryValue);
- setRestrictedIfNotificationFeaturesDisabled(summaryHideEntry, summaryHideEntryValue,
- DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
- entries.add(getString(R.string.lock_screen_notifications_summary_disable));
- values.add(Integer.toString(Notification.VISIBILITY_SECRET));
- mVisibilityOverride.setEntries(entries.toArray(new CharSequence[entries.size()]));
- mVisibilityOverride.setEntryValues(values.toArray(new CharSequence[values.size()]));
-
- if (sensitive == Ranking.VISIBILITY_NO_OVERRIDE) {
- mVisibilityOverride.setValue(Integer.toString(getGlobalVisibility()));
- } else {
- mVisibilityOverride.setValue(Integer.toString(sensitive));
- }
- mVisibilityOverride.setSummary("%s");
-
- mVisibilityOverride.setOnPreferenceChangeListener(
- new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- int sensitive = Integer.parseInt((String) newValue);
- if (sensitive == getGlobalVisibility()) {
- sensitive = Ranking.VISIBILITY_NO_OVERRIDE;
- }
- if (mChannel != null) {
- mChannel.setLockscreenVisibility(sensitive);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- } else {
- mBackend.setVisibilityOverride(mPkgInfo.packageName, mUid, sensitive);
- }
- return true;
- }
- });
- }
-
- private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
- CharSequence entryValue, int keyguardNotificationFeatures) {
- EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
- mContext, keyguardNotificationFeatures, mUserId);
- if (admin != null) {
- RestrictedItem item = new RestrictedItem(entry, entryValue, admin);
- mVisibilityOverride.addRestrictedItem(item);
- }
- }
-
- private int getGlobalVisibility() {
- int globalVis = Ranking.VISIBILITY_NO_OVERRIDE;
- if (!getLockscreenNotificationsEnabled()) {
- globalVis = Notification.VISIBILITY_SECRET;
- } else if (!getLockscreenAllowPrivateNotifications()) {
- globalVis = Notification.VISIBILITY_PRIVATE;
- }
- return globalVis;
- }
-
- private boolean getLockscreenNotificationsEnabled() {
- return Settings.Secure.getInt(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
- }
-
- private boolean getLockscreenAllowPrivateNotifications() {
- return Settings.Secure.getInt(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
- }
-
- private boolean isLockScreenSecure() {
- LockPatternUtils utils = new LockPatternUtils(getActivity());
- boolean lockscreenSecure = utils.isSecure(UserHandle.myUserId());
- UserInfo parentUser = mUm.getProfileParent(UserHandle.myUserId());
- if (parentUser != null){
- lockscreenSecure |= utils.isSecure(parentUser.id);
- }
-
- return lockscreenSecure;
- }
-
- protected void updateDependents(int importance) {
- if (getPreferenceScreen().findPreference(mBlock.getKey()) != null) {
- setVisible(mSilent, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN, importance));
- mSilent.setChecked(importance == NotificationManager.IMPORTANCE_LOW);
- }
- setVisible(mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance)
- || (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW, importance)
- && mDndVisualEffectsSuppressed));
- setVisible(mVisibilityOverride,
- checkCanBeVisible(NotificationManager.IMPORTANCE_MIN, importance)
- && isLockScreenSecure());
+ mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
}
protected void setVisible(Preference p, boolean visible) {
@@ -397,13 +158,6 @@
}
}
- protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
- if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) {
- return true;
- }
- return importance >= minImportanceVisible;
- }
-
protected void toastAndFinish() {
Toast.makeText(mContext, R.string.app_not_found_dlg_text, Toast.LENGTH_SHORT).show();
getActivity().finish();
diff --git a/src/com/android/settings/overlay/SupportFeatureProvider.java b/src/com/android/settings/overlay/SupportFeatureProvider.java
index 24ec7b5..0f8d424 100644
--- a/src/com/android/settings/overlay/SupportFeatureProvider.java
+++ b/src/com/android/settings/overlay/SupportFeatureProvider.java
@@ -21,9 +21,11 @@
import android.annotation.NonNull;
import android.annotation.StringRes;
import android.app.Activity;
+import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
+import android.os.Bundle;
import com.android.settings.support.SupportPhone;
import java.lang.annotation.Retention;
@@ -142,8 +144,13 @@
Intent getTipsAndTricksIntent(Context context);
/**
- * Returns the string for the disclaimer in the Support dialog
+ * Returns the string for the disclaimer in the Support dialog.
*/
@StringRes
int getDisclaimerStringResId();
+
+ /**
+ * launches the fragment that displays the system information being sent to support agents.
+ */
+ void launchSystemInfoFragment(Bundle args, FragmentManager manager);
}
diff --git a/src/com/android/settings/search2/CursorToSearchResultConverter.java b/src/com/android/settings/search2/CursorToSearchResultConverter.java
new file mode 100644
index 0000000..3d29323
--- /dev/null
+++ b/src/com/android/settings/search2/CursorToSearchResultConverter.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.search2;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.database.Cursor;
+import android.graphics.drawable.Drawable;
+import android.os.BadParcelableException;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
+import com.android.settings.search.Index;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_RANK;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_TITLE;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_SUMMARY_ON;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_CLASS_NAME;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_ICON;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_INTENT_ACTION;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_KEY;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_PAYLOAD_TYPE;
+import static com.android.settings.search2.DatabaseResultLoader.COLUMN_INDEX_PAYLOAD;
+
+/**
+ * Controller to Build search results from {@link Cursor} Objects.
+ *
+ * Each converted {@link Cursor} has the following fields:
+ * - String Title
+ * - String Summary
+ * - int rank
+ * - {@link Drawable} icon
+ * - {@link ResultPayload} payload
+ */
+class CursorToSearchResultConverter {
+
+ private final String TAG = "CursorConverter";
+
+ private final Context mContext;
+
+ public CursorToSearchResultConverter(Context context) {
+ mContext = context;
+ }
+
+ public List<SearchResult> convertCursor(Cursor cursorResults) {
+ if (cursorResults == null) {
+ return null;
+ }
+ final Map<String, Context> contextMap = new HashMap<>();
+ final ArrayList<SearchResult> results = new ArrayList<>();
+
+ while (cursorResults.moveToNext()) {
+ SearchResult result = buildSingleSearchResultFromCursor(contextMap, cursorResults);
+ if (result != null) {
+ results.add(result);
+ }
+ }
+ Collections.sort(results);
+ return results;
+ }
+
+ private SearchResult buildSingleSearchResultFromCursor(Map<String, Context> contextMap,
+ Cursor cursor) {
+ final String pkgName = cursor.getString(COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE);
+ final String action = cursor.getString(COLUMN_INDEX_INTENT_ACTION);
+ final String title = cursor.getString(COLUMN_INDEX_TITLE);
+ final String summaryOn = cursor.getString(COLUMN_INDEX_SUMMARY_ON);
+ final String className = cursor.getString(COLUMN_INDEX_CLASS_NAME);
+ final int rank = cursor.getInt(COLUMN_INDEX_RANK);
+ final String key = cursor.getString(COLUMN_INDEX_KEY);
+ final String iconResStr = cursor.getString(COLUMN_INDEX_ICON);
+ final int payloadType = cursor.getInt(COLUMN_INDEX_PAYLOAD_TYPE);
+ final byte[] marshalledPayload = cursor.getBlob(COLUMN_INDEX_PAYLOAD);
+ final ResultPayload payload;
+
+ if (marshalledPayload != null) {
+ payload = getUnmarshalledPayload(marshalledPayload, payloadType);
+ } else if (payloadType == ResultPayload.PayloadType.INTENT) {
+ payload = getIntentPayload(cursor, action, key, className, pkgName);
+ } else {
+ Log.w(TAG, "Error creating payload - bad marshalling data or mismatched types");
+ return null;
+ }
+
+ final SearchResult.Builder builder = new SearchResult.Builder();
+ builder.addTitle(title)
+ .addSummary(summaryOn)
+ .addRank(rank)
+ .addIcon(getIconForPackage(contextMap, pkgName, className, iconResStr))
+ .addPayload(payload);
+ return builder.build();
+ }
+
+ private Drawable getIconForPackage(Map<String, Context> contextMap, String pkgName,
+ String className, String iconResStr) {
+ final int iconId = TextUtils.isEmpty(iconResStr)
+ ? 0 : Integer.parseInt(iconResStr);
+ Drawable icon;
+ Context packageContext;
+ if (iconId == 0) {
+ icon = null;
+ } else {
+ if (TextUtils.isEmpty(className) && !TextUtils.isEmpty(pkgName)) {
+ packageContext = contextMap.get(pkgName);
+ if (packageContext == null) {
+ try {
+ packageContext = mContext.createPackageContext(pkgName, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Cannot create Context for package: " + pkgName);
+ return null;
+ }
+ contextMap.put(pkgName, packageContext);
+ }
+ } else {
+ packageContext = mContext;
+ }
+ try {
+ icon = packageContext.getDrawable(iconId);
+ } catch (Resources.NotFoundException nfe) {
+ icon = null;
+ }
+ }
+ return icon;
+ }
+
+ private IntentPayload getIntentPayload(Cursor cursor, String action, String key,
+ String className, String pkgName ) {
+ IntentPayload payload;
+ if (TextUtils.isEmpty(action)) {
+ final String screenTitle = cursor.getString(Index.COLUMN_INDEX_SCREEN_TITLE);
+ // Action is null, we will launch it as a sub-setting
+ final Bundle args = new Bundle();
+ args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
+ final Intent intent = Utils.onBuildStartFragmentIntent(mContext,
+ className, args, null, 0, screenTitle, false);
+ payload = new IntentPayload(intent);
+ } else {
+ final Intent intent = new Intent(action);
+ final String targetClass = cursor.getString(
+ Index.COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS);
+ if (!TextUtils.isEmpty(pkgName) && !TextUtils.isEmpty(targetClass)) {
+ final ComponentName component = new ComponentName(pkgName, targetClass);
+ intent.setComponent(component);
+ }
+ intent.putExtra(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
+ payload = new IntentPayload(intent);
+ }
+ return payload;
+ }
+
+ private ResultPayload getUnmarshalledPayload(byte[] unmarshalledPayload, int payloadType) {
+ try {
+ switch (payloadType) {
+ case ResultPayload.PayloadType.INLINE_SWITCH:
+ return ResultPayloadUtils.unmarshall(unmarshalledPayload,
+ InlineSwitchPayload.CREATOR);
+ }
+ } catch (BadParcelableException e) {
+ Log.w(TAG, "Error creating parcelable: " + e);
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/settings/search2/DatabaseIndexingUtils.java b/src/com/android/settings/search2/DatabaseIndexingUtils.java
index c7a7f92..9fdf732 100644
--- a/src/com/android/settings/search2/DatabaseIndexingUtils.java
+++ b/src/com/android/settings/search2/DatabaseIndexingUtils.java
@@ -66,6 +66,10 @@
*/
public static Map<String, PreferenceController> getPreferenceControllerUriMap(
String className, Context context) {
+ if (context == null) {
+ return null;
+ }
+
final Class<?> clazz = getIndexableClass(className);
if (clazz == null) {
@@ -77,6 +81,7 @@
// Will be non null only for a Local provider implementing a
// SEARCH_INDEX_DATA_PROVIDER field
final Indexable.SearchIndexProvider provider = getSearchIndexProvider(clazz);
+
List<PreferenceController> controllers =
provider.getPreferenceControllers(context);
@@ -94,8 +99,9 @@
}
/**
- * @param uriMap Map between the {@link PreferenceController} keys and the controllers themselves.
- * @param key The look up key
+ * @param uriMap Map between the {@link PreferenceController} keys
+ * and the controllers themselves.
+ * @param key The look-up key
* @return The Payload from the {@link PreferenceController} specified by the key, if it exists.
* Otherwise null.
*/
@@ -135,15 +141,13 @@
} catch (NoSuchFieldException e) {
Log.d(TAG, "Cannot find field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'");
} catch (SecurityException se) {
- Log.d(TAG,
- "Security exception for field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'");
+ Log.d(TAG, "Security exception for field '" +
+ FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'");
} catch (IllegalAccessException e) {
- Log.d(TAG,
- "Illegal access to field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'");
+ Log.d(TAG, "Illegal access to field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'");
} catch (IllegalArgumentException e) {
- Log.d(TAG,
- "Illegal argument when accessing field '" +
- FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'");
+ Log.d(TAG, "Illegal argument when accessing field '" +
+ FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'");
}
return null;
}
diff --git a/src/com/android/settings/search2/DatabaseResultLoader.java b/src/com/android/settings/search2/DatabaseResultLoader.java
index b268f6a..201d76f 100644
--- a/src/com/android/settings/search2/DatabaseResultLoader.java
+++ b/src/com/android/settings/search2/DatabaseResultLoader.java
@@ -48,14 +48,36 @@
public class DatabaseResultLoader extends AsyncLoader<List<SearchResult>> {
private static final String LOG = "DatabaseResultLoader";
private final String mQueryText;
- private final Context mContext;
+
protected final SQLiteDatabase mDatabase;
+ private final CursorToSearchResultConverter mConverter;
+
+ /* These indices are used to match the columns of the this loader's SELECT statement.
+ These are not necessarily the same order or coverage as the schema defined in
+ IndexDatabaseHelper */
+ public static final int COLUMN_INDEX_RANK = 0;
+ public static final int COLUMN_INDEX_TITLE = 1;
+ public static final int COLUMN_INDEX_SUMMARY_ON = 2;
+ public static final int COLUMN_INDEX_SUMMARY_OFF = 3;
+ public static final int COLUMN_INDEX_ENTRIES = 4;
+ public static final int COLUMN_INDEX_KEYWORDS = 5;
+ public static final int COLUMN_INDEX_CLASS_NAME = 6;
+ public static final int COLUMN_INDEX_SCREEN_TITLE = 7;
+ public static final int COLUMN_INDEX_ICON = 8;
+ public static final int COLUMN_INDEX_INTENT_ACTION = 9;
+ public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 10;
+ public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS = 11;
+ public static final int COLUMN_INDEX_ENABLED = 12;
+ public static final int COLUMN_INDEX_KEY = 13;
+ public static final int COLUMN_INDEX_PAYLOAD_TYPE = 14;
+ public static final int COLUMN_INDEX_PAYLOAD = 15;
+
public DatabaseResultLoader(Context context, String queryText) {
super(context);
mDatabase = IndexDatabaseHelper.getInstance(context).getReadableDatabase();
mQueryText = queryText;
- mContext = context;
+ mConverter = new CursorToSearchResultConverter(context);
}
@Override
@@ -72,7 +94,7 @@
String query = getSQLQuery();
Cursor result = mDatabase.rawQuery(query, null);
- return parseCursorForSearch(result);
+ return mConverter.convertCursor(result);
}
@Override
@@ -86,100 +108,12 @@
"data_summary_off, data_entries, data_keywords, class_name, screen_title,"
+ " icon, " +
"intent_action, intent_target_package, intent_target_class, enabled, " +
- "data_key_reference FROM prefs_index WHERE prefs_index MATCH "
+ "data_key_reference, payload_type, payload FROM prefs_index WHERE prefs_index MATCH "
+ "'data_title:%s* " +
"OR data_title_normalized:%s* OR data_keywords:%s*' AND locale = 'en_US'",
mQueryText, mQueryText, mQueryText);
}
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- public ArrayList<SearchResult> parseCursorForSearch(Cursor cursorResults) {
- if (cursorResults == null) {
- return null;
- }
- final Map<String, Context> contextMap = new HashMap<>();
- final ArrayList<SearchResult> results = new ArrayList<>();
- while (cursorResults.moveToNext()) {
- SearchResult result = buildSingleSearchResultFromCursor(contextMap, cursorResults);
- if (result != null) {
- results.add(result);
- }
- }
- Collections.sort(results);
- return results;
- }
-
- private SearchResult buildSingleSearchResultFromCursor(Map<String, Context> contextMap,
- Cursor cursor) {
- final String pkgName = cursor.getString(Index.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE);
- final String action = cursor.getString(Index.COLUMN_INDEX_INTENT_ACTION);
- final String title = cursor.getString(Index.COLUMN_INDEX_TITLE);
- final String summaryOn = cursor.getString(Index.COLUMN_INDEX_SUMMARY_ON);
- final String className = cursor.getString(Index.COLUMN_INDEX_CLASS_NAME);
- final int rank = cursor.getInt(Index.COLUMN_INDEX_RANK);
- final String key = cursor.getString(Index.COLUMN_INDEX_KEY);
- final String iconResStr = cursor.getString(Index.COLUMN_INDEX_ICON);
-
- final ResultPayload payload;
- if (TextUtils.isEmpty(action)) {
- final String screenTitle = cursor.getString(Index.COLUMN_INDEX_SCREEN_TITLE);
- // Action is null, we will launch it as a sub-setting
- final Bundle args = new Bundle();
- args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
- final Intent intent = Utils.onBuildStartFragmentIntent(mContext,
- className, args, null, 0, screenTitle, false);
- payload = new IntentPayload(intent);
- } else {
- final Intent intent = new Intent(action);
- final String targetClass = cursor.getString(
- Index.COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS);
- if (!TextUtils.isEmpty(pkgName) && !TextUtils.isEmpty(targetClass)) {
- final ComponentName component = new ComponentName(pkgName, targetClass);
- intent.setComponent(component);
- }
- intent.putExtra(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
- payload = new IntentPayload(intent);
- }
- SearchResult.Builder builder = new SearchResult.Builder();
- builder.addTitle(title)
- .addSummary(summaryOn)
- .addRank(rank)
- .addIcon(getIconForPackage(contextMap, pkgName, className, iconResStr))
- .addPayload(payload);
- return builder.build();
- }
-
- private Drawable getIconForPackage(Map<String, Context> contextMap, String pkgName,
- String className, String iconResStr) {
- final int iconId = TextUtils.isEmpty(iconResStr)
- ? 0 : Integer.parseInt(iconResStr);
- Drawable icon;
- Context packageContext;
- if (iconId == 0) {
- icon = null;
- } else {
- if (TextUtils.isEmpty(className) && !TextUtils.isEmpty(pkgName)) {
- packageContext = contextMap.get(pkgName);
- if (packageContext == null) {
- try {
- packageContext = mContext.createPackageContext(pkgName, 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG, "Cannot create Context for package: " + pkgName);
- return null;
- }
- contextMap.put(pkgName, packageContext);
- }
- } else {
- packageContext = mContext;
- }
- try {
- icon = packageContext.getDrawable(iconId);
- } catch (Resources.NotFoundException nfe) {
- icon = null;
- }
- }
- return icon;
- }
}
diff --git a/src/com/android/settings/search2/InlinePayload.java b/src/com/android/settings/search2/InlinePayload.java
new file mode 100644
index 0000000..4b1c168
--- /dev/null
+++ b/src/com/android/settings/search2/InlinePayload.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.search2;
+
+/**
+ * Abstract Payload for inline settings results.
+ */
+public abstract class InlinePayload extends ResultPayload {
+ /**
+ * Defines the URI to access and store the Setting the inline result represents
+ */
+ public String settingsUri;
+
+ /**
+ * The UI type for the inline result.
+ */
+ @PayloadType public int inlineType;
+
+ /**
+ * Defines where the Setting is stored.
+ */
+ @SettingsSource public int settingSource;
+
+ public InlinePayload(String uri, @PayloadType int type, @SettingsSource int source) {
+ settingsUri = uri;
+ inlineType = type;
+ settingSource = source;
+ }
+}
diff --git a/src/com/android/settings/search2/InlineSliderPayload.java b/src/com/android/settings/search2/InlineSliderPayload.java
deleted file mode 100644
index 8f08d59..0000000
--- a/src/com/android/settings/search2/InlineSliderPayload.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.search2;
-
-import android.net.Uri;
-import android.os.Parcel;
-
-/**
- * Payload for Inline Settings results represented by a Slider.
- */
-public class InlineSliderPayload extends ResultPayload {
- public final Uri uri;
-
- private InlineSliderPayload(Parcel in) {
- uri = in.readParcelable(InlineSliderPayload.class.getClassLoader());
- }
-
- public InlineSliderPayload(Uri newUri) {
- uri = newUri;
- }
-
- @Override
- public int getType() {
- return PayloadType.INLINE_SLIDER;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeParcelable(uri, flags);
- }
-
- public static final Creator<InlineSliderPayload> CREATOR = new Creator<InlineSliderPayload>() {
- @Override
- public InlineSliderPayload createFromParcel(Parcel in) {
- return new InlineSliderPayload(in);
- }
-
- @Override
- public InlineSliderPayload[] newArray(int size) {
- return new InlineSliderPayload[size];
- }
- };
-}
\ No newline at end of file
diff --git a/src/com/android/settings/search2/InlineSwitchPayload.java b/src/com/android/settings/search2/InlineSwitchPayload.java
new file mode 100644
index 0000000..76fb048
--- /dev/null
+++ b/src/com/android/settings/search2/InlineSwitchPayload.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.search2;
+
+import android.content.Context;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.provider.Settings;
+import android.util.ArrayMap;
+
+import java.util.Map;
+
+/**
+ * Payload for inline Switch results. Mappings from integer to boolean.
+ */
+public class InlineSwitchPayload extends InlinePayload {
+ /**
+ * Maps Inline values to UI-consumable Values.
+ * For example, if you have a switch preference whose values are stored as ints, the two valid
+ * list of mappings would be:
+ * < (0,True), (1, false) >
+ * < (1,True), (0, false) >
+ */
+ public final Map<Integer, Boolean> valueMap;
+
+ public InlineSwitchPayload(String newUri, @SettingsSource int settingsSource,
+ ArrayMap<Integer, Boolean> map) {
+ super(newUri, PayloadType.INLINE_SWITCH, settingsSource);
+ valueMap = map;
+ }
+
+ private InlineSwitchPayload(Parcel in) {
+ super(in.readString() /* Uri */ , in.readInt() /* Payload Type */,
+ in.readInt() /* Settings Source */);
+ valueMap = in.readHashMap(Integer.class.getClassLoader());
+ }
+
+ @Override
+ public int getType() {
+ return inlineType;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(settingsUri);
+ dest.writeInt(inlineType);
+ dest.writeInt(settingSource);
+ dest.writeMap(valueMap);
+ }
+
+ public static final Parcelable.Creator<InlineSwitchPayload> CREATOR =
+ new Parcelable.Creator<InlineSwitchPayload>() {
+ @Override
+ public InlineSwitchPayload createFromParcel(Parcel in) {
+ return new InlineSwitchPayload(in);
+ }
+
+ @Override
+ public InlineSwitchPayload[] newArray(int size) {
+ return new InlineSwitchPayload[size];
+ }
+ };
+
+ public boolean getSwitchValue(Context context) {
+ if (valueMap == null) {
+ throw new IllegalStateException("Value map is null");
+ }
+
+ int settingsValue = -1;
+ switch(settingSource) {
+ case SettingsSource.SECURE:
+ settingsValue = Settings.Secure.getInt(context.getContentResolver(),
+ settingsUri, 0);
+ }
+
+ if (settingsValue == -1) {
+ throw new IllegalStateException("Unable to find setting from uri: "
+ + settingsUri.toString());
+ }
+
+ for (Integer key : valueMap.keySet()) {
+ if ((key == settingsValue)) {
+ return valueMap.get(key);
+ }
+ }
+
+ throw new IllegalStateException("No results matched the key: " + settingsValue);
+ }
+
+ public void setSwitchValue(Context context, boolean isChecked) {
+ if (valueMap == null) {
+ throw new IllegalStateException("Value map is null");
+ }
+ int switchValue = -1;
+
+ for (Map.Entry<Integer, Boolean> pair : valueMap.entrySet()) {
+ if (pair.getValue() == isChecked) {
+ switchValue = pair.getKey();
+ break;
+ }
+ }
+
+ if (switchValue == -1) {
+ throw new IllegalStateException("Switch value is not set");
+ }
+
+ switch(settingSource) {
+ case SettingsSource.GLOBAL:
+ return;
+ case SettingsSource.SECURE:
+ Settings.Secure.putInt(context.getContentResolver(), settingsUri, switchValue);
+ case SettingsSource.SYSTEM:
+ return;
+ case SettingsSource.UNKNOWN:
+ return;
+ }
+ }
+}
diff --git a/src/com/android/settings/search2/InlineSwitchViewHolder.java b/src/com/android/settings/search2/InlineSwitchViewHolder.java
new file mode 100644
index 0000000..54d3523
--- /dev/null
+++ b/src/com/android/settings/search2/InlineSwitchViewHolder.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.search2;
+
+import android.app.Fragment;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewParent;
+import android.widget.CompoundButton;
+import android.widget.Switch;
+import android.widget.TextView;
+import android.content.Context;
+
+import com.android.internal.widget.PreferenceImageView;
+import com.android.settings.R;
+
+/**
+ * ViewHolder for Settings represented as SwitchPreferences.
+ */
+public class InlineSwitchViewHolder extends SearchViewHolder {
+ public final TextView titleView;
+ public final TextView summaryView;
+ public final PreferenceImageView iconView;
+ public final Switch switchView;
+
+ private final Context mContext;
+
+ private final String TAG = "SwitchViewHolder";
+
+ public InlineSwitchViewHolder(View view, Context context) {
+ super(view);
+ mContext = context;
+ titleView = (TextView) view.findViewById(android.R.id.title);
+ summaryView = (TextView) view.findViewById(android.R.id.summary);
+ iconView = (PreferenceImageView) view.findViewById(android.R.id.icon);
+ switchView = (Switch) view.findViewById(R.id.switchView);
+ }
+
+ @Override
+ public void onBind(Fragment fragment, SearchResult result) {
+ if (mContext == null) {
+ return;
+ }
+ final InlineSwitchPayload payload = (InlineSwitchPayload) result.payload;
+ switchView.setChecked(payload.getSwitchValue(mContext));
+
+ switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ payload.setSwitchValue(mContext, isChecked);
+ }
+ });
+
+ titleView.setText(result.title);
+ summaryView.setText(result.summary);
+ iconView.setImageDrawable(result.icon);
+ }
+}
diff --git a/src/com/android/settings/search2/IntentSearchViewHolder.java b/src/com/android/settings/search2/IntentSearchViewHolder.java
index 0ef27d0..da3f724 100644
--- a/src/com/android/settings/search2/IntentSearchViewHolder.java
+++ b/src/com/android/settings/search2/IntentSearchViewHolder.java
@@ -34,13 +34,13 @@
public IntentSearchViewHolder(View view) {
super(view);
- titleView = (TextView) view.findViewById(R.id.title);
- summaryView = (TextView) view.findViewById(R.id.summary);
- iconView = (ImageView) view.findViewById(R.id.icon);
+ titleView = (TextView) view.findViewById(android.R.id.title);
+ summaryView = (TextView) view.findViewById(android.R.id.summary);
+ iconView = (ImageView) view.findViewById(android.R.id.icon);
}
@Override
- public void onBind(Fragment fragment, SearchResult result) {
+ public void onBind(final Fragment fragment, final SearchResult result) {
titleView.setText(result.title);
summaryView.setText(result.summary);
iconView.setImageDrawable(result.icon);
diff --git a/src/com/android/settings/search2/ResultPayload.java b/src/com/android/settings/search2/ResultPayload.java
index 84df7b6..3842def 100644
--- a/src/com/android/settings/search2/ResultPayload.java
+++ b/src/com/android/settings/search2/ResultPayload.java
@@ -28,7 +28,8 @@
*/
public abstract class ResultPayload implements Parcelable {
- @IntDef({PayloadType.INLINE_SLIDER, PayloadType.INLINE_SWITCH, PayloadType.INTENT})
+ @IntDef({PayloadType.INLINE_SLIDER, PayloadType.INLINE_SWITCH,
+ PayloadType.INTENT})
@Retention(RetentionPolicy.SOURCE)
public @interface PayloadType {
/**
@@ -47,5 +48,16 @@
int INLINE_SWITCH = 2;
}
+ @IntDef({SettingsSource.UNKNOWN, SettingsSource.SYSTEM, SettingsSource.SECURE,
+ SettingsSource.GLOBAL})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SettingsSource {
+ int UNKNOWN = 0;
+ int SYSTEM = 1;
+ int SECURE = 2;
+ int GLOBAL = 3;
+ }
+
+
@ResultPayload.PayloadType public abstract int getType();
}
diff --git a/src/com/android/settings/search2/SearchResultsAdapter.java b/src/com/android/settings/search2/SearchResultsAdapter.java
index b588496..c318b41 100644
--- a/src/com/android/settings/search2/SearchResultsAdapter.java
+++ b/src/com/android/settings/search2/SearchResultsAdapter.java
@@ -16,8 +16,10 @@
package com.android.settings.search2;
+import android.content.Context;
import android.support.annotation.VisibleForTesting;
import android.support.v7.widget.RecyclerView.Adapter;
+import android.util.ArrayMap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -26,7 +28,6 @@
import com.android.settings.search2.ResultPayload.PayloadType;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,22 +39,23 @@
public SearchResultsAdapter(SearchFragment fragment) {
mFragment = fragment;
mSearchResults = new ArrayList<>();
- mResultsMap = new HashMap<>();
+ mResultsMap = new ArrayMap<>();
setHasStableIds(true);
}
@Override
public SearchViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
- switch (viewType) {
+ final Context context = parent.getContext();
+ final LayoutInflater inflater = LayoutInflater.from(context);
+ final View view;
+ switch(viewType) {
case PayloadType.INTENT:
- View view = inflater.inflate(R.layout.search_intent_item, parent, false);
+ view = inflater.inflate(R.layout.search_intent_item, parent, false);
return new IntentSearchViewHolder(view);
- case PayloadType.INLINE_SLIDER:
- return null;
case PayloadType.INLINE_SWITCH:
- return null;
+ view = inflater.inflate(R.layout.search_inline_switch_item, parent, false);
+ return new InlineSwitchViewHolder(view, context);
default:
return null;
}
diff --git a/src/com/android/settings/support/SupportDisclaimerDialogFragment.java b/src/com/android/settings/support/SupportDisclaimerDialogFragment.java
index 8ab607f..3a7102c 100644
--- a/src/com/android/settings/support/SupportDisclaimerDialogFragment.java
+++ b/src/com/android/settings/support/SupportDisclaimerDialogFragment.java
@@ -23,14 +23,18 @@
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
+import android.text.Annotation;
import android.text.Spannable;
+import android.text.Spanned;
import android.text.TextPaint;
+import android.text.TextUtils;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
@@ -44,8 +48,8 @@
implements DialogInterface.OnClickListener {
public static final String TAG = "SupportDisclaimerDialog";
- private static final String EXTRA_TYPE = "extra_type";
- private static final String EXTRA_ACCOUNT = "extra_account";
+ public static final String EXTRA_TYPE = "extra_type";
+ public static final String EXTRA_ACCOUNT = "extra_account";
public static SupportDisclaimerDialogFragment newInstance(Account account,
@SupportFeatureProvider.SupportType int type) {
@@ -69,8 +73,13 @@
final Activity activity = getActivity();
final SupportFeatureProvider supportFeatureProvider =
FeatureFactory.getFactory(activity).getSupportFeatureProvider(activity);
+
+ // sets the two links that go to privacy policy and terms of service
disclaimer.setText(supportFeatureProvider.getDisclaimerStringResId());
- stripUnderlines((Spannable) disclaimer.getText());
+ Spannable viewText = (Spannable) disclaimer.getText();
+ stripUnderlines(viewText);
+ SystemInformationSpan.linkify(viewText, this);
+ // sets the link that launches a dialog to expose the signals we are sending
return builder
.setView(content)
.create();
@@ -112,9 +121,11 @@
for (URLSpan span : urls) {
final int start = input.getSpanStart(span);
final int end = input.getSpanEnd(span);
- input.removeSpan(span);
- input.setSpan(new NoUnderlineUrlSpan(span.getURL()), start, end,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ if (!TextUtils.isEmpty(span.getURL())) {
+ input.removeSpan(span);
+ input.setSpan(new NoUnderlineUrlSpan(span.getURL()), start, end,
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
}
}
@@ -138,4 +149,69 @@
ds.setUnderlineText(false);
}
}
+
+ /**
+ * A {@link URLSpan} that opens a dialog when clicked
+ */
+ public static class SystemInformationSpan extends URLSpan {
+
+ private static final String ANNOTATION_URL = "url";
+ private final DialogFragment mDialog;
+ private SupportFeatureProvider mSupport;
+
+ public SystemInformationSpan(DialogFragment parent) {
+ // sets the url to empty string so we can prevent the NoUnderlineUrlSpan from stripping
+ // this one
+ super("");
+ mSupport = FeatureFactory.getFactory(parent.getContext())
+ .getSupportFeatureProvider(parent.getContext());
+ mDialog = parent;
+ }
+
+ @Override
+ public void onClick(View widget) {
+ Activity activity = mDialog.getActivity();
+ if (mSupport != null && activity != null) {
+ // launch the system info fragment
+ mSupport.launchSystemInfoFragment(mDialog.getArguments(),
+ activity.getFragmentManager());
+
+ // dismiss this fragment
+ mDialog.dismiss();
+ }
+ }
+
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ super.updateDrawState(ds);
+ // remove underline
+ ds.setUnderlineText(false);
+ }
+
+ /**
+ * This method takes a string and turns it into a url span that will launch a
+ * SupportSystemInformationDialogFragment
+ * @param msg The text to turn into a link
+ * @param parent The dialog the text is in
+ * @return A CharSequence containing the original text content as a url
+ */
+ public static CharSequence linkify(Spannable msg, DialogFragment parent) {
+ Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
+ for (Annotation annotation : spans) {
+ int start = msg.getSpanStart(annotation);
+ int end = msg.getSpanEnd(annotation);
+ if (ANNOTATION_URL.equals(annotation.getValue())) {
+ SystemInformationSpan link = new SystemInformationSpan(parent);
+ msg.removeSpan(annotation);
+ msg.setSpan(link, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ }
+ return msg;
+ }
+
+ @VisibleForTesting
+ public void setSupportProvider(SupportFeatureProvider prov) {
+ mSupport = prov;
+ }
+ }
}
diff --git a/src/com/android/settings/survey/SurveyMixin.java b/src/com/android/settings/survey/SurveyMixin.java
index 5e0754a..74b7f10 100644
--- a/src/com/android/settings/survey/SurveyMixin.java
+++ b/src/com/android/settings/survey/SurveyMixin.java
@@ -62,7 +62,7 @@
if (provider.getSurveyExpirationDate(activity, id) <= -1) {
// register the receiver to show the survey on completion.
mReceiver = provider.createAndRegisterReceiver(activity);
- provider.downloadSurvey(activity, id, "fakeData");
+ provider.downloadSurvey(activity, id, null /* data */);
} else {
provider.showSurveyIfAvailable(activity, id);
}
diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java
index 5e0a202..b06d403 100644
--- a/src/com/android/settings/system/SystemDashboardFragment.java
+++ b/src/com/android/settings/system/SystemDashboardFragment.java
@@ -19,6 +19,7 @@
import android.os.UserManager;
import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -42,7 +43,7 @@
@Override
public int getMetricsCategory() {
- return SYSTEM_CATEGORY_FRAGMENT;
+ return MetricsProto.MetricsEvent.SETTINGS_SYSTEM_CATEGORY;
}
@Override
diff --git a/tests/robotests/src/com/android/internal/hardware/AmbientDisplayConfiguration.java b/tests/robotests/src/com/android/internal/hardware/AmbientDisplayConfiguration.java
index bea9358..ffa6d96 100644
--- a/tests/robotests/src/com/android/internal/hardware/AmbientDisplayConfiguration.java
+++ b/tests/robotests/src/com/android/internal/hardware/AmbientDisplayConfiguration.java
@@ -17,6 +17,7 @@
package com.android.internal.hardware;
import android.provider.Settings;
+import android.content.Context;
/**
* Fake controller to make robolectric test compile. Should be removed when Robolectric supports
@@ -24,6 +25,8 @@
*/
public class AmbientDisplayConfiguration {
+ public AmbientDisplayConfiguration(Context context) {}
+
public boolean pulseOnPickupAvailable() {
return false;
}
diff --git a/tests/robotests/src/com/android/settings/PrivacySettingsTest.java b/tests/robotests/src/com/android/settings/PrivacySettingsTest.java
new file mode 100644
index 0000000..4aac314
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/PrivacySettingsTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class PrivacySettingsTest {
+
+ @Mock
+ private PreferenceScreen mScreen;
+ private PrivacySettings mSettings;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(mScreen.findPreference(PrivacySettings.BACKUP_DATA))
+ .thenReturn(mock(Preference.class));
+ when(mScreen.findPreference(PrivacySettings.CONFIGURE_ACCOUNT))
+ .thenReturn(mock(Preference.class));
+ when(mScreen.findPreference(PrivacySettings.DATA_MANAGEMENT))
+ .thenReturn(mock(Preference.class));
+ when(mScreen.findPreference(PrivacySettings.AUTO_RESTORE))
+ .thenReturn(mock(SwitchPreference.class));
+ mSettings = new PrivacySettings();
+ }
+
+ @Test
+ public void testSetPreference_noCrash() {
+ mSettings.setPreferenceReferences(mScreen);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index ba4a9e3..ff84741 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -1,6 +1,7 @@
package com.android.settings.fuelgauge;
import android.content.Context;
+import android.content.Intent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -9,6 +10,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Test;
+
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
@@ -18,6 +20,7 @@
import static com.android.settings.fuelgauge.PowerUsageBase.MENU_STATS_REFRESH;
import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_ADDITIONAL_BATTERY_INFO;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -25,16 +28,22 @@
/**
* Unit tests for {@link PowerUsageSummary}.
*/
+// TODO: Improve this test class so that it starts up the real activity and fragment.
@RunWith(RobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class PowerUsageSummaryTest {
+ private static final Intent ADDITIONAL_BATTERY_INFO_INTENT =
+ new Intent("com.example.app.ADDITIONAL_BATTERY_INFO");
+
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Menu mMenu;
@Mock
- private MenuItem mRefresh;
+ private MenuItem mRefreshMenu;
+ @Mock
+ private MenuItem mAdditionalBatteryInfoMenu;
@Mock
private MenuInflater mMenuInflater;
@@ -49,15 +58,19 @@
mFragment = new TestFragment(mContext);
- when(mMenu.add(Menu.NONE, PowerUsageBase.MENU_STATS_REFRESH, Menu.NONE,
+ when(mMenu.add(Menu.NONE, MENU_STATS_REFRESH, Menu.NONE,
R.string.menu_stats_refresh)
.setIcon(com.android.internal.R.drawable.ic_menu_refresh)
.setAlphabeticShortcut('r'))
- .thenReturn(mRefresh);
+ .thenReturn(mRefreshMenu);
+ when(mAdditionalBatteryInfoMenu.getItemId())
+ .thenReturn(MENU_ADDITIONAL_BATTERY_INFO);
+ when(mFeatureFactory.powerUsageFeatureProvider.getAdditionalBatteryInfoIntent())
+ .thenReturn(ADDITIONAL_BATTERY_INFO_INTENT);
}
@Test
- public void testOnCreateOptionsMenu_additionalBatteryInfoEnabled() {
+ public void testOptionsMenu_additionalBatteryInfoEnabled() {
when(mFeatureFactory.powerUsageFeatureProvider.isAdditionalBatteryInfoEnabled())
.thenReturn(true);
@@ -65,10 +78,15 @@
verify(mMenu).add(Menu.NONE, MENU_ADDITIONAL_BATTERY_INFO,
Menu.NONE, R.string.additional_battery_info);
+
+ mFragment.onOptionsItemSelected(mAdditionalBatteryInfoMenu);
+
+ assertThat(mFragment.mStartActivityCalled).isTrue();
+ assertThat(mFragment.mStartActivityIntent).isEqualTo(ADDITIONAL_BATTERY_INFO_INTENT);
}
@Test
- public void testOnCreateOptionsMenu_additionalBatteryInfoDisabled() {
+ public void testOptionsMenu_additionalBatteryInfoDisabled() {
when(mFeatureFactory.powerUsageFeatureProvider.isAdditionalBatteryInfoEnabled())
.thenReturn(false);
@@ -81,6 +99,8 @@
public static class TestFragment extends PowerUsageSummary {
private Context mContext;
+ private boolean mStartActivityCalled;
+ private Intent mStartActivityIntent;
public TestFragment(Context context) {
mContext = context;
@@ -90,5 +110,11 @@
public Context getContext() {
return mContext;
}
+
+ @Override
+ public void startActivity(Intent intent) {
+ mStartActivityCalled = true;
+ mStartActivityIntent = intent;
+ }
}
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
index 6a2e4ea..5f7d8b5 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
@@ -23,6 +23,8 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -91,4 +93,23 @@
assertThat(mController.isSwitchPrefEnabled()).isFalse();
}
+
+ @Test
+ public void testPreferenceController_ProperResultPayloadType() {
+ final Context context = ShadowApplication.getInstance().getApplicationContext();
+ mController = new DoubleTapPowerPreferenceController(context, null);
+ ResultPayload payload = mController.getResultPayload();
+ assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
+ }
+
+ @Test
+ public void testPreferenceController_CorrectPayload() {
+ final Context context = ShadowApplication.getInstance().getApplicationContext();
+ mController = new DoubleTapPowerPreferenceController(context, null);
+ InlineSwitchPayload payload = (InlineSwitchPayload) mController.getResultPayload();
+ assertThat(payload.settingsUri).isEqualTo("camera_double_tap_power_gesture_disabled");
+ assertThat(payload.settingSource).isEqualTo(ResultPayload.SettingsSource.SECURE);
+ assertThat(payload.valueMap.get(0)).isEqualTo(true);
+ assertThat(payload.valueMap.get(1)).isEqualTo(false);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index a25d34b..2f922d5 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -22,6 +22,8 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -79,4 +81,19 @@
assertThat(mController.isSwitchPrefEnabled()).isFalse();
}
+
+ @Test
+ public void testPreferenceController_ProperResultPayloadType() {
+ ResultPayload payload = mController.getResultPayload();
+ assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
+ }
+
+ @Test
+ public void testPreferenceController_CorrectPayload() {
+ InlineSwitchPayload payload = (InlineSwitchPayload) mController.getResultPayload();
+ assertThat(payload.settingsUri).isEqualTo("doze_pulse_on_double_tap");
+ assertThat(payload.settingSource).isEqualTo(ResultPayload.SettingsSource.SECURE);
+ assertThat(payload.valueMap.get(1)).isEqualTo(true);
+ assertThat(payload.valueMap.get(0)).isEqualTo(false);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
index 5b02182..ad682b2 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
@@ -24,6 +24,8 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -111,4 +113,19 @@
assertThat(mController.isSwitchPrefEnabled()).isFalse();
}
+
+ @Test
+ public void testPreferenceController_ProperResultPayloadType() {
+ ResultPayload payload = mController.getResultPayload();
+ assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
+ }
+
+ @Test
+ public void testPreferenceController_CorrectPayload() {
+ InlineSwitchPayload payload = (InlineSwitchPayload) mController.getResultPayload();
+ assertThat(payload.settingsUri).isEqualTo("camera_double_twist_to_flip_enabled");
+ assertThat(payload.settingSource).isEqualTo(ResultPayload.SettingsSource.SECURE);
+ assertThat(payload.valueMap.get(1)).isEqualTo(true);
+ assertThat(payload.valueMap.get(0)).isEqualTo(false);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PIckupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PIckupGesturePreferenceControllerTest.java
index 66ae679..f112b9e 100644
--- a/tests/robotests/src/com/android/settings/gestures/PIckupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PIckupGesturePreferenceControllerTest.java
@@ -22,6 +22,8 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -82,4 +84,18 @@
assertThat(mController.isSwitchPrefEnabled()).isFalse();
}
+ @Test
+ public void testPreferenceController_ProperResultPayloadType() {
+ ResultPayload payload = mController.getResultPayload();
+ assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
+ }
+
+ @Test
+ public void testPreferenceController_CorrectPayload() {
+ InlineSwitchPayload payload = (InlineSwitchPayload) mController.getResultPayload();
+ assertThat(payload.settingsUri).isEqualTo("doze_pulse_on_pick_up");
+ assertThat(payload.settingSource).isEqualTo(ResultPayload.SettingsSource.SECURE);
+ assertThat(payload.valueMap.get(1)).isEqualTo(true);
+ assertThat(payload.valueMap.get(0)).isEqualTo(false);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index 7b34666..49d73ea 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -22,6 +22,8 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -87,4 +89,19 @@
assertThat(mController.isSwitchPrefEnabled()).isFalse();
}
+
+ @Test
+ public void testPreferenceController_ProperResultPayloadType() {
+ ResultPayload payload = mController.getResultPayload();
+ assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
+ }
+
+ @Test
+ public void testPreferenceController_CorrectPayload() {
+ InlineSwitchPayload payload = (InlineSwitchPayload) mController.getResultPayload();
+ assertThat(payload.settingsUri).isEqualTo("system_navigation_keys_enabled");
+ assertThat(payload.settingSource).isEqualTo(ResultPayload.SettingsSource.SECURE);
+ assertThat(payload.valueMap.get(1)).isEqualTo(true);
+ assertThat(payload.valueMap.get(0)).isEqualTo(false);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java b/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
new file mode 100644
index 0000000..5b6824d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.search;
+
+import android.content.Context;
+
+import android.util.ArrayMap;
+import com.android.internal.hardware.AmbientDisplayConfiguration;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.gestures.DoubleTapPowerPreferenceController;
+import com.android.settings.gestures.DoubleTapScreenPreferenceController;
+import com.android.settings.gestures.DoubleTwistPreferenceController;
+import com.android.settings.gestures.PickupGesturePreferenceController;
+import com.android.settings.gestures.SwipeToNotificationPreferenceController;
+import com.android.settings.search2.DatabaseIndexingUtils;
+
+import com.android.settings.search2.IntentPayload;
+import com.android.settings.search2.ResultPayload;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import java.util.Map;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DatabaseIndexingUtilsTest {
+
+ private Context mContext;
+ @Mock
+ private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = ShadowApplication.getInstance().getApplicationContext();
+ }
+
+ @Test
+ public void testGetPreferenceControllerUriMap_BadClassName_ReturnsNull() {
+ Map map = DatabaseIndexingUtils.getPreferenceControllerUriMap("dummy", mContext);
+ assertThat(map).isNull();
+ }
+
+ @Test
+ public void testGetPreferenceControllerUriMap_NullContext_ReturnsNull() {
+ Map map = DatabaseIndexingUtils.getPreferenceControllerUriMap("dummy", null);
+ assertThat(map).isNull();
+ }
+
+ @Test
+ public void testGetPreferenceControllerUriMap_CompatibleClass_ReturnsNotNull() {
+ String className = "com.android.settings.gestures.GestureSettings";
+
+ Map map = DatabaseIndexingUtils.getPreferenceControllerUriMap(className, mContext);
+ assertThat(map).isNotNull();
+ }
+
+ @Test
+ public void testGetPreferenceControllerUriMap_CompatibleClass_ReturnsValidMap() {
+ String className = "com.android.settings.gestures.GestureSettings";
+
+ Map map = DatabaseIndexingUtils.getPreferenceControllerUriMap(className, mContext);
+ assertThat(map.get("gesture_double_twist"))
+ .isInstanceOf(DoubleTwistPreferenceController.class);
+ assertThat(map.get("gesture_swipe_down_fingerprint"))
+ .isInstanceOf(SwipeToNotificationPreferenceController.class);
+ assertThat(map.get("gesture_double_tap_screen"))
+ .isInstanceOf(DoubleTapScreenPreferenceController.class);
+ assertThat(map.get("gesture_pick_up"))
+ .isInstanceOf(PickupGesturePreferenceController.class);
+ assertThat(map.get("gesture_double_tap_power"))
+ .isInstanceOf(DoubleTapPowerPreferenceController.class);
+ }
+
+ @Test
+ public void testGetPayloadFromMap_NullMap_ReturnsNull() {
+ ResultPayload payload = DatabaseIndexingUtils.getPayloadFromUriMap(null, "");
+ assertThat(payload).isNull();
+ }
+
+ @Test
+ public void testGetPayloadFromMap_MatchingKey_ReturnsPayloa() {
+ final String key = "key";
+ PreferenceController prefController = new PreferenceController(mContext) {
+ @Override
+ public boolean isAvailable() {
+ return false;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return key;
+ }
+
+ @Override
+ public ResultPayload getResultPayload() {
+ return new IntentPayload(null);
+ }
+ };
+ ArrayMap<String,PreferenceController> map = new ArrayMap<>();
+ map.put(key, prefController);
+
+ ResultPayload payload = DatabaseIndexingUtils.getPayloadFromUriMap(map, key);
+ assertThat(payload).isInstanceOf(IntentPayload.class);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/search/InlineSliderPayloadTest.java b/tests/robotests/src/com/android/settings/search/InlineSliderPayloadTest.java
deleted file mode 100644
index d52eb94..0000000
--- a/tests/robotests/src/com/android/settings/search/InlineSliderPayloadTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.settings.search;
-
-import android.net.Uri;
-import android.os.Parcel;
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.search2.InlineSliderPayload;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.robolectric.annotation.Config;
-
-import static com.google.common.truth.Truth.assertThat;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class InlineSliderPayloadTest {
- private InlineSliderPayload mPayload;
-
- @Test
- public void testParcelOrdering_StaysValid() {
- Uri uri = Uri.parse("http://www.TESTURI.com");
- Parcel parcel = Parcel.obtain();
-
- mPayload = new InlineSliderPayload(uri);
- mPayload.writeToParcel(parcel, 0);
- // Reset parcel for reading
- parcel.setDataPosition(0);
- InlineSliderPayload newPayload = InlineSliderPayload.CREATOR.createFromParcel(parcel);
-
- String originalUri = mPayload.uri.toString();
- String copiedUri = newPayload.uri.toString();
- assertThat(originalUri).isEqualTo(copiedUri);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
new file mode 100644
index 0000000..701679c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.search;
+
+import android.os.Parcel;
+import android.util.ArrayMap;
+import android.content.Context;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.ResultPayload;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.fail;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class InlineSwitchPayloadTest {
+
+ @Test
+ public void testGetSwitch_EmptyMap_ExceptionThrown() {
+ final String uri = "test.com";
+ final int source = ResultPayload.SettingsSource.SECURE;
+
+ final Context context = ShadowApplication.getInstance().getApplicationContext();
+ InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, null);
+ try {
+ payload.getSwitchValue(context);
+ fail("Should have thrown exception for null map");
+ } catch (IllegalStateException e) {
+ assertThat(e).isNotNull();
+ }
+ }
+
+ @Test
+ public void testGetSwitch_BadMap_ExceptionThrown() {
+ final String uri = "test.com";
+ final int source = ResultPayload.SettingsSource.SECURE;
+ final ArrayMap<Integer, Boolean> map = new ArrayMap<>();
+
+ final Context context = ShadowApplication.getInstance().getApplicationContext();
+ InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, map);
+ try {
+ payload.getSwitchValue(context);
+ fail("Should have thrown exception for bad map");
+ } catch (IllegalStateException e) {
+ assertThat(e).isNotNull();
+ }
+ }
+
+ @Test
+ public void testConstructor_DataRetained() {
+ final String uri = "test.com";
+ final int type = ResultPayload.PayloadType.INLINE_SWITCH;
+ final int source = ResultPayload.SettingsSource.SECURE;
+ final ArrayMap<Integer, Boolean> map = new ArrayMap<>();
+ map.put(1, true);
+ map.put(0, false);
+
+ InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, map);
+ assertThat(payload.settingsUri).isEqualTo(uri);
+ assertThat(payload.inlineType).isEqualTo(type);
+ assertThat(payload.settingSource).isEqualTo(source);
+ assertThat(payload.valueMap.get(1)).isTrue();
+ assertThat(payload.valueMap.get(0)).isFalse();
+ }
+
+ @Test
+ public void testParcelConstructor_DataRetained() {
+ String uri = "test.com";
+ int type = ResultPayload.PayloadType.INLINE_SWITCH;
+ int source = ResultPayload.SettingsSource.SECURE;
+ final ArrayMap<Integer, Boolean> map = new ArrayMap<>();
+ map.put(1, true);
+ map.put(0, false);
+
+ Parcel parcel = Parcel.obtain();
+ parcel.writeString(uri);
+ parcel.writeInt(type);
+ parcel.writeInt(source);
+ parcel.writeMap(map);
+ parcel.setDataPosition(0);
+
+ InlineSwitchPayload payload = InlineSwitchPayload.CREATOR.createFromParcel(parcel);
+ assertThat(payload.settingsUri).isEqualTo(uri);
+ assertThat(payload.inlineType).isEqualTo(type);
+ assertThat(payload.settingSource).isEqualTo(source);
+ assertThat(payload.valueMap.get(1)).isTrue();
+ assertThat(payload.valueMap.get(0)).isFalse();
+ }
+
+
+}
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
new file mode 100644
index 0000000..efbad2f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.search;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.search2.InlineSwitchPayload;
+import com.android.settings.search2.InlineSwitchViewHolder;
+import com.android.settings.search2.IntentPayload;
+import com.android.settings.search2.SearchResult;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import java.util.ArrayList;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class InlineSwitchViewHolderTest {
+
+ private static final String TITLE = "title";
+ private static final String SUMMARY = "summary";
+
+ @Mock
+ private Fragment mFragment;
+
+ @Mock
+ private InlineSwitchPayload mPayload;
+ private InlineSwitchViewHolder mHolder;
+ private Drawable mIcon;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = ShadowApplication.getInstance().getApplicationContext();
+ View view = LayoutInflater.from(context).inflate(R.layout.search_inline_switch_item, null);
+ mHolder = new InlineSwitchViewHolder(view, context);
+
+ mIcon = context.getDrawable(R.drawable.ic_search_history);
+ }
+
+ @Test
+ public void testConstructor_MembersNotNull() {
+ assertThat(mHolder.titleView).isNotNull();
+ assertThat(mHolder.summaryView).isNotNull();
+ assertThat(mHolder.iconView).isNotNull();
+ assertThat(mHolder.switchView).isNotNull();
+ }
+
+ @Test
+ public void testBindViewElements_AllUpdated() {
+ when(mPayload.getSwitchValue(any(Context.class))).thenReturn(true);
+ SearchResult result = getSearchResult();
+ mHolder.onBind(mFragment, result);
+ mHolder.switchView.setChecked(true);
+
+ assertThat(mHolder.titleView.getText()).isEqualTo(TITLE);
+ assertThat(mHolder.summaryView.getText()).isEqualTo(SUMMARY);
+ assertThat(mHolder.iconView.getDrawable()).isEqualTo(mIcon);
+ assertThat(mHolder.switchView.isChecked()).isTrue();
+ }
+
+ private SearchResult getSearchResult() {
+ SearchResult.Builder builder = new SearchResult.Builder();
+ builder.addTitle(TITLE)
+ .addSummary(SUMMARY)
+ .addRank(1)
+ .addPayload(new InlineSwitchPayload("", 0, null))
+ .addBreadcrumbs(new ArrayList<String>())
+ .addIcon(mIcon)
+ .addPayload(mPayload);
+
+ return builder.build();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
index 805c7cb..ed503d8 100644
--- a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
@@ -93,7 +93,7 @@
.addSummary(SUMMARY)
.addRank(1)
.addPayload(new IntentPayload(null))
- .addBreadcrumbs(new ArrayList<>())
+ .addBreadcrumbs(new ArrayList<String>())
.addIcon(mIcon);
return builder.build();
diff --git a/tests/robotests/src/com/android/settings/search/SearchAdapterTest.java b/tests/robotests/src/com/android/settings/search/SearchAdapterTest.java
index 0756d3f..3627898 100644
--- a/tests/robotests/src/com/android/settings/search/SearchAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchAdapterTest.java
@@ -21,17 +21,22 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.search2.DatabaseResultLoader;
+import com.android.settings.search2.InlineSwitchViewHolder;
import com.android.settings.search2.IntentPayload;
+import com.android.settings.search2.IntentSearchViewHolder;
import com.android.settings.search2.ResultPayload;
import com.android.settings.search2.SearchFragment;
import com.android.settings.search2.SearchResult;
import com.android.settings.search2.SearchResult.Builder;
import com.android.settings.search2.SearchResultsAdapter;
+import com.android.settings.search2.SearchViewHolder;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,6 +44,8 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.shadows.ShadowViewGroup;
import java.util.ArrayList;
import java.util.List;
@@ -63,6 +70,47 @@
mLoaderClassName = DatabaseResultLoader.class.getName();
}
+ @Test
+ public void testNoResultsAdded_EmptyListReturned() {
+ List<SearchResult> updatedResults = mAdapter.getSearchResults();
+ assertThat(updatedResults).isEmpty();
+ }
+
+ @Test
+ public void testSingleSourceMerge_ExactCopyReturned() {
+ ArrayList<SearchResult> intentResults = getIntentSampleResults();
+ mAdapter.mergeResults(intentResults, mLoaderClassName);
+
+ List<SearchResult> updatedResults = mAdapter.getSearchResults();
+ assertThat(updatedResults).containsAllIn(intentResults);
+ }
+
+ @Test
+ public void testDuplicateSourceMerge_ExactCopyReturned() {
+ ArrayList<SearchResult> intentResults = getIntentSampleResults();
+ mAdapter.mergeResults(intentResults, mLoaderClassName);
+ mAdapter.mergeResults(intentResults, mLoaderClassName);
+
+ List<SearchResult> updatedResults = mAdapter.getSearchResults();
+ assertThat(updatedResults).containsAllIn(intentResults);
+ }
+
+ @Test
+ public void testCreatViewHolder_ReturnsIntentResult() {
+ ViewGroup group = new FrameLayout(mContext);
+ SearchViewHolder view = mAdapter.onCreateViewHolder(group,
+ ResultPayload.PayloadType.INTENT);
+ assertThat(view).isInstanceOf(IntentSearchViewHolder.class);
+ }
+
+ @Test
+ public void testCreatViewHolder_ReturnsInlineSwitchResult() {
+ ViewGroup group = new FrameLayout(mContext);
+ SearchViewHolder view = mAdapter.onCreateViewHolder(group,
+ ResultPayload.PayloadType.INLINE_SWITCH);
+ assertThat(view).isInstanceOf(InlineSwitchViewHolder.class);
+ }
+
private ArrayList<SearchResult> getIntentSampleResults() {
ArrayList<SearchResult> sampleResults = new ArrayList<>();
ArrayList<String> breadcrumbs = new ArrayList<>();
@@ -84,31 +132,4 @@
sampleResults.add(builder.build());
return sampleResults;
}
-
-
- @Test
- public void testNoResultsAdded_EmptyListReturned() {
- List<SearchResult> updatedResults = mAdapter.getSearchResults();
- assertThat(updatedResults).isEmpty();
- }
-
-
- @Test
- public void testSingleSourceMerge_ExactCopyReturned() {
- ArrayList<SearchResult> intentResults = getIntentSampleResults();
- mAdapter.mergeResults(intentResults, mLoaderClassName);
-
- List<SearchResult> updatedResults = mAdapter.getSearchResults();
- assertThat(updatedResults).containsAllIn(intentResults);
- }
-
- @Test
- public void testDuplicateSourceMerge_ExactCopyReturned() {
- ArrayList<SearchResult> intentResults = getIntentSampleResults();
- mAdapter.mergeResults(intentResults, mLoaderClassName);
- mAdapter.mergeResults(intentResults, mLoaderClassName);
-
- List<SearchResult> updatedResults = mAdapter.getSearchResults();
- assertThat(updatedResults).containsAllIn(intentResults);
- }
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/search/DatabaseResultLoaderTest.java b/tests/robotests/src/com/android/settings/search2/CursorToSearchResultConverterTest.java
similarity index 66%
rename from tests/robotests/src/com/android/settings/search/DatabaseResultLoaderTest.java
rename to tests/robotests/src/com/android/settings/search2/CursorToSearchResultConverterTest.java
index 1df7b1f..98b250d 100644
--- a/tests/robotests/src/com/android/settings/search/DatabaseResultLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/search2/CursorToSearchResultConverterTest.java
@@ -15,7 +15,7 @@
*
*/
-package com.android.settings.search;
+package com.android.settings.search2;
import android.app.Activity;
import android.content.Context;
@@ -23,16 +23,13 @@
import android.database.MatrixCursor;
import android.graphics.drawable.Drawable;
+import android.util.ArrayMap;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.SubSettings;
import com.android.settings.TestConfig;
import com.android.settings.gestures.GestureSettings;
-import com.android.settings.search2.DatabaseResultLoader;
-import com.android.settings.search2.IntentPayload;
-import com.android.settings.search2.ResultPayload;
import com.android.settings.search2.ResultPayload.PayloadType;
-import com.android.settings.search2.SearchResult;
import org.junit.Before;
import org.junit.Test;
@@ -47,12 +44,14 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class DatabaseResultLoaderTest {
- private DatabaseResultLoader mLoader;
+public class CursorToSearchResultConverterTest {
+
+ private CursorToSearchResultConverter mConverter;
private static final String[] COLUMNS = new String[]{"rank", "title", "summary_on",
"summary off", "entries", "keywords", "class name", "screen title", "icon",
- "intent action", "target package", "target class", "enabled", "key", "user id"};
+ "intent action", "target package", "target class", "enabled", "key",
+ "payload_type", "payload"};
private static final String[] TITLES = new String[]{"title1", "title2", "title3"};
private static final String SUMMARY = "SUMMARY";
@@ -66,24 +65,24 @@
public void setUp() {
Context context = Robolectric.buildActivity(Activity.class).get();
mDrawable = context.getDrawable(mIcon);
- mLoader = new DatabaseResultLoader(context, "");
+ mConverter = new CursorToSearchResultConverter(context);
}
@Test
public void testParseNullResults_ReturnsNull() {
- List<SearchResult> results = mLoader.parseCursorForSearch(null);
+ List<SearchResult> results = mConverter.convertCursor(null);
assertThat(results).isNull();
}
@Test
public void testParseCursor_NotNull() {
- List<SearchResult> results = mLoader.parseCursorForSearch(getDummyCursor());
+ List<SearchResult> results = mConverter.convertCursor(getDummyCursor());
assertThat(results).isNotNull();
}
@Test
public void testParseCursor_MatchesRank() {
- List<SearchResult> results = mLoader.parseCursorForSearch(getDummyCursor());
+ List<SearchResult> results = mConverter.convertCursor(getDummyCursor());
for (int i = 0; i < EXAMPLES; i++) {
assertThat(results.get(i).rank).isEqualTo(i);
}
@@ -91,7 +90,7 @@
@Test
public void testParseCursor_MatchesTitle() {
- List<SearchResult> results = mLoader.parseCursorForSearch(getDummyCursor());
+ List<SearchResult> results = mConverter.convertCursor(getDummyCursor());
for (int i = 0; i < EXAMPLES; i++) {
assertThat(results.get(i).title).isEqualTo(TITLES[i]);
}
@@ -99,7 +98,7 @@
@Test
public void testParseCursor_MatchesSummary() {
- List<SearchResult> results = mLoader.parseCursorForSearch(getDummyCursor());
+ List<SearchResult> results = mConverter.convertCursor(getDummyCursor());
for (int i = 0; i < EXAMPLES; i++) {
assertThat(results.get(i).summary).isEqualTo(SUMMARY);
}
@@ -107,7 +106,7 @@
@Test
public void testParseCursor_MatchesIcon() {
- List<SearchResult> results = mLoader.parseCursorForSearch(getDummyCursor());
+ List<SearchResult> results = mConverter.convertCursor(getDummyCursor());
for (int i = 0; i < EXAMPLES; i++) {
Drawable resultDrawable = results.get(i).icon;
assertThat(resultDrawable.toString()).isEqualTo(mDrawable.toString());
@@ -116,7 +115,7 @@
@Test
public void testParseCursor_NoIcon() {
- List<SearchResult> results = mLoader.parseCursorForSearch(
+ List<SearchResult> results = mConverter.convertCursor(
getDummyCursor(false /* hasIcon */));
for (int i = 0; i < EXAMPLES; i++) {
Drawable resultDrawable = results.get(i).icon;
@@ -126,7 +125,7 @@
@Test
public void testParseCursor_MatchesPayloadType() {
- List<SearchResult> results = mLoader.parseCursorForSearch(getDummyCursor());
+ List<SearchResult> results = mConverter.convertCursor(getDummyCursor());
ResultPayload payload;
for (int i = 0; i < EXAMPLES; i++) {
payload = results.get(i).payload;
@@ -153,9 +152,10 @@
BLANK, // target class
BLANK, // enabled
BLANK, // key
- BLANK // user id
+ 0, // Payload Type
+ null // Payload
});
- List<SearchResult> results = mLoader.parseCursorForSearch(cursor);
+ List<SearchResult> results = mConverter.convertCursor(cursor);
IntentPayload payload = (IntentPayload) results.get(0).payload;
Intent intent = payload.intent;
assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
@@ -163,7 +163,7 @@
@Test
public void testParseCursor_MatchesIntentPayload() {
- List<SearchResult> results = mLoader.parseCursorForSearch(getDummyCursor());
+ List<SearchResult> results = mConverter.convertCursor(getDummyCursor());
IntentPayload payload;
for (int i = 0; i < EXAMPLES; i++) {
payload = (IntentPayload) results.get(i).payload;
@@ -172,6 +172,46 @@
}
}
+ @Test
+ public void testParseCursor_MatchesInlineSwitchPayload() {
+ MatrixCursor cursor = new MatrixCursor(COLUMNS);
+ final String BLANK = "";
+ final String uri = "test.com";
+ final int type = ResultPayload.PayloadType.INLINE_SWITCH;
+ final int source = ResultPayload.SettingsSource.SECURE;
+ final ArrayMap<Integer, Boolean> map = new ArrayMap<>();
+ map.put(1, true);
+ map.put(0, false);
+ final InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, map);
+
+ cursor.addRow(new Object[]{
+ 0, // rank
+ TITLES[0],
+ SUMMARY,
+ SUMMARY, // summary off
+ BLANK, // entries
+ BLANK, // Keywords
+ GestureSettings.class.getName(),
+ BLANK, // screen title
+ null, // icon
+ BLANK, // action
+ null, // target package
+ BLANK, // target class
+ BLANK, // enabled
+ BLANK, // key
+ type, // Payload Type
+ ResultPayloadUtils.marshall(payload) // Payload
+ });
+ List<SearchResult> results = mConverter.convertCursor(cursor);
+ InlineSwitchPayload newPayload = (InlineSwitchPayload) results.get(0).payload;
+
+ assertThat(newPayload.settingsUri).isEqualTo(uri);
+ assertThat(newPayload.inlineType).isEqualTo(type);
+ assertThat(newPayload.settingSource).isEqualTo(source);
+ assertThat(newPayload.valueMap.get(1)).isTrue();
+ assertThat(newPayload.valueMap.get(0)).isFalse();
+ }
+
private MatrixCursor getDummyCursor() {
return getDummyCursor(true /* hasIcon */);
}
@@ -196,7 +236,10 @@
item.add(BLANK); // target class
item.add(BLANK); // enabled
item.add(BLANK); // key
- item.add(BLANK); // user id
+ // Note there is no user id. This is omitted because it is not being
+ // queried. Should the queries change, so should this method.
+ item.add(Integer.toString(0)); // Payload Type
+ item.add(null); // Payload
cursor.addRow(item);
}