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

Commit 22c384d3 authored by Abhijoy Saha's avatar Abhijoy Saha Committed by Automerger Merge Worker
Browse files

Merge "Allow HUNs to be shown over Overlay Window." into rvc-dev am: 4785a066

Change-Id: Id47de9075e5858cfe5c72d755ed0fb2ac3152522
parents 20e1fa7e 4785a066
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -73,7 +73,7 @@ public class CarNavigationBarController {
    }
    }


    /**
    /**
     * Hides all navigation bars.
     * Hides all system bars.
     */
     */
    public void hideBars() {
    public void hideBars() {
        if (mTopView != null) {
        if (mTopView != null) {
@@ -85,7 +85,7 @@ public class CarNavigationBarController {
    }
    }


    /**
    /**
     * Shows all navigation bars.
     * Shows all system bars.
     */
     */
    public void showBars() {
    public void showBars() {
        if (mTopView != null) {
        if (mTopView != null) {
+9 −14
Original line number Original line Diff line number Diff line
@@ -29,41 +29,40 @@ import android.widget.FrameLayout;
import com.android.car.notification.R;
import com.android.car.notification.R;
import com.android.car.notification.headsup.CarHeadsUpNotificationContainer;
import com.android.car.notification.headsup.CarHeadsUpNotificationContainer;
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.car.window.OverlayViewGlobalStateController;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.Main;


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


import dagger.Lazy;

/**
/**
 * A controller for SysUI's HUN display.
 * A controller for SysUI's HUN display.
 */
 */
@Singleton
@Singleton
public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotificationContainer {
public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotificationContainer {
    private final CarDeviceProvisionedController mCarDeviceProvisionedController;
    private final CarDeviceProvisionedController mCarDeviceProvisionedController;
    private final Lazy<NotificationPanelViewController> mNotificationPanelViewControllerLazy;
    private final OverlayViewGlobalStateController mOverlayViewGlobalStateController;


    private final ViewGroup mWindow;
    private final ViewGroup mWindow;
    private final FrameLayout mHeadsUpContentFrame;
    private final FrameLayout mHeadsUpContentFrame;


    private final boolean mEnableHeadsUpNotificationWhenNotificationShadeOpen;

    @Inject
    @Inject
    CarHeadsUpNotificationSystemContainer(Context context,
    CarHeadsUpNotificationSystemContainer(Context context,
            @Main Resources resources,
            @Main Resources resources,
            CarDeviceProvisionedController deviceProvisionedController,
            CarDeviceProvisionedController deviceProvisionedController,
            WindowManager windowManager,
            WindowManager windowManager,
            Lazy<NotificationPanelViewController> notificationPanelViewControllerLazy) {
            OverlayViewGlobalStateController overlayViewGlobalStateController) {
        mCarDeviceProvisionedController = deviceProvisionedController;
        mCarDeviceProvisionedController = deviceProvisionedController;
        mNotificationPanelViewControllerLazy = notificationPanelViewControllerLazy;
        mOverlayViewGlobalStateController = overlayViewGlobalStateController;


        boolean showOnBottom = resources.getBoolean(R.bool.config_showHeadsUpNotificationOnBottom);
        boolean showOnBottom = resources.getBoolean(R.bool.config_showHeadsUpNotificationOnBottom);


        // Use TYPE_STATUS_BAR_SUB_PANEL window type since we need to find a window that is above
        // status bar but below navigation bar.
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG,
                WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                        | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                PixelFormat.TRANSLUCENT);
                PixelFormat.TRANSLUCENT);
@@ -78,15 +77,11 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica
        windowManager.addView(mWindow, lp);
        windowManager.addView(mWindow, lp);
        mWindow.setVisibility(View.INVISIBLE);
        mWindow.setVisibility(View.INVISIBLE);
        mHeadsUpContentFrame = mWindow.findViewById(R.id.headsup_content);
        mHeadsUpContentFrame = mWindow.findViewById(R.id.headsup_content);

        mEnableHeadsUpNotificationWhenNotificationShadeOpen = resources.getBoolean(
                R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen);
    }
    }


    private void animateShow() {
    private void animateShow() {
        if ((mEnableHeadsUpNotificationWhenNotificationShadeOpen
        if (mCarDeviceProvisionedController.isCurrentUserFullySetup()
                || !mNotificationPanelViewControllerLazy.get().isPanelExpanded())
                && mOverlayViewGlobalStateController.shouldShowHUN()) {
                && mCarDeviceProvisionedController.isCurrentUserFullySetup()) {
            mWindow.setVisibility(View.VISIBLE);
            mWindow.setVisibility(View.VISIBLE);
        }
        }
    }
    }
+15 −0
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ public class NotificationPanelViewController extends OverlayPanelViewController
    private final CarNotificationListener mCarNotificationListener;
    private final CarNotificationListener mCarNotificationListener;
    private final NotificationClickHandlerFactory mNotificationClickHandlerFactory;
    private final NotificationClickHandlerFactory mNotificationClickHandlerFactory;
    private final StatusBarStateController mStatusBarStateController;
    private final StatusBarStateController mStatusBarStateController;
    private final boolean mEnableHeadsUpNotificationWhenNotificationShadeOpen;


    private float mInitialBackgroundAlpha;
    private float mInitialBackgroundAlpha;
    private float mBackgroundAlphaDiff;
    private float mBackgroundAlphaDiff;
@@ -144,6 +145,10 @@ public class NotificationPanelViewController extends OverlayPanelViewController
                            + " percentage");
                            + " percentage");
        }
        }
        mBackgroundAlphaDiff = finalBackgroundAlpha - mInitialBackgroundAlpha;
        mBackgroundAlphaDiff = finalBackgroundAlpha - mInitialBackgroundAlpha;

        mEnableHeadsUpNotificationWhenNotificationShadeOpen = mResources.getBoolean(
                com.android.car.notification.R.bool
                        .config_enableHeadsUpNotificationWhenNotificationShadeOpen);
    }
    }


    @Override
    @Override
@@ -151,6 +156,16 @@ public class NotificationPanelViewController extends OverlayPanelViewController
        reinflate();
        reinflate();
    }
    }


    @Override
    protected boolean shouldShowNavigationBar() {
        return true;
    }

    @Override
    protected boolean shouldShowHUN() {
        return mEnableHeadsUpNotificationWhenNotificationShadeOpen;
    }

    /** Reinflates the view. */
    /** Reinflates the view. */
    public void reinflate() {
    public void reinflate() {
        ViewGroup container = (ViewGroup) getLayout();
        ViewGroup container = (ViewGroup) getLayout();
+2 −2
Original line number Original line Diff line number Diff line
@@ -375,10 +375,10 @@ public abstract class OverlayPanelViewController extends OverlayViewController {
        }
        }


        if (visible && !getOverlayViewGlobalStateController().isWindowVisible()) {
        if (visible && !getOverlayViewGlobalStateController().isWindowVisible()) {
            getOverlayViewGlobalStateController().setWindowVisible(true);
            getOverlayViewGlobalStateController().showView(/* panelViewController= */ this);
        }
        }
        if (!visible && getOverlayViewGlobalStateController().isWindowVisible()) {
        if (!visible && getOverlayViewGlobalStateController().isWindowVisible()) {
            getOverlayViewGlobalStateController().setWindowVisible(false);
            getOverlayViewGlobalStateController().hideView(/* panelViewController= */ this);
        }
        }
        getLayout().setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        getLayout().setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        getOverlayViewGlobalStateController().setWindowFocusable(visible);
        getOverlayViewGlobalStateController().setWindowFocusable(visible);
+15 −2
Original line number Original line Diff line number Diff line
@@ -54,7 +54,6 @@ public class OverlayViewController {
        mOverlayViewGlobalStateController.hideView(/* viewController= */ this, this::hide);
        mOverlayViewGlobalStateController.hideView(/* viewController= */ this, this::hide);
    }
    }



    /**
    /**
     * Inflate layout owned by controller.
     * Inflate layout owned by controller.
     */
     */
@@ -72,7 +71,7 @@ public class OverlayViewController {
    }
    }


    /**
    /**
     * Returns [@code true} if layout owned by controller has been inflated.
     * Returns {@code true} if layout owned by controller has been inflated.
     */
     */
    public final boolean isInflated() {
    public final boolean isInflated() {
        return mLayout != null;
        return mLayout != null;
@@ -125,4 +124,18 @@ public class OverlayViewController {
    protected final OverlayViewGlobalStateController getOverlayViewGlobalStateController() {
    protected final OverlayViewGlobalStateController getOverlayViewGlobalStateController() {
        return mOverlayViewGlobalStateController;
        return mOverlayViewGlobalStateController;
    }
    }

    /**
     * Returns {@code true} if heads up notifications should be displayed over this view.
     */
    protected boolean shouldShowHUN() {
        return true;
    }

    /**
     * Returns {@code true} if navigation bar should be displayed over this view.
     */
    protected boolean shouldShowNavigationBar() {
        return false;
    }
}
}
Loading