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

Commit 4c21197c authored by Andreas Miko's avatar Andreas Miko Committed by Android (Google) Code Review
Browse files

Merge "Introduce BundleInteractor and BundleRepository" into main

parents a6c807eb 5f818034
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -34,11 +34,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModelImpl;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModel;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationHeaderViewWrapper;
import com.android.systemui.statusbar.notification.shared.NotificationBundleUi;

@@ -59,6 +60,8 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
    private NotificationTestHelper mNotificationTestHelper;
    private NotificationChildrenContainer mChildrenContainer;

    private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this);

    @Before
    public void setUp() throws Exception {
        allowTestableLooperAsMainThread();
@@ -288,7 +291,7 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
        View currentView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertFalse(currentView instanceof ComposeView);

        BundleHeaderViewModelImpl viewModel = new BundleHeaderViewModelImpl();
        BundleHeaderViewModel viewModel = mKosmos.getBundleHeaderViewModel();
        mChildrenContainer.initBundleHeader(viewModel);
        currentView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertTrue(currentView instanceof ComposeView);
+10 −1
Original line number Diff line number Diff line
@@ -17,11 +17,20 @@ package com.android.systemui.statusbar.notification.collection

import android.app.NotificationChannel
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.data.repository.BundleRepository
import java.util.Collections
import kotlinx.coroutines.flow.MutableStateFlow

/** Class to represent notifications bundled by classification. */
/**
 * Class to represent notifications bundled by classification.
 *
 * This is the model used by the pipeline.
 */
class BundleEntry(key: String) : PipelineEntry(key) {

    /** The model used by UI. */
    val bundleRepository = BundleRepository()

    // TODO(b/394483200): move NotificationEntry's implementation to PipelineEntry?
    val isSensitive: MutableStateFlow<Boolean> = MutableStateFlow(false)

+2 −2
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ import com.android.systemui.statusbar.notification.people.PeopleNotificationIden
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.shared.LockscreenOtpRedaction;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModelImpl;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModel;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationCompactMessagingTemplateViewWrapper;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.statusbar.notification.shared.NotificationAddXOnHoverToDismiss;
@@ -1878,7 +1878,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     * Init the bundle header view. The ComposeView is initialized within with the passed viewModel.
     * This can only be init once and not in conjunction with any other header view.
     */
    public void initBundleHeader(@NonNull BundleHeaderViewModelImpl bundleHeaderViewModel) {
    public void initBundleHeader(@NonNull BundleHeaderViewModel bundleHeaderViewModel) {
        if (NotificationBundleUi.isUnexpectedlyInLegacyMode()) return;
        NotificationChildrenContainer childrenContainer = getChildrenContainerNonNull();
        bundleHeaderViewModel.setOnExpandClickListener(mExpandClickListener);
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.row.data.repository

import android.graphics.drawable.Drawable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue

/** Holds information about a BundleEntry that is relevant to UI. */
class BundleRepository {
    var titleText by mutableStateOf("")

    var numberOfChildren by mutableStateOf<Int?>(0)

    var hasUnreadMessages by mutableStateOf(true)

    var bundleIcon by mutableStateOf<Drawable?>(null)

    var previewIcons by mutableStateOf(listOf<Drawable>())
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.row.domain.interactor

import com.android.systemui.statusbar.notification.row.data.repository.BundleRepository

/** Provides functionality for UI to interact with a Notification Bundle. */
class BundleInteractor(private val repository: BundleRepository) {
    val titleText
        get() = repository.titleText

    val numberOfChildren
        get() = repository.numberOfChildren

    val hasUnreadMessages
        get() = repository.hasUnreadMessages

    val bundleIcon
        get() = repository.bundleIcon

    val previewIcons
        get() = repository.previewIcons

    fun rowExpanded() {
        repository.hasUnreadMessages = false
    }
}
Loading