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

Commit e652a039 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Adding zen duration preference" into pi-dev

parents 5906621e 3f3c8acc
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -6917,6 +6917,9 @@
    <!-- Do not disturb: Title for the page describing what can bypass DND. [CHAR LIMIT=30] -->
    <string name="zen_mode_behavior_settings_title">Exceptions</string>
    <!-- Do not disturb: Title for the dnd duration setting (user can specify how long dnd will last when toggling dnd on from qs or settings) [CHAR LIMIT=30] -->
    <string name="zen_mode_duration_settings_title">Duration</string>
    <!-- Do not disturb: Instructions indicating what types of sounds can bypass DND. [CHAR LIMIT=52] -->
    <string name="zen_mode_behavior_allow_title">Allow sounds and vibrations from</string>
@@ -7038,6 +7041,21 @@
    <!-- Sound settings screen, summary format of do not disturb when on with no extra information. [CHAR LIMIT=NONE] -->
    <string name="zen_mode_sound_summary_on">On</string>
    <!--  Do not disturb: Summary for zen mode duration setting indicating user will be prompted to set dnd duration whenever dnd is manually toggled on [CHAR LIMIT=NONE]-->
    <string name="zen_mode_duration_summary_always_prompt">Ask every time (unless turned on automatically)</string>
    <!--  Do not disturb: Summary for zen mode duration setting indicating how long dnd will last when dnd is manually toggled on [CHAR LIMIT=NONE] -->
    <string name="zen_mode_duration_summary_forever">Until you turn off (unless turned on automatically)</string>
    <!--  Do not disturb: Summary for zen mode duration setting indicating how long dnd will last when dnd is manually toggled on [CHAR LIMIT=NONE] -->
    <plurals name="zen_mode_duration_summary_time_hours">
        <item quantity="one">1 hour (unless turned on automatically)</item>
        <item quantity="other"><xliff:g id="num_hours" example="3">%d</xliff:g> hours (unless turned on automatically)</item>
    </plurals>
    <!--  Do not disturb: Summary for zen mode duration setting indicating how long dnd will last when toggled on -->
    <string name="zen_mode_duration_summary_time_minutes"><xliff:g id="num_minutes" example="5">%d</xliff:g> minutes (unless turned on automatically)</string>
    <!-- Summary for the Sound Do not Disturb option when at least one automatic rules is enabled. [CHAR LIMIT=NONE]-->
    <plurals name="zen_mode_sound_summary_summary_off_info">
        <item quantity="one">1 rule can turn on automatically</item>
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@
            android:title="@string/zen_mode_behavior_settings_title"
            android:fragment="com.android.settings.notification.ZenModeBehaviorSettings" />

    <!-- DND duration settings -->
    <Preference
        android:key="zen_mode_duration_settings"
        android:title="@string/zen_mode_duration_settings_title" />

    <!-- Automatic rules -->
    <Preference
        android:key="zen_mode_automation_settings"
+10 −5
Original line number Diff line number Diff line
@@ -112,10 +112,17 @@ abstract public class AbstractZenModePreferenceController extends
                mBackend.mZenMode);
    }

    protected int getZenDuration() {
        return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ZEN_DURATION,
                0);
    }

    class SettingObserver extends ContentObserver {
        private final Uri ZEN_MODE_URI = Settings.Global.getUriFor(Settings.Global.ZEN_MODE);
        private final Uri ZEN_MODE_CONFIG_ETAG_URI = Settings.Global.getUriFor(
                Settings.Global.ZEN_MODE_CONFIG_ETAG);
        private final Uri ZEN_MODE_DURATION_URI = Settings.Global.getUriFor(
                Settings.Global.ZEN_DURATION);

        private final Preference mPreference;

@@ -127,6 +134,7 @@ abstract public class AbstractZenModePreferenceController extends
        public void register(ContentResolver cr) {
            cr.registerContentObserver(ZEN_MODE_URI, false, this, UserHandle.USER_ALL);
            cr.registerContentObserver(ZEN_MODE_CONFIG_ETAG_URI, false, this, UserHandle.USER_ALL);
            cr.registerContentObserver(ZEN_MODE_DURATION_URI, false, this, UserHandle.USER_ALL);
        }

        public void unregister(ContentResolver cr) {
@@ -136,11 +144,8 @@ abstract public class AbstractZenModePreferenceController extends
        @Override
        public void onChange(boolean selfChange, Uri uri) {
            super.onChange(selfChange, uri);
            if (ZEN_MODE_URI.equals(uri)) {
                updateState(mPreference);
            }

            if (ZEN_MODE_CONFIG_ETAG_URI.equals(uri)) {
            if (ZEN_MODE_URI.equals(uri) || ZEN_MODE_CONFIG_ETAG_URI.equals(uri)
                    || ZEN_MODE_DURATION_URI.equals(uri)) {
                updateState(mPreference);
            }
        }
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.Dialog;
import android.os.Bundle;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

public class SettingsZenDurationDialog extends InstrumentedDialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new com.android.settingslib.notification.ZenDurationDialog(
                getContext()).createDialog();
    }

    @Override
    public int getMetricsCategory() {
        return MetricsProto.MetricsEvent.NOTIFICATION_ZEN_MODE_DURATION_DIALOG;
    }
}
+16 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.content.Context;
Loading