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

Commit 454f59b7 authored by Heemin Seog's avatar Heemin Seog Committed by Android (Google) Code Review
Browse files

Merge "Separate ShadeController from StatusBar"

parents a224f353 ba6337f3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
import com.android.systemui.statusbar.car.CarShadeControllerImpl;
import com.android.systemui.statusbar.car.CarStatusBar;
import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -119,7 +120,7 @@ abstract class CarSystemUIModule {
            KeyguardEnvironmentImpl keyguardEnvironment);

    @Binds
    abstract ShadeController provideShadeController(CarStatusBar statusBar);
    abstract ShadeController provideShadeController(CarShadeControllerImpl shadeController);

    @Provides
    @Singleton
+85 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.car;

import android.view.View;
import android.view.WindowManager;

import com.android.car.notification.CarNotificationView;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.ShadeControllerImpl;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarWindowController;

import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Lazy;

/** Car specific implementation of {@link com.android.systemui.statusbar.phone.ShadeController}. */
@Singleton
public class CarShadeControllerImpl extends ShadeControllerImpl {

    @Inject
    public CarShadeControllerImpl(CommandQueue commandQueue,
            StatusBarStateController statusBarStateController,
            StatusBarWindowController statusBarWindowController,
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            WindowManager windowManager,
            Lazy<StatusBar> statusBarLazy,
            Lazy<AssistManager> assistManagerLazy,
            Lazy<BubbleController> bubbleControllerLazy) {
        super(commandQueue, statusBarStateController, statusBarWindowController,
                statusBarKeyguardViewManager, windowManager,
                statusBarLazy, assistManagerLazy, bubbleControllerLazy);
    }

    @Override
    public void animateCollapsePanels(int flags, boolean force, boolean delayed,
            float speedUpFactor) {
        super.animateCollapsePanels(flags, force, delayed, speedUpFactor);
        if (!getCarStatusBar().isPanelExpanded()
                || getCarNotificationView().getVisibility() == View.INVISIBLE) {
            return;
        }

        mStatusBarWindowController.setStatusBarFocusable(false);
        getCarStatusBar().getStatusBarWindowViewController().cancelExpandHelper();
        getStatusBarView().collapsePanel(true /* animate */, delayed, speedUpFactor);

        getCarStatusBar().animateNotificationPanel(getCarStatusBar().getClosingVelocity(), true);

        if (!getCarStatusBar().isTracking()) {
            mStatusBarWindowController.setPanelVisible(false);
            getCarNotificationView().setVisibility(View.INVISIBLE);
        }

        getCarStatusBar().setPanelExpanded(false);
    }

    private CarStatusBar getCarStatusBar() {
        return (CarStatusBar) mStatusBarLazy.get();
    }

    private CarNotificationView getCarNotificationView() {
        return getCarStatusBar().getCarNotificationView();
    }
}
+17 −21
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import com.android.systemui.statusbar.phone.LockscreenWallpaper;
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarComponent;
import com.android.systemui.statusbar.phone.StatusBarIconController;
@@ -175,6 +176,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
    private final Object mQueueLock = new Object();
    private final CarNavigationBarController mCarNavigationBarController;
    private final Lazy<PowerManagerHelper> mPowerManagerHelperLazy;
    private final ShadeController mShadeController;
    private final CarServiceProvider mCarServiceProvider;

    private DeviceProvisionedController mDeviceProvisionedController;
@@ -308,6 +310,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
            LightsOutNotifController lightsOutNotifController,
            StatusBarNotificationActivityStarter.Builder
                    statusBarNotificationActivityStarterBuilder,
            ShadeController shadeController,
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            ViewMediatorCallback viewMediatorCallback,
            DismissCallbackRegistry dismissCallbackRegistry,
@@ -385,6 +388,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                dividerOptional,
                lightsOutNotifController,
                statusBarNotificationActivityStarterBuilder,
                shadeController,
                superStatusBarViewFactory,
                statusBarKeyguardViewManager,
                viewMediatorCallback,
@@ -392,6 +396,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        mScrimController = scrimController;
        mLockscreenLockIconController = lockscreenLockIconController;
        mDeviceProvisionedController = deviceProvisionedController;
        mShadeController = shadeController;
        mCarServiceProvider = carServiceProvider;
        mPowerManagerHelperLazy = powerManagerHelperLazy;
        mFullscreenUserSwitcherLazy = fullscreenUserSwitcherLazy;
@@ -506,7 +511,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                    @Override
                    protected void close() {
                        if (mPanelExpanded) {
                            animateCollapsePanels();
                            mShadeController.animateCollapsePanels();
                        }
                    }
                });
@@ -516,7 +521,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                    @Override
                    protected void close() {
                        if (mPanelExpanded) {
                            animateCollapsePanels();
                            mShadeController.animateCollapsePanels();
                        }
                    }
                });
