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

Commit 21416c74 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Make notification-shade-collapse-after-dismiss behaviour configurable." into cm-10.2

parents 804dd92b 44e61e43
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2818,6 +2818,19 @@ public final class Settings {
         */
        public static final String STATUS_BAR_IME_SWITCHER = "status_bar_ime_switcher";

        /**
         * Whether to collapse the notification area after dismissing the last notification
         * @hide
         */
        public static final String STATUS_BAR_COLLAPSE_ON_DISMISS = "status_bar_collapse_on_dismiss";

        /** @hide */
        public static final int STATUS_BAR_COLLAPSE_NEVER = 0;
        /** @hide */
        public static final int STATUS_BAR_COLLAPSE_IF_EMPTIED = 1;
        /** @hide */
        public static final int STATUS_BAR_COLLAPSE_IF_NO_CLEARABLE = 2;

         /**
         * Expanded desktop on/off state
         * @hide
+55 −10
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ public abstract class BaseStatusBar extends SystemUI implements
    protected Display mDisplay;

    private boolean mDeviceProvisioned = false;
    private int mAutoCollapseBehaviour;

    public IStatusBarService getStatusBarService() {
        return mBarService;
@@ -198,7 +199,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        return mDeviceProvisioned;
    }

    private ContentObserver mProvisioningObserver = new ContentObserver(new Handler()) {
    private ContentObserver mProvisioningObserver = new ContentObserver(mHandler) {
        @Override
        public void onChange(boolean selfChange) {
            final boolean provisioned = 0 != Settings.Global.getInt(
@@ -210,6 +211,33 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    };

    private class SettingsObserver extends ContentObserver {
        public SettingsObserver(Handler handler) {
            super(handler);
        }

        public void observe() {
            ContentResolver resolver = mContext.getContentResolver();
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.STATUS_BAR_COLLAPSE_ON_DISMISS), false, this);
            update();
        }

        @Override
        public void onChange(boolean selfChange) {
            update();
        }

        private void update() {
            ContentResolver resolver = mContext.getContentResolver();
            mAutoCollapseBehaviour = Settings.System.getIntForUser(resolver,
                    Settings.System.STATUS_BAR_COLLAPSE_ON_DISMISS,
                    Settings.System.STATUS_BAR_COLLAPSE_IF_NO_CLEARABLE, UserHandle.USER_CURRENT);
        }
    };

    private SettingsObserver mSettingsObserver = new SettingsObserver(mHandler);

    private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() {
        @Override
        public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) {
@@ -252,6 +280,8 @@ public abstract class BaseStatusBar extends SystemUI implements
                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true,
                mProvisioningObserver);

        mSettingsObserver.observe();

        mBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));

@@ -975,9 +1005,27 @@ public abstract class BaseStatusBar extends SystemUI implements
        if (rowParent != null) rowParent.removeView(entry.row);
        updateExpansionStates();
        updateNotificationIcons();
        maybeCollapseAfterNotificationRemoval(entry.userDismissed());

        return entry.notification;
    }

        if (CLOSE_PANEL_WHEN_EMPTIED && isNotificationPanelFullyVisible()) {
            if (entry.userDismissed() && !mNotificationData.hasClearableItems()) {
    protected void maybeCollapseAfterNotificationRemoval(boolean userDismissed) {
        if (mAutoCollapseBehaviour == Settings.System.STATUS_BAR_COLLAPSE_NEVER) {
            return;
        }
        if (!isNotificationPanelFullyVisible()) {
            return;
        }

        boolean collapseDueToEmpty =
                mAutoCollapseBehaviour == Settings.System.STATUS_BAR_COLLAPSE_IF_EMPTIED
                && mNotificationData.size() == 0;
        boolean collapseDueToNoClearable =
                mAutoCollapseBehaviour == Settings.System.STATUS_BAR_COLLAPSE_IF_NO_CLEARABLE
                && !mNotificationData.hasClearableItems();

        if (userDismissed && (collapseDueToEmpty || collapseDueToNoClearable)) {
            mHandler.removeCallbacks(mPanelCollapseRunnable);
            mHandler.postDelayed(mPanelCollapseRunnable, COLLAPSE_AFTER_DISMISS_DELAY);
        } else if (mNotificationData.size() == 0) {
@@ -986,9 +1034,6 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }

        return entry.notification;
    }

    protected StatusBarIconView addNotificationViews(IBinder key,
            StatusBarNotification notification) {
        if (DEBUG) {
+1 −1
Original line number Diff line number Diff line
@@ -2598,7 +2598,7 @@ public class PhoneStatusBar extends BaseStatusBar {
                }

                if (snapshot.isEmpty()) {
                    animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
                    maybeCollapseAfterNotificationRemoval(true);
                    return;
                }