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

Commit 2d1bdd8d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "DND string fixes"

parents c8a34adc 02b81c13
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -45,7 +45,9 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Inde
        controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
        controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle));
        controllers.add(new ZenModeCallsPreferenceController(context, lifecycle));
        controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle));
        controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
                context.getResources().getInteger(com.android.internal.R.integer
                .config_zen_repeat_callers_threshold)));
        controllers.add(new ZenModeScreenOnPreferenceController(context, lifecycle));
        controllers.add(new ZenModeScreenOffPreferenceController(context, lifecycle));
        controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle));
+21 −2
Original line number Diff line number Diff line
@@ -21,9 +21,11 @@ import android.content.Context;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;

public class ZenModeRepeatCallersPreferenceController extends AbstractZenModePreferenceController
@@ -31,8 +33,15 @@ public class ZenModeRepeatCallersPreferenceController extends AbstractZenModePre

    protected static final String KEY = "zen_mode_repeat_callers";

    public ZenModeRepeatCallersPreferenceController(Context context, Lifecycle lifecycle) {
    private final ZenModeBackend mBackend;
    private final int mRepeatCallersThreshold;

    public ZenModeRepeatCallersPreferenceController(Context context, Lifecycle lifecycle,
            int repeatCallersThreshold) {
        super(context, KEY, lifecycle);

        mRepeatCallersThreshold = repeatCallersThreshold;
        mBackend = ZenModeBackend.getInstance(context);
    }

    @Override
@@ -45,12 +54,17 @@ public class ZenModeRepeatCallersPreferenceController extends AbstractZenModePre
        return true;
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        setRepeatCallerSummary(screen.findPreference(KEY));
    }

    @Override
    public void updateState(Preference preference) {
        super.updateState(preference);

        SwitchPreference pref = (SwitchPreference) preference;

        switch (getZenMode()) {
            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
            case Settings.Global.ZEN_MODE_ALARMS:
@@ -84,4 +98,9 @@ public class ZenModeRepeatCallersPreferenceController extends AbstractZenModePre
        mBackend.saveSoundPolicy(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, allowRepeatCallers);
        return true;
    }

    private void setRepeatCallerSummary(Preference preference) {
        preference.setSummary(mContext.getString(R.string.zen_mode_repeat_callers_summary,
                mRepeatCallersThreshold));
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@ public class ZenModeRepeatCallersPreferenceControllerTest {
        mContentResolver = RuntimeEnvironment.application.getContentResolver();
        when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);

        mController = new ZenModeRepeatCallersPreferenceController(mContext, mock(Lifecycle.class));
        mController = new ZenModeRepeatCallersPreferenceController(mContext, mock(Lifecycle.class),
                15);
        ReflectionHelpers.setField(mController, "mBackend", mBackend);

        when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+1 −1

File changed.

Contains only whitespace changes.