@@ -551,7 +556,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        mNotificationClickHandlerFactory.registerClickListener((launchResult, alertEntry) -> {
            if (launchResult == ActivityManager.START_TASK_TO_FRONT
                    || launchResult == ActivityManager.START_SUCCESS) {
                animateCollapsePanels();
                mShadeController.animateCollapsePanels();
            }
        });
        CarNotificationListener carNotificationListener = new CarNotificationListener();
@@ -712,25 +717,16 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        setPanelExpanded(true);
    }

    @Override
    public void animateCollapsePanels(int flags, boolean force, boolean delayed,
            float speedUpFactor) {
        super.animateCollapsePanels(flags, force, delayed, speedUpFactor);
        if (!mPanelExpanded || mNotificationView.getVisibility() == View.INVISIBLE) {
            return;
    public CarNotificationView getCarNotificationView() {
        return mNotificationView;
    }
        mStatusBarWindowController.setStatusBarFocusable(false);
        mStatusBarWindowViewController.cancelExpandHelper();
        mStatusBarView.collapsePanel(true /* animate */, delayed, speedUpFactor);

        animateNotificationPanel(mClosingVelocity, true);

        if (!mIsTracking) {
            mStatusBarWindowController.setPanelVisible(false);
            mNotificationView.setVisibility(View.INVISIBLE);
    public float getClosingVelocity() {
        return mClosingVelocity;
    }

        setPanelExpanded(false);
    public boolean isTracking() {
        return mIsTracking;
    }

    private void maybeCompleteAnimation(MotionEvent event) {
@@ -749,7 +745,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
     * close the notification shade completely with a velocity. If the animation is to close the
     * notification shade this method also makes the view invisible after animation ends.
     */
    private void animateNotificationPanel(float velocity, boolean isClosing) {
    void animateNotificationPanel(float velocity, boolean isClosing) {
        float to = 0;
        if (!isClosing) {
            to = mNotificationView.getHeight();
+3 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import com.android.systemui.statusbar.phone.LockscreenWallpaper;
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBarComponent;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
@@ -183,6 +184,7 @@ public class CarStatusBarModule {
            LightsOutNotifController lightsOutNotifController,
            StatusBarNotificationActivityStarter.Builder
                    statusBarNotificationActivityStarterBuilder,
            ShadeController shadeController,
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            ViewMediatorCallback viewMediatorCallback,
            DismissCallbackRegistry dismissCallbackRegistry,
@@ -259,6 +261,7 @@ public class CarStatusBarModule {
                superStatusBarViewFactory,
                lightsOutNotifController,
                statusBarNotificationActivityStarterBuilder,
                shadeController,
                statusBarKeyguardViewManager,
                viewMediatorCallback,
                dismissCallbackRegistry,
+5 −7
Original line number Diff line number Diff line
@@ -109,8 +109,6 @@ import java.util.function.Consumer;
import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Lazy;

/**
 * Bubbles are a special type of content that can "float" on top of other apps or System UI.
 * Bubbles can be expanded to show more content.
@@ -147,7 +145,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
    private BubbleExpandListener mExpandListener;
    @Nullable private BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer;
    private final NotificationGroupManager mNotificationGroupManager;
    private final Lazy<ShadeController> mShadeController;
    private final ShadeController mShadeController;
    private final RemoteInputUriController mRemoteInputUriController;
    private Handler mHandler = new Handler() {};

@@ -243,7 +241,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
    public BubbleController(Context context,
            StatusBarWindowController statusBarWindowController,
            StatusBarStateController statusBarStateController,
            Lazy<ShadeController> shadeController,
            ShadeController shadeController,
            BubbleData data,
            ConfigurationController configurationController,
            NotificationInterruptionStateProvider interruptionStateProvider,
@@ -261,7 +259,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
    public BubbleController(Context context,
            StatusBarWindowController statusBarWindowController,
            StatusBarStateController statusBarStateController,
            Lazy<ShadeController> shadeController,
            ShadeController shadeController,
            BubbleData data,
            @Nullable BubbleStackView.SurfaceSynchronizer synchronizer,
            ConfigurationController configurationController,
@@ -272,6 +270,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
            NotificationEntryManager entryManager,
            RemoteInputUriController remoteInputUriController) {
        mContext = context;
        mShadeController = shadeController;
        mNotificationInterruptionStateProvider = interruptionStateProvider;
        mNotifUserManager = notifUserManager;
        mZenModeController = zenModeController;
@@ -319,7 +318,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                    }
                });

        mShadeController = shadeController;
        mStatusBarWindowController = statusBarWindowController;
        mStatusBarStateListener = new StatusBarStateListener();
        statusBarStateController.addCallback(mStatusBarStateListener);
@@ -579,7 +577,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
        if (DEBUG_EXPERIMENTS || DEBUG_BUBBLE_CONTROLLER) {
            Log.d(TAG, "onUserCreatedBubble: " + entry.getKey());
        }
        mShadeController.get().collapsePanel(true);
        mShadeController.collapsePanel(true);
        entry.setFlagBubble(true);
        updateBubble(entry, true /* suppressFlyout */, false /* showInShade */);
        mUserCreatedBubbles.add(entry.getKey());
Loading