Settings: Update to follow new volume design.
- "Sound & Notification" (not Notifications) - Remove ringer-mode pref. - Add zen-mode pref to renamed "Interruptions" screen. - Implement two separate "Sound" & "Notification" sections. - Remove "Showing notifications" screen, migrate settings. - Remove custom category styling now that we have a platform style. - Implement new "days" sleep mode and corresponding dialog pref. - Corresponding changes to indexable resources. Associated frameworks/base change: I35afe38646f04d2ba0dbac11c2c6356120a33694 Bug:15831713 Change-Id: I6ed56791784968adfbd684f490dbbebed285a2dd
This commit is contained in:
@@ -1698,21 +1698,6 @@
|
|||||||
android:resource="@id/notification_settings" />
|
android:resource="@id/notification_settings" />
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
<activity android:name="Settings$NotificationDisplaySettingsActivity"
|
|
||||||
android:label="@string/notification_display_settings"
|
|
||||||
android:exported="true"
|
|
||||||
android:taskAffinity="">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<action android:name="android.settings.ACTION_NOTIFICATION_DISPLAY_SETTINGS" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
|
||||||
android:value="com.android.settings.notification.NotificationDisplaySettings" />
|
|
||||||
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
|
|
||||||
android:resource="@id/notification_settings" />
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name="Settings$OtherSoundSettingsActivity"
|
<activity android:name="Settings$OtherSoundSettingsActivity"
|
||||||
android:label="@string/other_sound_settings"
|
android:label="@string/other_sound_settings"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
25
res/layout/zen_mode_section_first.xml → res/layout/zen_downtime_day.xml
Normal file → Executable file
25
res/layout/zen_mode_section_first.xml → res/layout/zen_downtime_day.xml
Normal file → Executable file
@@ -1,5 +1,5 @@
|
|||||||
<!--
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
Copyright (C) 2014 The Android Open Source Project
|
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -13,18 +13,13 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
|
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="@dimen/zen_downtime_checkbox_padding"
|
||||||
<TextView
|
android:layout_marginStart="@dimen/zen_downtime_margin"
|
||||||
android:id="@android:id/title"
|
android:layout_marginEnd="@dimen/zen_downtime_margin" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@@ -1,37 +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.
|
|
||||||
-->
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="2dip"
|
|
||||||
android:layout_marginBottom="4dip"
|
|
||||||
android:alpha="?android:attr/disabledAlpha"
|
|
||||||
android:background="#000" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@@ -1,5 +1,5 @@
|
|||||||
<!--
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
Copyright (C) 2014 The Android Open Source Project
|
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -13,8 +13,9 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
style="?android:attr/listSeparatorTextViewStyle"
|
<resources>
|
||||||
android:id="@android:id/title"
|
<item name="notification_app_section" type="layout">@*android:layout/preference_category_material
|
||||||
android:layout_width="match_parent"
|
</item>
|
||||||
android:layout_height="wrap_content" />
|
</resources>
|
||||||
|
|
@@ -86,6 +86,8 @@
|
|||||||
<dimen name="notification_app_icon_badge_margin">4dp</dimen>
|
<dimen name="notification_app_icon_badge_margin">4dp</dimen>
|
||||||
<dimen name="notification_app_settings_divider_height">48dp</dimen>
|
<dimen name="notification_app_settings_divider_height">48dp</dimen>
|
||||||
<dimen name="zen_mode_dropdown_width">160dp</dimen>
|
<dimen name="zen_mode_dropdown_width">160dp</dimen>
|
||||||
|
<dimen name="zen_downtime_checkbox_padding">7dp</dimen>
|
||||||
|
<dimen name="zen_downtime_margin">10dp</dimen>
|
||||||
|
|
||||||
<!-- Default text size for caption preview samples. Uses dp rather than sp because captions are not scaled. -->
|
<!-- Default text size for caption preview samples. Uses dp rather than sp because captions are not scaled. -->
|
||||||
<dimen name="caption_preview_text_size">48dp</dimen>
|
<dimen name="caption_preview_text_size">48dp</dimen>
|
||||||
|
@@ -5139,113 +5139,113 @@
|
|||||||
<string name="default_sound">Default sound</string>
|
<string name="default_sound">Default sound</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Sounds and Notifications -->
|
<!-- Sounds and Notification -->
|
||||||
|
|
||||||
<!-- Sound & notifications: Settings header. [CHAR LIMIT=20] -->
|
<!-- Sound & notification: Settings header. [CHAR LIMIT=20] -->
|
||||||
<string name="notification_settings">Sound & Notifications</string>
|
<string name="notification_settings">Sound & Notification</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the option managing media volume. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the option managing media volume. [CHAR LIMIT=30] -->
|
||||||
<string name="media_volume_option_title">Media volume</string>
|
<string name="media_volume_option_title">Media volume</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the option managing alarm volume. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the option managing alarm volume. [CHAR LIMIT=30] -->
|
||||||
<string name="alarm_volume_option_title">Alarm volume</string>
|
<string name="alarm_volume_option_title">Alarm volume</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the option managing ringer volume. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the option managing ringer volume. [CHAR LIMIT=30] -->
|
||||||
<string name="ring_volume_option_title">Ring volume</string>
|
<string name="ring_volume_option_title">Ring volume</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the option managing notification volume. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the option managing notification volume. [CHAR LIMIT=30] -->
|
||||||
<string name="notification_volume_option_title">Notification volume</string>
|
<string name="notification_volume_option_title">Notification volume</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the Do not disturb option and associated settings page. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the Interruptions option and associated settings page. [CHAR LIMIT=30] -->
|
||||||
<string name="zen_mode_settings_title">Do not disturb</string>
|
<string name="zen_mode_settings_title">Interruptions</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the ringer mode option. [CHAR LIMIT=60] -->
|
<!-- Sound & notification > Sound section: Title for the zen mode option. [CHAR LIMIT=60] -->
|
||||||
<string name="ringer_mode_title">When calls and notifications arrive</string>
|
<string name="zen_mode_option_title">When calls and notifications arrive</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the ringer mode option on devices without voice. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the zen mode option for devices without voice. [CHAR LIMIT=60] -->
|
||||||
<string name="ringer_mode_title_novoice">When notifications arrive</string>
|
<string name="zen_mode_option_title_novoice">When notifications arrive</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Value for the ringer mode option when audible. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Zen mode option: Off [CHAR LIMIT=60] -->
|
||||||
<string name="ringer_mode_audible">Ring</string>
|
<string name="zen_mode_option_off">Always interrupt</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Value for the ringer mode option when vibrate. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
|
||||||
<string name="ringer_mode_vibrate">Vibrate instead of ringing</string>
|
<string name="zen_mode_option_important_interruptions">Allow only priority interruptions</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Value for the ringer mode option when silent. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Zen mode option: No interruptions [CHAR LIMIT=60] -->
|
||||||
<string name="ringer_mode_silent">Don\'t ring or vibrate</string>
|
<string name="zen_mode_option_no_interruptions">Don\'t interrupt</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
|
||||||
<string name="ringtone_title">Phone ringtone</string>
|
<string name="ringtone_title">Phone ringtone</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the option defining the default notification ringtone. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the option defining the default notification ringtone. [CHAR LIMIT=30] -->
|
||||||
<string name="notification_ringtone_title">Default notification ringtone</string>
|
<string name="notification_ringtone_title">Default notification ringtone</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the option managing whether or not to vibrate when ringing. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the option managing whether or not to vibrate when ringing. [CHAR LIMIT=30] -->
|
||||||
<string name="vibrate_when_ringing_title">Vibrate when ringing</string>
|
<string name="vibrate_when_ringing_title">Also vibrate for calls</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the showing notifications option and associated settings page. [CHAR LIMIT=30] -->
|
<!-- Sound & notification: Notification section header [CHAR LIMIT=30] -->
|
||||||
<string name="notification_display_settings">Showing notifications</string>
|
<string name="notification_section_header">Notification</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Showing notifications: Title for the pulse notification light option. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Notification section: Title for the pulse notification light option. [CHAR LIMIT=30] -->
|
||||||
<string name="notification_pulse_title">Pulse notification light</string>
|
<string name="notification_pulse_title">Pulse notification light</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Showing notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Notification section: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
|
||||||
<string name="lock_screen_notifications_title">When device is locked</string>
|
<string name="lock_screen_notifications_title">When device is locked</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Showing notifications: Value for lockscreen notifications: all information will be
|
<!-- Sound & notification > Notification section: Value for lockscreen notifications: all information will be
|
||||||
shown in notifications shown on a secure lock screen
|
shown in notifications shown on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
<string name="lock_screen_notifications_summary_show">Show all notification content</string>
|
<string name="lock_screen_notifications_summary_show">Show all notification content</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Showing notifications: Value for lockscreen notifications: sensitive information will be
|
<!-- Sound & notification > Notification section: Value for lockscreen notifications: sensitive information will be
|
||||||
hidden or redacted from notifications shown on a secure lock screen
|
hidden or redacted from notifications shown on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
<string name="lock_screen_notifications_summary_hide">Hide sensitive notification content</string>
|
<string name="lock_screen_notifications_summary_hide">Hide sensitive notification content</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Showing notifications: Value for lockscreen notifications: notifications will not appear on a secure lock screen
|
<!-- Sound & notification > Notification section: Value for lockscreen notifications: notifications will not appear on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
<string name="lock_screen_notifications_summary_disable">Don\'t show notifications at all</string>
|
<string name="lock_screen_notifications_summary_disable">Don\'t show notifications at all</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Showing notifications: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Notification section: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
|
||||||
<string name="app_notifications_title">App notifications</string>
|
<string name="app_notifications_title">App notifications</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for the other sounds option and associated settings page. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Sound section: Title for the other sounds option and associated settings page. [CHAR LIMIT=30] -->
|
||||||
<string name="other_sound_settings">Other sounds</string>
|
<string name="other_sound_settings">Other sounds</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Title for the option enabling touch sounds for dial pad tones. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Title for the option enabling touch sounds for dial pad tones. [CHAR LIMIT=30] -->
|
||||||
<string name="dial_pad_tones_title">Dial pad tones</string>
|
<string name="dial_pad_tones_title">Dial pad tones</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Title for the option enabling touch sounds for screen locking sounds. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Title for the option enabling touch sounds for screen locking sounds. [CHAR LIMIT=30] -->
|
||||||
<string name="screen_locking_sounds_title">Screen locking sounds</string>
|
<string name="screen_locking_sounds_title">Screen locking sounds</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Title for the option enabling docking sounds. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Title for the option enabling docking sounds. [CHAR LIMIT=30] -->
|
||||||
<string name="docking_sounds_title">Docking sounds</string>
|
<string name="docking_sounds_title">Docking sounds</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
|
||||||
<string name="touch_sounds_title">Touch sounds</string>
|
<string name="touch_sounds_title">Touch sounds</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Title for the option enabling haptic feedback on touch. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Title for the option enabling haptic feedback on touch. [CHAR LIMIT=30] -->
|
||||||
<string name="vibrate_on_touch_title">Vibrate on touch</string>
|
<string name="vibrate_on_touch_title">Vibrate on touch</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=30] -->
|
||||||
<string name="dock_audio_media_title">Dock speaker plays</string>
|
<string name="dock_audio_media_title">Dock speaker plays</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Value for the dock audio media with value 0: disabled. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Value for the dock audio media with value 0: disabled. [CHAR LIMIT=30] -->
|
||||||
<string name="dock_audio_media_disabled">All audio</string>
|
<string name="dock_audio_media_disabled">All audio</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Value for the dock audio media with value 1: enabled. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Value for the dock audio media with value 1: enabled. [CHAR LIMIT=30] -->
|
||||||
<string name="dock_audio_media_enabled">Media audio only</string>
|
<string name="dock_audio_media_enabled">Media audio only</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Value for the emergency tone option with value 0: silent. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Value for the emergency tone option with value 0: silent. [CHAR LIMIT=30] -->
|
||||||
<string name="emergency_tone_silent">Silent</string>
|
<string name="emergency_tone_silent">Silent</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Value for the emergency tone option with value 1: alert. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Value for the emergency tone option with value 1: alert. [CHAR LIMIT=30] -->
|
||||||
<string name="emergency_tone_alert">Alert</string>
|
<string name="emergency_tone_alert">Alert</string>
|
||||||
|
|
||||||
<!-- Sound & notifications > Other sounds: Value for the emergency tone option with value 2: vibrate. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Other sounds: Value for the emergency tone option with value 2: vibrate. [CHAR LIMIT=30] -->
|
||||||
<string name="emergency_tone_vibrate">Vibrate</string>
|
<string name="emergency_tone_vibrate">Vibrate</string>
|
||||||
|
|
||||||
<!-- Sound & notifications: Title for managing notification listeners option. [CHAR LIMIT=30] -->
|
<!-- Sound & notification > Notification section: Title for managing notification listeners option. [CHAR LIMIT=30] -->
|
||||||
<string name="manage_notification_access_title">Notification access</string>
|
<string name="manage_notification_access_title">Notification access</string>
|
||||||
|
|
||||||
<!-- Summary of preference to manage notification listeners, when none are enabled -->
|
<!-- Summary of preference to manage notification listeners, when none are enabled -->
|
||||||
@@ -5327,14 +5327,20 @@
|
|||||||
<!-- [CHAR LIMIT=30] Zen mode settings: Exit condition selection dialog, default option -->
|
<!-- [CHAR LIMIT=30] Zen mode settings: Exit condition selection dialog, default option -->
|
||||||
<string name="zen_mode_default_option">Until you turn this off</string>
|
<string name="zen_mode_default_option">Until you turn this off</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=40] Zen mode settings: General category text -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: Important category text -->
|
||||||
<string name="zen_mode_general_category">Block all interruptions except</string>
|
<string name="zen_mode_important_category">Priority interruptions</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=40] Zen mode settings: Automatic category text -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: Downtime category text -->
|
||||||
<string name="zen_mode_automatic_category">At night</string>
|
<string name="zen_mode_downtime_category">Downtime (priority interruptions only)</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=40] Zen mode settings: Downtime days option title -->
|
||||||
|
<string name="zen_mode_downtime_days">Days</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=40] Zen mode settings: Downtime days option value, no days set -->
|
||||||
|
<string name="zen_mode_downtime_days_none">None</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=40] Zen mode settings: Automation category text -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: Automation category text -->
|
||||||
<string name="zen_mode_automation_category">Other automation</string>
|
<string name="zen_mode_automation_category">Automation</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=40] Zen mode settings: Entry conditions option: title -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: Entry conditions option: title -->
|
||||||
<string name="zen_mode_entry_conditions_title">Automatically turn on</string>
|
<string name="zen_mode_entry_conditions_title">Automatically turn on</string>
|
||||||
@@ -5364,7 +5370,7 @@
|
|||||||
<string name="zen_mode_from_starred">Starred contacts only</string>
|
<string name="zen_mode_from_starred">Starred contacts only</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=60] Zen mode settings: Reminder text about alarms -->
|
<!-- [CHAR LIMIT=60] Zen mode settings: Reminder text about alarms -->
|
||||||
<string name="zen_mode_alarm_info">Alarms and timers are never blocked</string>
|
<string name="zen_mode_alarm_info">Alarms and timers are always priority interruptions</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=20] Zen mode settings: When option -->
|
<!-- [CHAR LIMIT=20] Zen mode settings: When option -->
|
||||||
<string name="zen_mode_when">Automatically turn on</string>
|
<string name="zen_mode_when">Automatically turn on</string>
|
||||||
|
@@ -1,42 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:title="@string/notification_display_settings"
|
|
||||||
android:key="notification_display_settings"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
|
||||||
|
|
||||||
<!-- Pulse notification light -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="notification_pulse"
|
|
||||||
android:title="@string/notification_pulse_title"
|
|
||||||
android:switchTextOff=""
|
|
||||||
android:switchTextOn=""
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<!-- When device is locked -->
|
|
||||||
<com.android.settings.notification.DropDownPreference
|
|
||||||
android:key="lock_screen_notifications"
|
|
||||||
android:title="@string/lock_screen_notifications_title"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<!-- App notifications -->
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="app_notifications"
|
|
||||||
android:title="@string/app_notifications_title"
|
|
||||||
android:fragment="com.android.settings.notification.AppNotificationSettings" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -19,6 +19,10 @@
|
|||||||
android:key="notification_settings"
|
android:key="notification_settings"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="sound"
|
||||||
|
android:title="@string/sound_settings" >
|
||||||
|
|
||||||
<!-- Media volume -->
|
<!-- Media volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
android:key="media_volume"
|
android:key="media_volume"
|
||||||
@@ -43,18 +47,18 @@
|
|||||||
android:icon="@*android:drawable/ic_audio_ring_notif"
|
android:icon="@*android:drawable/ic_audio_ring_notif"
|
||||||
android:title="@string/notification_volume_option_title" />
|
android:title="@string/notification_volume_option_title" />
|
||||||
|
|
||||||
<!-- Do not disturb -->
|
<!-- Also vibrate for calls -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="vibrate_when_ringing"
|
||||||
|
android:title="@string/vibrate_when_ringing_title"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<!-- Interruptions -->
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="zen_mode"
|
android:key="zen_mode"
|
||||||
android:title="@string/zen_mode_settings_title"
|
android:title="@string/zen_mode_settings_title"
|
||||||
android:fragment="com.android.settings.notification.ZenModeSettings" />
|
android:fragment="com.android.settings.notification.ZenModeSettings" />
|
||||||
|
|
||||||
<!-- When calls and notifications arrive -->
|
|
||||||
<com.android.settings.notification.DropDownPreference
|
|
||||||
android:key="ringer_mode"
|
|
||||||
android:title="@string/ringer_mode_title"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<!-- Phone ringtone -->
|
<!-- Phone ringtone -->
|
||||||
<com.android.settings.DefaultRingtonePreference
|
<com.android.settings.DefaultRingtonePreference
|
||||||
android:key="ringtone"
|
android:key="ringtone"
|
||||||
@@ -71,28 +75,39 @@
|
|||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:ringtoneType="notification" />
|
android:ringtoneType="notification" />
|
||||||
|
|
||||||
<!-- Vibrate when ringing -->
|
<!-- Other sounds -->
|
||||||
<SwitchPreference
|
|
||||||
android:key="vibrate_when_ringing"
|
|
||||||
android:title="@string/vibrate_when_ringing_title"
|
|
||||||
android:switchTextOff=""
|
|
||||||
android:switchTextOn=""
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<!-- Showing notifications -->
|
|
||||||
<Preference
|
|
||||||
android:key="showing_notifications"
|
|
||||||
android:title="@string/notification_display_settings"
|
|
||||||
android:persistent="false"
|
|
||||||
android:fragment="com.android.settings.notification.NotificationDisplaySettings" />
|
|
||||||
|
|
||||||
<!-- Touch sounds -->
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="other_sounds"
|
android:key="other_sounds"
|
||||||
android:title="@string/other_sound_settings"
|
android:title="@string/other_sound_settings"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:fragment="com.android.settings.notification.OtherSoundSettings" />
|
android:fragment="com.android.settings.notification.OtherSoundSettings" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="notification"
|
||||||
|
android:title="@string/notification_section_header" >
|
||||||
|
|
||||||
|
<!-- Pulse notification light -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="notification_pulse"
|
||||||
|
android:title="@string/notification_pulse_title"
|
||||||
|
android:switchTextOff=""
|
||||||
|
android:switchTextOn=""
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<!-- When device is locked -->
|
||||||
|
<com.android.settings.notification.DropDownPreference
|
||||||
|
android:key="lock_screen_notifications"
|
||||||
|
android:title="@string/lock_screen_notifications_title"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<!-- App notifications -->
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="app_notifications"
|
||||||
|
android:title="@string/app_notifications_title"
|
||||||
|
android:fragment="com.android.settings.notification.AppNotificationSettings" />
|
||||||
|
|
||||||
<!-- Notification access -->
|
<!-- Notification access -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="manage_notification_access"
|
android:key="manage_notification_access"
|
||||||
@@ -100,4 +115,6 @@
|
|||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:fragment="com.android.settings.notification.NotificationAccessSettings" />
|
android:fragment="com.android.settings.notification.NotificationAccessSettings" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -19,42 +19,58 @@
|
|||||||
android:key="zen_mode_settings"
|
android:key="zen_mode_settings"
|
||||||
android:title="@string/zen_mode_settings_title" >
|
android:title="@string/zen_mode_settings_title" >
|
||||||
|
|
||||||
|
<!-- When calls and notifications arrive -->
|
||||||
|
<com.android.settings.notification.DropDownPreference
|
||||||
|
android:key="zen_mode"
|
||||||
|
android:title="@string/zen_mode_option_title"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="general"
|
android:key="important"
|
||||||
android:layout="@layout/zen_mode_section_first"
|
android:title="@string/zen_mode_important_category" >
|
||||||
android:title="@string/zen_mode_general_category" >
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="phone_calls"
|
android:key="phone_calls"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:switchTextOff=""
|
android:switchTextOff=""
|
||||||
android:switchTextOn=""
|
android:switchTextOn=""
|
||||||
android:title="@string/zen_mode_phone_calls" />
|
android:title="@string/zen_mode_phone_calls" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="messages"
|
android:key="messages"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:switchTextOff=""
|
android:switchTextOff=""
|
||||||
android:switchTextOn=""
|
android:switchTextOn=""
|
||||||
android:title="@string/zen_mode_messages" />
|
android:title="@string/zen_mode_messages" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="automatic"
|
android:key="downtime"
|
||||||
android:layout="@layout/zen_mode_section"
|
android:title="@string/zen_mode_downtime_category" >
|
||||||
android:title="@string/zen_mode_automatic_category" />
|
|
||||||
|
<Preference
|
||||||
|
android:key="days"
|
||||||
|
android:title="@string/zen_mode_downtime_days"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="automation"
|
android:key="automation"
|
||||||
android:layout="@layout/zen_mode_section"
|
|
||||||
android:title="@string/zen_mode_automation_category" >
|
android:title="@string/zen_mode_automation_category" >
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="entry"
|
android:key="entry"
|
||||||
android:title="@string/zen_mode_entry_conditions_title"
|
android:title="@string/zen_mode_entry_conditions_title"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="manage_condition_providers"
|
android:key="manage_condition_providers"
|
||||||
android:title="@string/manage_condition_providers"
|
android:title="@string/manage_condition_providers"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:fragment="com.android.settings.notification.ConditionProviderSettings" />
|
android:fragment="com.android.settings.notification.ConditionProviderSettings" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -88,7 +88,6 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class NotificationSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class NotificationSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class NotificationDisplaySettingsActivity extends SettingsActivity { /* empty */ }
|
|
||||||
public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class OtherSoundSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class OtherSoundSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
|
||||||
|
@@ -353,7 +353,7 @@ public class AppNotificationSettings extends ListFragment {
|
|||||||
public void bindView(final View view, Row r, boolean animate) {
|
public void bindView(final View view, Row r, boolean animate) {
|
||||||
if (!(r instanceof AppRow)) {
|
if (!(r instanceof AppRow)) {
|
||||||
// it's a section row
|
// it's a section row
|
||||||
TextView tv = (TextView)view;
|
final TextView tv = (TextView)view.findViewById(android.R.id.title);
|
||||||
tv.setText(r.section);
|
tv.setText(r.section);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,184 +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.notification;
|
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.database.ContentObserver;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.preference.TwoStatePreference;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
|
||||||
|
|
||||||
public class NotificationDisplaySettings extends SettingsPreferenceFragment {
|
|
||||||
private static final String TAG = "NotificationDisplaySettings";
|
|
||||||
|
|
||||||
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
|
|
||||||
private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "lock_screen_notifications";
|
|
||||||
|
|
||||||
private final Handler mHandler = new Handler();
|
|
||||||
private final SettingsObserver mSettingsObserver = new SettingsObserver();
|
|
||||||
|
|
||||||
private TwoStatePreference mNotificationPulse;
|
|
||||||
private DropDownPreference mLockscreen;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.notification_display_settings);
|
|
||||||
|
|
||||||
final PreferenceScreen root = getPreferenceScreen();
|
|
||||||
initPulse(root);
|
|
||||||
initLockscreenNotifications(root);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
mSettingsObserver.register(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
mSettingsObserver.register(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// === Pulse notification light ===
|
|
||||||
|
|
||||||
private void initPulse(PreferenceScreen parent) {
|
|
||||||
mNotificationPulse = (TwoStatePreference) parent.findPreference(KEY_NOTIFICATION_PULSE);
|
|
||||||
if (mNotificationPulse == null) return;
|
|
||||||
if (!getResources()
|
|
||||||
.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) {
|
|
||||||
parent.removePreference(mNotificationPulse);
|
|
||||||
} else {
|
|
||||||
updatePulse();
|
|
||||||
mNotificationPulse.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
final boolean val = (Boolean)newValue;
|
|
||||||
return Settings.System.putInt(getContentResolver(),
|
|
||||||
Settings.System.NOTIFICATION_LIGHT_PULSE,
|
|
||||||
val ? 1 : 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePulse() {
|
|
||||||
if (mNotificationPulse == null) return;
|
|
||||||
try {
|
|
||||||
mNotificationPulse.setChecked(Settings.System.getInt(getContentResolver(),
|
|
||||||
Settings.System.NOTIFICATION_LIGHT_PULSE) == 1);
|
|
||||||
} catch (Settings.SettingNotFoundException snfe) {
|
|
||||||
Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// === Lockscreen (public / private) notifications ===
|
|
||||||
|
|
||||||
private void initLockscreenNotifications(PreferenceScreen parent) {
|
|
||||||
mLockscreen = (DropDownPreference) parent.findPreference(KEY_LOCK_SCREEN_NOTIFICATIONS);
|
|
||||||
if (mLockscreen == null) return;
|
|
||||||
mLockscreen.addItem(R.string.lock_screen_notifications_summary_show,
|
|
||||||
R.string.lock_screen_notifications_summary_show);
|
|
||||||
mLockscreen.addItem(R.string.lock_screen_notifications_summary_hide,
|
|
||||||
R.string.lock_screen_notifications_summary_hide);
|
|
||||||
mLockscreen.addItem(R.string.lock_screen_notifications_summary_disable,
|
|
||||||
R.string.lock_screen_notifications_summary_disable);
|
|
||||||
updateLockscreenNotifications();
|
|
||||||
mLockscreen.setCallback(new DropDownPreference.Callback() {
|
|
||||||
@Override
|
|
||||||
public boolean onItemSelected(int pos, Object value) {
|
|
||||||
final int val = (Integer) value;
|
|
||||||
final boolean enabled = val != R.string.lock_screen_notifications_summary_disable;
|
|
||||||
final boolean show = val == R.string.lock_screen_notifications_summary_show;
|
|
||||||
Settings.Secure.putInt(getContentResolver(),
|
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
|
|
||||||
Settings.Global.putInt(getContentResolver(),
|
|
||||||
Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLockscreenNotifications() {
|
|
||||||
if (mLockscreen == null) return;
|
|
||||||
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
|
|
||||||
final boolean enabled = getLockscreenNotificationsEnabled();
|
|
||||||
final int val = !enabled ? R.string.lock_screen_notifications_summary_disable :
|
|
||||||
allowPrivate ? R.string.lock_screen_notifications_summary_show :
|
|
||||||
R.string.lock_screen_notifications_summary_hide;
|
|
||||||
mLockscreen.setSelectedValue(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean getLockscreenNotificationsEnabled() {
|
|
||||||
return Settings.Global.getInt(getContentResolver(),
|
|
||||||
Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean getLockscreenAllowPrivateNotifications() {
|
|
||||||
return Settings.Secure.getInt(getContentResolver(),
|
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// === Callbacks ===
|
|
||||||
|
|
||||||
private final class SettingsObserver extends ContentObserver {
|
|
||||||
private final Uri NOTIFICATION_LIGHT_PULSE_URI =
|
|
||||||
Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
|
|
||||||
private final Uri LOCK_SCREEN_PRIVATE_URI =
|
|
||||||
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);
|
|
||||||
private final Uri LOCK_SCREEN_SHOW_URI =
|
|
||||||
Settings.Global.getUriFor(Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS);
|
|
||||||
|
|
||||||
public SettingsObserver() {
|
|
||||||
super(mHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register(boolean register) {
|
|
||||||
final ContentResolver cr = getContentResolver();
|
|
||||||
if (register) {
|
|
||||||
cr.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI, false, this);
|
|
||||||
cr.registerContentObserver(LOCK_SCREEN_PRIVATE_URI, false, this);
|
|
||||||
cr.registerContentObserver(LOCK_SCREEN_SHOW_URI, false, this);
|
|
||||||
} else {
|
|
||||||
cr.unregisterContentObserver(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
|
||||||
super.onChange(selfChange, uri);
|
|
||||||
if (NOTIFICATION_LIGHT_PULSE_URI.equals(uri)) {
|
|
||||||
updatePulse();
|
|
||||||
}
|
|
||||||
if (LOCK_SCREEN_PRIVATE_URI.equals(uri) || LOCK_SCREEN_SHOW_URI.equals(uri)) {
|
|
||||||
updateLockscreenNotifications();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -16,11 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@@ -35,12 +32,13 @@ import android.os.Looper;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.SeekBarVolumizer;
|
import android.preference.SeekBarVolumizer;
|
||||||
import android.preference.TwoStatePreference;
|
import android.preference.TwoStatePreference;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
@@ -55,14 +53,17 @@ import java.util.List;
|
|||||||
public class NotificationSettings extends SettingsPreferenceFragment implements Indexable {
|
public class NotificationSettings extends SettingsPreferenceFragment implements Indexable {
|
||||||
private static final String TAG = "NotificationSettings";
|
private static final String TAG = "NotificationSettings";
|
||||||
|
|
||||||
|
private static final String KEY_SOUND = "sound";
|
||||||
private static final String KEY_MEDIA_VOLUME = "media_volume";
|
private static final String KEY_MEDIA_VOLUME = "media_volume";
|
||||||
private static final String KEY_ALARM_VOLUME = "alarm_volume";
|
private static final String KEY_ALARM_VOLUME = "alarm_volume";
|
||||||
private static final String KEY_RING_VOLUME = "ring_volume";
|
private static final String KEY_RING_VOLUME = "ring_volume";
|
||||||
private static final String KEY_NOTIFICATION_VOLUME = "notification_volume";
|
private static final String KEY_NOTIFICATION_VOLUME = "notification_volume";
|
||||||
private static final String KEY_RINGER_MODE = "ringer_mode";
|
|
||||||
private static final String KEY_PHONE_RINGTONE = "ringtone";
|
private static final String KEY_PHONE_RINGTONE = "ringtone";
|
||||||
private static final String KEY_NOTIFICATION_RINGTONE = "notification_ringtone";
|
private static final String KEY_NOTIFICATION_RINGTONE = "notification_ringtone";
|
||||||
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
||||||
|
private static final String KEY_NOTIFICATION = "notification";
|
||||||
|
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
|
||||||
|
private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "lock_screen_notifications";
|
||||||
private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access";
|
private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access";
|
||||||
|
|
||||||
private static final int SAMPLE_CUTOFF = 2000; // manually cap sample playback at 2 seconds
|
private static final int SAMPLE_CUTOFF = 2000; // manually cap sample playback at 2 seconds
|
||||||
@@ -75,10 +76,11 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
private PackageManager mPM;
|
private PackageManager mPM;
|
||||||
private boolean mVoiceCapable;
|
private boolean mVoiceCapable;
|
||||||
|
|
||||||
private DropDownPreference mRingerMode;
|
|
||||||
private Preference mPhoneRingtonePreference;
|
private Preference mPhoneRingtonePreference;
|
||||||
private Preference mNotificationRingtonePreference;
|
private Preference mNotificationRingtonePreference;
|
||||||
private TwoStatePreference mVibrateWhenRinging;
|
private TwoStatePreference mVibrateWhenRinging;
|
||||||
|
private TwoStatePreference mNotificationPulse;
|
||||||
|
private DropDownPreference mLockscreen;
|
||||||
private Preference mNotificationAccess;
|
private Preference mNotificationAccess;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,19 +91,23 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
mVoiceCapable = Utils.isVoiceCapable(mContext);
|
mVoiceCapable = Utils.isVoiceCapable(mContext);
|
||||||
addPreferencesFromResource(R.xml.notification_settings);
|
addPreferencesFromResource(R.xml.notification_settings);
|
||||||
|
|
||||||
final PreferenceScreen root = getPreferenceScreen();
|
final PreferenceCategory sound = (PreferenceCategory) findPreference(KEY_SOUND);
|
||||||
initVolumePreference(KEY_MEDIA_VOLUME, AudioManager.STREAM_MUSIC);
|
initVolumePreference(KEY_MEDIA_VOLUME, AudioManager.STREAM_MUSIC);
|
||||||
initVolumePreference(KEY_ALARM_VOLUME, AudioManager.STREAM_ALARM);
|
initVolumePreference(KEY_ALARM_VOLUME, AudioManager.STREAM_ALARM);
|
||||||
if (mVoiceCapable) {
|
if (mVoiceCapable) {
|
||||||
initVolumePreference(KEY_RING_VOLUME, AudioManager.STREAM_RING);
|
initVolumePreference(KEY_RING_VOLUME, AudioManager.STREAM_RING);
|
||||||
removePreference(KEY_NOTIFICATION_VOLUME);
|
sound.removePreference(sound.findPreference(KEY_NOTIFICATION_VOLUME));
|
||||||
} else {
|
} else {
|
||||||
initVolumePreference(KEY_NOTIFICATION_VOLUME, AudioManager.STREAM_NOTIFICATION);
|
initVolumePreference(KEY_NOTIFICATION_VOLUME, AudioManager.STREAM_NOTIFICATION);
|
||||||
removePreference(KEY_RING_VOLUME);
|
sound.removePreference(sound.findPreference(KEY_RING_VOLUME));
|
||||||
}
|
}
|
||||||
initRingerMode(root);
|
initRingtones(sound);
|
||||||
initRingtones(root);
|
initVibrateWhenRinging(sound);
|
||||||
initVibrateWhenRinging(root);
|
|
||||||
|
final PreferenceCategory notification = (PreferenceCategory)
|
||||||
|
findPreference(KEY_NOTIFICATION);
|
||||||
|
initPulse(notification);
|
||||||
|
initLockscreenNotifications(notification);
|
||||||
|
|
||||||
mNotificationAccess = findPreference(KEY_NOTIFICATION_ACCESS);
|
mNotificationAccess = findPreference(KEY_NOTIFICATION_ACCESS);
|
||||||
refreshNotificationListeners();
|
refreshNotificationListeners();
|
||||||
@@ -112,8 +118,6 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
refreshNotificationListeners();
|
refreshNotificationListeners();
|
||||||
lookupRingtoneNames();
|
lookupRingtoneNames();
|
||||||
final IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
|
||||||
mContext.registerReceiver(mReceiver, filter);
|
|
||||||
mSettingsObserver.register(true);
|
mSettingsObserver.register(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +125,6 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mVolumeCallback.stopSample();
|
mVolumeCallback.stopSample();
|
||||||
mContext.unregisterReceiver(mReceiver);
|
|
||||||
mSettingsObserver.register(false);
|
mSettingsObserver.register(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,37 +158,10 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// === Ringer mode ===
|
|
||||||
|
|
||||||
private void initRingerMode(PreferenceScreen root) {
|
|
||||||
mRingerMode = (DropDownPreference) root.findPreference(KEY_RINGER_MODE);
|
|
||||||
if (mRingerMode == null) return;
|
|
||||||
if (!mVoiceCapable) {
|
|
||||||
mRingerMode.setTitle(R.string.ringer_mode_title_novoice);
|
|
||||||
}
|
|
||||||
final AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
mRingerMode.addItem(R.string.ringer_mode_audible, AudioManager.RINGER_MODE_NORMAL);
|
|
||||||
mRingerMode.addItem(R.string.ringer_mode_vibrate, AudioManager.RINGER_MODE_VIBRATE);
|
|
||||||
mRingerMode.addItem(R.string.ringer_mode_silent, AudioManager.RINGER_MODE_SILENT);
|
|
||||||
updateRingerMode();
|
|
||||||
mRingerMode.setCallback(new DropDownPreference.Callback() {
|
|
||||||
@Override
|
|
||||||
public boolean onItemSelected(int pos, Object value) {
|
|
||||||
final int val = (Integer) value;
|
|
||||||
am.setRingerMode(val);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateRingerMode() {
|
|
||||||
final AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
mRingerMode.setSelectedValue(am.getRingerMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
// === Phone & notification ringtone ===
|
// === Phone & notification ringtone ===
|
||||||
|
|
||||||
private void initRingtones(PreferenceScreen root) {
|
private void initRingtones(PreferenceCategory root) {
|
||||||
mPhoneRingtonePreference = root.findPreference(KEY_PHONE_RINGTONE);
|
mPhoneRingtonePreference = root.findPreference(KEY_PHONE_RINGTONE);
|
||||||
if (mPhoneRingtonePreference != null && !mVoiceCapable) {
|
if (mPhoneRingtonePreference != null && !mVoiceCapable) {
|
||||||
root.removePreference(mPhoneRingtonePreference);
|
root.removePreference(mPhoneRingtonePreference);
|
||||||
@@ -219,7 +195,10 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static CharSequence updateRingtoneName(Context context, int type) {
|
private static CharSequence updateRingtoneName(Context context, int type) {
|
||||||
if (context == null) return null;
|
if (context == null) {
|
||||||
|
Log.e(TAG, "Unable to update ringtone name, no context provided");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
|
Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
|
||||||
CharSequence summary = context.getString(com.android.internal.R.string.ringtone_unknown);
|
CharSequence summary = context.getString(com.android.internal.R.string.ringtone_unknown);
|
||||||
// Is it a silent ringtone?
|
// Is it a silent ringtone?
|
||||||
@@ -249,9 +228,12 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
// === Vibrate when ringing ===
|
// === Vibrate when ringing ===
|
||||||
|
|
||||||
private void initVibrateWhenRinging(PreferenceScreen root) {
|
private void initVibrateWhenRinging(PreferenceCategory root) {
|
||||||
mVibrateWhenRinging = (TwoStatePreference) root.findPreference(KEY_VIBRATE_WHEN_RINGING);
|
mVibrateWhenRinging = (TwoStatePreference) root.findPreference(KEY_VIBRATE_WHEN_RINGING);
|
||||||
if (mVibrateWhenRinging == null) return;
|
if (mVibrateWhenRinging == null) {
|
||||||
|
Log.i(TAG, "Preference not found: " + KEY_VIBRATE_WHEN_RINGING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!mVoiceCapable) {
|
if (!mVoiceCapable) {
|
||||||
root.removePreference(mVibrateWhenRinging);
|
root.removePreference(mVibrateWhenRinging);
|
||||||
mVibrateWhenRinging = null;
|
mVibrateWhenRinging = null;
|
||||||
@@ -276,6 +258,95 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
Settings.System.VIBRATE_WHEN_RINGING, 0) != 0);
|
Settings.System.VIBRATE_WHEN_RINGING, 0) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Pulse notification light ===
|
||||||
|
|
||||||
|
private void initPulse(PreferenceCategory parent) {
|
||||||
|
mNotificationPulse = (TwoStatePreference) parent.findPreference(KEY_NOTIFICATION_PULSE);
|
||||||
|
if (mNotificationPulse == null) {
|
||||||
|
Log.i(TAG, "Preference not found: " + KEY_NOTIFICATION_PULSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getResources()
|
||||||
|
.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) {
|
||||||
|
parent.removePreference(mNotificationPulse);
|
||||||
|
} else {
|
||||||
|
updatePulse();
|
||||||
|
mNotificationPulse.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
final boolean val = (Boolean)newValue;
|
||||||
|
return Settings.System.putInt(getContentResolver(),
|
||||||
|
Settings.System.NOTIFICATION_LIGHT_PULSE,
|
||||||
|
val ? 1 : 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePulse() {
|
||||||
|
if (mNotificationPulse == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mNotificationPulse.setChecked(Settings.System.getInt(getContentResolver(),
|
||||||
|
Settings.System.NOTIFICATION_LIGHT_PULSE) == 1);
|
||||||
|
} catch (Settings.SettingNotFoundException snfe) {
|
||||||
|
Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Lockscreen (public / private) notifications ===
|
||||||
|
|
||||||
|
private void initLockscreenNotifications(PreferenceCategory parent) {
|
||||||
|
mLockscreen = (DropDownPreference) parent.findPreference(KEY_LOCK_SCREEN_NOTIFICATIONS);
|
||||||
|
if (mLockscreen == null) {
|
||||||
|
Log.i(TAG, "Preference not found: " + KEY_LOCK_SCREEN_NOTIFICATIONS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mLockscreen.addItem(R.string.lock_screen_notifications_summary_show,
|
||||||
|
R.string.lock_screen_notifications_summary_show);
|
||||||
|
mLockscreen.addItem(R.string.lock_screen_notifications_summary_hide,
|
||||||
|
R.string.lock_screen_notifications_summary_hide);
|
||||||
|
mLockscreen.addItem(R.string.lock_screen_notifications_summary_disable,
|
||||||
|
R.string.lock_screen_notifications_summary_disable);
|
||||||
|
updateLockscreenNotifications();
|
||||||
|
mLockscreen.setCallback(new DropDownPreference.Callback() {
|
||||||
|
@Override
|
||||||
|
public boolean onItemSelected(int pos, Object value) {
|
||||||
|
final int val = (Integer) value;
|
||||||
|
final boolean enabled = val != R.string.lock_screen_notifications_summary_disable;
|
||||||
|
final boolean show = val == R.string.lock_screen_notifications_summary_show;
|
||||||
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
|
||||||
|
Settings.Global.putInt(getContentResolver(),
|
||||||
|
Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateLockscreenNotifications() {
|
||||||
|
if (mLockscreen == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
|
||||||
|
final boolean enabled = getLockscreenNotificationsEnabled();
|
||||||
|
final int selectedVal = !enabled ? R.string.lock_screen_notifications_summary_disable :
|
||||||
|
allowPrivate ? R.string.lock_screen_notifications_summary_show :
|
||||||
|
R.string.lock_screen_notifications_summary_hide;
|
||||||
|
mLockscreen.setSelectedValue(selectedVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getLockscreenNotificationsEnabled() {
|
||||||
|
return Settings.Global.getInt(getContentResolver(),
|
||||||
|
Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getLockscreenAllowPrivateNotifications() {
|
||||||
|
return Settings.Secure.getInt(getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
// === Notification listeners ===
|
// === Notification listeners ===
|
||||||
|
|
||||||
private void refreshNotificationListeners() {
|
private void refreshNotificationListeners() {
|
||||||
@@ -299,18 +370,15 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
// === Callbacks ===
|
// === Callbacks ===
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(intent.getAction())) {
|
|
||||||
updateRingerMode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final class SettingsObserver extends ContentObserver {
|
private final class SettingsObserver extends ContentObserver {
|
||||||
private final Uri VIBRATE_WHEN_RINGING_URI =
|
private final Uri VIBRATE_WHEN_RINGING_URI =
|
||||||
Settings.System.getUriFor(Settings.System.VIBRATE_WHEN_RINGING);
|
Settings.System.getUriFor(Settings.System.VIBRATE_WHEN_RINGING);
|
||||||
|
private final Uri NOTIFICATION_LIGHT_PULSE_URI =
|
||||||
|
Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
|
||||||
|
private final Uri LOCK_SCREEN_PRIVATE_URI =
|
||||||
|
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);
|
||||||
|
private final Uri LOCK_SCREEN_SHOW_URI =
|
||||||
|
Settings.Global.getUriFor(Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS);
|
||||||
|
|
||||||
public SettingsObserver() {
|
public SettingsObserver() {
|
||||||
super(mHandler);
|
super(mHandler);
|
||||||
@@ -320,6 +388,9 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
final ContentResolver cr = getContentResolver();
|
final ContentResolver cr = getContentResolver();
|
||||||
if (register) {
|
if (register) {
|
||||||
cr.registerContentObserver(VIBRATE_WHEN_RINGING_URI, false, this);
|
cr.registerContentObserver(VIBRATE_WHEN_RINGING_URI, false, this);
|
||||||
|
cr.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI, false, this);
|
||||||
|
cr.registerContentObserver(LOCK_SCREEN_PRIVATE_URI, false, this);
|
||||||
|
cr.registerContentObserver(LOCK_SCREEN_SHOW_URI, false, this);
|
||||||
} else {
|
} else {
|
||||||
cr.unregisterContentObserver(this);
|
cr.unregisterContentObserver(this);
|
||||||
}
|
}
|
||||||
@@ -331,6 +402,12 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
if (VIBRATE_WHEN_RINGING_URI.equals(uri)) {
|
if (VIBRATE_WHEN_RINGING_URI.equals(uri)) {
|
||||||
updateVibrateWhenRinging();
|
updateVibrateWhenRinging();
|
||||||
}
|
}
|
||||||
|
if (NOTIFICATION_LIGHT_PULSE_URI.equals(uri)) {
|
||||||
|
updatePulse();
|
||||||
|
}
|
||||||
|
if (LOCK_SCREEN_PRIVATE_URI.equals(uri) || LOCK_SCREEN_SHOW_URI.equals(uri)) {
|
||||||
|
updateLockscreenNotifications();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ public class SettingPref {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(SettingsPreferenceFragment settings) {
|
public Preference init(SettingsPreferenceFragment settings) {
|
||||||
final Context context = settings.getActivity();
|
final Context context = settings.getActivity();
|
||||||
Preference p = settings.getPreferenceScreen().findPreference(mKey);
|
Preference p = settings.getPreferenceScreen().findPreference(mKey);
|
||||||
if (p != null && !isApplicable(context)) {
|
if (p != null && !isApplicable(context)) {
|
||||||
@@ -84,14 +84,18 @@ public class SettingPref {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (mDropDown != null) {
|
return mTwoState;
|
||||||
|
}
|
||||||
|
if (mDropDown != null) {
|
||||||
mDropDown.setCallback(new DropDownPreference.Callback() {
|
mDropDown.setCallback(new DropDownPreference.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemSelected(int pos, Object value) {
|
public boolean onItemSelected(int pos, Object value) {
|
||||||
return setSetting(context, (Integer) value);
|
return setSetting(context, (Integer) value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return mDropDown;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean setSetting(Context context, int value) {
|
protected boolean setSetting(Context context, int value) {
|
||||||
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* 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.notification;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.service.notification.ZenModeConfig;
|
||||||
|
import android.util.SparseBooleanArray;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
public class ZenModeDowntimeDaysSelection extends LinearLayout {
|
||||||
|
private static final int[] DAYS = {
|
||||||
|
Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY,
|
||||||
|
Calendar.SATURDAY, Calendar.SUNDAY
|
||||||
|
};
|
||||||
|
private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("EEEE");
|
||||||
|
|
||||||
|
private final SparseBooleanArray mDays = new SparseBooleanArray();
|
||||||
|
|
||||||
|
public ZenModeDowntimeDaysSelection(Context context, String mode) {
|
||||||
|
super(context);
|
||||||
|
final int[] days = ZenModeConfig.tryParseDays(mode);
|
||||||
|
if (days != null) {
|
||||||
|
for (int i = 0; i < days.length; i++) {
|
||||||
|
mDays.put(days[i], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setOrientation(VERTICAL);
|
||||||
|
final Calendar c = Calendar.getInstance();
|
||||||
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
|
for (int i = 0; i < DAYS.length; i++) {
|
||||||
|
final int day = DAYS[i];
|
||||||
|
final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.zen_downtime_day,
|
||||||
|
this, false);
|
||||||
|
c.set(Calendar.DAY_OF_WEEK, day);
|
||||||
|
checkBox.setText(DAY_FORMAT.format(c.getTime()));
|
||||||
|
checkBox.setChecked(mDays.get(day));
|
||||||
|
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
mDays.put(day, isChecked);
|
||||||
|
onChanged(getMode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addView(checkBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMode() {
|
||||||
|
final StringBuilder sb = new StringBuilder(ZenModeConfig.SLEEP_MODE_DAYS_PREFIX);
|
||||||
|
boolean empty = true;
|
||||||
|
for (int i = 0; i < mDays.size(); i++) {
|
||||||
|
final int day = mDays.keyAt(i);
|
||||||
|
if (!mDays.valueAt(i)) continue;
|
||||||
|
if (empty) {
|
||||||
|
empty = false;
|
||||||
|
} else {
|
||||||
|
sb.append(',');
|
||||||
|
}
|
||||||
|
sb.append(day);
|
||||||
|
}
|
||||||
|
return empty ? null : sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onChanged(String mode) {
|
||||||
|
// event hook for subclasses
|
||||||
|
}
|
||||||
|
}
|
@@ -30,7 +30,6 @@ import android.content.res.Resources;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
@@ -48,37 +47,34 @@ import android.util.Log;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
import com.android.settings.search.SearchIndexableRaw;
|
import com.android.settings.search.SearchIndexableRaw;
|
||||||
import com.android.settings.widget.SwitchBar;
|
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ZenModeSettings extends SettingsPreferenceFragment implements Indexable,
|
public class ZenModeSettings extends SettingsPreferenceFragment implements Indexable {
|
||||||
SwitchBar.OnSwitchChangeListener {
|
|
||||||
private static final String TAG = "ZenModeSettings";
|
private static final String TAG = "ZenModeSettings";
|
||||||
private static final boolean DEBUG = true;
|
private static final boolean DEBUG = true;
|
||||||
private static final boolean SHOW_CONDITION_DIALOG = false;
|
|
||||||
|
|
||||||
private static final String KEY_GENERAL = "general";
|
private static final String KEY_ZEN_MODE = "zen_mode";
|
||||||
|
private static final String KEY_IMPORTANT = "important";
|
||||||
private static final String KEY_CALLS = "phone_calls";
|
private static final String KEY_CALLS = "phone_calls";
|
||||||
private static final String KEY_MESSAGES = "messages";
|
private static final String KEY_MESSAGES = "messages";
|
||||||
private static final String KEY_STARRED = "starred";
|
private static final String KEY_STARRED = "starred";
|
||||||
|
|
||||||
private static final String KEY_AUTOMATIC = "automatic";
|
private static final String KEY_DOWNTIME = "downtime";
|
||||||
private static final String KEY_WHEN = "when";
|
private static final String KEY_DAYS = "days";
|
||||||
private static final String KEY_START_TIME = "start_time";
|
private static final String KEY_START_TIME = "start_time";
|
||||||
private static final String KEY_END_TIME = "end_time";
|
private static final String KEY_END_TIME = "end_time";
|
||||||
|
|
||||||
@@ -86,16 +82,36 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
private static final String KEY_ENTRY = "entry";
|
private static final String KEY_ENTRY = "entry";
|
||||||
private static final String KEY_CONDITION_PROVIDERS = "manage_condition_providers";
|
private static final String KEY_CONDITION_PROVIDERS = "manage_condition_providers";
|
||||||
|
|
||||||
|
private static final SettingPref PREF_ZEN_MODE = new SettingPref(SettingPref.TYPE_GLOBAL,
|
||||||
|
KEY_ZEN_MODE, Global.ZEN_MODE, Global.ZEN_MODE_OFF, Global.ZEN_MODE_OFF,
|
||||||
|
Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, Global.ZEN_MODE_NO_INTERRUPTIONS) {
|
||||||
|
protected String getCaption(Resources res, int value) {
|
||||||
|
switch (value) {
|
||||||
|
case Global.ZEN_MODE_NO_INTERRUPTIONS:
|
||||||
|
return res.getString(R.string.zen_mode_option_no_interruptions);
|
||||||
|
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
||||||
|
return res.getString(R.string.zen_mode_option_important_interruptions);
|
||||||
|
default:
|
||||||
|
return res.getString(R.string.zen_mode_option_off);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("EEE");
|
||||||
|
|
||||||
private static SparseArray<String> allKeyTitles(Context context) {
|
private static SparseArray<String> allKeyTitles(Context context) {
|
||||||
final SparseArray<String> rt = new SparseArray<String>();
|
final SparseArray<String> rt = new SparseArray<String>();
|
||||||
rt.put(R.string.zen_mode_general_category, KEY_GENERAL);
|
rt.put(R.string.zen_mode_important_category, KEY_IMPORTANT);
|
||||||
if (Utils.isVoiceCapable(context)) {
|
if (Utils.isVoiceCapable(context)) {
|
||||||
rt.put(R.string.zen_mode_phone_calls, KEY_CALLS);
|
rt.put(R.string.zen_mode_phone_calls, KEY_CALLS);
|
||||||
|
rt.put(R.string.zen_mode_option_title, KEY_ZEN_MODE);
|
||||||
|
} else {
|
||||||
|
rt.put(R.string.zen_mode_option_title_novoice, KEY_ZEN_MODE);
|
||||||
}
|
}
|
||||||
rt.put(R.string.zen_mode_messages, KEY_MESSAGES);
|
rt.put(R.string.zen_mode_messages, KEY_MESSAGES);
|
||||||
rt.put(R.string.zen_mode_from_starred, KEY_STARRED);
|
rt.put(R.string.zen_mode_from_starred, KEY_STARRED);
|
||||||
rt.put(R.string.zen_mode_automatic_category, KEY_AUTOMATIC);
|
rt.put(R.string.zen_mode_downtime_category, KEY_DOWNTIME);
|
||||||
rt.put(R.string.zen_mode_when, KEY_WHEN);
|
rt.put(R.string.zen_mode_downtime_days, KEY_DAYS);
|
||||||
rt.put(R.string.zen_mode_start_time, KEY_START_TIME);
|
rt.put(R.string.zen_mode_start_time, KEY_START_TIME);
|
||||||
rt.put(R.string.zen_mode_end_time, KEY_END_TIME);
|
rt.put(R.string.zen_mode_end_time, KEY_END_TIME);
|
||||||
rt.put(R.string.zen_mode_automation_category, KEY_AUTOMATION);
|
rt.put(R.string.zen_mode_automation_category, KEY_AUTOMATION);
|
||||||
@@ -106,7 +122,6 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
private final SettingsObserver mSettingsObserver = new SettingsObserver();
|
private final SettingsObserver mSettingsObserver = new SettingsObserver();
|
||||||
|
|
||||||
private SwitchBar mSwitchBar;
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private PackageManager mPM;
|
private PackageManager mPM;
|
||||||
private ZenModeConfig mConfig;
|
private ZenModeConfig mConfig;
|
||||||
@@ -114,42 +129,20 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
private SwitchPreference mCalls;
|
private SwitchPreference mCalls;
|
||||||
private SwitchPreference mMessages;
|
private SwitchPreference mMessages;
|
||||||
private DropDownPreference mStarred;
|
private DropDownPreference mStarred;
|
||||||
private DropDownPreference mWhen;
|
private Preference mDays;
|
||||||
private TimePickerPreference mStart;
|
private TimePickerPreference mStart;
|
||||||
private TimePickerPreference mEnd;
|
private TimePickerPreference mEnd;
|
||||||
private PreferenceCategory mAutomationCategory;
|
private PreferenceCategory mAutomationCategory;
|
||||||
private Preference mEntry;
|
private Preference mEntry;
|
||||||
private Preference mConditionProviders;
|
private Preference mConditionProviders;
|
||||||
private AlertDialog mDialog;
|
|
||||||
private boolean mIgnoreNext;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSwitchChanged(Switch switchView, final boolean isChecked) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
if (DEBUG) Log.d(TAG, "onPreferenceChange isChecked=" + isChecked
|
super.onCreate(savedInstanceState);
|
||||||
+ " mIgnoreNext=" + mIgnoreNext);
|
|
||||||
if (mIgnoreNext) {
|
|
||||||
mIgnoreNext = false;
|
|
||||||
}
|
|
||||||
AsyncTask.execute(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final int v = isChecked ? Global.ZEN_MODE_ON : Global.ZEN_MODE_OFF;
|
|
||||||
putZenModeSetting(v);
|
|
||||||
final int n = ConditionProviderSettings.getEnabledProviderCount(mContext);
|
|
||||||
if (SHOW_CONDITION_DIALOG && n > 0) {
|
|
||||||
mHandler.post(isChecked ? mShowDialog : mHideDialog);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
mContext = getActivity();
|
mContext = getActivity();
|
||||||
mPM = mContext.getPackageManager();
|
mPM = mContext.getPackageManager();
|
||||||
final Resources res = mContext.getResources();
|
final Resources res = mContext.getResources();
|
||||||
final int p = res.getDimensionPixelSize(R.dimen.content_margin_left);
|
final int padding = res.getDimensionPixelSize(R.dimen.content_margin_left);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.zen_mode_settings);
|
addPreferencesFromResource(R.xml.zen_mode_settings);
|
||||||
final PreferenceScreen root = getPreferenceScreen();
|
final PreferenceScreen root = getPreferenceScreen();
|
||||||
@@ -157,13 +150,15 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
mConfig = getZenModeConfig();
|
mConfig = getZenModeConfig();
|
||||||
if (DEBUG) Log.d(TAG, "Loaded mConfig=" + mConfig);
|
if (DEBUG) Log.d(TAG, "Loaded mConfig=" + mConfig);
|
||||||
|
|
||||||
mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
|
final Preference zenMode = PREF_ZEN_MODE.init(this);
|
||||||
mSwitchBar.addOnSwitchChangeListener(this);
|
if (!Utils.isVoiceCapable(mContext)) {
|
||||||
mSwitchBar.show();
|
zenMode.setTitle(R.string.zen_mode_option_title_novoice);
|
||||||
|
}
|
||||||
|
|
||||||
final PreferenceCategory general = (PreferenceCategory) root.findPreference(KEY_GENERAL);
|
final PreferenceCategory important =
|
||||||
|
(PreferenceCategory) root.findPreference(KEY_IMPORTANT);
|
||||||
|
|
||||||
mCalls = (SwitchPreference) general.findPreference(KEY_CALLS);
|
mCalls = (SwitchPreference) important.findPreference(KEY_CALLS);
|
||||||
if (Utils.isVoiceCapable(mContext)) {
|
if (Utils.isVoiceCapable(mContext)) {
|
||||||
mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -178,11 +173,11 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
general.removePreference(mCalls);
|
important.removePreference(mCalls);
|
||||||
mCalls = null;
|
mCalls = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mMessages = (SwitchPreference) general.findPreference(KEY_MESSAGES);
|
mMessages = (SwitchPreference) important.findPreference(KEY_MESSAGES);
|
||||||
mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
@@ -216,44 +211,52 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
return setZenModeConfig(newConfig);
|
return setZenModeConfig(newConfig);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
general.addPreference(mStarred);
|
important.addPreference(mStarred);
|
||||||
|
|
||||||
final Preference alarmInfo = new Preference(mContext) {
|
final Preference alarmInfo = new Preference(mContext) {
|
||||||
@Override
|
@Override
|
||||||
public View getView(View convertView, ViewGroup parent) {
|
public View getView(View convertView, ViewGroup parent) {
|
||||||
final TextView tv = new TextView(mContext);
|
final TextView tv = new TextView(mContext);
|
||||||
tv.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC));
|
tv.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC));
|
||||||
tv.setPadding(p, p, p, p);
|
tv.setPadding(padding, padding, padding, padding);
|
||||||
tv.setText(R.string.zen_mode_alarm_info);
|
tv.setText(R.string.zen_mode_alarm_info);
|
||||||
return tv;
|
return tv;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
alarmInfo.setPersistent(false);
|
alarmInfo.setPersistent(false);
|
||||||
alarmInfo.setSelectable(false);
|
alarmInfo.setSelectable(false);
|
||||||
general.addPreference(alarmInfo);
|
important.addPreference(alarmInfo);
|
||||||
|
|
||||||
final PreferenceCategory auto = (PreferenceCategory) root.findPreference(KEY_AUTOMATIC);
|
final PreferenceCategory downtime = (PreferenceCategory) root.findPreference(KEY_DOWNTIME);
|
||||||
|
|
||||||
mWhen = new DropDownPreference(mContext);
|
mDays = downtime.findPreference(KEY_DAYS);
|
||||||
mWhen.setKey(KEY_WHEN);
|
mDays.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
mWhen.setTitle(R.string.zen_mode_when);
|
|
||||||
mWhen.setDropDownWidth(R.dimen.zen_mode_dropdown_width);
|
|
||||||
mWhen.addItem(R.string.zen_mode_when_every_night, ZenModeConfig.SLEEP_MODE_NIGHTS);
|
|
||||||
mWhen.addItem(R.string.zen_mode_when_weeknights, ZenModeConfig.SLEEP_MODE_WEEKNIGHTS);
|
|
||||||
mWhen.addItem(R.string.zen_mode_when_never, null);
|
|
||||||
mWhen.setCallback(new DropDownPreference.Callback() {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemSelected(int pos, Object value) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
if (mDisableListeners) return true;
|
new AlertDialog.Builder(mContext)
|
||||||
final String mode = (String) value;
|
.setTitle(R.string.zen_mode_downtime_days)
|
||||||
if (Objects.equals(mode, mConfig.sleepMode)) return true;
|
.setView(new ZenModeDowntimeDaysSelection(mContext, mConfig.sleepMode) {
|
||||||
if (DEBUG) Log.d(TAG, "onPrefChange sleepMode=" + mode);
|
@Override
|
||||||
|
protected void onChanged(String mode) {
|
||||||
|
if (mDisableListeners) return;
|
||||||
|
if (Objects.equals(mode, mConfig.sleepMode)) return;
|
||||||
|
if (DEBUG) Log.d(TAG, "days.onChanged sleepMode=" + mode);
|
||||||
final ZenModeConfig newConfig = mConfig.copy();
|
final ZenModeConfig newConfig = mConfig.copy();
|
||||||
newConfig.sleepMode = mode;
|
newConfig.sleepMode = mode;
|
||||||
return setZenModeConfig(newConfig);
|
setZenModeConfig(newConfig);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setOnDismissListener(new OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
updateDays();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setPositiveButton(R.string.done_button, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
auto.addPreference(mWhen);
|
|
||||||
|
|
||||||
final FragmentManager mgr = getFragmentManager();
|
final FragmentManager mgr = getFragmentManager();
|
||||||
|
|
||||||
@@ -276,8 +279,8 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
return setZenModeConfig(newConfig);
|
return setZenModeConfig(newConfig);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
auto.addPreference(mStart);
|
downtime.addPreference(mStart);
|
||||||
mStart.setDependency(mWhen.getKey());
|
mStart.setDependency(mDays.getKey());
|
||||||
|
|
||||||
mEnd = new TimePickerPreference(mContext, mgr);
|
mEnd = new TimePickerPreference(mContext, mgr);
|
||||||
mEnd.setKey(KEY_END_TIME);
|
mEnd.setKey(KEY_END_TIME);
|
||||||
@@ -298,8 +301,8 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
return setZenModeConfig(newConfig);
|
return setZenModeConfig(newConfig);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
auto.addPreference(mEnd);
|
downtime.addPreference(mEnd);
|
||||||
mEnd.setDependency(mWhen.getKey());
|
mEnd.setDependency(mDays.getKey());
|
||||||
|
|
||||||
mAutomationCategory = (PreferenceCategory) findPreference(KEY_AUTOMATION);
|
mAutomationCategory = (PreferenceCategory) findPreference(KEY_AUTOMATION);
|
||||||
mEntry = findPreference(KEY_ENTRY);
|
mEntry = findPreference(KEY_ENTRY);
|
||||||
@@ -322,10 +325,39 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
});
|
});
|
||||||
mConditionProviders = findPreference(KEY_CONDITION_PROVIDERS);
|
mConditionProviders = findPreference(KEY_CONDITION_PROVIDERS);
|
||||||
|
|
||||||
updateZenMode();
|
|
||||||
updateControls();
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDays() {
|
||||||
|
if (mConfig != null) {
|
||||||
|
final int[] days = ZenModeConfig.tryParseDays(mConfig.sleepMode);
|
||||||
|
if (days != null && days.length != 0) {
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
final Calendar c = Calendar.getInstance();
|
||||||
|
for (int i = 0; i < ZenModeConfig.ALL_DAYS.length; i++) {
|
||||||
|
final int day = ZenModeConfig.ALL_DAYS[i];
|
||||||
|
for (int j = 0; j < days.length; j++) {
|
||||||
|
if (day == days[j]) {
|
||||||
|
c.set(Calendar.DAY_OF_WEEK, day);
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
sb.append(mContext.getString(R.string.summary_divider_text));
|
||||||
|
}
|
||||||
|
sb.append(DAY_FORMAT.format(c.getTime()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
mDays.setSummary(sb);
|
||||||
|
mDays.notifyDependencyChange(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mDays.setSummary(R.string.zen_mode_downtime_days_none);
|
||||||
|
mDays.notifyDependencyChange(true);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateEndSummary() {
|
private void updateEndSummary() {
|
||||||
final int startMin = 60 * mConfig.sleepStartHour + mConfig.sleepStartMinute;
|
final int startMin = 60 * mConfig.sleepStartHour + mConfig.sleepStartMinute;
|
||||||
final int endMin = 60 * mConfig.sleepEndHour + mConfig.sleepEndMinute;
|
final int endMin = 60 * mConfig.sleepEndHour + mConfig.sleepEndMinute;
|
||||||
@@ -340,7 +372,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
}
|
}
|
||||||
mMessages.setChecked(mConfig.allowMessages);
|
mMessages.setChecked(mConfig.allowMessages);
|
||||||
mStarred.setSelectedValue(mConfig.allowFrom);
|
mStarred.setSelectedValue(mConfig.allowFrom);
|
||||||
mWhen.setSelectedValue(mConfig.sleepMode);
|
updateDays();
|
||||||
mStart.setTime(mConfig.sleepStartHour, mConfig.sleepStartMinute);
|
mStart.setTime(mConfig.sleepStartHour, mConfig.sleepStartMinute);
|
||||||
mEnd.setTime(mConfig.sleepEndHour, mConfig.sleepEndMinute);
|
mEnd.setTime(mConfig.sleepEndHour, mConfig.sleepEndMinute);
|
||||||
mDisableListeners = false;
|
mDisableListeners = false;
|
||||||
@@ -398,7 +430,6 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
updateControls();
|
updateControls();
|
||||||
updateZenMode();
|
|
||||||
mSettingsObserver.register();
|
mSettingsObserver.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,22 +439,6 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
mSettingsObserver.unregister();
|
mSettingsObserver.unregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
super.onDestroyView();
|
|
||||||
mSwitchBar.removeOnSwitchChangeListener(this);
|
|
||||||
mSwitchBar.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateZenMode() {
|
|
||||||
final boolean zenMode = Global.getInt(getContentResolver(),
|
|
||||||
Global.ZEN_MODE, Global.ZEN_MODE_OFF) != Global.ZEN_MODE_OFF;
|
|
||||||
if (mSwitchBar.isChecked() != zenMode) {
|
|
||||||
mSwitchBar.setChecked(zenMode);
|
|
||||||
mIgnoreNext = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateZenModeConfig() {
|
private void updateZenModeConfig() {
|
||||||
final ZenModeConfig config = getZenModeConfig();
|
final ZenModeConfig config = getZenModeConfig();
|
||||||
if (Objects.equals(config, mConfig)) return;
|
if (Objects.equals(config, mConfig)) return;
|
||||||
@@ -468,38 +483,6 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
return new ZenModeConditionSelection(mContext);
|
return new ZenModeConditionSelection(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Runnable mHideDialog = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (mDialog != null) {
|
|
||||||
mDialog.dismiss();
|
|
||||||
mDialog = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final Runnable mShowDialog = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mDialog = new AlertDialog.Builder(mContext)
|
|
||||||
.setTitle(R.string.zen_mode_settings_title)
|
|
||||||
.setView(newConditionSelection())
|
|
||||||
.setNegativeButton(R.string.dlg_cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
putZenModeSetting(Global.ZEN_MODE_OFF);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Enable indexing of searchable data
|
// Enable indexing of searchable data
|
||||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider() {
|
new BaseSearchIndexProvider() {
|
||||||
@@ -549,7 +532,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
|||||||
public void onChange(boolean selfChange, Uri uri) {
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
super.onChange(selfChange, uri);
|
super.onChange(selfChange, uri);
|
||||||
if (ZEN_MODE_URI.equals(uri)) {
|
if (ZEN_MODE_URI.equals(uri)) {
|
||||||
updateZenMode();
|
PREF_ZEN_MODE.update(mContext);
|
||||||
}
|
}
|
||||||
if (ZEN_MODE_CONFIG_ETAG_URI.equals(uri)) {
|
if (ZEN_MODE_CONFIG_ETAG_URI.equals(uri)) {
|
||||||
updateZenModeConfig();
|
updateZenModeConfig();
|
||||||
|
@@ -36,7 +36,6 @@ import com.android.settings.fuelgauge.PowerUsageSummary;
|
|||||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||||
import com.android.settings.location.LocationSettings;
|
import com.android.settings.location.LocationSettings;
|
||||||
import com.android.settings.net.DataUsageMeteredSettings;
|
import com.android.settings.net.DataUsageMeteredSettings;
|
||||||
import com.android.settings.notification.NotificationDisplaySettings;
|
|
||||||
import com.android.settings.notification.NotificationSettings;
|
import com.android.settings.notification.NotificationSettings;
|
||||||
import com.android.settings.notification.OtherSoundSettings;
|
import com.android.settings.notification.OtherSoundSettings;
|
||||||
import com.android.settings.notification.ZenModeSettings;
|
import com.android.settings.notification.ZenModeSettings;
|
||||||
@@ -108,7 +107,6 @@ public final class Ranking {
|
|||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
sRankMap.put(NotificationSettings.class.getName(), RANK_NOTIFICATIONS);
|
sRankMap.put(NotificationSettings.class.getName(), RANK_NOTIFICATIONS);
|
||||||
sRankMap.put(NotificationDisplaySettings.class.getName(), RANK_NOTIFICATIONS);
|
|
||||||
sRankMap.put(OtherSoundSettings.class.getName(), RANK_NOTIFICATIONS);
|
sRankMap.put(OtherSoundSettings.class.getName(), RANK_NOTIFICATIONS);
|
||||||
sRankMap.put(ZenModeSettings.class.getName(), RANK_NOTIFICATIONS);
|
sRankMap.put(ZenModeSettings.class.getName(), RANK_NOTIFICATIONS);
|
||||||
|
|
||||||
|
@@ -39,7 +39,6 @@ import com.android.settings.fuelgauge.PowerUsageSummary;
|
|||||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||||
import com.android.settings.location.LocationSettings;
|
import com.android.settings.location.LocationSettings;
|
||||||
import com.android.settings.net.DataUsageMeteredSettings;
|
import com.android.settings.net.DataUsageMeteredSettings;
|
||||||
import com.android.settings.notification.NotificationDisplaySettings;
|
|
||||||
import com.android.settings.notification.NotificationSettings;
|
import com.android.settings.notification.NotificationSettings;
|
||||||
import com.android.settings.notification.OtherSoundSettings;
|
import com.android.settings.notification.OtherSoundSettings;
|
||||||
import com.android.settings.notification.ZenModeSettings;
|
import com.android.settings.notification.ZenModeSettings;
|
||||||
@@ -129,13 +128,6 @@ public final class SearchIndexableResources {
|
|||||||
NotificationSettings.class.getName(),
|
NotificationSettings.class.getName(),
|
||||||
R.drawable.ic_settings_notifications));
|
R.drawable.ic_settings_notifications));
|
||||||
|
|
||||||
sResMap.put(NotificationDisplaySettings.class.getName(),
|
|
||||||
new SearchIndexableResource(
|
|
||||||
Ranking.getRankForClassName(NotificationDisplaySettings.class.getName()),
|
|
||||||
R.xml.notification_display_settings,
|
|
||||||
NotificationDisplaySettings.class.getName(),
|
|
||||||
R.drawable.ic_settings_notifications));
|
|
||||||
|
|
||||||
sResMap.put(OtherSoundSettings.class.getName(),
|
sResMap.put(OtherSoundSettings.class.getName(),
|
||||||
new SearchIndexableResource(
|
new SearchIndexableResource(
|
||||||
Ranking.getRankForClassName(OtherSoundSettings.class.getName()),
|
Ranking.getRankForClassName(OtherSoundSettings.class.getName()),
|
||||||
|
Reference in New Issue
Block a user