Merge "Adds mobile indicators to QQS header when multiple SIMs are in use" into udc-qpr-dev

This commit is contained in:
Shawn Lee
2023-06-27 22:40:18 +00:00
committed by Android (Google) Code Review
3 changed files with 31 additions and 5 deletions

View File

@@ -195,7 +195,9 @@ constructor(
set(value) { set(value) {
if (visible && field != value) { if (visible && field != value) {
field = value field = value
iconContainer.setQsExpansionTransitioning(value > 0f && value < 1.0f)
updatePosition() updatePosition()
updateIgnoredSlots()
} }
} }
@@ -216,6 +218,8 @@ constructor(
view.onApplyWindowInsets(insets) view.onApplyWindowInsets(insets)
} }
private var singleCarrier = false
private val demoModeReceiver = private val demoModeReceiver =
object : DemoMode { object : DemoMode {
override fun demoCommands() = listOf(DemoMode.COMMAND_CLOCK) override fun demoCommands() = listOf(DemoMode.COMMAND_CLOCK)
@@ -479,17 +483,20 @@ constructor(
private fun updateListeners() { private fun updateListeners() {
mShadeCarrierGroupController.setListening(visible) mShadeCarrierGroupController.setListening(visible)
if (visible) { if (visible) {
updateSingleCarrier(mShadeCarrierGroupController.isSingleCarrier) singleCarrier = mShadeCarrierGroupController.isSingleCarrier
updateIgnoredSlots()
mShadeCarrierGroupController.setOnSingleCarrierChangedListener { mShadeCarrierGroupController.setOnSingleCarrierChangedListener {
updateSingleCarrier(it) singleCarrier = it
updateIgnoredSlots()
} }
} else { } else {
mShadeCarrierGroupController.setOnSingleCarrierChangedListener(null) mShadeCarrierGroupController.setOnSingleCarrierChangedListener(null)
} }
} }
private fun updateSingleCarrier(singleCarrier: Boolean) { private fun updateIgnoredSlots() {
if (singleCarrier) { // switching from QQS to QS state halfway through the transition
if (singleCarrier || qsExpandedFraction < 0.5) {
iconContainer.removeIgnoredSlots(carrierIconSlots) iconContainer.removeIgnoredSlots(carrierIconSlots)
} else { } else {
iconContainer.addIgnoredSlots(carrierIconSlots) iconContainer.addIgnoredSlots(carrierIconSlots)

View File

@@ -64,6 +64,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
private boolean mNeedsUnderflow; private boolean mNeedsUnderflow;
// Individual StatusBarIconViews draw their etc dots centered in this width // Individual StatusBarIconViews draw their etc dots centered in this width
private int mIconDotFrameWidth; private int mIconDotFrameWidth;
private boolean mQsExpansionTransitioning;
private boolean mShouldRestrictIcons = true; private boolean mShouldRestrictIcons = true;
// Used to count which states want to be visible during layout // Used to count which states want to be visible during layout
private ArrayList<StatusIconState> mLayoutStates = new ArrayList<>(); private ArrayList<StatusIconState> mLayoutStates = new ArrayList<>();
@@ -87,6 +88,10 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
super.onFinishInflate(); super.onFinishInflate();
} }
public void setQsExpansionTransitioning(boolean expansionTransitioning) {
mQsExpansionTransitioning = expansionTransitioning;
}
public void setShouldRestrictIcons(boolean should) { public void setShouldRestrictIcons(boolean should) {
mShouldRestrictIcons = should; mShouldRestrictIcons = should;
} }
@@ -386,6 +391,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
StatusIconState vs = getViewStateFromChild(child); StatusIconState vs = getViewStateFromChild(child);
if (vs != null) { if (vs != null) {
vs.applyToView(child); vs.applyToView(child);
vs.qsExpansionTransitioning = mQsExpansionTransitioning;
} }
} }
} }
@@ -420,6 +426,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
/// StatusBarIconView.STATE_* /// StatusBarIconView.STATE_*
public int visibleState = STATE_ICON; public int visibleState = STATE_ICON;
public boolean justAdded = true; public boolean justAdded = true;
public boolean qsExpansionTransitioning = false;
// How far we are from the end of the view actually is the most relevant for animation // How far we are from the end of the view actually is the most relevant for animation
float distanceToViewEnd = -1; float distanceToViewEnd = -1;
@@ -462,12 +469,13 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
} }
icon.setVisibleState(visibleState, animateVisibility); icon.setVisibleState(visibleState, animateVisibility);
if (animationProperties != null) { if (animationProperties != null && !qsExpansionTransitioning) {
animateTo(view, animationProperties); animateTo(view, animationProperties);
} else { } else {
super.applyToView(view); super.applyToView(view);
} }
qsExpansionTransitioning = false;
justAdded = false; justAdded = false;
distanceToViewEnd = currentDistanceToEnd; distanceToViewEnd = currentDistanceToEnd;

View File

@@ -237,10 +237,21 @@ class ShadeHeaderControllerTest : SysuiTestCase() {
whenever(mShadeCarrierGroupController.isSingleCarrier).thenReturn(false) whenever(mShadeCarrierGroupController.isSingleCarrier).thenReturn(false)
makeShadeVisible() makeShadeVisible()
shadeHeaderController.qsExpandedFraction = 1.0f
verify(statusIcons).addIgnoredSlots(carrierIconSlots) verify(statusIcons).addIgnoredSlots(carrierIconSlots)
} }
@Test
fun dualCarrier_enablesCarrierIconsInStatusIcons_qsExpanded() {
whenever(mShadeCarrierGroupController.isSingleCarrier).thenReturn(false)
makeShadeVisible()
shadeHeaderController.qsExpandedFraction = 0.0f
verify(statusIcons, times(2)).removeIgnoredSlots(carrierIconSlots)
}
@Test @Test
fun disableQS_notDisabled_visible() { fun disableQS_notDisabled_visible() {
makeShadeVisible() makeShadeVisible()