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

Commit cb586210 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

DO NOT MERGE Move Heads Up Notifications to their own window am: 89edc879 am: fa9c008b

Change-Id: I0211d6fa4eac08876f1906cb6d7eb35611a5fbb3
parents 45c514ff fa9c008b
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -72,11 +72,6 @@
        android:layout_marginBottom="@dimen/navigation_bar_height"
        android:visibility="invisible"/>

    <include layout="@layout/headsup_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="invisible"/>

    <include layout="@layout/status_bar_expanded"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui;

import com.android.systemui.biometrics.AuthController;
import com.android.systemui.bubbles.dagger.BubbleModule;
import com.android.systemui.car.notification.CarNotificationModule;
import com.android.systemui.globalactions.GlobalActionsComponent;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.dagger.KeyguardModule;
@@ -49,7 +50,8 @@ import dagger.multibindings.IntoMap;

/** Binder for car specific {@link SystemUI} modules. */
@Module(includes = {RecentsModule.class, CarStatusBarModule.class, NotificationsModule.class,
        BubbleModule.class, KeyguardModule.class, OverlayWindowModule.class})
        BubbleModule.class, KeyguardModule.class, OverlayWindowModule.class,
        CarNotificationModule.class})
public abstract class CarSystemUIBinder {
    /** Inject into AuthController. */
    @Binds
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME;
import android.content.Context;

import com.android.keyguard.KeyguardViewController;
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.car.CarDeviceProvisionedControllerImpl;
import com.android.systemui.dagger.SystemUIRootComponent;
import com.android.systemui.dock.DockManager;
@@ -137,4 +138,8 @@ abstract class CarSystemUIModule {
    @Binds
    abstract DeviceProvisionedController bindDeviceProvisionedController(
            CarDeviceProvisionedControllerImpl deviceProvisionedController);

    @Binds
    abstract CarDeviceProvisionedController bindCarDeviceProvisionedController(
            CarDeviceProvisionedControllerImpl deviceProvisionedController);
}
+118 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.car.notification;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.android.car.notification.R;
import com.android.car.notification.headsup.CarHeadsUpNotificationContainer;
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.statusbar.car.CarStatusBar;

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

import dagger.Lazy;

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

    private final ViewGroup mWindow;
    private final FrameLayout mHeadsUpContentFrame;

    private final boolean mEnableHeadsUpNotificationWhenNotificationShadeOpen;

    @Inject
    CarHeadsUpNotificationSystemContainer(Context context,
            @Main Resources resources,
            CarDeviceProvisionedController deviceProvisionedController,
            WindowManager windowManager,
            // TODO: Remove dependency on CarStatusBar
            Lazy<CarStatusBar> carStatusBarLazy) {
        mCarDeviceProvisionedController = deviceProvisionedController;
        mCarStatusBarLazy = carStatusBarLazy;

        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                PixelFormat.TRANSLUCENT);

        lp.gravity = Gravity.TOP;
        lp.setTitle("HeadsUpNotification");

        mWindow = (ViewGroup) LayoutInflater.from(context)
                .inflate(R.layout.headsup_container, null, false);
        windowManager.addView(mWindow, lp);
        mWindow.setVisibility(View.INVISIBLE);
        mHeadsUpContentFrame = mWindow.findViewById(R.id.headsup_content);

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

    private void animateShow() {
        if ((mEnableHeadsUpNotificationWhenNotificationShadeOpen
                || !mCarStatusBarLazy.get().isPanelExpanded()) && isCurrentUserSetup()) {
            mWindow.setVisibility(View.VISIBLE);
        }
    }

    private void animateHide() {
        mWindow.setVisibility(View.INVISIBLE);
    }

    @Override
    public void displayNotification(View notificationView) {
        mHeadsUpContentFrame.addView(notificationView);
        animateShow();
    }

    @Override
    public void removeNotification(View notificationView) {
        mHeadsUpContentFrame.removeView(notificationView);
        if (mHeadsUpContentFrame.getChildCount() == 0) {
            animateHide();
        }
    }

    @Override
    public boolean isVisible() {
        return mWindow.getVisibility() == View.VISIBLE;
    }

    private boolean isCurrentUserSetup() {
        return mCarDeviceProvisionedController.isCurrentUserSetup()
                && !mCarDeviceProvisionedController.isCurrentUserSetupInProgress();
    }
}
+84 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.car.notification;

import android.content.Context;

import com.android.car.notification.CarHeadsUpNotificationManager;
import com.android.car.notification.CarNotificationListener;
import com.android.car.notification.CarUxRestrictionManagerWrapper;
import com.android.car.notification.NotificationClickHandlerFactory;
import com.android.car.notification.NotificationDataManager;
import com.android.car.notification.headsup.CarHeadsUpNotificationContainer;
import com.android.internal.statusbar.IStatusBarService;

import javax.inject.Singleton;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

/**
 * Module for Car SysUI Notifications
 */
@Module
public abstract class CarNotificationModule {
    @Provides
    @Singleton
    static NotificationClickHandlerFactory provideNotificationClickHandlerFactory(
            IStatusBarService barService) {
        return new NotificationClickHandlerFactory(barService);
    }

    @Provides
    @Singleton
    static NotificationDataManager provideNotificationDataManager() {
        return new NotificationDataManager();
    }

    @Provides
    @Singleton
    static CarUxRestrictionManagerWrapper provideCarUxRestrictionManagerWrapper() {
        return new CarUxRestrictionManagerWrapper();
    }

    @Provides
    @Singleton
    static CarNotificationListener provideCarNotificationListener(Context context,
            CarUxRestrictionManagerWrapper carUxRestrictionManagerWrapper,
            CarHeadsUpNotificationManager carHeadsUpNotificationManager,
            NotificationDataManager notificationDataManager) {
        CarNotificationListener listener = new CarNotificationListener();
        listener.registerAsSystemService(context, carUxRestrictionManagerWrapper,
                carHeadsUpNotificationManager, notificationDataManager);
        return listener;
    }

    @Provides
    @Singleton
    static CarHeadsUpNotificationManager provideCarHeadsUpNotificationManager(Context context,
            NotificationClickHandlerFactory notificationClickHandlerFactory,
            NotificationDataManager notificationDataManager,
            CarHeadsUpNotificationContainer headsUpNotificationDisplay) {
        return new CarHeadsUpNotificationManager(context, notificationClickHandlerFactory,
                notificationDataManager, headsUpNotificationDisplay);
    }

    @Binds
    abstract CarHeadsUpNotificationContainer bindsCarHeadsUpNotificationContainer(
            CarHeadsUpNotificationSystemContainer carHeadsUpNotificationSystemContainer);
}
Loading