androidx / androidx/media

Android TV - Default Time Bar D-pad right/left long press does not bring the time bar into focus

Open
#1,828 2 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Oct 25, 2024.

needs triage question
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

I have D-pad right and D-left button usage condition to request focus and clear focus whenever needed
Below is the snippet of it

      boolean isLongPress = event.getRepeatCount() > 0;
        int keyCode = -1;
        // Determine which key code to use based on the action
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            if (isDpadRightAction || isFastForwardAction) {
                keyCode = KeyEvent.KEYCODE_DPAD_RIGHT;
            } else if (isRewindAction || isDpadLeftAction) {
                keyCode = KeyEvent.KEYCODE_DPAD_LEFT;
            }
        }

        // Dispatch the key event if a valid key code was found
        if (defaultTimeBar != null) {
            if (keyCode != -1) {
                if (event.getAction() == KeyEvent.ACTION_DOWN || isLongPress) {
                    defaultTimeBar.requestFocus();
                    defaultTimeBar.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
                    return true;
                }
            } else {
                defaultTimeBar.clearFocus();
            }
        }

Here I also did some debugging and it is getting true for long press so when defaultTimeBar.requestFocus() is added it should bring time bar into focus even when I long press.

It brings the DefaultTimeBar into focus only when I release the button
Also in xml I have focusable set to true for defaulttimebar

If there is something else I need to add to bring it in focus as soon as I press D-pad right or left button whether its single press or long press then please suggest that Thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.