home-assistant / android

:iphone: Home Assistant Companion for Android

Home Page:https://companion.home-assistant.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Edge Swipe for navigation drawer (2023.4+)

breakthestatic opened this issue · comments

Home Assistant Android app version(s):
2023.3.0-full

Android version(s):
Android 13 (OneUI 5.1)

Device model(s):
Samsung Galaxy S20

Home Assistant version:
2023.4

Last working Home Assistant release (if known):
2023.3

Description of problem, include YAML if issue is related to notifications:
Not very familiar with the background reasoning, but it appears that control of the sidebar needs to be moved over to the companion apps (see home-assistant/iOS#2328 for the iOS-specific work). I looked around the issues and PRs but didn't see any work slated to re-add the gesture on Android.

Companion App Logs:


Screenshot or video of problem:

Additional information:

What happens in Chrome for Android? Do you see the same issue there?

Chrome on Android has its own edge swipe gesture which navigates back in history. Perhaps that's related to the original reason for the removal?

yea we also need to be mindful of android own navigation swipe gestures in addition to our own 3 finger swipe gestures

its own edge swipe gesture which navigates back in history

Isn't that just the default Android back gesture? (available in any app)

Isn't that just the default Android back gesture? (available in any app)

No, there's two separate (but potentially competing) gestures.

I use dedicated navigation buttons (separate back, home & recents), but Chrome specifically has its own left edge swipe that navigates back a page in the browser history, not backwards through the OS app history.

As noted above, there is also the OS-level gesture navigation, which repalces the 3 dedicated buttons with a single bar (similar to iOS). In that paradigm, edge swipes perform an OS-controlled navigation event backwards through the app history (there's also some current work in Android to make the back behavior more intelligent using so AI stuff (https://www.androidpolice.com/android-14-gesture-navigation-predictive-back-excited/, but I think that is a bit tangential).

When I was experimenting with the gesture navigation in the past, even though edge swipe was controlled by the OS, you could still trigger the hamburger expansion by holding the left edge for a moment before actually swiping.

Relabeling this as a feature request because removal from the frontend was intentional.

Adding a gesture to the app could restore some of the functionality, but it won't exactly match the old behavior because of the split between frontend and app. Also related: #2180 (which is 10x harder because of the drawer's complexity).

Is this feature coming back? I can't go to the menu anymore on companion app, cause I have kiosk mode Running (no title bar)
Thnx

Huge limitation for kiosk mode

commented

I instantly noticed this. Now I cannot get my menu back easily in app.

@jpelgrom This is a critical feature that all but one of my devices relied on and family members are getting frustrated with. Was this removal planned? I can rework my frontend but I didn't see anything on the breaking changes for 2023.4. If it was I would have waited to update. I can always roll back but I won't have time to do that for at least a couple of weeks - work is insane.

I don't know if it was planned or simply merged because it was ready, I don't work on the frontend. Agree it would have been nice if it was listed in the breaking changes. The related change has taken 1.5 years with long periods of inactivity; home-assistant/frontend#10335.

I'm having this issue on iOS too. I don't like the cluttered navigation bar so I got rid of the icons a-la kiosk mode with card-mod themes, but used swipe to access the sidebar on mobile. This feature really needs to come back.

I managed to get the sidebar to show via browser_mod.javascript service call.
Just add this to a button or an element on your frontend and when clicked it will show the sidebar.
There may be a more elegant way of doing this but it works.

tap_action:
  action: fire-dom-event
  browser_mod:
    service: browser_mod.javascript
    data:
      browser_id: THIS
      code: "document.querySelector('body > home-assistant').shadowRoot.querySelector('home-assistant-main').dispatchEvent(new CustomEvent('hass-toggle-menu', {detail: {open: true}}));"

Nope, updated to current HA version, cleared app cache and start the app. It still doesn't work.

I managed to get the sidebar to show via browser_mod.javascript service call. Just add this to a button or an element on your frontend and when clicked it will show the sidebar. There may be a more elegant way of doing this but it works.

tap_action:
  action: fire-dom-event
  browser_mod:
    service: browser_mod.javascript
    data:
      browser_id: THIS
      code: "document.querySelector('body > home-assistant').shadowRoot.querySelector('home-assistant-main').dispatchEvent(new CustomEvent('hass-toggle-menu', {detail: {open: true}}));"

Mushroom cards have "Menu" chip and it works too, but from lovelace page only. If I go deep into settings of HA companion, I have to press the back key ten times at the top of the screen and have to reach, it's annoying.

commented

Please bring this back on android, the companion app is now incredibly annoying to navigate, and in some cases, unusable.

This is a frustrating change considering the button to open the sidebar is the furthest position from where my thumb is.

Same problem here using Android APP.

I can live without the swipe feature missing, but the back button on the top does not work at all.
Basically there is no native way to get back to the sidebar, essentially losing functionality.

I was missing some of the basics on how to reproduce this solution, so after figuring out the missing steps posting this for other newbies like me here is a script for reference; once script is created just add it to dashboard.

  1. Install "browser_mod 2" from HACS
  2. Create below script
  3. Add script to your dashboard (HA Show Sidebar), position it to the top ideally.
alias: HA Show Sidebar
sequence:
  - service: browser_mod.javascript
    data:
      code: >-
        document.querySelector('body >
        home-assistant').shadowRoot.querySelector('home-assistant-main').dispatchEvent(new
        CustomEvent('hass-toggle-menu', {detail: {open: true}}));
mode: single
icon: phu:playback-button
commented

I have a hard time understanding what's being solved here.

I have 2 issues after updating the app:

  1. The swiping between tabs did not work anymore. In the meantime I have updated to https://github.com/zanna-37/hass-swipe-navigation and that solved that issue.
  2. I used to swipe from left to right and show the menu (ipanel?) of homeassistant. This is now gone and still not working. I mis it every time opening the app.

What solution from above is for what and what do I exactly need to do to restore the behavior for number 2?

The solution (workaround) is for point 2 , to swipe from left to right to show menu

commented

3. Add script to your dashboard (HA Show Sidebar), position it to the top ideally.

How and where do I do this:
Add script to your dashboard (HA Show Sidebar), position it to the top ideally.

I don't use it as a script, but behind a button with tap action

commented

Sorry, I do not get what I need to do now. Can you please describe what and how and where I need to do?

commented

"use this"... do you mean when I put the code under a button I need to press the button? In order to get the sidebar?

Correct! It's a temp workaround

Guys any news here?
Is there in plan to return us old gesture or any new?
There is so much painful to navigate without sidebar.
Card/button isn't good answer, because I cant access sidebar from deep of HA setting, for example, or one of tons lovelace pages without those cards.

Chrome on Android has its own edge swipe gesture which navigates back in history. Perhaps that's related to the original reason for the removal?

The left swiping back gesture while using gesture navigation would interfere with the menu coming out and cause it to come out for 1px making the whole sidebar navigation unusable and piss me off to the point of multiple times wanting to throw my phone out. I'm glad its gone.

The left swiping back gesture while using gesture navigation would interfere with the menu coming out and cause it to come out for 1px making the whole sidebar navigation unusable and piss me off to the point of multiple times wanting to throw my phone out. I'm glad its gone.

There's actually a common pattern for apps that use a hamburger menu still which utilizes a quick tap and pause before swiping to differentiate between the OS nav gesture and sidebar swiping. The initial tap and hold makes the sidebar start to peek out and if you then swipe it won't trigger the OS gesture.

One of the nice things about Android is choice and customization. It would be great if users could turn the app gesture on or off to suit their needs.

FYI for all who are interested - since I hadn't seen any movement on this ticket, I went ahead and wrote a quick front-end utility loaded via the web to restore this functionality. If you're interested, check out https://github.com/breakthestatic/hass-sidebar-swipe.

FYI for all who are interested - since I hadn't seen any movement on this ticket, I went ahead and wrote a quick front-end utility loaded via the web to restore this functionality. If you're interested, check out https://github.com/breakthestatic/hass-sidebar-swipe.

Thank you @breakthestatic, it works great! 😄

@breakthestatic considering this is a JS hack around a basic navigation issue I must say it works really well. From my perspective there is just one minor giveaway that it is not "right": when the drawer is open, pressing the back key should really just close the drawer, at present it closes the activity, but I can certainly live with that compared to the alternative. Hats off!

That is a good idea. Dealing with overriding browser/webview navigation events can be a bit thorny, but I'll definitely look into this. I created an issue in my repo to track it: breakthestatic/hass-sidebar-swipe#2. Please feel free to add anything else you think might be pertinent!