Coder Social home page Coder Social logo

Comments (10)

jpelgrom avatar jpelgrom commented on July 22, 2024 1

A quick test of 1, are you able to add this in and test on that device?

After adding this in, I no longer get any haptic feedback at all even though it is enabled on the Galaxy Watch 4 with Wear OS 4 I'm using.

from horologist.

Kpeved avatar Kpeved commented on July 22, 2024 1

We returned Samsung haptics to its original state, so it should be working as before - haptics setting shouldn't influence compose haptics on GW devices

from horologist.

yschimke avatar yschimke commented on July 22, 2024

Thanks for the report. We can add specific haptics but we would need to know which ones are preferred. I'll see if it's doing something stupid and using the ones for a different model.

Is there documentation for this setting? Or it's a standard wear one?

from horologist.

jpelgrom avatar jpelgrom commented on July 22, 2024

I can confirm the same 'issue' exists on a Samsung Galaxy Watch 4 with the touch bezel (= rotary input on this device). In the system settings app > General > Touch bezel, there is an option "Vibration feedback". Sounds like it is kind of standard Wear but depends on the device what it's called and where it is located.

Turning it off doesn't change the behavior of apps using the rotaryWithScroll modifier, while other apps that (presumably) use a classic ScrollView do change and stop vibrating when rotating. Easy to spot as thin vs thick scroll bar.

from horologist.

blakadder avatar blakadder commented on July 22, 2024

Thanks for the report. We can add specific haptics but we would need to know which ones are preferred. I'll see if it's doing something stupid and using the ones for a different model.

Is there documentation for this setting? Or it's a standard wear one?

Specific or not the existing one is overly aggressive and should be toned down. Best course of action would be to use the same one used in all the standard apps

The setting also exists on the Pixel Watch as "Using crown" - https://www.verizon.com/support/knowledge-base-303381/

from horologist.

yschimke avatar yschimke commented on July 22, 2024

So I think we need to do one of two things

  1. Find the relevant haptics code for this device, or hopefully class of devices.
  2. Fallback to reading the setting, possibly Settings.Global.getInt(context.contentResolver, "wear_vibrate_for_rotary_input")

It's possible neither are public APIs.

A quick test of 1, are you able to add this in and test on that device?

public class LikePixelWatchRotaryHapticFeedback(private val view: View) : RotaryHapticFeedback {

    @ExperimentalHorologistApi
    override fun performHapticFeedback(
        type: RotaryHapticsType,
    ) {
        when (type) {
            RotaryHapticsType.ScrollItemFocus -> {
                view.performHapticFeedback(
                    if (Build.VERSION.SDK_INT >= 33) {
                        ROTARY_SCROLL_ITEM_FOCUS
                    } else {
                        WEAR_SCROLL_ITEM_FOCUS
                    },
                )
            }

            RotaryHapticsType.ScrollTick -> {
                view.performHapticFeedback(
                    if (Build.VERSION.SDK_INT >= 33) ROTARY_SCROLL_TICK else WEAR_SCROLL_TICK,
                )
            }

            RotaryHapticsType.ScrollLimit -> {
                view.performHapticFeedback(
                    if (Build.VERSION.SDK_INT >= 33) ROTARY_SCROLL_LIMIT else WEAR_SCROLL_LIMIT,
                )
            }
        }
    }

    private companion object {
        // Hidden constants from HapticFeedbackConstants.java specific for Pixel Watch
        // API 33
        public const val ROTARY_SCROLL_TICK: Int = 18
        public const val ROTARY_SCROLL_ITEM_FOCUS: Int = 19
        public const val ROTARY_SCROLL_LIMIT: Int = 20

        // API 30
        public const val WEAR_SCROLL_TICK: Int = 10002
        public const val WEAR_SCROLL_ITEM_FOCUS: Int = 10003
        public const val WEAR_SCROLL_LIMIT: Int = 10003
    }
}

you would pass it into

public fun rememberRotaryHapticHandler(
    scrollableState: ScrollableState,
    throttleThresholdMs: Long = 30,
    hapticsThresholdPx: Long = 50,
    hapticsChannel: Channel<RotaryHapticsType> = rememberHapticChannel(),
    rotaryHaptics: RotaryHapticFeedback = rememberDefaultRotaryHapticFeedback(),
): RotaryHapticHandler {

And then that into the scroll modifiers

public fun Modifier.rotaryWithScroll(
    scrollableState: ScrollableState,
    focusRequester: FocusRequester = rememberActiveFocusRequester(),
    flingBehavior: FlingBehavior? = ScrollableDefaults.flingBehavior(),
    rotaryHaptics: RotaryHapticHandler = rememberRotaryHapticHandler(scrollableState),
    reverseDirection: Boolean = false,
): Modifier = rotaryHandler(

from horologist.

yschimke avatar yschimke commented on July 22, 2024

I think we would stick with the current Samsung code. But mainly interested in devices other than pixel or Samsung.

Is the current published code not working for Samsung for you.

from horologist.

Kpeved avatar Kpeved commented on July 22, 2024

I created a prototype branch which should use device specific haptics based on the Wear version rather than specific device.
Change: 40a7940
Branch: https://github.com/google/horologist/tree/version_specific_rotary_haptics_16.10

Please test this solution and see whether it solves your problem @blakadder @jpelgrom .
Unfortunately I don't have a lot of devices at hand for testing so would be great to test that before submitting.

from horologist.

jpelgrom avatar jpelgrom commented on July 22, 2024

Sorry for the delay, I see the change was already merged. I only have a Galaxy Watch 4 to test which is using the same haptics settings as with <= 0.5.8 so nothing to test for me.

from horologist.

yschimke avatar yschimke commented on July 22, 2024

Released with 0.4.16. If still happening, raise an issue with specific device details, but should be fixed.

from horologist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.