Hi, I've ended up on this thread because I've recently got myself an Android Wear OS watch which I've been experimenting with building apps and Bluetooth LE stuff on, and I've had some ideas for stuff to do with a Tesla (but not actually having a Tesla myself makes that a bit difficult for me to try out at the moment, lol). So I thought I'd see what already exists for Tesla on Wear OS anyway (as I see Apple Watch apps mentioned all the time in Tesla groups etc, but never Android Wear). Not having a Tesla, I haven't actually tried your app to see what exactly its UI is like, but:
The Wear OS swipe-to-dismiss thing (and avoiding it) is one of the things I've been experimenting with in my apps, so I just thought I'd mention in case you haven't already realised, you absolutely can disable it and use that gesture for your own purposes. It's explained in the documentation
here, but I'd say not very clearly really, so here's my summary of what I've found by experimenting with each method mentioned there myself:
- You can completely disable swipe-to-dismiss by adding
<item name="android:windowSwipeToDismiss">false</item>
to the app's theme (in styles.xml), or disable it for a single activity by making a child theme with that set and applying that theme to the activity. This is definitely the simplest way to do it, but then you have to provide some other way of going back/exiting the app, or users will have to just use the home (power) button on their watch to get back to their home screen.
- You can try to use a
SwipeDismissFrameLayout
to make only swipes from the very edge of the screen dismiss the activity, but in my experience that was a confusing mess that I couldn't get to work properly. It seems as though all Wear OS activities that don't have android:windowSwipeToDismiss
set to false
in their theme automatically get surrounded in a SwipeDismissFrameLayout
which has some extra stuff set to make it behave in the way that it does, and that part doesn't seem to be documented anywhere (or available in the open source part of Android), so I gave up on trying to make it function the same way while only allowing swipes from the very edge (which the documentation seems to imply should be easy to do!)
- If the
View
that you swipe on returns true
for canScrollHorizontally (int direction)
, that actually prevents the swipe-to-dismiss from occuring (even without doing anything else mentioned above)! I think this should be the case for any standard scrolling View which isn't already scrolled all the way across, but you can also override that method on any view so that it always returns true
. This is what I've settled on for one of my test apps which has a central horizontal RecyclerView
that is sometimes scrollable, sometimes not (depending on how much stuff is in it) - to prevent accidentally closing the app (which currently kills its Bluetooth LE connections), I've made it always return true so that it behaves consistently. The view doesn't quite reach all the way to the edges (at least on a round screen), so swiping from the edge of the screen still works to dismiss the app.
Hope that all makes sense and is of some use to you