Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b86ab6ef authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Controls UI - Haptics updates" into rvc-dev

parents fa01d2ad 095dfedb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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))
        }
+3 −2
Original line number Diff line number Diff line
@@ -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()
    }