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

Commit d58af8ca authored by Steve Elliott's avatar Steve Elliott
Browse files

Extract interface for NotificationShelfController

Bug: 271161129
Test: make
Change-Id: I479f60830c37bc468565bf7f199cc73efcaf281c
parent a1319a35
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import javax.inject.Inject;
 * Controller class for {@link NotificationShelf}.
 */
@NotificationRowScope
public class NotificationShelfController {
public class LegacyNotificationShelfControllerImpl implements NotificationShelfController {
    private final NotificationShelf mView;
    private final ActivatableNotificationViewController mActivatableNotificationViewController;
    private final KeyguardBypassController mKeyguardBypassController;
@@ -43,7 +43,7 @@ public class NotificationShelfController {
    private AmbientState mAmbientState;

    @Inject
    public NotificationShelfController(
    public LegacyNotificationShelfControllerImpl(
            NotificationShelf notificationShelf,
            ActivatableNotificationViewController activatableNotificationViewController,
            KeyguardBypassController keyguardBypassController,
@@ -78,33 +78,40 @@ public class NotificationShelfController {
        }
    }

    @Override
    public NotificationShelf getView() {
        return mView;
    }

    @Override
    public boolean canModifyColorOfNotifications() {
        return mAmbientState.isShadeExpanded()
                && !(mAmbientState.isOnKeyguard() && mKeyguardBypassController.getBypassEnabled());
    }

    @Override
    public NotificationIconContainer getShelfIcons() {
        return mView.getShelfIcons();
    }

    @Override
    public void bind(AmbientState ambientState,
            NotificationStackScrollLayoutController notificationStackScrollLayoutController) {
        mView.bind(ambientState, notificationStackScrollLayoutController);
        mAmbientState = ambientState;
    }

    @Override
    public int getIntrinsicHeight() {
        return mView.getIntrinsicHeight();
    }

    @Override
    public void setOnActivatedListener(ActivatableNotificationView.OnActivatedListener listener) {
        mView.setOnActivatedListener(listener);
    }

    @Override
    public void setOnClickListener(View.OnClickListener onClickListener) {
        mView.setOnClickListener(onClickListener);
    }
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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

import android.view.View
import android.view.View.OnClickListener
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView.OnActivatedListener
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.stack.AmbientState
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.phone.NotificationIconContainer

/** Controller interface for [NotificationShelf]. */
interface NotificationShelfController {
    /** The [NotificationShelf] controlled by this Controller. */
    val view: NotificationShelf

    /** @see ExpandableView.getIntrinsicHeight */
    val intrinsicHeight: Int

    /** Container view for icons displayed in the shelf. */
    val shelfIcons: NotificationIconContainer

    /** Whether or not the shelf can modify the color of notifications in the shade. */
    fun canModifyColorOfNotifications(): Boolean

    /** @see ActivatableNotificationView.setOnActivatedListener */
    fun setOnActivatedListener(listener: OnActivatedListener)

    /** Binds the shelf to the host [NotificationStackScrollLayout], via its Controller. */
    fun bind(
        ambientState: AmbientState,
        notificationStackScrollLayoutController: NotificationStackScrollLayoutController,
    )

    /** @see View.setOnClickListener */
    fun setOnClickListener(listener: OnClickListener)
}
+3 −2
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package com.android.systemui.statusbar.notification.row.dagger;

import com.android.systemui.statusbar.LegacyNotificationShelfControllerImpl;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;

import dagger.Binds;
@@ -46,7 +46,8 @@ public interface NotificationShelfComponent {
     * Creates a NotificationShelfController.
     */
    @NotificationRowScope
    NotificationShelfController getNotificationShelfController();
    LegacyNotificationShelfControllerImpl getNotificationShelfController();

    /**
     * Dagger Module that extracts interesting properties from a NotificationShelf.
     */
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.systemui.shade.NotificationShadeWindowView;
import com.android.systemui.shade.NotificationsQuickSettingsContainer;
import com.android.systemui.shade.ShadeExpansionStateManager;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.LegacyNotificationShelfControllerImpl;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.OperatorNameViewController;
@@ -135,7 +136,7 @@ public abstract class StatusBarViewModule {
        NotificationShelfComponent component = notificationShelfComponentBuilder
                .notificationShelf(notificationShelf)
                .build();
        NotificationShelfController notificationShelfController =
        LegacyNotificationShelfControllerImpl notificationShelfController =
                component.getNotificationShelfController();
        notificationShelfController.init();