Merge "Merge "Controls UI - Haptics updates" into rvc-dev am: b86ab6ef33 am: 54209841db" into rvc-d1-dev-plus-aosp

This commit is contained in:
Automerger Merge Worker
2020-05-19 17:13:05 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 3 deletions

View File

@@ -58,7 +58,7 @@ class ControlActionCoordinatorImpl @Inject constructor(
override fun toggle(cvh: ControlViewHolder, templateId: String, isChecked: Boolean) { override fun toggle(cvh: ControlViewHolder, templateId: String, isChecked: Boolean) {
bouncerOrRun { bouncerOrRun {
val effect = if (isChecked) Vibrations.toggleOnEffect else Vibrations.toggleOffEffect val effect = if (!isChecked) Vibrations.toggleOnEffect else Vibrations.toggleOffEffect
vibrate(effect) vibrate(effect)
cvh.action(BooleanAction(templateId, !isChecked)) cvh.action(BooleanAction(templateId, !isChecked))
} }

View File

@@ -20,7 +20,7 @@ import android.os.VibrationEffect
import android.os.VibrationEffect.Composition.PRIMITIVE_TICK import android.os.VibrationEffect.Composition.PRIMITIVE_TICK
object Vibrations { object Vibrations {
private const val TOGGLE_TICK_COUNT = 12 private const val TOGGLE_TICK_COUNT = 40
val toggleOnEffect = initToggleOnEffect() val toggleOnEffect = initToggleOnEffect()
val toggleOffEffect = initToggleOffEffect() val toggleOffEffect = initToggleOffEffect()
@@ -29,6 +29,7 @@ object Vibrations {
private fun initToggleOnEffect(): VibrationEffect { private fun initToggleOnEffect(): VibrationEffect {
val composition = VibrationEffect.startComposition() val composition = VibrationEffect.startComposition()
composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 200)
var i = 0 var i = 0
while (i++ < TOGGLE_TICK_COUNT) { while (i++ < TOGGLE_TICK_COUNT) {
composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 0) composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 0)
@@ -43,7 +44,7 @@ object Vibrations {
composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 100) composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 100)
var i = 0 var i = 0
while (i++ < TOGGLE_TICK_COUNT) { while (i++ < TOGGLE_TICK_COUNT) {
composition?.addPrimitive(PRIMITIVE_TICK, 0.05f, 0) composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 0)
} }
return composition.compose() return composition.compose()
} }