Merge "Settings - add support for Launch by Default"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 35e679d..74a49f2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -82,7 +82,8 @@
android:hardwareAccelerated="true"
android:requiredForAllUsers="true"
android:supportsRtl="true"
- android:allowBackup="false">
+ android:allowBackup="false"
+ android:usesCleartextTraffic="false">
<!-- Settings -->
@@ -666,6 +667,27 @@
android:value="true" />
</activity>
+ <activity android:name="Settings$ZenModePrioritySettingsActivity"
+ android:label="@string/zen_mode_priority_settings_title"
+ android:exported="true"
+ android:taskAffinity="">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="com.android.settings.SHORTCUT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.notification.ZenModePrioritySettings" />
+ <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
+ android:resource="@id/notification_settings" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
<activity android:name="Settings$HomeSettingsActivity"
android:label="@string/home_settings"
android:taskAffinity="">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 630d2a4..c1ef87d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -985,6 +985,9 @@
<!-- Title for preference that guides the user through creating an unlock password [CHAR LIMIT=45] -->
<string name="unlock_set_unlock_password_summary">High security</string>
+ <!-- Summary specifying that this is the current screen lock setting [CHAR LIMIT=45] -->
+ <string name="current_screen_lock">Current screen lock</string>
+
<!-- Content of warning dialog about disabling device protection features when user is switching from a secure unlock method to an insecure one. [CHAR LIMIT=NONE] -->
<string name="unlock_disable_frp_warning_content">Device protection features will no longer work.</string>
@@ -5681,7 +5684,10 @@
<string name="notification_volume_option_title">Notification volume</string>
<!-- Sound & notification > Sound section: Title for the Interruptions option and associated settings page. [CHAR LIMIT=30] -->
- <string name="zen_mode_settings_title">Interruptions</string>
+ <string name="zen_mode_settings_title">Block interruptions</string>
+
+ <!-- Sound & notification > Sound section: Title for the Priority interruptions option and associated settings page. [CHAR LIMIT=30] -->
+ <string name="zen_mode_priority_settings_title">Priority only allows</string>
<!-- Sound & notification > Sound section: Title for the zen mode option. [CHAR LIMIT=60] -->
<string name="zen_mode_option_title">When calls and notifications arrive</string>
@@ -5692,6 +5698,9 @@
<!-- Sound & notification > Sound section: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
<string name="zen_mode_option_important_interruptions">Allow only priority interruptions</string>
+ <!-- Sound & notification > Sound section: Zen mode option: Alarms only [CHAR LIMIT=60] -->
+ <string name="zen_mode_option_alarms">Allow only alarms</string>
+
<!-- Sound & notification > Sound section: Zen mode option: No interruptions [CHAR LIMIT=60] -->
<string name="zen_mode_option_no_interruptions">Don\'t interrupt</string>
@@ -5866,9 +5875,6 @@
<!-- [CHAR LIMIT=30] Zen mode settings: Exit condition selection dialog, default option -->
<string name="zen_mode_default_option">Until you turn this off</string>
- <!-- [CHAR LIMIT=40] Zen mode settings: Important category text -->
- <string name="zen_mode_important_category">Priority interruptions</string>
-
<!-- [CHAR LIMIT=60] Zen mode settings: Downtime category text -->
<string name="zen_mode_downtime_category">Downtime</string>
@@ -5917,11 +5923,14 @@
<!-- [CHAR LIMIT=30] Zen mode settings: From option value: Starred contacts -->
<string name="zen_mode_from_starred">Starred contacts only</string>
- <!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
- <string name="zen_mode_events">Events and reminders</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Alarms option -->
+ <string name="zen_mode_alarms">Alarms</string>
- <!-- [CHAR LIMIT=80] Zen mode settings: Reminder text about alarms -->
- <string name="zen_mode_alarm_info">Alarms are always priority interruptions</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
+ <string name="zen_mode_reminders">Reminders</string>
+
+ <!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
+ <string name="zen_mode_events">Events</string>
<!-- [CHAR LIMIT=20] Zen mode settings: When option -->
<string name="zen_mode_when">Automatically turn on</string>
diff --git a/res/xml/timezones.xml b/res/xml/timezones.xml
index 1c92c2d..440d098 100644
--- a/res/xml/timezones.xml
+++ b/res/xml/timezones.xml
@@ -38,6 +38,7 @@
<timezone id="Africa/Brazzaville"></timezone>
<timezone id="Asia/Amman"></timezone>
<timezone id="Europe/Athens"></timezone>
+ <timezone id="Europe/Istanbul"></timezone>
<timezone id="Asia/Beirut"></timezone>
<timezone id="Africa/Cairo"></timezone>
<timezone id="Europe/Helsinki"></timezone>
diff --git a/res/xml/zen_mode_priority_settings.xml b/res/xml/zen_mode_priority_settings.xml
new file mode 100644
index 0000000..e8bab66
--- /dev/null
+++ b/res/xml/zen_mode_priority_settings.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="zen_mode_settings"
+ android:title="@string/zen_mode_priority_settings_title" >
+
+ <!-- Alarms -->
+ <SwitchPreference
+ android:key="alarms"
+ android:title="@string/zen_mode_alarms"
+ android:enabled="false"
+ android:defaultValue="true"
+ android:persistent="false"
+ android:switchTextOff=""
+ android:switchTextOn="" />
+
+ <!-- Reminders -->
+ <SwitchPreference
+ android:key="reminders"
+ android:title="@string/zen_mode_reminders"
+ android:persistent="false"
+ android:switchTextOff=""
+ android:switchTextOn="" />
+
+ <!-- Events -->
+ <SwitchPreference
+ android:key="events"
+ android:title="@string/zen_mode_events"
+ android:persistent="false"
+ android:switchTextOff=""
+ android:switchTextOn="" />
+
+ <!-- Messages -->
+ <SwitchPreference
+ android:key="messages"
+ android:title="@string/zen_mode_messages"
+ android:persistent="false"
+ android:switchTextOff=""
+ android:switchTextOn="" />
+
+ <!-- Calls -->
+ <SwitchPreference
+ android:key="calls"
+ android:title="@string/zen_mode_calls"
+ android:persistent="false"
+ android:switchTextOff=""
+ android:switchTextOn="" />
+
+ <!-- Messages/calls from -->
+ <com.android.settings.DropDownPreference
+ android:key="starred"
+ android:title="@string/zen_mode_from"
+ android:persistent="false" />
+
+</PreferenceScreen>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 3ac4eef..7c8dc7a 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -25,45 +25,11 @@
android:title="@string/zen_mode_option_title"
android:persistent="false" />
- <PreferenceCategory
- android:key="important"
- android:title="@string/zen_mode_important_category" >
-
- <SwitchPreference
- android:key="events"
- android:title="@string/zen_mode_events"
- android:persistent="false"
- android:switchTextOff=""
- android:switchTextOn="" />
-
- <SwitchPreference
- android:key="calls"
- android:title="@string/zen_mode_calls"
- android:persistent="false"
- android:switchTextOff=""
- android:switchTextOn="" />
-
- <SwitchPreference
- android:key="messages"
- android:title="@string/zen_mode_messages"
- android:persistent="false"
- android:switchTextOff=""
- android:switchTextOn="" />
-
- <com.android.settings.DropDownPreference
- android:key="starred"
- android:title="@string/zen_mode_from"
- android:persistent="false" />
-
- <Preference
- android:key="alarm_info"
- android:title=""
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/colorForegroundInverse"
- android:selectable="false"
- android:summary="@string/zen_mode_alarm_info" />
-
- </PreferenceCategory>
+ <!-- Priority only allows -->
+ <PreferenceScreen
+ android:key="priority_settings"
+ android:title="@string/zen_mode_priority_settings_title"
+ android:fragment="com.android.settings.notification.ZenModePrioritySettings" />
<!-- Downtime -->
<PreferenceCategory
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index cb0ce5f..1da9ac7 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -244,12 +244,40 @@
}
addPreferencesFromResource(R.xml.security_settings_picker);
disableUnusablePreferences(quality, hideDisabledPrefs);
+ updateCurrentPreference();
updatePreferenceSummaryIfNeeded();
} else {
updateUnlockMethodAndFinish(quality, false);
}
}
+ private void updateCurrentPreference() {
+ String currentKey = getKeyForCurrent();
+ Preference preference = findPreference(currentKey);
+ if (preference != null) {
+ preference.setSummary(R.string.current_screen_lock);
+ }
+ }
+
+ private String getKeyForCurrent() {
+ if (mLockPatternUtils.isLockScreenDisabled()) {
+ return KEY_UNLOCK_SET_OFF;
+ }
+ switch (mLockPatternUtils.getKeyguardStoredPasswordQuality()) {
+ case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
+ return KEY_UNLOCK_SET_PATTERN;
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
+ return KEY_UNLOCK_SET_PIN;
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
+ return KEY_UNLOCK_SET_PASSWORD;
+ case DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED:
+ return KEY_UNLOCK_SET_NONE;
+ }
+ return null;
+ }
+
/** increases the quality if necessary */
private int upgradeQuality(int quality) {
quality = upgradeQualityForDPM(quality);
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index 77927d9..fa98bac 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -754,7 +754,7 @@
HttpURLConnection urlConnection = null;
try {
// TODO: Hardcoded for now, make it UI configurable
- URL url = new URL("http://www.google.com");
+ URL url = new URL("https://www.google.com");
urlConnection = (HttpURLConnection) url.openConnection();
if (urlConnection.getResponseCode() == 200) {
mHttpClientTestResult = "Pass";
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 864cc95..dc4ae48 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -94,6 +94,7 @@
public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class ZenModePrioritySettingsActivity extends SettingsActivity { /* empty */ }
public static class NotificationSettingsActivity extends SettingsActivity { /* empty */ }
public static class NotificationAppListActivity extends SettingsActivity { /* empty */ }
public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/notification/ZenModePrioritySettings.java b/src/com/android/settings/notification/ZenModePrioritySettings.java
new file mode 100644
index 0000000..062c12a
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModePrioritySettings.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceScreen;
+import android.preference.SwitchPreference;
+import android.service.notification.ZenModeConfig;
+import android.util.Log;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.settings.DropDownPreference;
+import com.android.settings.R;
+import com.android.settings.search.Indexable;
+
+public class ZenModePrioritySettings extends ZenModeSettingsBase implements Indexable {
+ private static final String KEY_REMINDERS = "reminders";
+ private static final String KEY_EVENTS = "events";
+ private static final String KEY_MESSAGES = "messages";
+ private static final String KEY_CALLS = "calls";
+ private static final String KEY_STARRED = "starred";
+
+ private boolean mDisableListeners;
+ private SwitchPreference mReminders;
+ private SwitchPreference mEvents;
+ private SwitchPreference mMessages;
+ private SwitchPreference mCalls;
+ private DropDownPreference mStarred;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.zen_mode_priority_settings);
+ final PreferenceScreen root = getPreferenceScreen();
+
+ mReminders = (SwitchPreference) root.findPreference(KEY_REMINDERS);
+ mReminders.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mDisableListeners) return true;
+ final boolean val = (Boolean) newValue;
+ if (val == mConfig.allowReminders) return true;
+ if (DEBUG) Log.d(TAG, "onPrefChange allowReminders=" + val);
+ final ZenModeConfig newConfig = mConfig.copy();
+ newConfig.allowReminders = val;
+ return setZenModeConfig(newConfig);
+ }
+ });
+
+ mEvents = (SwitchPreference) root.findPreference(KEY_EVENTS);
+ mEvents.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mDisableListeners) return true;
+ final boolean val = (Boolean) newValue;
+ if (val == mConfig.allowEvents) return true;
+ if (DEBUG) Log.d(TAG, "onPrefChange allowEvents=" + val);
+ final ZenModeConfig newConfig = mConfig.copy();
+ newConfig.allowEvents = val;
+ return setZenModeConfig(newConfig);
+ }
+ });
+
+ mMessages = (SwitchPreference) root.findPreference(KEY_MESSAGES);
+ mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mDisableListeners) return true;
+ final boolean val = (Boolean) newValue;
+ if (val == mConfig.allowMessages) return true;
+ if (DEBUG) Log.d(TAG, "onPrefChange allowMessages=" + val);
+ final ZenModeConfig newConfig = mConfig.copy();
+ newConfig.allowMessages = val;
+ return setZenModeConfig(newConfig);
+ }
+ });
+
+ mCalls = (SwitchPreference) root.findPreference(KEY_CALLS);
+ mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mDisableListeners) return true;
+ final boolean val = (Boolean) newValue;
+ if (val == mConfig.allowCalls) return true;
+ if (DEBUG) Log.d(TAG, "onPrefChange allowCalls=" + val);
+ final ZenModeConfig newConfig = mConfig.copy();
+ newConfig.allowCalls = val;
+ return setZenModeConfig(newConfig);
+ }
+ });
+
+ mStarred = (DropDownPreference) root.findPreference(KEY_STARRED);
+ mStarred.addItem(R.string.zen_mode_from_anyone, ZenModeConfig.SOURCE_ANYONE);
+ mStarred.addItem(R.string.zen_mode_from_contacts, ZenModeConfig.SOURCE_CONTACT);
+ mStarred.addItem(R.string.zen_mode_from_starred, ZenModeConfig.SOURCE_STAR);
+ mStarred.setCallback(new DropDownPreference.Callback() {
+ @Override
+ public boolean onItemSelected(int pos, Object newValue) {
+ if (mDisableListeners) return true;
+ final int val = (Integer) newValue;
+ if (val == mConfig.allowFrom) return true;
+ if (DEBUG) Log.d(TAG, "onPrefChange allowFrom=" +
+ ZenModeConfig.sourceToString(val));
+ final ZenModeConfig newConfig = mConfig.copy();
+ newConfig.allowFrom = val;
+ return setZenModeConfig(newConfig);
+ }
+ });
+
+ updateControls();
+ }
+
+ @Override
+ protected void onZenModeChanged() {
+ // don't care
+ }
+
+ @Override
+ protected void updateControls() {
+ mDisableListeners = true;
+ if (mCalls != null) {
+ mCalls.setChecked(mConfig.allowCalls);
+ }
+ mMessages.setChecked(mConfig.allowMessages);
+ mStarred.setSelectedValue(mConfig.allowFrom);
+ mReminders.setChecked(mConfig.allowReminders);
+ mEvents.setChecked(mConfig.allowEvents);
+ updateStarredEnabled();
+ mDisableListeners = false;
+ }
+
+ @Override
+ protected int getMetricsCategory() {
+ return MetricsLogger.NOTIFICATION_ZEN_MODE_PRIORITY;
+ }
+
+ private void updateStarredEnabled() {
+ mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages);
+ }
+
+}
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index c2e143a..053d2ef 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -30,17 +30,12 @@
import android.content.DialogInterface.OnDismissListener;
import android.content.pm.PackageManager;
import android.content.res.Resources;
-import android.database.ContentObserver;
-import android.net.Uri;
import android.os.Bundle;
-import android.os.Handler;
import android.os.ServiceManager;
import android.preference.Preference;
-import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
-import android.preference.SwitchPreference;
import android.provider.Settings.Global;
import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
@@ -64,18 +59,9 @@
import java.util.List;
import java.util.Objects;
-public class ZenModeSettings extends SettingsPreferenceFragment implements Indexable {
- private static final String TAG = "ZenModeSettings";
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-
+public class ZenModeSettings extends ZenModeSettingsBase implements Indexable {
private static final String KEY_ZEN_MODE = "zen_mode";
- private static final String KEY_IMPORTANT = "important";
- private static final String KEY_CALLS = "calls";
- private static final String KEY_MESSAGES = "messages";
- private static final String KEY_STARRED = "starred";
- private static final String KEY_EVENTS = "events";
- private static final String KEY_ALARM_INFO = "alarm_info";
-
+ private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
private static final String KEY_DOWNTIME = "downtime";
private static final String KEY_DAYS = "days";
private static final String KEY_START_TIME = "start_time";
@@ -88,12 +74,14 @@
private static final SettingPrefWithCallback PREF_ZEN_MODE = new SettingPrefWithCallback(
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_OFF, Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, Global.ZEN_MODE_ALARMS,
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_ALARMS:
+ return res.getString(R.string.zen_mode_option_alarms);
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
return res.getString(R.string.zen_mode_option_important_interruptions);
default:
@@ -106,13 +94,8 @@
private static SparseArray<String> allKeyTitles(Context context) {
final SparseArray<String> rt = new SparseArray<String>();
- rt.put(R.string.zen_mode_important_category, KEY_IMPORTANT);
- rt.put(R.string.zen_mode_calls, KEY_CALLS);
rt.put(R.string.zen_mode_option_title, KEY_ZEN_MODE);
- 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_events, KEY_EVENTS);
- rt.put(R.string.zen_mode_alarm_info, KEY_ALARM_INFO);
+ rt.put(R.string.zen_mode_priority_settings_title, KEY_PRIORITY_SETTINGS);
rt.put(R.string.zen_mode_downtime_category, KEY_DOWNTIME);
rt.put(R.string.zen_mode_downtime_days, KEY_DAYS);
rt.put(R.string.zen_mode_start_time, KEY_START_TIME);
@@ -123,18 +106,10 @@
return rt;
}
- private final Handler mHandler = new Handler();
- private final SettingsObserver mSettingsObserver = new SettingsObserver();
-
- private Context mContext;
private PackageManager mPM;
- private ZenModeConfig mConfig;
private boolean mDisableListeners;
- private SwitchPreference mCalls;
- private SwitchPreference mMessages;
- private DropDownPreference mStarred;
- private SwitchPreference mEvents;
private boolean mDowntimeSupported;
+ private Preference mPrioritySettings;
private Preference mDays;
private TimePickerPreference mStart;
private TimePickerPreference mEnd;
@@ -150,17 +125,18 @@
}
@Override
+ protected void onZenModeChanged() {
+ PREF_ZEN_MODE.update(mContext);
+ }
+
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mContext = getActivity();
mPM = mContext.getPackageManager();
addPreferencesFromResource(R.xml.zen_mode_settings);
final PreferenceScreen root = getPreferenceScreen();
- mConfig = getZenModeConfig();
- if (DEBUG) Log.d(TAG, "Loaded mConfig=" + mConfig);
-
PREF_ZEN_MODE.init(this);
PREF_ZEN_MODE.setCallback(new SettingPrefWithCallback.Callback() {
@Override
@@ -171,69 +147,7 @@
}
});
- final PreferenceCategory important =
- (PreferenceCategory) root.findPreference(KEY_IMPORTANT);
-
- mCalls = (SwitchPreference) important.findPreference(KEY_CALLS);
- mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (mDisableListeners) return true;
- final boolean val = (Boolean) newValue;
- if (val == mConfig.allowCalls) return true;
- if (DEBUG) Log.d(TAG, "onPrefChange allowCalls=" + val);
- final ZenModeConfig newConfig = mConfig.copy();
- newConfig.allowCalls = val;
- return setZenModeConfig(newConfig);
- }
- });
-
- mMessages = (SwitchPreference) important.findPreference(KEY_MESSAGES);
- mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (mDisableListeners) return true;
- final boolean val = (Boolean) newValue;
- if (val == mConfig.allowMessages) return true;
- if (DEBUG) Log.d(TAG, "onPrefChange allowMessages=" + val);
- final ZenModeConfig newConfig = mConfig.copy();
- newConfig.allowMessages = val;
- return setZenModeConfig(newConfig);
- }
- });
-
- mStarred = (DropDownPreference) important.findPreference(KEY_STARRED);
- mStarred.addItem(R.string.zen_mode_from_anyone, ZenModeConfig.SOURCE_ANYONE);
- mStarred.addItem(R.string.zen_mode_from_contacts, ZenModeConfig.SOURCE_CONTACT);
- mStarred.addItem(R.string.zen_mode_from_starred, ZenModeConfig.SOURCE_STAR);
- mStarred.setCallback(new DropDownPreference.Callback() {
- @Override
- public boolean onItemSelected(int pos, Object newValue) {
- if (mDisableListeners) return true;
- final int val = (Integer) newValue;
- if (val == mConfig.allowFrom) return true;
- if (DEBUG) Log.d(TAG, "onPrefChange allowFrom=" +
- ZenModeConfig.sourceToString(val));
- final ZenModeConfig newConfig = mConfig.copy();
- newConfig.allowFrom = val;
- return setZenModeConfig(newConfig);
- }
- });
- important.addPreference(mStarred);
-
- mEvents = (SwitchPreference) important.findPreference(KEY_EVENTS);
- mEvents.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (mDisableListeners) return true;
- final boolean val = (Boolean) newValue;
- if (val == mConfig.allowEvents) return true;
- if (DEBUG) Log.d(TAG, "onPrefChange allowEvents=" + val);
- final ZenModeConfig newConfig = mConfig.copy();
- newConfig.allowEvents = val;
- return setZenModeConfig(newConfig);
- }
- });
+ mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
final PreferenceCategory downtime = (PreferenceCategory) root.findPreference(KEY_DOWNTIME);
mDowntimeSupported = isDowntimeSupported(mContext);
@@ -404,15 +318,9 @@
mEnd.setSummaryFormat(summaryFormat);
}
- private void updateControls() {
+ @Override
+ protected void updateControls() {
mDisableListeners = true;
- if (mCalls != null) {
- mCalls.setChecked(mConfig.allowCalls);
- }
- mMessages.setChecked(mConfig.allowMessages);
- mStarred.setSelectedValue(mConfig.allowFrom);
- mEvents.setChecked(mConfig.allowEvents);
- updateStarredEnabled();
if (mDowntimeSupported) {
updateDays();
mStart.setTime(mConfig.sleepStartHour, mConfig.sleepStartMinute);
@@ -422,10 +330,24 @@
mDisableListeners = false;
refreshAutomationSection();
updateEndSummary();
+ updatePrioritySettingsSummary();
}
- private void updateStarredEnabled() {
- mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages);
+ private void updatePrioritySettingsSummary() {
+ String s = getResources().getString(R.string.zen_mode_alarms);
+ s = appendLowercase(s, mConfig.allowReminders, R.string.zen_mode_reminders);
+ s = appendLowercase(s, mConfig.allowEvents, R.string.zen_mode_events);
+ s = appendLowercase(s, mConfig.allowCalls, R.string.zen_mode_calls);
+ s = appendLowercase(s, mConfig.allowMessages, R.string.zen_mode_messages);
+ mPrioritySettings.setSummary(s);
+ }
+
+ private String appendLowercase(String s, boolean condition, int resId) {
+ if (condition) {
+ return getResources().getString(R.string.join_many_items_middle, s,
+ getResources().getString(resId).toLowerCase());
+ }
+ return s;
}
private void refreshAutomationSection() {
@@ -474,56 +396,6 @@
}
}
- @Override
- public void onResume() {
- super.onResume();
- updateControls();
- mSettingsObserver.register();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mSettingsObserver.unregister();
- }
-
- private void updateZenModeConfig() {
- final ZenModeConfig config = getZenModeConfig();
- if (Objects.equals(config, mConfig)) return;
- mConfig = config;
- if (DEBUG) Log.d(TAG, "updateZenModeConfig mConfig=" + mConfig);
- updateControls();
- }
-
- private ZenModeConfig getZenModeConfig() {
- final INotificationManager nm = INotificationManager.Stub.asInterface(
- ServiceManager.getService(Context.NOTIFICATION_SERVICE));
- try {
- return nm.getZenModeConfig();
- } catch (Exception e) {
- Log.w(TAG, "Error calling NoMan", e);
- return new ZenModeConfig();
- }
- }
-
- private boolean setZenModeConfig(ZenModeConfig config) {
- final INotificationManager nm = INotificationManager.Stub.asInterface(
- ServiceManager.getService(Context.NOTIFICATION_SERVICE));
- try {
- final boolean success = nm.setZenModeConfig(config);
- if (success) {
- mConfig = config;
- if (DEBUG) Log.d(TAG, "Saved mConfig=" + mConfig);
- updateEndSummary();
- updateStarredEnabled();
- }
- return success;
- } catch (Exception e) {
- Log.w(TAG, "Error calling NoMan", e);
- return false;
- }
- }
-
protected void putZenModeSetting(int value) {
Global.putInt(getContentResolver(), Global.ZEN_MODE, value);
}
@@ -661,35 +533,6 @@
}
}
- private final class SettingsObserver extends ContentObserver {
- private final Uri ZEN_MODE_URI = Global.getUriFor(Global.ZEN_MODE);
- private final Uri ZEN_MODE_CONFIG_ETAG_URI = Global.getUriFor(Global.ZEN_MODE_CONFIG_ETAG);
-
- public SettingsObserver() {
- super(mHandler);
- }
-
- public void register() {
- getContentResolver().registerContentObserver(ZEN_MODE_URI, false, this);
- getContentResolver().registerContentObserver(ZEN_MODE_CONFIG_ETAG_URI, false, this);
- }
-
- public void unregister() {
- getContentResolver().unregisterContentObserver(this);
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- super.onChange(selfChange, uri);
- if (ZEN_MODE_URI.equals(uri)) {
- PREF_ZEN_MODE.update(mContext);
- }
- if (ZEN_MODE_CONFIG_ETAG_URI.equals(uri)) {
- updateZenModeConfig();
- }
- }
- }
-
private static class TimePickerPreference extends Preference {
private final Context mContext;
diff --git a/src/com/android/settings/notification/ZenModeSettingsBase.java b/src/com/android/settings/notification/ZenModeSettingsBase.java
new file mode 100644
index 0000000..d436965
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModeSettingsBase.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import android.app.INotificationManager;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.ServiceManager;
+import android.provider.Settings.Global;
+import android.service.notification.ZenModeConfig;
+import android.util.Log;
+
+import com.android.settings.SettingsPreferenceFragment;
+
+import java.util.Objects;
+
+abstract public class ZenModeSettingsBase extends SettingsPreferenceFragment {
+ protected static final String TAG = "ZenModeSettings";
+ protected static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
+ private final Handler mHandler = new Handler();
+ private final SettingsObserver mSettingsObserver = new SettingsObserver();
+
+ protected Context mContext;
+ protected ZenModeConfig mConfig;
+
+ abstract protected void onZenModeChanged();
+ abstract protected void updateControls();
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ mContext = getActivity();
+ mConfig = getZenModeConfig();
+ if (DEBUG) Log.d(TAG, "Loaded mConfig=" + mConfig);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mConfig = getZenModeConfig();
+ updateControls();
+ mSettingsObserver.register();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mSettingsObserver.unregister();
+ }
+
+ protected boolean setZenModeConfig(ZenModeConfig config) {
+ final INotificationManager nm = INotificationManager.Stub.asInterface(
+ ServiceManager.getService(Context.NOTIFICATION_SERVICE));
+ try {
+ final boolean success = nm.setZenModeConfig(config);
+ if (success) {
+ mConfig = config;
+ if (DEBUG) Log.d(TAG, "Saved mConfig=" + mConfig);
+ updateControls();
+ }
+ return success;
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ return false;
+ }
+ }
+
+ private void updateZenModeConfig() {
+ final ZenModeConfig config = getZenModeConfig();
+ if (Objects.equals(config, mConfig)) return;
+ mConfig = config;
+ if (DEBUG) Log.d(TAG, "updateZenModeConfig mConfig=" + mConfig);
+ updateControls();
+ }
+
+ private ZenModeConfig getZenModeConfig() {
+ final INotificationManager nm = INotificationManager.Stub.asInterface(
+ ServiceManager.getService(Context.NOTIFICATION_SERVICE));
+ try {
+ return nm.getZenModeConfig();
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ return new ZenModeConfig();
+ }
+ }
+
+ private final class SettingsObserver extends ContentObserver {
+ private final Uri ZEN_MODE_URI = Global.getUriFor(Global.ZEN_MODE);
+ private final Uri ZEN_MODE_CONFIG_ETAG_URI = Global.getUriFor(Global.ZEN_MODE_CONFIG_ETAG);
+
+ private SettingsObserver() {
+ super(mHandler);
+ }
+
+ public void register() {
+ getContentResolver().registerContentObserver(ZEN_MODE_URI, false, this);
+ getContentResolver().registerContentObserver(ZEN_MODE_CONFIG_ETAG_URI, false, this);
+ }
+
+ public void unregister() {
+ getContentResolver().unregisterContentObserver(this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ if (ZEN_MODE_URI.equals(uri)) {
+ onZenModeChanged();
+ }
+ if (ZEN_MODE_CONFIG_ETAG_URI.equals(uri)) {
+ updateZenModeConfig();
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index c96ce09..e4e5d12 100644
--- a/src/com/android/settings/search/Ranking.java
+++ b/src/com/android/settings/search/Ranking.java
@@ -42,6 +42,7 @@
import com.android.settings.net.DataUsageMeteredSettings;
import com.android.settings.notification.NotificationSettings;
import com.android.settings.notification.OtherSoundSettings;
+import com.android.settings.notification.ZenModePrioritySettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.sim.SimSettings;
@@ -123,6 +124,7 @@
sRankMap.put(NotificationSettings.class.getName(), RANK_NOTIFICATIONS);
sRankMap.put(OtherSoundSettings.class.getName(), RANK_NOTIFICATIONS);
sRankMap.put(ZenModeSettings.class.getName(), RANK_NOTIFICATIONS);
+ sRankMap.put(ZenModePrioritySettings.class.getName(), RANK_NOTIFICATIONS);
// Storage
sRankMap.put(Memory.class.getName(), RANK_STORAGE);
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 102e0bf..d57a1f1 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -43,6 +43,7 @@
import com.android.settings.net.DataUsageMeteredSettings;
import com.android.settings.notification.NotificationSettings;
import com.android.settings.notification.OtherSoundSettings;
+import com.android.settings.notification.ZenModePrioritySettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.sim.SimSettings;
@@ -162,6 +163,13 @@
ZenModeSettings.class.getName(),
R.drawable.ic_settings_notifications));
+ sResMap.put(ZenModePrioritySettings.class.getName(),
+ new SearchIndexableResource(
+ Ranking.getRankForClassName(ZenModePrioritySettings.class.getName()),
+ R.xml.zen_mode_priority_settings,
+ ZenModePrioritySettings.class.getName(),
+ R.drawable.ic_settings_notifications));
+
sResMap.put(Memory.class.getName(),
new SearchIndexableResource(
Ranking.getRankForClassName(Memory.class.getName()),
diff --git a/src/com/android/settings/wifi/WifiStatusTest.java b/src/com/android/settings/wifi/WifiStatusTest.java
index 85afb7c..269058c 100644
--- a/src/com/android/settings/wifi/WifiStatusTest.java
+++ b/src/com/android/settings/wifi/WifiStatusTest.java
@@ -396,7 +396,7 @@
HttpURLConnection urlConnection = null;
try {
// TODO: Hardcoded for now, make it UI configurable
- URL url = new URL("http://www.google.com");
+ URL url = new URL("https://www.google.com");
urlConnection = (HttpURLConnection) url.openConnection();
if (urlConnection.getResponseCode() == 200) {
mHttpClientTestResult = "Pass";
diff --git a/tests/src/com/android/settings/vpn2/VpnTests.java b/tests/src/com/android/settings/vpn2/VpnTests.java
index 6a01cc5..8300534 100644
--- a/tests/src/com/android/settings/vpn2/VpnTests.java
+++ b/tests/src/com/android/settings/vpn2/VpnTests.java
@@ -24,6 +24,7 @@
import android.os.ServiceManager;
import android.security.Credentials;
import android.security.KeyStore;
+import android.security.NetworkSecurityPolicy;
import android.test.InstrumentationTestCase;
import android.test.InstrumentationTestRunner;
import android.test.suitebuilder.annotation.LargeTest;
@@ -225,6 +226,13 @@
private String getIpAddress() {
String ip = null;
HttpURLConnection urlConnection = null;
+ // TODO: Rewrite this test to use an HTTPS URL.
+ // Because this test uses cleartext HTTP, the network security policy of this app needs to
+ // be temporarily relaxed to permit such traffic.
+ NetworkSecurityPolicy networkSecurityPolicy = NetworkSecurityPolicy.getInstance();
+ boolean cleartextTrafficPermittedBeforeTest =
+ networkSecurityPolicy.isCleartextTrafficPermitted();
+ networkSecurityPolicy.setCleartextTrafficPermitted(true);
try {
URL url = new URL(EXTERNAL_SERVER);
urlConnection = (HttpURLConnection) url.openConnection();
@@ -248,6 +256,7 @@
} catch (JSONException e) {
Log.e(TAG, "exception while creating JSONObject: " + e.toString());
} finally {
+ networkSecurityPolicy.setCleartextTrafficPermitted(cleartextTrafficPermittedBeforeTest);
if (urlConnection != null) {
urlConnection.disconnect();
}