diff options
| author | 2020-06-01 10:56:54 -0400 | |
|---|---|---|
| committer | 2020-06-01 10:56:54 -0400 | |
| commit | f4b531982b29d51c5730f5c9265d85db8614b604 (patch) | |
| tree | 86503aaeccad9f11c7a792d15c1818fc042b43f9 | |
| parent | 75bda7880bee6b4b2c38b42aa529c21f3954cb13 (diff) | |
Controls UI - Haptics fixes
Use normal haptic click for touch events. Fix drag end for range
controls.
Fixes: 154697212
Test: manual
Change-Id: Ie60b24b5abc5a558bc5c8846520daa5def8fca7a
3 files changed, 6 insertions, 32 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt index 10e913743224..2a40b76eb326 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt @@ -58,16 +58,14 @@ class ControlActionCoordinatorImpl @Inject constructor( override fun toggle(cvh: ControlViewHolder, templateId: String, isChecked: Boolean) { bouncerOrRun { - val effect = if (!isChecked) Vibrations.toggleOnEffect else Vibrations.toggleOffEffect - vibrate(effect) + cvh.layout.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK) cvh.action(BooleanAction(templateId, !isChecked)) } } override fun touch(cvh: ControlViewHolder, templateId: String, control: Control) { - vibrate(Vibrations.toggleOnEffect) - bouncerOrRun { + cvh.layout.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK) if (cvh.usePanel()) { showDialog(cvh, control.getAppIntent().getIntent()) } else { 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 1f0ca9be2ecc..0ec4cc555b9d 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt @@ -231,9 +231,11 @@ class ToggleRangeBehavior : Behavior { rangeAnimator?.cancel() if (isDragging) { - clipLayer.level = newLevel val isEdge = newLevel == MIN_LEVEL || newLevel == MAX_LEVEL - cvh.controlActionCoordinator.drag(isEdge) + if (clipLayer.level != newLevel) { + cvh.controlActionCoordinator.drag(isEdge) + clipLayer.level = newLevel + } } else if (newLevel != clipLayer.level) { rangeAnimator = ValueAnimator.ofInt(cvh.clipLayer.level, newLevel).apply { addUpdateListener { diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/Vibrations.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/Vibrations.kt index c0f6aabe2427..29b7e985fabc 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/Vibrations.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/Vibrations.kt @@ -20,35 +20,9 @@ import android.os.VibrationEffect import android.os.VibrationEffect.Composition.PRIMITIVE_TICK object Vibrations { - private const val TOGGLE_TICK_COUNT = 40 - - val toggleOnEffect = initToggleOnEffect() - val toggleOffEffect = initToggleOffEffect() val rangeEdgeEffect = initRangeEdgeEffect() val rangeMiddleEffect = initRangeMiddleEffect() - private fun initToggleOnEffect(): VibrationEffect { - val composition = VibrationEffect.startComposition() - composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 200) - var i = 0 - while (i++ < TOGGLE_TICK_COUNT) { - composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 0) - } - composition.addPrimitive(PRIMITIVE_TICK, 0.5f, 100) - return composition.compose() - } - - private fun initToggleOffEffect(): VibrationEffect { - val composition = VibrationEffect.startComposition() - composition.addPrimitive(PRIMITIVE_TICK, 0.5f, 0) - composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 100) - var i = 0 - while (i++ < TOGGLE_TICK_COUNT) { - composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 0) - } - return composition.compose() - } - private fun initRangeEdgeEffect(): VibrationEffect { val composition = VibrationEffect.startComposition() composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_TICK, 0.5f) |