Merge "Controls UI - Haptics updates" into rvc-dev am: b86ab6ef33 am: 19ebdcd575
Change-Id: Ida3509e5198cf774241642cb4f7aded13eb5befe
This commit is contained in:
@@ -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))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user