<!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
<string name="zen_mode_events">Events</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Selected callers summary -->
+ <string name="zen_mode_selected_callers">Selected callers</string>
+
+ <!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option -->
+ <string name="zen_mode_repeat_callers">Repeat callers</string>
+
+ <!-- [CHAR LIMIT=200] Zen mode settings: Repeat callers option summary -->
+ <string name="zen_mode_repeat_callers_summary">If the same person calls a second time within a <xliff:g id="minutes">%d</xliff:g> minute period, allow it</string>
+
<!-- [CHAR LIMIT=20] Zen mode settings: When option -->
<string name="zen_mode_when">Automatically turn on</string>
android:title="@string/zen_mode_from"
android:persistent="false" />
+ <!-- Repeat callers -->
+ <SwitchPreference
+ android:key="repeat_callers"
+ android:title="@string/zen_mode_repeat_callers"
+ android:persistent="false"
+ android:switchTextOff=""
+ android:switchTextOn="" />
+
</PreferenceScreen>
private static final String KEY_MESSAGES = "messages";
private static final String KEY_CALLS = "calls";
private static final String KEY_STARRED = "starred";
+ private static final String KEY_REPEAT_CALLERS = "repeat_callers";
private boolean mDisableListeners;
private SwitchPreference mReminders;
private SwitchPreference mMessages;
private SwitchPreference mCalls;
private DropDownPreference mStarred;
+ private SwitchPreference mRepeatCallers;
@Override
public void onCreate(Bundle savedInstanceState) {
}
});
+ mRepeatCallers = (SwitchPreference) root.findPreference(KEY_REPEAT_CALLERS);
+ mRepeatCallers.setSummary(mContext.getString(R.string.zen_mode_repeat_callers_summary,
+ mContext.getResources().getInteger(com.android.internal.R.integer
+ .config_zen_repeat_callers_threshold)));
+ mRepeatCallers.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mDisableListeners) return true;
+ final boolean val = (Boolean) newValue;
+ if (val == mConfig.allowRepeatCallers) return true;
+ if (DEBUG) Log.d(TAG, "onPrefChange allowRepeatCallers=" + val);
+ final ZenModeConfig newConfig = mConfig.copy();
+ newConfig.allowRepeatCallers = val;
+ return setZenModeConfig(newConfig);
+ }
+ });
+
updateControls();
}
}
mMessages.setChecked(mConfig.allowMessages);
mStarred.setSelectedValue(mConfig.allowFrom);
+ mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages);
mReminders.setChecked(mConfig.allowReminders);
mEvents.setChecked(mConfig.allowEvents);
- updateStarredEnabled();
+ mRepeatCallers.setChecked(mConfig.allowRepeatCallers);
+ mRepeatCallers.setEnabled(!mConfig.allowCalls
+ || mConfig.allowFrom != ZenModeConfig.SOURCE_ANYONE);
mDisableListeners = false;
}
return MetricsLogger.NOTIFICATION_ZEN_MODE_PRIORITY;
}
- private void updateStarredEnabled() {
- mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages);
- }
-
}
}
private void updatePrioritySettingsSummary() {
+ final boolean callers = mConfig.allowCalls || mConfig.allowRepeatCallers;
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, callers, R.string.zen_mode_selected_callers);
s = appendLowercase(s, mConfig.allowMessages, R.string.zen_mode_messages);
mPrioritySettings.setSummary(s);
}