From b41574aa0a0431bf8ab751de8fe970b698ce33bb Mon Sep 17 00:00:00 2001 From: Juan Sebastian Martinez Date: Mon, 23 Sep 2024 11:17:09 -0700 Subject: Avoiding click dispatching after long-clicks on QS tiles. When the QSLongPressEffect is enabled, the a no-op long-click listener is added to the view so that the long-click gesture is fully consumed. This avoids clicks from being dispacthed by the View when the tiles are long-pressed. Test: manual. Verified no clicks are detected after a long-press is processed. Test: atest QSTileViewImplTest Flag: com.android.systemui.quick_settings_visual_haptics_longpress Bug: 367952297 Change-Id: Idebe980e23bcba41a69e1f0f27f137d4607116c0 --- .../android/systemui/qs/tileimpl/QSTileViewImpl.kt | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index 6a8cc1715aca..4f3ea8331a17 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -126,12 +126,12 @@ constructor( private val overlayColorActive = Utils.applyAlpha( /* alpha= */ 0.11f, - Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive) + Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive), ) private val overlayColorInactive = Utils.applyAlpha( /* alpha= */ 0.08f, - Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactive) + Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactive), ) private val colorLabelActive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive) @@ -188,10 +188,7 @@ constructor( private var lastState = INVALID private var lastIconTint = 0 private val launchableViewDelegate = - LaunchableViewDelegate( - this, - superSetVisibility = { super.setVisibility(it) }, - ) + LaunchableViewDelegate(this, superSetVisibility = { super.setVisibility(it) }) private var lastDisabledByPolicy = false private val locInScreen = IntArray(2) @@ -418,7 +415,7 @@ constructor( initLongPressEffectCallback() init( { _: View -> longPressEffect.onTileClick() }, - null, // Haptics and long-clicks will be handled by the [QSLongPressEffect] + { _: View -> true }, // Haptics and long-clicks are handled by [QSLongPressEffect] ) } else { val expandable = Expandable.fromView(this) @@ -583,7 +580,7 @@ constructor( AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK.id, resources.getString( R.string.accessibility_tile_disabled_by_policy_action_description - ) + ), ) ) } else { @@ -591,7 +588,7 @@ constructor( info.addAction( AccessibilityNodeInfo.AccessibilityAction( AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK.id, - resources.getString(R.string.accessibility_long_click_tile) + resources.getString(R.string.accessibility_long_click_tile), ) ) } @@ -716,35 +713,35 @@ constructor( state.spec, state.state, state.disabledByPolicy, - getBackgroundColorForState(state.state, state.disabledByPolicy) + getBackgroundColorForState(state.state, state.disabledByPolicy), ) if (allowAnimations) { singleAnimator.setValues( colorValuesHolder( BACKGROUND_NAME, backgroundColor, - getBackgroundColorForState(state.state, state.disabledByPolicy) + getBackgroundColorForState(state.state, state.disabledByPolicy), ), colorValuesHolder( LABEL_NAME, label.currentTextColor, - getLabelColorForState(state.state, state.disabledByPolicy) + getLabelColorForState(state.state, state.disabledByPolicy), ), colorValuesHolder( SECONDARY_LABEL_NAME, secondaryLabel.currentTextColor, - getSecondaryLabelColorForState(state.state, state.disabledByPolicy) + getSecondaryLabelColorForState(state.state, state.disabledByPolicy), ), colorValuesHolder( CHEVRON_NAME, chevronView.imageTintList?.defaultColor ?: 0, - getChevronColorForState(state.state, state.disabledByPolicy) + getChevronColorForState(state.state, state.disabledByPolicy), ), colorValuesHolder( OVERLAY_NAME, backgroundOverlayColor, - getOverlayColorForState(state.state) - ) + getOverlayColorForState(state.state), + ), ) singleAnimator.start() } else { @@ -753,7 +750,7 @@ constructor( getLabelColorForState(state.state, state.disabledByPolicy), getSecondaryLabelColorForState(state.state, state.disabledByPolicy), getChevronColorForState(state.state, state.disabledByPolicy), - getOverlayColorForState(state.state) + getOverlayColorForState(state.state), ) } } @@ -1077,7 +1074,7 @@ constructor( backgroundColor, label.currentTextColor, secondaryLabel.currentTextColor, - chevronView.imageTintList?.defaultColor ?: 0 + chevronView.imageTintList?.defaultColor ?: 0, ) inner class StateChangeRunnable(private val state: QSTile.State) : Runnable { -- cgit v1.2.3-59-g8ed1b