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

Commit 137667cc authored by Steve Elliott's avatar Steve Elliott
Browse files

Setup view-binder entry points for NotifIconContainer

Bug: 290787599
Test: make
Change-Id: I33e247b67233feae8ddeee62e58ffa691d26b0f6
parent fbe4d08e
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -50,6 +50,10 @@ import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider
import com.android.systemui.statusbar.notification.icon.ui.viewmodel.NotificationIconContainerAlwaysOnDisplayViewModel
import com.android.systemui.statusbar.notification.icon.ui.viewmodel.NotificationIconContainerShelfViewModel
import com.android.systemui.statusbar.notification.icon.ui.viewmodel.NotificationIconContainerStatusBarViewModel
import com.android.systemui.statusbar.notification.shelf.ui.viewbinder.NotificationShelfViewBinderWrapperControllerImpl
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.phone.NotificationIconAreaController
@@ -60,6 +64,7 @@ import com.android.wm.shell.bubbles.Bubbles
import java.util.Optional
import java.util.function.Function
import javax.inject.Inject
import kotlinx.coroutines.DisposableHandle

/**
 * Controller class for [NotificationIconContainer]. This implementation serves as a temporary
@@ -86,6 +91,9 @@ constructor(
    featureFlags: FeatureFlags,
    private val statusBarWindowController: StatusBarWindowController,
    private val screenOffAnimationController: ScreenOffAnimationController,
    private val shelfIconsViewModel: NotificationIconContainerShelfViewModel,
    private val statusBarIconsViewModel: NotificationIconContainerStatusBarViewModel,
    private val aodIconsViewModel: NotificationIconContainerAlwaysOnDisplayViewModel,
) :
    NotificationIconAreaController,
    DarkIconDispatcher.DarkReceiver,
@@ -106,6 +114,7 @@ constructor(
    private var notificationIcons: NotificationIconContainer? = null
    private var shelfIcons: NotificationIconContainer? = null
    private var aodIcons: NotificationIconContainer? = null
    private var aodBindJob: DisposableHandle? = null
    private var aodIconAppearTranslation = 0
    private var animationsEnabled = false
    private var aodIconTint = 0
@@ -142,9 +151,11 @@ constructor(
        if (changed) {
            this.aodIcons!!.setAnimationsEnabled(false)
            this.aodIcons!!.removeAllViews()
            aodBindJob?.dispose()
        }
        this.aodIcons = aodIcons
        this.aodIcons!!.setOnLockScreen(true)
        aodBindJob = NotificationIconContainerViewBinder.bind(aodIcons, aodIconsViewModel)
        updateAodIconsVisibility(animate = false, forceUpdate = changed)
        updateAnimations()
        if (changed) {
@@ -153,13 +164,12 @@ constructor(
        updateIconLayoutParams(context)
    }

    override fun setupShelf(notificationShelfController: NotificationShelfController) {
        shelfRefactor.assertDisabled()
        shelfIcons = notificationShelfController.shelfIcons
    }
    override fun setupShelf(notificationShelfController: NotificationShelfController) =
        NotificationShelfViewBinderWrapperControllerImpl.unsupported

    override fun setShelfIcons(icons: NotificationIconContainer) {
        if (shelfRefactor.expectEnabled()) {
            NotificationIconContainerViewBinder.bind(icons, shelfIconsViewModel)
            shelfIcons = icons
        }
    }
@@ -329,6 +339,7 @@ constructor(
        val layoutInflater = LayoutInflater.from(context)
        notificationIconArea = inflateIconArea(layoutInflater)
        notificationIcons = notificationIconArea?.findViewById(R.id.notificationIcons)
        NotificationIconContainerViewBinder.bind(notificationIcons!!, statusBarIconsViewModel)
    }

    private fun updateIconLayoutParams(context: Context) {
+3 −2
Original line number Diff line number Diff line
@@ -20,13 +20,14 @@ import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.statusbar.notification.icon.ui.viewmodel.NotificationIconContainerViewModel
import com.android.systemui.statusbar.phone.NotificationIconContainer
import kotlinx.coroutines.DisposableHandle

/** Binds a [NotificationIconContainer] to its [view model][NotificationIconContainerViewModel]. */
object NotificationIconContainerViewBinder {
    fun bind(
        view: NotificationIconContainer,
        viewModel: NotificationIconContainerViewModel,
    ) {
        view.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) {} }
    ): DisposableHandle {
        return view.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) {} }
    }
}
+22 −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.notification.icon.ui.viewmodel

import javax.inject.Inject

/** View-model for the row of notification icons displayed on the always-on display. */
class NotificationIconContainerAlwaysOnDisplayViewModel @Inject constructor() :
    NotificationIconContainerViewModel
+22 −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.notification.icon.ui.viewmodel

import javax.inject.Inject

/** View-model for the overflow row of notification icons displayed in the notification shade. */
class NotificationIconContainerShelfViewModel @Inject constructor() :
    NotificationIconContainerViewModel
+22 −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.notification.icon.ui.viewmodel

import javax.inject.Inject

/** View-model for the row of notification icons displayed in the status bar, */
class NotificationIconContainerStatusBarViewModel @Inject constructor() :
    NotificationIconContainerViewModel
Loading