Skip to content

Commit

Permalink
GH-67 Add TV remote buttons to open search
Browse files Browse the repository at this point in the history
Add "Channel up" and "Search" buttons.
  • Loading branch information
Radiokot committed Oct 8, 2023
1 parent 1a43c39 commit 0b8ea48
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -799,21 +799,29 @@ class GalleryActivity : BaseActivity() {
}
}

override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean = when (keyCode) {
// Hope it works for TV remotes, I can't test it.
if (keyCode in setOf(
KeyEvent.KEYCODE_SETTINGS,
KeyEvent.KEYCODE_MENU,
KeyEvent.KEYCODE_BOOKMARK,
KeyEvent.KEYCODE_TV_INPUT_COMPOSITE_1, // "Context menu" button
KeyEvent.KEYCODE_CHANNEL_DOWN,
)
) {
in setOf(
KeyEvent.KEYCODE_SETTINGS,
KeyEvent.KEYCODE_MENU,
KeyEvent.KEYCODE_BOOKMARK,
KeyEvent.KEYCODE_TV_INPUT_COMPOSITE_1, // "Context menu" button
KeyEvent.KEYCODE_CHANNEL_DOWN,
) -> {
viewModel.onPreferencesButtonClicked()
return true
true
}

in setOf(
KeyEvent.KEYCODE_SEARCH,
KeyEvent.KEYCODE_CHANNEL_UP,
) -> {
view.searchBar.callOnClick()
true
}

return super.onKeyDown(keyCode, event)
else ->
super.onKeyDown(keyCode, event)
}

private val GalleryViewModel.Error.localizedMessage: String
Expand Down

0 comments on commit 0b8ea48

Please sign in to comment.