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

Commit b2e90390 authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Remove unused do-not-disturb items."

parents 75d71b7e 0ac7b73b
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -24,17 +24,6 @@
         all of the currently visible notifications. [CHAR LIMIT=10]-->
    <string name="status_bar_clear_all_button">Clear</string>

    <!-- The text for the button in the notification window-shade that turns
         on do not disturb mode, where notifications no longer show their ticker,
         no sound plays, and no icons are visible.  The windowshade continues to show
         the notifications. [CHAR LIMIT=25]-->
    <string name="status_bar_do_not_disturb_button">Do not disturb</string>

    <!-- The text for the button in the notification window-shade that turns
         off do not disturb mode.  After clicking this, notifications will be
         shown again. [CHAR LIMIT=25] -->
    <string name="status_bar_please_disturb_button">Show notifications</string>

    <!-- Title shown in recents popup for removing an application from the list -->
    <string name="status_bar_recent_remove_item_title">Remove from list</string>

@@ -436,13 +425,6 @@
         application -->
    <string name="status_bar_notification_inspect_item_title">App info</string>

    <!-- Title for the pseudo-notification shown when notifications are disabled (do-not-disturb
         mode) -->
    <string name="notifications_off_title">Notifications off</string>

    <!-- Content text for do-not-disturb mode notification -->
    <string name="notifications_off_text">Tap here to turn notifications back on.</string>

    <!-- Description of the button in the phone-style notification panel that controls auto-rotation, when auto-rotation is on. [CHAR LIMIT=NONE] -->
    <string name="accessibility_rotation_lock_off">Screen will rotate automatically.</string>

+0 −56
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 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.systemui.statusbar;

import android.app.StatusBarManager;
import android.content.Context;
import android.content.SharedPreferences;

import com.android.systemui.statusbar.policy.Prefs;

public class DoNotDisturb implements SharedPreferences.OnSharedPreferenceChangeListener {
    private Context mContext;
    private StatusBarManager mStatusBar;
    SharedPreferences mPrefs;
    private boolean mDoNotDisturb;

    public DoNotDisturb(Context context) {
        mContext = context;
        mStatusBar = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE);
        mPrefs = Prefs.read(context);
        mPrefs.registerOnSharedPreferenceChangeListener(this);
        mDoNotDisturb = mPrefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT);
        updateDisableRecord();
    }

    public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
        final boolean val = prefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF,
                Prefs.DO_NOT_DISTURB_DEFAULT);
        if (val != mDoNotDisturb) {
            mDoNotDisturb = val;
            updateDisableRecord();
        }
    }

    private void updateDisableRecord() {
        final int disabled = StatusBarManager.DISABLE_NOTIFICATION_ICONS
                | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
                | StatusBarManager.DISABLE_NOTIFICATION_TICKER;
        mStatusBar.disable(mDoNotDisturb ? disabled : 0);
    }
}
+0 −71
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 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.systemui.statusbar.policy;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.CompoundButton;

public class DoNotDisturbController implements CompoundButton.OnCheckedChangeListener,
        SharedPreferences.OnSharedPreferenceChangeListener {
    private static final String TAG = "StatusBar.DoNotDisturbController";

    SharedPreferences mPrefs;
    private Context mContext;
    private CompoundButton mCheckBox;

    private boolean mDoNotDisturb;

    public DoNotDisturbController(Context context, CompoundButton checkbox) {
        mContext = context;

        mPrefs = Prefs.read(context);
        mPrefs.registerOnSharedPreferenceChangeListener(this);
        mDoNotDisturb = mPrefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT);

        mCheckBox = checkbox;
        checkbox.setOnCheckedChangeListener(this);

        checkbox.setChecked(!mDoNotDisturb);
    }

    // The checkbox is ON for notifications coming in and OFF for Do not disturb, so we
    // don't have a double negative.
    public void onCheckedChanged(CompoundButton view, boolean checked) {
        //Log.d(TAG, "onCheckedChanged checked=" + checked + " mDoNotDisturb=" + mDoNotDisturb);
        final boolean value = !checked;
        if (value != mDoNotDisturb) {
            SharedPreferences.Editor editor = Prefs.edit(mContext);
            editor.putBoolean(Prefs.DO_NOT_DISTURB_PREF, value);
            editor.apply();
        }
    }
    
    public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
        final boolean val = prefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF,
                Prefs.DO_NOT_DISTURB_DEFAULT);
        if (val != mDoNotDisturb) {
            mDoNotDisturb = val;
            mCheckBox.setChecked(!val);
        }
    }

    public void release() {
        mPrefs.unregisterOnSharedPreferenceChangeListener(this);
    }
}
+0 −4
Original line number Diff line number Diff line
@@ -22,10 +22,6 @@ import android.content.SharedPreferences;
public class Prefs {
    private static final String SHARED_PREFS_NAME = "status_bar";

    // a boolean
    public static final String DO_NOT_DISTURB_PREF = "do_not_disturb";
    public static final boolean DO_NOT_DISTURB_DEFAULT = false;

    public static final String SHOWN_COMPAT_MODE_HELP = "shown_compat_mode_help";
    public static final String SHOWN_QUICK_SETTINGS_HELP = "shown_quick_settings_help";