Settings: Display 'Calls' category on non-voice devices.

Since the category applies to any call, include config for
this interruption even on non-voice-capable devices.

Bug: 17666139
Change-Id: I3732246179c527220f8c6bee539ba7bc1e80de18
This commit is contained in:
John Spurlock
2014-10-20 14:22:38 -04:00
parent 1768f1aa63
commit 9a940cbf04
3 changed files with 20 additions and 45 deletions

View File

@@ -5631,9 +5631,6 @@
<!-- Sound & notification > Sound section: Title for the zen mode option. [CHAR LIMIT=60] --> <!-- 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> <string name="zen_mode_option_title">When calls and notifications arrive</string>
<!-- Sound & notification > Sound section: Title for the zen mode option for devices without voice. [CHAR LIMIT=60] -->
<string name="zen_mode_option_title_novoice">When notifications arrive</string>
<!-- Sound & notification > Sound section: Zen mode option: Off [CHAR LIMIT=60] --> <!-- Sound & notification > Sound section: Zen mode option: Off [CHAR LIMIT=60] -->
<string name="zen_mode_option_off">Always interrupt</string> <string name="zen_mode_option_off">Always interrupt</string>
@@ -5832,8 +5829,8 @@
<!-- [CHAR LIMIT=40] Zen mode settings: Entry conditions option: value when blank --> <!-- [CHAR LIMIT=40] Zen mode settings: Entry conditions option: value when blank -->
<string name="zen_mode_entry_conditions_summary_none">Never</string> <string name="zen_mode_entry_conditions_summary_none">Never</string>
<!-- [CHAR LIMIT=20] Zen mode settings: Phone calls option --> <!-- [CHAR LIMIT=20] Zen mode settings: Calls option -->
<string name="zen_mode_phone_calls">Calls</string> <string name="zen_mode_calls">Calls</string>
<!-- [CHAR LIMIT=20] Zen mode settings: Messages option --> <!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
<string name="zen_mode_messages">Messages</string> <string name="zen_mode_messages">Messages</string>

View File

@@ -37,8 +37,8 @@
android:switchTextOn="" /> android:switchTextOn="" />
<SwitchPreference <SwitchPreference
android:key="phone_calls" android:key="calls"
android:title="@string/zen_mode_phone_calls" android:title="@string/zen_mode_calls"
android:persistent="false" android:persistent="false"
android:switchTextOff="" android:switchTextOff=""
android:switchTextOn="" /> android:switchTextOn="" />

View File

@@ -51,8 +51,6 @@ import android.widget.TimePicker;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.notification.DropDownPreference.Callback;
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;
@@ -69,7 +67,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
private static final String KEY_ZEN_MODE = "zen_mode"; private static final String KEY_ZEN_MODE = "zen_mode";
private static final String KEY_IMPORTANT = "important"; private static final String KEY_IMPORTANT = "important";
private static final String KEY_CALLS = "phone_calls"; private static final String KEY_CALLS = "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_EVENTS = "events"; private static final String KEY_EVENTS = "events";
@@ -105,12 +103,8 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
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_important_category, KEY_IMPORTANT); rt.put(R.string.zen_mode_important_category, KEY_IMPORTANT);
if (Utils.isVoiceCapable(context)) { rt.put(R.string.zen_mode_calls, KEY_CALLS);
rt.put(R.string.zen_mode_phone_calls, KEY_CALLS); rt.put(R.string.zen_mode_option_title, KEY_ZEN_MODE);
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_events, KEY_EVENTS); rt.put(R.string.zen_mode_events, KEY_EVENTS);
@@ -155,7 +149,7 @@ 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);
final Preference zenMode = PREF_ZEN_MODE.init(this); PREF_ZEN_MODE.init(this);
PREF_ZEN_MODE.setCallback(new SettingPrefWithCallback.Callback() { PREF_ZEN_MODE.setCallback(new SettingPrefWithCallback.Callback() {
@Override @Override
public void onSettingSelected(int value) { public void onSettingSelected(int value) {
@@ -164,31 +158,23 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
} }
} }
}); });
if (!Utils.isVoiceCapable(mContext)) {
zenMode.setTitle(R.string.zen_mode_option_title_novoice);
}
final PreferenceCategory important = final PreferenceCategory important =
(PreferenceCategory) root.findPreference(KEY_IMPORTANT); (PreferenceCategory) root.findPreference(KEY_IMPORTANT);
mCalls = (SwitchPreference) important.findPreference(KEY_CALLS); mCalls = (SwitchPreference) important.findPreference(KEY_CALLS);
if (Utils.isVoiceCapable(mContext)) { mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override
@Override public boolean onPreferenceChange(Preference preference, Object newValue) {
public boolean onPreferenceChange(Preference preference, Object newValue) { if (mDisableListeners) return true;
if (mDisableListeners) return true; final boolean val = (Boolean) newValue;
final boolean val = (Boolean) newValue; if (val == mConfig.allowCalls) return true;
if (val == mConfig.allowCalls) return true; if (DEBUG) Log.d(TAG, "onPrefChange allowCalls=" + val);
if (DEBUG) Log.d(TAG, "onPrefChange allowCalls=" + val); final ZenModeConfig newConfig = mConfig.copy();
final ZenModeConfig newConfig = mConfig.copy(); newConfig.allowCalls = val;
newConfig.allowCalls = val; return setZenModeConfig(newConfig);
return setZenModeConfig(newConfig); }
} });
});
} else {
important.removePreference(mCalls);
mCalls = null;
}
mMessages = (SwitchPreference) important.findPreference(KEY_MESSAGES); mMessages = (SwitchPreference) important.findPreference(KEY_MESSAGES);
mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@@ -554,14 +540,6 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
} }
return result; return result;
} }
public List<String> getNonIndexableKeys(Context context) {
final ArrayList<String> rt = new ArrayList<String>();
if (!Utils.isVoiceCapable(context)) {
rt.add(KEY_CALLS);
}
return rt;
}
}; };
private static class SettingPrefWithCallback extends SettingPref { private static class SettingPrefWithCallback extends SettingPref {