summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Caitlin Shkuratov <caitlinshk@google.com> 2024-09-04 21:48:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-09-04 21:48:42 +0000
commit4cd6e8337ba91b4ff781747de8f93b06d913e479 (patch)
treebd1bbbc8bb6c7fce6eded233aa1b3280ec031bbe
parent8a1ec1fcd4c91cc71e9e0f783b4789851d52c0d5 (diff)
parent5e0c335158284d38a1430f3e1b20f827bc2b9913 (diff)
Merge changes from topic "caitlinshk-ongoingchip-primary" into main
* changes: [SB][RONs] Move ongoing activity chip binding to separate binder class. [SB][RONs] Rename chip resource ID to ongoing_activity_chip_primary.
-rw-r--r--packages/SystemUI/res/layout/ongoing_activity_chip.xml1
-rw-r--r--packages/SystemUI/res/layout/status_bar.xml5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt314
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt304
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModel.kt9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt46
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java55
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeCollapsedStatusBarViewModel.kt2
11 files changed, 394 insertions, 374 deletions
diff --git a/packages/SystemUI/res/layout/ongoing_activity_chip.xml b/packages/SystemUI/res/layout/ongoing_activity_chip.xml
index 154397d2b4a1..690a89a044b7 100644
--- a/packages/SystemUI/res/layout/ongoing_activity_chip.xml
+++ b/packages/SystemUI/res/layout/ongoing_activity_chip.xml
@@ -17,7 +17,6 @@
the chip. -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/ongoing_activity_chip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|start"
diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml
index 4247c7eef0d0..ee75b3145aef 100644
--- a/packages/SystemUI/res/layout/status_bar.xml
+++ b/packages/SystemUI/res/layout/status_bar.xml
@@ -99,7 +99,10 @@
android:gravity="center_vertical|start"
/>
- <include layout="@layout/ongoing_activity_chip" />
+ <include layout="@layout/ongoing_activity_chip"
+ android:id="@+id/ongoing_activity_chip_primary"/>
+
+ <!-- TODO(b/364653005): Add a second activity chip. -->
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/notification_icon_area"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt
new file mode 100644
index 000000000000..3b1e565e122b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt
@@ -0,0 +1,314 @@
+/*
+ * Copyright (C) 2024 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.chips.ui.binder
+
+import android.annotation.IdRes
+import android.content.res.ColorStateList
+import android.graphics.drawable.GradientDrawable
+import android.view.View
+import android.view.ViewGroup
+import android.widget.FrameLayout
+import android.widget.ImageView
+import android.widget.TextView
+import com.android.systemui.common.ui.binder.IconViewBinder
+import com.android.systemui.res.R
+import com.android.systemui.statusbar.StatusBarIconView
+import com.android.systemui.statusbar.chips.ron.shared.StatusBarRonChips
+import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
+import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
+import com.android.systemui.statusbar.chips.ui.view.ChipChronometer
+
+/** Binder for ongoing activity chip views. */
+object OngoingActivityChipBinder {
+ /** Binds the given [chipModel] data to the given [chipView]. */
+ fun bind(chipModel: OngoingActivityChipModel, chipView: View) {
+ val chipContext = chipView.context
+ val chipDefaultIconView: ImageView =
+ chipView.requireViewById(R.id.ongoing_activity_chip_icon)
+ val chipTimeView: ChipChronometer =
+ chipView.requireViewById(R.id.ongoing_activity_chip_time)
+ val chipTextView: TextView = chipView.requireViewById(R.id.ongoing_activity_chip_text)
+ val chipBackgroundView: ChipBackgroundContainer =
+ chipView.requireViewById(R.id.ongoing_activity_chip_background)
+
+ when (chipModel) {
+ is OngoingActivityChipModel.Shown -> {
+ // Data
+ setChipIcon(chipModel, chipBackgroundView, chipDefaultIconView)
+ setChipMainContent(chipModel, chipTextView, chipTimeView)
+ chipView.setOnClickListener(chipModel.onClickListener)
+ updateChipPadding(
+ chipModel,
+ chipBackgroundView,
+ chipTextView,
+ chipTimeView,
+ )
+
+ // Accessibility
+ setChipAccessibility(chipModel, chipView, chipBackgroundView)
+
+ // Colors
+ val textColor = chipModel.colors.text(chipContext)
+ chipTimeView.setTextColor(textColor)
+ chipTextView.setTextColor(textColor)
+ (chipBackgroundView.background as GradientDrawable).color =
+ chipModel.colors.background(chipContext)
+ }
+ is OngoingActivityChipModel.Hidden -> {
+ // The Chronometer should be stopped to prevent leaks -- see b/192243808 and
+ // [Chronometer.start].
+ chipTimeView.stop()
+ }
+ }
+ }
+
+ private fun setChipIcon(
+ chipModel: OngoingActivityChipModel.Shown,
+ backgroundView: ChipBackgroundContainer,
+ defaultIconView: ImageView,
+ ) {
+ // Always remove any previously set custom icon. If we have a new custom icon, we'll re-add
+ // it.
+ backgroundView.removeView(backgroundView.getCustomIconView())
+
+ val iconTint = chipModel.colors.text(defaultIconView.context)
+
+ when (val icon = chipModel.icon) {
+ null -> {
+ defaultIconView.visibility = View.GONE
+ }
+ is OngoingActivityChipModel.ChipIcon.SingleColorIcon -> {
+ IconViewBinder.bind(icon.impl, defaultIconView)
+ defaultIconView.visibility = View.VISIBLE
+ defaultIconView.tintView(iconTint)
+ }
+ is OngoingActivityChipModel.ChipIcon.FullColorAppIcon -> {
+ StatusBarRonChips.assertInNewMode()
+ IconViewBinder.bind(icon.impl, defaultIconView)
+ defaultIconView.visibility = View.VISIBLE
+ defaultIconView.untintView()
+ }
+ is OngoingActivityChipModel.ChipIcon.StatusBarView -> {
+ // Hide the default icon since we'll show this custom icon instead.
+ defaultIconView.visibility = View.GONE
+
+ // Add the new custom icon:
+ // 1. Set up the right visual params.
+ val iconView = icon.impl
+ with(iconView) {
+ id = CUSTOM_ICON_VIEW_ID
+ // TODO(b/354930838): Update the content description to not include "phone" and
+ // maybe include the app name.
+ contentDescription =
+ context.resources.getString(R.string.ongoing_phone_call_content_description)
+ tintView(iconTint)
+ }
+
+ // 2. If we just reinflated the view, we may need to detach the icon view from the
+ // old chip before we reattach it to the new one.
+ // See also: NotificationIconContainerViewBinder#bindIcons.
+ val currentParent = iconView.parent as? ViewGroup
+ if (currentParent != null && currentParent != backgroundView) {
+ currentParent.removeView(iconView)
+ currentParent.removeTransientView(iconView)
+ }
+
+ // 3: Add the icon as the starting view.
+ backgroundView.addView(
+ iconView,
+ /* index= */ 0,
+ generateCustomIconLayoutParams(iconView),
+ )
+ }
+ }
+ }
+
+ private fun View.getCustomIconView(): StatusBarIconView? {
+ return this.findViewById(CUSTOM_ICON_VIEW_ID)
+ }
+
+ private fun ImageView.tintView(color: Int) {
+ this.imageTintList = ColorStateList.valueOf(color)
+ }
+
+ private fun ImageView.untintView() {
+ this.imageTintList = null
+ }
+
+ private fun generateCustomIconLayoutParams(iconView: ImageView): FrameLayout.LayoutParams {
+ val customIconSize =
+ iconView.context.resources.getDimensionPixelSize(
+ R.dimen.ongoing_activity_chip_embedded_padding_icon_size
+ )
+ return FrameLayout.LayoutParams(customIconSize, customIconSize)
+ }
+
+ private fun setChipMainContent(
+ chipModel: OngoingActivityChipModel.Shown,
+ chipTextView: TextView,
+ chipTimeView: ChipChronometer,
+ ) {
+ when (chipModel) {
+ is OngoingActivityChipModel.Shown.Countdown -> {
+ chipTextView.text = chipModel.secondsUntilStarted.toString()
+ chipTextView.visibility = View.VISIBLE
+
+ chipTimeView.hide()
+ }
+ is OngoingActivityChipModel.Shown.Text -> {
+ chipTextView.text = chipModel.text
+ chipTextView.visibility = View.VISIBLE
+
+ chipTimeView.hide()
+ }
+ is OngoingActivityChipModel.Shown.Timer -> {
+ ChipChronometerBinder.bind(chipModel.startTimeMs, chipTimeView)
+ chipTimeView.visibility = View.VISIBLE
+
+ chipTextView.visibility = View.GONE
+ }
+ is OngoingActivityChipModel.Shown.IconOnly -> {
+ chipTextView.visibility = View.GONE
+ chipTimeView.hide()
+ }
+ }
+ }
+
+ private fun ChipChronometer.hide() {
+ // The Chronometer should be stopped to prevent leaks -- see b/192243808 and
+ // [Chronometer.start].
+ this.stop()
+ this.visibility = View.GONE
+ }
+
+ private fun updateChipPadding(
+ chipModel: OngoingActivityChipModel.Shown,
+ backgroundView: View,
+ chipTextView: TextView,
+ chipTimeView: ChipChronometer,
+ ) {
+ if (chipModel.icon != null) {
+ if (chipModel.icon is OngoingActivityChipModel.ChipIcon.StatusBarView) {
+ // If the icon is a custom [StatusBarIconView], then it should've come from
+ // `Notification.smallIcon`, which is required to embed its own paddings. We need to
+ // adjust the other paddings to make everything look good :)
+ backgroundView.setBackgroundPaddingForEmbeddedPaddingIcon()
+ chipTextView.setTextPaddingForEmbeddedPaddingIcon()
+ chipTimeView.setTextPaddingForEmbeddedPaddingIcon()
+ } else {
+ backgroundView.setBackgroundPaddingForNormalIcon()
+ chipTextView.setTextPaddingForNormalIcon()
+ chipTimeView.setTextPaddingForNormalIcon()
+ }
+ } else {
+ backgroundView.setBackgroundPaddingForNoIcon()
+ chipTextView.setTextPaddingForNoIcon()
+ chipTimeView.setTextPaddingForNoIcon()
+ }
+ }
+
+ private fun View.setTextPaddingForEmbeddedPaddingIcon() {
+ val newPaddingEnd =
+ context.resources.getDimensionPixelSize(
+ R.dimen.ongoing_activity_chip_text_end_padding_for_embedded_padding_icon
+ )
+ setPaddingRelative(
+ // The icon should embed enough padding between the icon and time view.
+ /* start= */ 0,
+ this.paddingTop,
+ newPaddingEnd,
+ this.paddingBottom,
+ )
+ }
+
+ private fun View.setTextPaddingForNormalIcon() {
+ this.setPaddingRelative(
+ this.context.resources.getDimensionPixelSize(
+ R.dimen.ongoing_activity_chip_icon_text_padding
+ ),
+ paddingTop,
+ // The background view will contain the right end padding.
+ /* end= */ 0,
+ paddingBottom,
+ )
+ }
+
+ private fun View.setTextPaddingForNoIcon() {
+ // The background view will have even start & end paddings, so we don't want the text view
+ // to add any additional padding.
+ this.setPaddingRelative(/* start= */ 0, paddingTop, /* end= */ 0, paddingBottom)
+ }
+
+ private fun View.setBackgroundPaddingForEmbeddedPaddingIcon() {
+ val sidePadding =
+ context.resources.getDimensionPixelSize(
+ R.dimen.ongoing_activity_chip_side_padding_for_embedded_padding_icon
+ )
+ setPaddingRelative(
+ sidePadding,
+ paddingTop,
+ sidePadding,
+ paddingBottom,
+ )
+ }
+
+ private fun View.setBackgroundPaddingForNormalIcon() {
+ val sidePadding =
+ context.resources.getDimensionPixelSize(R.dimen.ongoing_activity_chip_side_padding)
+ setPaddingRelative(
+ sidePadding,
+ paddingTop,
+ sidePadding,
+ paddingBottom,
+ )
+ }
+
+ private fun View.setBackgroundPaddingForNoIcon() {
+ // The padding for the normal icon is also appropriate for no icon.
+ setBackgroundPaddingForNormalIcon()
+ }
+
+ private fun setChipAccessibility(
+ chipModel: OngoingActivityChipModel.Shown,
+ chipView: View,
+ chipBackgroundView: View,
+ ) {
+ when (chipModel) {
+ is OngoingActivityChipModel.Shown.Countdown -> {
+ // Set as assertive so talkback will announce the countdown
+ chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE
+ }
+ is OngoingActivityChipModel.Shown.Timer,
+ is OngoingActivityChipModel.Shown.Text,
+ is OngoingActivityChipModel.Shown.IconOnly -> {
+ chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_NONE
+ }
+ }
+ // Clickable chips need to be a minimum size for accessibility purposes, but let
+ // non-clickable chips be smaller.
+ if (chipModel.onClickListener != null) {
+ chipBackgroundView.minimumWidth =
+ chipBackgroundView.context.resources.getDimensionPixelSize(
+ R.dimen.min_clickable_item_size
+ )
+ } else {
+ chipBackgroundView.minimumWidth = 0
+ }
+ }
+
+ @IdRes private val CUSTOM_ICON_VIEW_ID = R.id.ongoing_activity_chip_custom_icon
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt
index 04c4516c9bed..199eb0613a0c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt
@@ -151,13 +151,13 @@ constructor(
}
/**
- * A flow modeling the chip that should be shown in the status bar after accounting for possibly
- * multiple ongoing activities and animation requirements.
+ * A flow modeling the primary chip that should be shown in the status bar after accounting for
+ * possibly multiple ongoing activities and animation requirements.
*
* [com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment] is responsible for
* actually displaying the chip.
*/
- val chip: StateFlow<OngoingActivityChipModel> =
+ val primaryChip: StateFlow<OngoingActivityChipModel> =
internalChip
.pairwise(initialValue = DEFAULT_INTERNAL_HIDDEN_MODEL)
.map { (old, new) ->
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
index 5be4ba222174..4a0fdeebe82b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
@@ -121,7 +121,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
private MultiSourceMinAlphaController mEndSideAlphaController;
private LinearLayout mEndSideContent;
private View mClockView;
- private View mOngoingActivityChip;
+ private View mPrimaryOngoingActivityChip;
private View mNotificationIconAreaInner;
// Visibilities come in from external system callers via disable flags, but we also sometimes
// modify the visibilities internally. We need to store both so that we don't accidentally
@@ -354,7 +354,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
mEndSideContent = mStatusBar.findViewById(R.id.status_bar_end_side_content);
mEndSideAlphaController = new MultiSourceMinAlphaController(mEndSideContent);
mClockView = mStatusBar.findViewById(R.id.clock);
- mOngoingActivityChip = mStatusBar.findViewById(R.id.ongoing_activity_chip);
+ mPrimaryOngoingActivityChip = mStatusBar.findViewById(R.id.ongoing_activity_chip_primary);
showEndSideContent(false);
showClock(false);
initOperatorName();
@@ -636,9 +636,9 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
// icons so if the icons are disabled then the activity chip should be, too.)
boolean showOngoingActivityChip = hasOngoingActivity && !disableNotifications;
if (showOngoingActivityChip) {
- showOngoingActivityChip(animate);
+ showPrimaryOngoingActivityChip(animate);
} else {
- hideOngoingActivityChip(animate);
+ hidePrimaryOngoingActivityChip(animate);
}
}
@@ -729,20 +729,20 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
animateShow(mClockView, animate);
}
- /** Hides the ongoing activity chip. */
- private void hideOngoingActivityChip(boolean animate) {
- animateHiddenState(mOngoingActivityChip, View.GONE, animate);
+ /** Hides the primary ongoing activity chip. */
+ private void hidePrimaryOngoingActivityChip(boolean animate) {
+ animateHiddenState(mPrimaryOngoingActivityChip, View.GONE, animate);
}
/**
- * Displays the ongoing activity chip.
+ * Displays the primary ongoing activity chip.
*
* If Flags.statusBarScreenSharingChips is disabled, this chip will only ever contain the
* ongoing call information, If that flag is enabled, it will support different kinds of ongoing
* activities. See b/332662551.
*/
- private void showOngoingActivityChip(boolean animate) {
- animateShow(mOngoingActivityChip, animate);
+ private void showPrimaryOngoingActivityChip(boolean animate) {
+ animateShow(mPrimaryOngoingActivityChip, animate);
}
/**
@@ -850,7 +850,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
private void initOngoingCallChip() {
mOngoingCallController.addCallback(mOngoingCallListener);
- mOngoingCallController.setChipView(mOngoingActivityChip);
+ mOngoingCallController.setChipView(mPrimaryOngoingActivityChip);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt
index c24d69465043..87d0e6420128 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt
@@ -18,28 +18,16 @@ package com.android.systemui.statusbar.pipeline.shared.ui.binder
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
-import android.annotation.IdRes
-import android.content.res.ColorStateList
-import android.graphics.drawable.GradientDrawable
import android.view.View
-import android.view.ViewGroup
-import android.widget.FrameLayout
-import android.widget.ImageView
-import android.widget.TextView
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.Flags
-import com.android.systemui.common.ui.binder.IconViewBinder
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlag
-import com.android.systemui.statusbar.StatusBarIconView
-import com.android.systemui.statusbar.chips.ron.shared.StatusBarRonChips
-import com.android.systemui.statusbar.chips.ui.binder.ChipChronometerBinder
+import com.android.systemui.statusbar.chips.ui.binder.OngoingActivityChipBinder
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
-import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
-import com.android.systemui.statusbar.chips.ui.view.ChipChronometer
import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor
import com.android.systemui.statusbar.pipeline.shared.ui.viewmodel.CollapsedStatusBarViewModel
import javax.inject.Inject
@@ -93,58 +81,22 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa
}
if (Flags.statusBarScreenSharingChips()) {
- val chipView: View = view.requireViewById(R.id.ongoing_activity_chip)
- val chipContext = chipView.context
- val chipDefaultIconView: ImageView =
- chipView.requireViewById(R.id.ongoing_activity_chip_icon)
- val chipTimeView: ChipChronometer =
- chipView.requireViewById(R.id.ongoing_activity_chip_time)
- val chipTextView: TextView =
- chipView.requireViewById(R.id.ongoing_activity_chip_text)
- val chipBackgroundView =
- chipView.requireViewById<ChipBackgroundContainer>(
- R.id.ongoing_activity_chip_background
- )
+ val primaryChipView: View =
+ view.requireViewById(R.id.ongoing_activity_chip_primary)
launch {
- viewModel.ongoingActivityChip.collect { chipModel ->
- when (chipModel) {
- is OngoingActivityChipModel.Shown -> {
- // Data
- setChipIcon(chipModel, chipBackgroundView, chipDefaultIconView)
- setChipMainContent(chipModel, chipTextView, chipTimeView)
- chipView.setOnClickListener(chipModel.onClickListener)
- updateChipPadding(
- chipModel,
- chipBackgroundView,
- chipTextView,
- chipTimeView,
- )
-
- // Accessibility
- setChipAccessibility(chipModel, chipView, chipBackgroundView)
-
- // Colors
- val textColor = chipModel.colors.text(chipContext)
- chipTimeView.setTextColor(textColor)
- chipTextView.setTextColor(textColor)
- (chipBackgroundView.background as GradientDrawable).color =
- chipModel.colors.background(chipContext)
-
- // Notify listeners
+ viewModel.primaryOngoingActivityChip.collect { primaryChipModel ->
+ OngoingActivityChipBinder.bind(primaryChipModel, primaryChipView)
+ when (primaryChipModel) {
+ is OngoingActivityChipModel.Shown ->
listener.onOngoingActivityStatusChanged(
hasOngoingActivity = true,
shouldAnimate = true,
)
- }
- is OngoingActivityChipModel.Hidden -> {
- // The Chronometer should be stopped to prevent leaks -- see
- // b/192243808 and [Chronometer.start].
- chipTimeView.stop()
+ is OngoingActivityChipModel.Hidden ->
listener.onOngoingActivityStatusChanged(
hasOngoingActivity = false,
- shouldAnimate = chipModel.shouldAnimate,
+ shouldAnimate = primaryChipModel.shouldAnimate,
)
- }
}
}
}
@@ -161,240 +113,6 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa
}
}
- private fun setChipIcon(
- chipModel: OngoingActivityChipModel.Shown,
- backgroundView: ChipBackgroundContainer,
- defaultIconView: ImageView,
- ) {
- // Always remove any previously set custom icon. If we have a new custom icon, we'll re-add
- // it.
- backgroundView.removeView(backgroundView.getCustomIconView())
-
- val iconTint = chipModel.colors.text(defaultIconView.context)
-
- when (val icon = chipModel.icon) {
- null -> {
- defaultIconView.visibility = View.GONE
- }
- is OngoingActivityChipModel.ChipIcon.SingleColorIcon -> {
- IconViewBinder.bind(icon.impl, defaultIconView)
- defaultIconView.visibility = View.VISIBLE
- defaultIconView.tintView(iconTint)
- }
- is OngoingActivityChipModel.ChipIcon.FullColorAppIcon -> {
- StatusBarRonChips.assertInNewMode()
- IconViewBinder.bind(icon.impl, defaultIconView)
- defaultIconView.visibility = View.VISIBLE
- defaultIconView.untintView()
- }
- is OngoingActivityChipModel.ChipIcon.StatusBarView -> {
- // Hide the default icon since we'll show this custom icon instead.
- defaultIconView.visibility = View.GONE
-
- // Add the new custom icon:
- // 1. Set up the right visual params.
- val iconView = icon.impl
- with(iconView) {
- id = CUSTOM_ICON_VIEW_ID
- // TODO(b/354930838): Update the content description to not include "phone" and
- // maybe include the app name.
- contentDescription =
- context.resources.getString(R.string.ongoing_phone_call_content_description)
- tintView(iconTint)
- }
-
- // 2. If we just reinflated the view, we may need to detach the icon view from the
- // old chip before we reattach it to the new one.
- // See also: NotificationIconContainerViewBinder#bindIcons.
- val currentParent = iconView.parent as? ViewGroup
- if (currentParent != null && currentParent != backgroundView) {
- currentParent.removeView(iconView)
- currentParent.removeTransientView(iconView)
- }
-
- // 3: Add the icon as the starting view.
- backgroundView.addView(
- iconView,
- /* index= */ 0,
- generateCustomIconLayoutParams(iconView),
- )
- }
- }
- }
-
- private fun View.getCustomIconView(): StatusBarIconView? {
- return this.findViewById(CUSTOM_ICON_VIEW_ID)
- }
-
- private fun ImageView.tintView(color: Int) {
- this.imageTintList = ColorStateList.valueOf(color)
- }
-
- private fun ImageView.untintView() {
- this.imageTintList = null
- }
-
- private fun generateCustomIconLayoutParams(iconView: ImageView): FrameLayout.LayoutParams {
- val customIconSize =
- iconView.context.resources.getDimensionPixelSize(
- R.dimen.ongoing_activity_chip_embedded_padding_icon_size
- )
- return FrameLayout.LayoutParams(customIconSize, customIconSize)
- }
-
- private fun setChipMainContent(
- chipModel: OngoingActivityChipModel.Shown,
- chipTextView: TextView,
- chipTimeView: ChipChronometer,
- ) {
- when (chipModel) {
- is OngoingActivityChipModel.Shown.Countdown -> {
- chipTextView.text = chipModel.secondsUntilStarted.toString()
- chipTextView.visibility = View.VISIBLE
-
- chipTimeView.hide()
- }
- is OngoingActivityChipModel.Shown.Text -> {
- chipTextView.text = chipModel.text
- chipTextView.visibility = View.VISIBLE
-
- chipTimeView.hide()
- }
- is OngoingActivityChipModel.Shown.Timer -> {
- ChipChronometerBinder.bind(chipModel.startTimeMs, chipTimeView)
- chipTimeView.visibility = View.VISIBLE
-
- chipTextView.visibility = View.GONE
- }
- is OngoingActivityChipModel.Shown.IconOnly -> {
- chipTextView.visibility = View.GONE
- chipTimeView.hide()
- }
- }
- }
-
- private fun ChipChronometer.hide() {
- // The Chronometer should be stopped to prevent leaks -- see b/192243808 and
- // [Chronometer.start].
- this.stop()
- this.visibility = View.GONE
- }
-
- private fun updateChipPadding(
- chipModel: OngoingActivityChipModel.Shown,
- backgroundView: View,
- chipTextView: TextView,
- chipTimeView: ChipChronometer,
- ) {
- if (chipModel.icon != null) {
- if (chipModel.icon is OngoingActivityChipModel.ChipIcon.StatusBarView) {
- // If the icon is a custom [StatusBarIconView], then it should've come from
- // `Notification.smallIcon`, which is required to embed its own paddings. We need to
- // adjust the other paddings to make everything look good :)
- backgroundView.setBackgroundPaddingForEmbeddedPaddingIcon()
- chipTextView.setTextPaddingForEmbeddedPaddingIcon()
- chipTimeView.setTextPaddingForEmbeddedPaddingIcon()
- } else {
- backgroundView.setBackgroundPaddingForNormalIcon()
- chipTextView.setTextPaddingForNormalIcon()
- chipTimeView.setTextPaddingForNormalIcon()
- }
- } else {
- backgroundView.setBackgroundPaddingForNoIcon()
- chipTextView.setTextPaddingForNoIcon()
- chipTimeView.setTextPaddingForNoIcon()
- }
- }
-
- private fun View.setTextPaddingForEmbeddedPaddingIcon() {
- val newPaddingEnd =
- context.resources.getDimensionPixelSize(
- R.dimen.ongoing_activity_chip_text_end_padding_for_embedded_padding_icon
- )
- setPaddingRelative(
- // The icon should embed enough padding between the icon and time view.
- /* start= */ 0,
- this.paddingTop,
- newPaddingEnd,
- this.paddingBottom,
- )
- }
-
- private fun View.setTextPaddingForNormalIcon() {
- this.setPaddingRelative(
- this.context.resources.getDimensionPixelSize(
- R.dimen.ongoing_activity_chip_icon_text_padding
- ),
- paddingTop,
- // The background view will contain the right end padding.
- /* end= */ 0,
- paddingBottom,
- )
- }
-
- private fun View.setTextPaddingForNoIcon() {
- // The background view will have even start & end paddings, so we don't want the text view
- // to add any additional padding.
- this.setPaddingRelative(/* start= */ 0, paddingTop, /* end= */ 0, paddingBottom)
- }
-
- private fun View.setBackgroundPaddingForEmbeddedPaddingIcon() {
- val sidePadding =
- context.resources.getDimensionPixelSize(
- R.dimen.ongoing_activity_chip_side_padding_for_embedded_padding_icon
- )
- setPaddingRelative(
- sidePadding,
- paddingTop,
- sidePadding,
- paddingBottom,
- )
- }
-
- private fun View.setBackgroundPaddingForNormalIcon() {
- val sidePadding =
- context.resources.getDimensionPixelSize(R.dimen.ongoing_activity_chip_side_padding)
- setPaddingRelative(
- sidePadding,
- paddingTop,
- sidePadding,
- paddingBottom,
- )
- }
-
- private fun View.setBackgroundPaddingForNoIcon() {
- // The padding for the normal icon is also appropriate for no icon.
- setBackgroundPaddingForNormalIcon()
- }
-
- private fun setChipAccessibility(
- chipModel: OngoingActivityChipModel.Shown,
- chipView: View,
- chipBackgroundView: View,
- ) {
- when (chipModel) {
- is OngoingActivityChipModel.Shown.Countdown -> {
- // Set as assertive so talkback will announce the countdown
- chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE
- }
- is OngoingActivityChipModel.Shown.Timer,
- is OngoingActivityChipModel.Shown.Text,
- is OngoingActivityChipModel.Shown.IconOnly -> {
- chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_NONE
- }
- }
- // Clickable chips need to be a minimum size for accessibility purposes, but let
- // non-clickable chips be smaller.
- if (chipModel.onClickListener != null) {
- chipBackgroundView.minimumWidth =
- chipBackgroundView.context.resources.getDimensionPixelSize(
- R.dimen.min_clickable_item_size
- )
- } else {
- chipBackgroundView.minimumWidth = 0
- }
- }
-
private fun animateLightsOutView(view: View, visible: Boolean) {
view.animate().cancel()
@@ -424,10 +142,6 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa
)
.start()
}
-
- companion object {
- @IdRes private val CUSTOM_ICON_VIEW_ID = R.id.ongoing_activity_chip_custom_icon
- }
}
/** Listener for various events that may affect the status bar's visibility. */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModel.kt
index d6c3834c1bf1..547423156eb8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModel.kt
@@ -64,8 +64,11 @@ interface CollapsedStatusBarViewModel {
/** Emits whenever a transition from lockscreen to dream has started. */
val transitionFromLockscreenToDreamStartedEvent: Flow<Unit>
- /** The ongoing activity chip that should be shown on the left-hand side of the status bar. */
- val ongoingActivityChip: StateFlow<OngoingActivityChipModel>
+ /**
+ * The ongoing activity chip that should be primarily shown on the left-hand side of the status
+ * bar. If there are multiple ongoing activity chips, this one should take priority.
+ */
+ val primaryOngoingActivityChip: StateFlow<OngoingActivityChipModel>
/**
* True if the current scene can show the home status bar (aka this status bar), and false if
@@ -108,7 +111,7 @@ constructor(
.filter { it.transitionState == TransitionState.STARTED }
.map {}
- override val ongoingActivityChip = ongoingActivityChipsViewModel.chip
+ override val primaryOngoingActivityChip = ongoingActivityChipsViewModel.primaryChip
override val isHomeStatusBarAllowedByScene: StateFlow<Boolean> =
combine(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt
index bd5df07b7ece..f528ebbd9e63 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt
@@ -107,69 +107,69 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
}
@Test
- fun chip_allHidden_hidden() =
+ fun primaryChip_allHidden_hidden() =
testScope.runTest {
screenRecordState.value = ScreenRecordModel.DoingNothing
mediaProjectionState.value = MediaProjectionState.NotProjecting
callRepo.setOngoingCallState(OngoingCallModel.NoCall)
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java)
}
@Test
- fun chip_screenRecordShow_restHidden_screenRecordShown() =
+ fun primaryChip_screenRecordShow_restHidden_screenRecordShown() =
testScope.runTest {
screenRecordState.value = ScreenRecordModel.Recording
mediaProjectionState.value = MediaProjectionState.NotProjecting
callRepo.setOngoingCallState(OngoingCallModel.NoCall)
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsScreenRecordChip(latest)
}
@Test
- fun chip_screenRecordShowAndCallShow_screenRecordShown() =
+ fun primaryChip_screenRecordShowAndCallShow_screenRecordShown() =
testScope.runTest {
screenRecordState.value = ScreenRecordModel.Recording
callRepo.setOngoingCallState(inCallModel(startTimeMs = 34))
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsScreenRecordChip(latest)
}
@Test
- fun chip_screenRecordShowAndShareToAppShow_screenRecordShown() =
+ fun primaryChip_screenRecordShowAndShareToAppShow_screenRecordShown() =
testScope.runTest {
screenRecordState.value = ScreenRecordModel.Recording
mediaProjectionState.value =
MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
callRepo.setOngoingCallState(OngoingCallModel.NoCall)
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsScreenRecordChip(latest)
}
@Test
- fun chip_shareToAppShowAndCallShow_shareToAppShown() =
+ fun primaryChip_shareToAppShowAndCallShow_shareToAppShown() =
testScope.runTest {
screenRecordState.value = ScreenRecordModel.DoingNothing
mediaProjectionState.value =
MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
callRepo.setOngoingCallState(inCallModel(startTimeMs = 34))
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsShareToAppChip(latest)
}
@Test
- fun chip_screenRecordAndShareToAppAndCastToOtherHideAndCallShown_callShown() =
+ fun primaryChip_screenRecordAndShareToAppAndCastToOtherHideAndCallShown_callShown() =
testScope.runTest {
screenRecordState.value = ScreenRecordModel.DoingNothing
// MediaProjection covers both share-to-app and cast-to-other-device
@@ -177,14 +177,14 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
callRepo.setOngoingCallState(inCallModel(startTimeMs = 34))
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsCallChip(latest)
}
@Test
@EnableFlags(FLAG_STATUS_BAR_RON_CHIPS)
- fun chip_higherPriorityChipAdded_lowerPriorityChipReplaced() =
+ fun primaryChip_higherPriorityChipAdded_lowerPriorityChipReplaced() =
testScope.runTest {
// Start with just the lowest priority chip shown
addDemoRonChip(commandRegistry, pw)
@@ -193,7 +193,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
mediaProjectionState.value = MediaProjectionState.NotProjecting
screenRecordState.value = ScreenRecordModel.DoingNothing
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsDemoRonChip(latest)
@@ -223,7 +223,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
@Test
@EnableFlags(FLAG_STATUS_BAR_RON_CHIPS)
- fun chip_highestPriorityChipRemoved_showsNextPriorityChip() =
+ fun primaryChip_highestPriorityChipRemoved_showsNextPriorityChip() =
testScope.runTest {
// WHEN all chips are active
screenRecordState.value = ScreenRecordModel.Recording
@@ -232,7 +232,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
callRepo.setOngoingCallState(inCallModel(startTimeMs = 34))
addDemoRonChip(commandRegistry, pw)
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
// THEN the highest priority screen record is used
assertIsScreenRecordChip(latest)
@@ -258,11 +258,11 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
/** Regression test for b/347726238. */
@Test
- fun chip_timerDoesNotResetAfterSubscribersRestart() =
+ fun primaryChip_timerDoesNotResetAfterSubscribersRestart() =
testScope.runTest {
var latest: OngoingActivityChipModel? = null
- val job1 = underTest.chip.onEach { latest = it }.launchIn(this)
+ val job1 = underTest.primaryChip.onEach { latest = it }.launchIn(this)
// Start a chip with a timer
systemClock.setElapsedRealtime(1234)
@@ -279,7 +279,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
systemClock.setElapsedRealtime(5678)
// WHEN we re-subscribe to the chip flow
- val job2 = underTest.chip.onEach { latest = it }.launchIn(this)
+ val job2 = underTest.primaryChip.onEach { latest = it }.launchIn(this)
runCurrent()
@@ -290,13 +290,13 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
}
@Test
- fun chip_screenRecordStoppedViaDialog_chipHiddenWithoutAnimation() =
+ fun primaryChip_screenRecordStoppedViaDialog_chipHiddenWithoutAnimation() =
testScope.runTest {
screenRecordState.value = ScreenRecordModel.Recording
mediaProjectionState.value = MediaProjectionState.NotProjecting
callRepo.setOngoingCallState(OngoingCallModel.NoCall)
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsScreenRecordChip(latest)
@@ -310,14 +310,14 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
}
@Test
- fun chip_projectionStoppedViaDialog_chipHiddenWithoutAnimation() =
+ fun primaryChip_projectionStoppedViaDialog_chipHiddenWithoutAnimation() =
testScope.runTest {
mediaProjectionState.value =
MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
screenRecordState.value = ScreenRecordModel.DoingNothing
callRepo.setOngoingCallState(OngoingCallModel.NoCall)
- val latest by collectLastValue(underTest.chip)
+ val latest by collectLastValue(underTest.primaryChip)
assertIsShareToAppChip(latest)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
index bea027f0e98b..6e337efd68af 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
@@ -432,8 +432,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -445,8 +444,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
- assertEquals(View.VISIBLE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.VISIBLE, getPrimaryOngoingActivityChipView().getVisibility());
assertEquals(View.INVISIBLE, getNotificationAreaView().getVisibility());
}
@@ -460,8 +458,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
fragment.disable(DEFAULT_DISPLAY,
StatusBarManager.DISABLE_NOTIFICATION_ICONS, 0, false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -474,8 +471,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -487,22 +483,19 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
when(mOngoingCallController.hasOngoingCall()).thenReturn(true);
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
- assertEquals(View.VISIBLE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.VISIBLE, getPrimaryOngoingActivityChipView().getVisibility());
// Ongoing call ended
when(mOngoingCallController.hasOngoingCall()).thenReturn(false);
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
// Ongoing call started
when(mOngoingCallController.hasOngoingCall()).thenReturn(true);
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
- assertEquals(View.VISIBLE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.VISIBLE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -536,8 +529,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
/* hasOngoingActivity= */ false, /* shouldAnimate= */ false);
// THEN the old callback value is used, so the view is shown
- assertEquals(View.VISIBLE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.VISIBLE, getPrimaryOngoingActivityChipView().getVisibility());
// WHEN there's *no* ongoing call via old callback
when(mOngoingCallController.hasOngoingCall()).thenReturn(false);
@@ -548,8 +540,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
/* hasOngoingActivity= */ true, /* shouldAnimate= */ false);
// THEN the old callback value is used, so the view is hidden
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -564,8 +555,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
mCollapsedStatusBarViewBinder.getListener().onOngoingActivityStatusChanged(
/* hasOngoingActivity= */ false, /* shouldAnimate= */ false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -576,8 +566,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
mCollapsedStatusBarViewBinder.getListener().onOngoingActivityStatusChanged(
/* hasOngoingActivity= */ true, /* shouldAnimate= */ false);
- assertEquals(View.VISIBLE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.VISIBLE, getPrimaryOngoingActivityChipView().getVisibility());
assertEquals(View.INVISIBLE, getNotificationAreaView().getVisibility());
}
@@ -592,8 +581,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
fragment.disable(DEFAULT_DISPLAY,
StatusBarManager.DISABLE_NOTIFICATION_ICONS, 0, false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -607,8 +595,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -620,15 +607,13 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
mCollapsedStatusBarViewBinder.getListener().onOngoingActivityStatusChanged(
/* hasOngoingActivity= */ true, /* shouldAnimate= */ false);
- assertEquals(View.VISIBLE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.VISIBLE, getPrimaryOngoingActivityChipView().getVisibility());
// Ongoing activity ended
mCollapsedStatusBarViewBinder.getListener().onOngoingActivityStatusChanged(
/* hasOngoingActivity= */ false, /* shouldAnimate= */ false);
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -661,8 +646,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
/* hasOngoingActivity= */ false, /* shouldAnimate= */ false);
// THEN the new callback value is used, so the view is hidden
- assertEquals(View.GONE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.GONE, getPrimaryOngoingActivityChipView().getVisibility());
// WHEN there's *no* ongoing call via old callback
when(mOngoingCallController.hasOngoingCall()).thenReturn(false);
@@ -673,8 +657,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
/* hasOngoingActivity= */ true, /* shouldAnimate= */ false);
// THEN the new callback value is used, so the view is shown
- assertEquals(View.VISIBLE,
- mFragment.getView().findViewById(R.id.ongoing_activity_chip).getVisibility());
+ assertEquals(View.VISIBLE, getPrimaryOngoingActivityChipView().getVisibility());
}
@Test
@@ -1023,4 +1006,8 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
private View getNotificationAreaView() {
return mFragment.getView().findViewById(R.id.notificationIcons);
}
+
+ private View getPrimaryOngoingActivityChipView() {
+ return mFragment.getView().findViewById(R.id.ongoing_activity_chip_primary);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt
index 60750cf96e67..7ae6ea51b912 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt
@@ -415,9 +415,9 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() {
}
@Test
- fun ongoingActivityChip_matchesViewModel() =
+ fun primaryOngoingActivityChip_matchesViewModel() =
testScope.runTest {
- val latest by collectLastValue(underTest.ongoingActivityChip)
+ val latest by collectLastValue(underTest.primaryOngoingActivityChip)
kosmos.screenRecordRepository.screenRecordState.value = ScreenRecordModel.Recording
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeCollapsedStatusBarViewModel.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeCollapsedStatusBarViewModel.kt
index cefdf7e43fae..e71f5217095c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeCollapsedStatusBarViewModel.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeCollapsedStatusBarViewModel.kt
@@ -28,7 +28,7 @@ class FakeCollapsedStatusBarViewModel : CollapsedStatusBarViewModel {
override val transitionFromLockscreenToDreamStartedEvent = MutableSharedFlow<Unit>()
- override val ongoingActivityChip: MutableStateFlow<OngoingActivityChipModel> =
+ override val primaryOngoingActivityChip: MutableStateFlow<OngoingActivityChipModel> =
MutableStateFlow(OngoingActivityChipModel.Hidden())
override val isHomeStatusBarAllowedByScene = MutableStateFlow(false)