Merge "Controls UI - Haptics fixes" into rvc-dev
This commit is contained in:
@@ -58,16 +58,14 @@ 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
|
cvh.layout.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
|
||||||
vibrate(effect)
|
|
||||||
cvh.action(BooleanAction(templateId, !isChecked))
|
cvh.action(BooleanAction(templateId, !isChecked))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun touch(cvh: ControlViewHolder, templateId: String, control: Control) {
|
override fun touch(cvh: ControlViewHolder, templateId: String, control: Control) {
|
||||||
vibrate(Vibrations.toggleOnEffect)
|
|
||||||
|
|
||||||
bouncerOrRun {
|
bouncerOrRun {
|
||||||
|
cvh.layout.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
|
||||||
if (cvh.usePanel()) {
|
if (cvh.usePanel()) {
|
||||||
showDialog(cvh, control.getAppIntent().getIntent())
|
showDialog(cvh, control.getAppIntent().getIntent())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -231,9 +231,11 @@ class ToggleRangeBehavior : Behavior {
|
|||||||
|
|
||||||
rangeAnimator?.cancel()
|
rangeAnimator?.cancel()
|
||||||
if (isDragging) {
|
if (isDragging) {
|
||||||
clipLayer.level = newLevel
|
|
||||||
val isEdge = newLevel == MIN_LEVEL || newLevel == MAX_LEVEL
|
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) {
|
} else if (newLevel != clipLayer.level) {
|
||||||
rangeAnimator = ValueAnimator.ofInt(cvh.clipLayer.level, newLevel).apply {
|
rangeAnimator = ValueAnimator.ofInt(cvh.clipLayer.level, newLevel).apply {
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
|
|||||||
@@ -20,35 +20,9 @@ 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 = 40
|
|
||||||
|
|
||||||
val toggleOnEffect = initToggleOnEffect()
|
|
||||||
val toggleOffEffect = initToggleOffEffect()
|
|
||||||
val rangeEdgeEffect = initRangeEdgeEffect()
|
val rangeEdgeEffect = initRangeEdgeEffect()
|
||||||
val rangeMiddleEffect = initRangeMiddleEffect()
|
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 {
|
private fun initRangeEdgeEffect(): VibrationEffect {
|
||||||
val composition = VibrationEffect.startComposition()
|
val composition = VibrationEffect.startComposition()
|
||||||
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_TICK, 0.5f)
|
composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_TICK, 0.5f)
|
||||||
|
|||||||
Reference in New Issue
Block a user