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

Cant navigate to search field on android tv #67

Open
ippocratis opened this issue Jul 28, 2023 · 9 comments
Open

Cant navigate to search field on android tv #67

ippocratis opened this issue Jul 28, 2023 · 9 comments
Labels
wontfix This will not be worked on

Comments

@ippocratis
Copy link
Contributor

There is no way I can navigate and use the search field on android TV with a TV remote

@Radiokot
Copy link
Owner

The search view is quite complicated to adapt it for keyboard navigation, unfortunately I have no time to do it now.

@Radiokot Radiokot added the bug Something isn't working label Jul 29, 2023
@rrednaxela
Copy link

Maybe as a workaround for Android TV users you could add a key mapping to focus the search bar?
I managed to get the following to work:
in your method "onKeyDown" in the GalleryActivity view I added

else if (keyCode in setOf(
                KeyEvent.KEYCODE_8
                )
            ) {
            view.searchBar.requestFocus()
        }

which sets the focus to the SearchBar when the key 8 is pressed on the remote. By pressing OK on DPad, you get into the search view then.
I tried to find a more meaningful key mapping, but I was having trouble to find out the right name/key for the buttons on my remote.
For the settings dialogue, neither KEYCODE_SETTINGS, KEYCODE_MENU, KEYCODE_BOOKMARK were working with my remote... I'll try to debug the key mappings further when I have more time.

@Radiokot
Copy link
Owner

Radiokot commented Oct 4, 2023

@rrednaxela thanks for investigating 🔎

@rrednaxela
Copy link

So I found this app to get reliable key codes for my remote contorl, and from Android Developer you can get the matching KeyEvent.
Turns out that on my remote the button "context menu" has the key event KEYCODE_TV_INPUT_COMPOSITE_1 (which makes little sense).
Most Android TV remote controls will however very likely have the keys KEYCODE_CHANNEL_UP and KEYCODE_CHANNEL_DOWN (used in TV mode to switch channels).
So I would suggest to map
KEYCODE_CHANNEL_UP to the searchview, and
KEYCODE_CHANNEL_DOWN to the preferences, i.e. viewModel.onPreferencesButtonClicked() - this should work for any user I guess.

@Radiokot is there a method or could you add one to directly open the search view, similar to how viewModel.onPreferencesButtonClicked() opens the preferences?
My try of view.searchBar.requestFocus() requires to press DPAD-OK afterwards, which is an unnecessary click.

If we can implement this and add a short hint for it on first launch for Android TV users, you can maybe finally get it approved for the TV store ;)

@Radiokot
Copy link
Owner

Radiokot commented Oct 7, 2023

Many thanks for debugging key inputs from your remote control. I'll add CHANNEL_DOWN and INPUT_COMPOSITE_1 to the bindings which open the settings screen.
The search, however, is more complicated case. It is not only about the search bar focus. The search configuration view is hard to adapt for keyboard navigation, unfortunately I have no time to do it now.

@rrednaxela
Copy link

What exactly do you mean?
I was able to navigate the search view and select/remove people or albums with the dpad. It's not perfect but definitely doable.
We do however need to be able to open it in an easy way :)

@Radiokot
Copy link
Owner

Radiokot commented Oct 8, 2023

Wow, that's interesting 🤔 On TV emulator, I wasn't able to do almost anything useful.

Radiokot added a commit that referenced this issue Oct 8, 2023
Add "Context menu" and "Channel down" buttons.
Radiokot added a commit that referenced this issue Oct 8, 2023
Add "Channel up" and "Search" buttons.
@rrednaxela
Copy link

Thanks for adding the channel up button to open search 🚀 🚀 🚀
I am able to browse an album now on my TV.
I also tried the TV simulator; the behavior is somewhat similar to real TV: after opening the search, it is at first unclear what is active, but if you press dpad-right 4-5 times, you'll suddenly see the albums becoming active. It would probably help if there was more contrast for the selected/hovered album (not just light-grey/grey).
with dpad-down you can navigate to the apply button; this part isn't always working. I'll debug it further when I have time.

@ippocratis
Copy link
Contributor Author

ippocratis commented Oct 16, 2023

Channel up button opens search screen.
Left/right on the dpad enables the cursor so that you can navigate to the search screen elements.
OK button while on the search bar pops up the keyboard and you can type search filters.
After enabling the cursor you can use up,down,left,right to navigate to people,album,type select with OK and use the apply button.

Nice work.

Thanks @Radiokot and thanks @rrednaxela for helping this happen

@Radiokot Radiokot added wontfix This will not be worked on and removed bug Something isn't working labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants