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

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

Merge "Add msg to shade when dnd is suppressing notis" into pi-dev

parents 95d4b5b5 9cf1756f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1062,6 +1062,9 @@
    <!-- The text to clear all notifications. [CHAR LIMIT=60] -->
    <string name="clear_all_notifications_text">Clear all</string>

    <!-- The text to show in the notifications shade when dnd is suppressing notifications. [CHAR LIMIT=100] -->
    <string name="dnd_suppressing_shade_text">Do Not disturb is hiding notifications</string>

    <!-- Media projection permission dialog action text. [CHAR LIMIT=60] -->
    <string name="media_projection_action_text">Start now</string>

+8 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar;

import android.annotation.ColorInt;
import android.annotation.StringRes;
import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
@@ -30,6 +31,7 @@ import com.android.systemui.statusbar.stack.StackScrollState;
public class EmptyShadeView extends StackScrollerDecorView {

    private TextView mEmptyText;
    private @StringRes int mText = R.string.empty_shade_text;

    public EmptyShadeView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -38,7 +40,7 @@ public class EmptyShadeView extends StackScrollerDecorView {
    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mEmptyText.setText(R.string.empty_shade_text);
        mEmptyText.setText(mText);
    }

    @Override
@@ -50,6 +52,11 @@ public class EmptyShadeView extends StackScrollerDecorView {
        mEmptyText.setTextColor(color);
    }

    public void setText(@StringRes int text) {
        mText = text;
        mEmptyText.setText(mText);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
+7 −0
Original line number Diff line number Diff line
@@ -232,6 +232,7 @@ import com.android.systemui.statusbar.policy.PreviewInflater;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.util.NotificationChannels;
import com.android.systemui.volume.VolumeComponent;
@@ -407,6 +408,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    protected NotificationEntryManager mEntryManager;
    protected NotificationViewHierarchyManager mViewHierarchyManager;
    protected AppOpsListener mAppOpsListener;
    private ZenModeController mZenController;

    /**
     * Helper that is responsible for showing the right toast when a disallowed activity operation
@@ -626,6 +628,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        mViewHierarchyManager = Dependency.get(NotificationViewHierarchyManager.class);
        mAppOpsListener = Dependency.get(AppOpsListener.class);
        mAppOpsListener.setUpWithPresenter(this, mEntryManager);
        mZenController = Dependency.get(ZenModeController.class);

        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
        mColorExtractor.addOnColorsChangedListener(this);
@@ -1166,6 +1169,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
        mEmptyShadeView = (EmptyShadeView) LayoutInflater.from(mContext).inflate(
                R.layout.status_bar_no_notifications, mStackScroller, false);
        mEmptyShadeView.setText(R.string.empty_shade_text);
        mStackScroller.setEmptyShadeView(mEmptyShadeView);
    }

@@ -1498,6 +1502,9 @@ public class StatusBar extends SystemUI implements DemoMode,
        return entry.row.getParent() instanceof NotificationStackScrollLayout;
    }

    public boolean areNotificationsHidden() {
        return mZenController.areNotificationsHiddenInShade();
    }

    public void requestNotificationUpdate() {
        mEntryManager.updateNotifications();
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public interface ZenModeController extends CallbackController<Callback> {
    boolean isCountdownConditionSupported();
    int getCurrentUser();
    boolean isVolumeRestricted();
    boolean areNotificationsHiddenInShade();

    public static interface Callback {
        default void onZenChanged(int zen) {}
+19 −27
Original line number Diff line number Diff line
@@ -33,13 +33,11 @@ import android.os.UserManager;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
import android.service.notification.Condition;
import android.service.notification.IConditionListener;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ZenRule;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.qs.GlobalSetting;
import com.android.systemui.settings.CurrentUserTracker;
import com.android.systemui.util.Utils;
@@ -64,9 +62,9 @@ public class ZenModeControllerImpl extends CurrentUserTracker implements ZenMode
    private final UserManager mUserManager;

    private int mUserId;
    private boolean mRequesting;
    private boolean mRegistered;
    private ZenModeConfig mConfig;
    private int mZenMode;

    public ZenModeControllerImpl(Context context, Handler handler) {
        super(context);
@@ -74,6 +72,7 @@ public class ZenModeControllerImpl extends CurrentUserTracker implements ZenMode
        mModeSetting = new GlobalSetting(mContext, handler, Global.ZEN_MODE) {
            @Override
            protected void handleValueChanged(int value) {
                updateZenMode(value);
                fireZenChanged(value);
            }
        };
@@ -86,7 +85,9 @@ public class ZenModeControllerImpl extends CurrentUserTracker implements ZenMode
        mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mConfig = mNoMan.getZenModeConfig();
        mModeSetting.setListening(true);
        updateZenMode(mModeSetting.getValue());
        mConfigSetting.setListening(true);
        updateZenModeConfig();
        mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        mSetupObserver = new SetupObserver(handler);
        mSetupObserver.register();
@@ -100,6 +101,15 @@ public class ZenModeControllerImpl extends CurrentUserTracker implements ZenMode
                new UserHandle(mUserId));
    }

    @Override
    public boolean areNotificationsHiddenInShade() {
        if (mZenMode != Global.ZEN_MODE_OFF) {
            return (mConfig.suppressedVisualEffects & NotificationManager.Policy
                    .SUPPRESSED_EFFECT_NOTIFICATION_LIST) != 0;
        }
        return false;
    }

    @Override
    public void addCallback(Callback callback) {
        mCallbacks.add(callback);
@@ -186,10 +196,6 @@ public class ZenModeControllerImpl extends CurrentUserTracker implements ZenMode
        Utils.safeForeach(mCallbacks, c -> c.onZenAvailableChanged(available));
    }

    private void fireConditionsChanged(Condition[] conditions) {
        Utils.safeForeach(mCallbacks, c -> c.onConditionsChanged(conditions));
    }

    private void fireManualRuleChanged(ZenRule rule) {
        Utils.safeForeach(mCallbacks, c -> c.onManualRuleChanged(rule));
    }
@@ -199,17 +205,13 @@ public class ZenModeControllerImpl extends CurrentUserTracker implements ZenMode
        Utils.safeForeach(mCallbacks, c -> c.onConfigChanged(config));
    }

    private void updateConditions(Condition[] conditions) {
        if (conditions == null || conditions.length == 0) return;
        for (Condition c : conditions) {
            if ((c.flags & Condition.FLAG_RELEVANT_NOW) == 0) continue;
            mConditions.put(c.id, c);
        }
        fireConditionsChanged(
                mConditions.values().toArray(new Condition[mConditions.values().size()]));
    @VisibleForTesting
    protected void updateZenMode(int mode) {
        mZenMode = mode;
    }

    private void updateZenModeConfig() {
    @VisibleForTesting
    protected void updateZenModeConfig() {
        final ZenModeConfig config = mNoMan.getZenModeConfig();
        if (Objects.equals(config, mConfig)) return;
        final ZenRule oldRule = mConfig != null ? mConfig.manualRule : null;
@@ -220,16 +222,6 @@ public class ZenModeControllerImpl extends CurrentUserTracker implements ZenMode
        fireManualRuleChanged(newRule);
    }

    private final IConditionListener mListener = new IConditionListener.Stub() {
        @Override
        public void onConditionsReceived(Condition[] conditions) {
            if (DEBUG) Slog.d(TAG, "onConditionsReceived "
                    + (conditions == null ? 0 : conditions.length) + " mRequesting=" + mRequesting);
            if (!mRequesting) return;
            updateConditions(conditions);
        }
    };

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
Loading