From 4be7595e86c4edf7392bed819e31861009341bf2 Mon Sep 17 00:00:00 2001 From: mkulaha Date: Thu, 15 Feb 2024 17:28:38 +0000 Subject: [PATCH 1/2] Adding device specific constants for Samsung devices. These constants should bring better consistency with views rotary experience --- .../horologist/compose/rotaryinput/Haptics.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/compose-layout/src/main/java/com/google/android/horologist/compose/rotaryinput/Haptics.kt b/compose-layout/src/main/java/com/google/android/horologist/compose/rotaryinput/Haptics.kt index 2619bf88cc..9c1b4b5987 100644 --- a/compose-layout/src/main/java/com/google/android/horologist/compose/rotaryinput/Haptics.kt +++ b/compose-layout/src/main/java/com/google/android/horologist/compose/rotaryinput/Haptics.kt @@ -265,10 +265,8 @@ public fun rememberDefaultRotaryHapticFeedback(): RotaryHapticFeedback = LocalView.current.let { view -> remember { findDeviceSpecificHapticFeedback(view) } } internal fun findDeviceSpecificHapticFeedback(view: View): RotaryHapticFeedback = - if (isGalaxyWatchClassic()) { - GalaxyWatchClassicHapticFeedback(view) - } else if (isGalaxyWatch()) { - DefaultRotaryHapticFeedback(view) + if (isGalaxyWatchClassic() || isGalaxyWatch()) { + GalaxyWatchHapticFeedback(view) } else if (isWear3point5(view.context)) { Wear3point5RotaryHapticFeedback(view) } else if (isWear4AtLeast()) { @@ -372,10 +370,10 @@ private class Wear4AtLeastRotaryHapticFeedback(private val view: View) : RotaryH } /** - * Implementation of [RotaryHapticFeedback] for Galaxy Watch 4 and 6 Classic + * Implementation of [RotaryHapticFeedback] for Galaxy Watches */ @ExperimentalHorologistApi -private class GalaxyWatchClassicHapticFeedback(private val view: View) : RotaryHapticFeedback { +private class GalaxyWatchHapticFeedback(private val view: View) : RotaryHapticFeedback { @ExperimentalHorologistApi override fun performHapticFeedback( @@ -383,15 +381,15 @@ private class GalaxyWatchClassicHapticFeedback(private val view: View) : RotaryH ) { when (type) { RotaryHapticsType.ScrollItemFocus -> { - // No haptic for scroll snap ( we have physical bezel) + view.performHapticFeedback(102) } RotaryHapticsType.ScrollTick -> { - // No haptic for scroll tick ( we have physical bezel) + view.performHapticFeedback(102) } RotaryHapticsType.ScrollLimit -> { - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) + view.performHapticFeedback(50107) } } } From 01f81d149578f393b9cefedc5d67233e4aed5df0 Mon Sep 17 00:00:00 2001 From: mkulaha Date: Fri, 16 Feb 2024 16:35:49 +0000 Subject: [PATCH 2/2] Adding device specific constants for Samsung devices. These constants should bring better consistency with views rotary experience --- .../android/horologist/compose/rotaryinput/HapticsTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose-layout/src/test/java/com/google/android/horologist/compose/rotaryinput/HapticsTest.kt b/compose-layout/src/test/java/com/google/android/horologist/compose/rotaryinput/HapticsTest.kt index 4beebe392f..788f26b6e3 100644 --- a/compose-layout/src/test/java/com/google/android/horologist/compose/rotaryinput/HapticsTest.kt +++ b/compose-layout/src/test/java/com/google/android/horologist/compose/rotaryinput/HapticsTest.kt @@ -116,7 +116,7 @@ class HapticsTest { val hapticFeedback = getHapticFeedback() - assertThat(hapticFeedback.javaClass.simpleName).isEqualTo("GalaxyWatchClassicHapticFeedback") + assertThat(hapticFeedback.javaClass.simpleName).isEqualTo("GalaxyWatchHapticFeedback") } @Test @@ -128,7 +128,7 @@ class HapticsTest { val hapticFeedback = getHapticFeedback() - assertThat(hapticFeedback.javaClass.simpleName).isEqualTo("DefaultRotaryHapticFeedback") + assertThat(hapticFeedback.javaClass.simpleName).isEqualTo("GalaxyWatchHapticFeedback") } private fun getHapticFeedback(): RotaryHapticFeedback {