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

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

Merge "Bubble expanded view - update header color on uimode and overlay change"

parents 3ec026d6 f1c9b8ba
Loading
Loading
Loading
Loading
+26 −5
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.systemui.statusbar.notification.NotificationInterruptionState
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.NotificationContentInflater.InflationFlag;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.ConfigurationController;

import java.lang.annotation.Retention;

@@ -74,7 +75,8 @@ import javax.inject.Singleton;
 * The controller manages addition, removal, and visible state of bubbles on screen.
 */
@Singleton
public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListener {
public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListener,
        ConfigurationController.ConfigurationListener {

    private static final String TAG = "BubbleController";

@@ -84,6 +86,7 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
    @IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
            DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION})
    @interface DismissReason {}

    static final int DISMISS_USER_GESTURE = 1;
    static final int DISMISS_AGED = 2;
    static final int DISMISS_TASK_FINISHED = 3;
@@ -151,6 +154,7 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
    public interface BubbleExpandListener {
        /**
         * Called when the expansion state of the bubble stack changes.
         *
         * @param isExpanding whether it's expanding or collapsing
         * @param key the notification key associated with bubble being expanded
         */
@@ -179,13 +183,16 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe

    @Inject
    public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
                            BubbleData data) {
        this(context, statusBarWindowController, data, null /* synchronizer */);
            BubbleData data, ConfigurationController configurationController) {
        this(context, statusBarWindowController, data, null /* synchronizer */,
                configurationController);
    }

    public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
            BubbleData data, @Nullable BubbleStackView.SurfaceSynchronizer synchronizer) {
            BubbleData data, @Nullable BubbleStackView.SurfaceSynchronizer synchronizer,
            ConfigurationController configurationController) {
        mContext = context;
        configurationController.addCallback(this /* configurationListener */);

        mNotificationEntryManager = Dependency.get(NotificationEntryManager.class);
        mNotificationEntryManager.addNotificationEntryListener(mEntryListener);
@@ -215,6 +222,20 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
        mSurfaceSynchronizer = synchronizer;
    }

    @Override
    public void onUiModeChanged() {
        if (mStackView != null) {
            mStackView.onConfigChanged();
        }
    }

    @Override
    public void onOverlayChanged() {
        if (mStackView != null) {
            mStackView.onConfigChanged();
        }
    }

    /**
     * Set a listener to be notified when some states of the bubbles change.
     */
+7 −0
Original line number Diff line number Diff line
@@ -354,6 +354,13 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        }
    }

    /**
     * Update bubble expanded view header when user toggles dark mode.
     */
    void updateHeaderColor() {
        mHeaderView.setBackgroundColor(mContext.getColor(R.attr.colorAccent));
    }

    private void updateHeaderView() {
        mSettingsIcon.setContentDescription(getResources().getString(
                R.string.bubbles_settings_button_description, mAppName));
+7 −0
Original line number Diff line number Diff line
@@ -238,6 +238,13 @@ public class BubbleStackView extends FrameLayout {
        mBubbleContainer.bringToFront();
    }

    /**
     * Handle config changes.
     */
    public void onConfigChanged() {
        mExpandedBubble.expandedView.updateHeaderColor();
    }

    @Override
    public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
        getBoundsOnScreen(outRect);
+9 −3
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.ConfigurationController;

import org.junit.Before;
import org.junit.Test;
@@ -66,6 +67,9 @@ public class BubbleControllerTest extends SysuiTestCase {
    private IActivityManager mActivityManager;
    @Mock
    private DozeParameters mDozeParameters;
    @Mock
    private ConfigurationController mConfigurationController;

    private FrameLayout mStatusBarView;
    @Captor
    private ArgumentCaptor<NotificationEntryListener> mEntryListenerCaptor;
@@ -97,6 +101,7 @@ public class BubbleControllerTest extends SysuiTestCase {
        mStatusBarView = new FrameLayout(mContext);
        mDependency.injectTestDependency(NotificationEntryManager.class, mNotificationEntryManager);


        // Bubbles get added to status bar window view
        mStatusBarWindowController = new StatusBarWindowController(mContext, mWindowManager,
                mActivityManager, mDozeParameters);
@@ -115,7 +120,7 @@ public class BubbleControllerTest extends SysuiTestCase {

        mBubbleData = new BubbleData();
        mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController,
                mBubbleData);
                mBubbleData, mConfigurationController);
        mBubbleController.setBubbleStateChangeListener(mBubbleStateChangeListener);
        mBubbleController.setExpandListener(mBubbleExpandListener);

@@ -331,8 +336,9 @@ public class BubbleControllerTest extends SysuiTestCase {
    static class TestableBubbleController extends BubbleController {
        // Let's assume surfaces can be synchronized immediately.
        TestableBubbleController(Context context,
                StatusBarWindowController statusBarWindowController, BubbleData data) {
            super(context, statusBarWindowController, data, Runnable::run);
                StatusBarWindowController statusBarWindowController, BubbleData data,
                ConfigurationController configurationController) {
            super(context, statusBarWindowController, data, Runnable::run, configurationController);
        }

        @Override