Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding device specific haptic constants for Samsung devices. #2035

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -372,26 +370,26 @@ 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(
type: RotaryHapticsType,
) {
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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class HapticsTest {

val hapticFeedback = getHapticFeedback()

assertThat(hapticFeedback.javaClass.simpleName).isEqualTo("GalaxyWatchClassicHapticFeedback")
assertThat(hapticFeedback.javaClass.simpleName).isEqualTo("GalaxyWatchHapticFeedback")
}

@Test
Expand All @@ -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 {
Expand Down
Loading