Merge "Controls UI - Haptics updates" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b86ab6ef33
@@ -58,7 +58,7 @@ class ControlActionCoordinatorImpl @Inject constructor(
|
||||
|
||||
override fun toggle(cvh: ControlViewHolder, templateId: String, isChecked: Boolean) {
|
||||
bouncerOrRun {
|
||||
val effect = if (isChecked) Vibrations.toggleOnEffect else Vibrations.toggleOffEffect
|
||||
val effect = if (!isChecked) Vibrations.toggleOnEffect else Vibrations.toggleOffEffect
|
||||
vibrate(effect)
|
||||
cvh.action(BooleanAction(templateId, !isChecked))
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.os.VibrationEffect
|
||||
import android.os.VibrationEffect.Composition.PRIMITIVE_TICK
|
||||
|
||||
object Vibrations {
|
||||
private const val TOGGLE_TICK_COUNT = 12
|
||||
private const val TOGGLE_TICK_COUNT = 40
|
||||
|
||||
val toggleOnEffect = initToggleOnEffect()
|
||||
val toggleOffEffect = initToggleOffEffect()
|
||||
@@ -29,6 +29,7 @@ object Vibrations {
|
||||
|
||||
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)
|
||||
@@ -43,7 +44,7 @@ object Vibrations {
|
||||
composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 100)
|
||||
var i = 0
|
||||
while (i++ < TOGGLE_TICK_COUNT) {
|
||||
composition?.addPrimitive(PRIMITIVE_TICK, 0.05f, 0)
|
||||
composition.addPrimitive(PRIMITIVE_TICK, 0.05f, 0)
|
||||
}
|
||||
return composition.compose()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user