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

Fix event handlers for DPad arrows on Android TV #21143

Conversation

krzysztofciombor
Copy link

Fixes #20924
DPad arrow events were missing from KEY_EVENTS_ACTIONS which meant that they were not broadcasted by TVEventHandler.

Test Plan:

  1. DPad arrow events are correctly send to JS and are received by TVEventHandler

    this.tvEventHandler.enable(this, function(cmp, evt) {
      console.log('TVEvent', evt);
    });

    zrzut ekranu 2018-09-17 o 10 08 37

  2. All other events ("select", "playPause", etc.) are still sent correctly
    zrzut ekranu 2018-09-17 o 10 11 10

  3. Navigating between selectable components still works correctly

Release Notes:

[ANDROID] [BUGFIX] [AndroidTV] - Fixed missing DPad arrow event handlers

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 17, 2018
@Weetbix
Copy link

Weetbix commented Sep 19, 2018

Thanks for this :) I tried to fix this myself a while ago but for some reason I couldn't get my RN changes to reflect in my app... Was going to try again but there you've already done it!

With this change it will be possible to manually navigate lists and items (as the built-in touchable navigation behavior is kind of broken), so thanks!

Copy link
Contributor

@mdvacca mdvacca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, but I would keep using the MapBuilder and we can avoid the static block. What do you think?

KeyEvent.KEYCODE_MEDIA_FAST_FORWARD,
"fastForward"
);
private static final Map<Integer, String> KEY_EVENTS_ACTIONS = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can keep using MapBuilder here:

private static final Map<Integer, String> KEY_EVENTS_ACTIONS = MapBuilder.of()
.put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
....
.build();

@krzysztofciombor
Copy link
Author

@mdvacca Updated. Note that I had to use an explicit MapBuilder.<Integer, String>.builder() call, otherwise the returned Map would be of type Map<Object, Object>

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mdvacca has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Sep 24, 2018
@react-native-bot
Copy link
Collaborator

@krzysztofciombor merged commit 4d71b15 into facebook:master.


Once this commit is added to a release, you will see the corresponding version tag below the description at 4d71b15. If the commit has a single master tag, it is not yet part of a release.

@facebook facebook locked as resolved and limited conversation to collaborators Sep 24, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 24, 2018
grabbou pushed a commit that referenced this pull request Oct 2, 2018
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->

Fixes #20924
DPad arrow events were missing from `KEY_EVENTS_ACTIONS` which meant that they were not broadcasted by `TVEventHandler`.
Pull Request resolved: #21143

Differential Revision: D10007851

Pulled By: mdvacca

fbshipit-source-id: 9a03cad249a4a1917975d1de10b6112e69d32a72
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
t-nanava pushed a commit to microsoft/react-native-macos that referenced this pull request Jun 17, 2019
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->

Fixes facebook#20924
DPad arrow events were missing from `KEY_EVENTS_ACTIONS` which meant that they were not broadcasted by `TVEventHandler`.
Pull Request resolved: facebook#21143

Differential Revision: D10007851

Pulled By: mdvacca

fbshipit-source-id: 9a03cad249a4a1917975d1de10b6112e69d32a72
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android TV - TVEventHandler doesn't recognize D-Pad (arrow) event's
6 participants