From 3b859c3db31482146acbd9e82cc6ebd3acc7d351 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Thu, 18 Jun 2020 15:27:13 -0400 Subject: [PATCH] Controls UI - Do not update while drag in progress This could result in the UI state getting out of sync, and assume that the user interaction will result in another update. Fixes: 159341180 Test: manual, drag controls Change-Id: If2e122e6139aac939900081900c58dc49ec61c2b --- .../com/android/systemui/controls/ui/ControlViewHolder.kt | 7 +++++++ .../android/systemui/controls/ui/ToggleRangeBehavior.kt | 2 ++ 2 files changed, 9 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt index 400d830e782e3..4eb7527bff6e1 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt @@ -128,6 +128,8 @@ class ControlViewHolder( val controlTemplate: ControlTemplate get() = cws.control?.let { it.controlTemplate } ?: ControlTemplate.NO_TEMPLATE + var userInteractionInProgress = false + init { val ld = layout.getBackground() as LayerDrawable ld.mutate() @@ -139,6 +141,11 @@ class ControlViewHolder( } fun bindData(cws: ControlWithState) { + // If an interaction is in progress, the update may visually interfere with the action the + // action the user wants to make. Don't apply the update, and instead assume a new update + // will coming from when the user interaction is complete. + if (userInteractionInProgress) return + this.cws = cws cancelUpdate?.run() diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt index 04881af6ed45c..aa11df41a7b77 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt @@ -216,6 +216,7 @@ class ToggleRangeBehavior : Behavior { } fun beginUpdateRange() { + cvh.userInteractionInProgress = true cvh.setStatusTextSize(context.getResources() .getDimensionPixelSize(R.dimen.control_status_expanded).toFloat()) } @@ -296,6 +297,7 @@ class ToggleRangeBehavior : Behavior { cvh.setStatusText("$currentStatusText $currentRangeValue", /* immediately */ true) cvh.controlActionCoordinator.setValue(cvh, rangeTemplate.getTemplateId(), findNearestStep(levelToRangeValue(clipLayer.getLevel()))) + cvh.userInteractionInProgress = false } fun findNearestStep(value: Float): Float {