Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35fba3ee authored by John Spurlock's avatar John Spurlock
Browse files

Settings: New zen option to allow repeat callers.

Bug: 20064962
Change-Id: Icc65da146503386c057d7f78d6610f83f56d1a92
parent d333a7d9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -5915,6 +5915,15 @@
    <!-- [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>

+8 −0
Original line number Diff line number Diff line
@@ -67,4 +67,12 @@
            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>
+23 −5
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
    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;
@@ -42,6 +43,7 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
    private SwitchPreference mMessages;
    private SwitchPreference mCalls;
    private DropDownPreference mStarred;
    private SwitchPreference mRepeatCallers;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -123,6 +125,23 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
            }
        });

        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();
    }

@@ -143,9 +162,12 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
        }
        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;
    }

@@ -154,8 +176,4 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
        return MetricsLogger.NOTIFICATION_ZEN_MODE_PRIORITY;
    }

    private void updateStarredEnabled() {
        mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages);
    }

}
+2 −1
Original line number Diff line number Diff line
@@ -159,10 +159,11 @@ public class ZenModeSettings extends ZenModeSettingsBase
    }

    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);
    }