Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +9 −5 Original line number Diff line number Diff line Loading @@ -779,11 +779,15 @@ constructor( lastIconTint = icon.getColor(state) // Long-press effects longPressEffect?.qsTile?.state?.handlesLongClick = state.handlesLongClick if ( state.handlesLongClick && longPressEffect?.initializeEffect(longPressEffectDuration) == true ) { updateLongPressEffect(state.handlesLongClick) } private fun updateLongPressEffect(handlesLongClick: Boolean) { // The long press effect in the tile can't be updated if it is still running if (longPressEffect?.state != QSLongPressEffect.State.IDLE) return longPressEffect.qsTile?.state?.handlesLongClick = handlesLongClick if (handlesLongClick && longPressEffect.initializeEffect(longPressEffectDuration)) { showRippleEffect = false longPressEffect.qsTile?.state?.state = lastState // Store the tile's state longPressEffect.resetState() Loading packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +21 −3 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ class QSTileViewImplTest : SysuiTestCase() { context.orCreateTestableResources.addOverride( R.array.tile_states_internet, arrayOf(unavailableString, offString, onString) arrayOf(unavailableString, offString, onString), ) // State UNAVAILABLE Loading Loading @@ -341,7 +341,7 @@ class QSTileViewImplTest : SysuiTestCase() { val testA11yLabel = "TEST_LABEL" context.orCreateTestableResources.addOverride( R.string.accessibility_tile_disabled_by_policy_action_description, testA11yLabel testA11yLabel, ) val stateDisabledByPolicy = QSTile.State() Loading Loading @@ -374,7 +374,7 @@ class QSTileViewImplTest : SysuiTestCase() { context.orCreateTestableResources.addOverride( R.array.tile_states_internet, arrayOf(unavailableString, offString, onString) arrayOf(unavailableString, offString, onString), ) tileView.changeState(state) Loading Loading @@ -476,6 +476,24 @@ class QSTileViewImplTest : SysuiTestCase() { assertThat(tileView.areLongPressEffectPropertiesSet).isTrue() } @Test fun onStateChange_fromLongPress_toNoLongPress_whileLongPressRuns_doesNotClearResources() { // GIVEN that the long-press effect has been initialized val state = QSTile.State() state.handlesLongClick = true tileView.changeState(state) // WHEN the long-press effect is running kosmos.qsLongPressEffect.setState(QSLongPressEffect.State.RUNNING_FORWARD) // WHEN a state changed happens so that the tile no longer handles long-press state.handlesLongClick = false tileView.changeState(state) // THEN the long-press effect resources are not cleared assertThat(tileView.areLongPressEffectPropertiesSet).isTrue() } @Test fun onStateChange_withoutLongPressEffect_fromLongPress_to_noLongPress_neverSetsProperties() { // GIVEN a tile where the long-press effect is null Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +9 −5 Original line number Diff line number Diff line Loading @@ -779,11 +779,15 @@ constructor( lastIconTint = icon.getColor(state) // Long-press effects longPressEffect?.qsTile?.state?.handlesLongClick = state.handlesLongClick if ( state.handlesLongClick && longPressEffect?.initializeEffect(longPressEffectDuration) == true ) { updateLongPressEffect(state.handlesLongClick) } private fun updateLongPressEffect(handlesLongClick: Boolean) { // The long press effect in the tile can't be updated if it is still running if (longPressEffect?.state != QSLongPressEffect.State.IDLE) return longPressEffect.qsTile?.state?.handlesLongClick = handlesLongClick if (handlesLongClick && longPressEffect.initializeEffect(longPressEffectDuration)) { showRippleEffect = false longPressEffect.qsTile?.state?.state = lastState // Store the tile's state longPressEffect.resetState() Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +21 −3 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ class QSTileViewImplTest : SysuiTestCase() { context.orCreateTestableResources.addOverride( R.array.tile_states_internet, arrayOf(unavailableString, offString, onString) arrayOf(unavailableString, offString, onString), ) // State UNAVAILABLE Loading Loading @@ -341,7 +341,7 @@ class QSTileViewImplTest : SysuiTestCase() { val testA11yLabel = "TEST_LABEL" context.orCreateTestableResources.addOverride( R.string.accessibility_tile_disabled_by_policy_action_description, testA11yLabel testA11yLabel, ) val stateDisabledByPolicy = QSTile.State() Loading Loading @@ -374,7 +374,7 @@ class QSTileViewImplTest : SysuiTestCase() { context.orCreateTestableResources.addOverride( R.array.tile_states_internet, arrayOf(unavailableString, offString, onString) arrayOf(unavailableString, offString, onString), ) tileView.changeState(state) Loading Loading @@ -476,6 +476,24 @@ class QSTileViewImplTest : SysuiTestCase() { assertThat(tileView.areLongPressEffectPropertiesSet).isTrue() } @Test fun onStateChange_fromLongPress_toNoLongPress_whileLongPressRuns_doesNotClearResources() { // GIVEN that the long-press effect has been initialized val state = QSTile.State() state.handlesLongClick = true tileView.changeState(state) // WHEN the long-press effect is running kosmos.qsLongPressEffect.setState(QSLongPressEffect.State.RUNNING_FORWARD) // WHEN a state changed happens so that the tile no longer handles long-press state.handlesLongClick = false tileView.changeState(state) // THEN the long-press effect resources are not cleared assertThat(tileView.areLongPressEffectPropertiesSet).isTrue() } @Test fun onStateChange_withoutLongPressEffect_fromLongPress_to_noLongPress_neverSetsProperties() { // GIVEN a tile where the long-press effect is null Loading