react-native-tvos 0.73.7-0 → 0.73.7-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Core/ReactNativeVersion.js +10 -4
- package/README.md +2 -0
- package/React/Base/RCTVersion.m +3 -3
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/publish.gradle +51 -45
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +3 -3
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java +9 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +1 -3
- package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java +18 -0
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/package.json +3 -3
- package/sdks/.hermesversion +1 -1
- package/template/package.json +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java +0 -98
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated by scripts/set-rn-version.js
|
|
3
|
-
*
|
|
4
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
3
|
*
|
|
6
4
|
* This source code is licensed under the MIT license found in the
|
|
7
5
|
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @flow strict
|
|
8
|
+
* @generated by scripts/releases/set-rn-version.js
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
const version: $ReadOnly<{
|
|
12
|
+
major: number,
|
|
13
|
+
minor: number,
|
|
14
|
+
patch: number,
|
|
15
|
+
prerelease: string | null,
|
|
16
|
+
}> = {
|
|
13
17
|
major: 0,
|
|
14
18
|
minor: 73,
|
|
15
19
|
patch: 7,
|
|
16
|
-
prerelease: '
|
|
20
|
+
prerelease: '2',
|
|
17
21
|
};
|
|
22
|
+
|
|
23
|
+
module.exports = {version};
|
package/README.md
CHANGED
|
@@ -202,6 +202,8 @@ class Game2048 extends React.Component {
|
|
|
202
202
|
- `enableTVPanGesture`/`disableTVPanGesture`: Methods to enable and disable detection of finger touches that pan across the touch surface of the Siri remote. See `TVEventHandlerExample` in the `RNTester` app for a demo.
|
|
203
203
|
- `enableGestureHandlersCancelTouches`/`disableGestureHandlersCancelTouches`: Methods to turn on and turn off cancellation of touches by the gesture handlers in `RCTTVRemoteHandler` (see #366). Cancellation of touches is turned on (enabled) by default in 0.69 and earlier releases.
|
|
204
204
|
|
|
205
|
+
- Accessibility: We have an additional `accessibilityFocus` [accessibility action](https://reactnative.dev/docs/accessibility#accessibility-actions) on Android that you can use for detecting focus changes on every *accessible* element (like a regular `Text`) when `TalkBack` is enabled.
|
|
206
|
+
|
|
205
207
|
- _TVFocusGuideView_: This component provides support for Apple's `UIFocusGuide` API and is implemented in the same way for Android TV, to help ensure that focusable controls can be navigated to, even if they are not directly in line with other controls. An example is provided in `RNTester` that shows two different ways of using this component.
|
|
206
208
|
|
|
207
209
|
| Prop | Value | Description |
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated by scripts/set-rn-version.js
|
|
3
|
-
*
|
|
4
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
3
|
*
|
|
6
4
|
* This source code is licensed under the MIT license found in the
|
|
7
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @generated by scripts/releases/set-rn-version.js
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
#import "RCTVersion.h"
|
|
@@ -24,7 +24,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
|
|
|
24
24
|
RCTVersionMajor: @(0),
|
|
25
25
|
RCTVersionMinor: @(73),
|
|
26
26
|
RCTVersionPatch: @(7),
|
|
27
|
-
RCTVersionPrerelease: @"
|
|
27
|
+
RCTVersionPrerelease: @"2",
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
return __rnVersion;
|
|
@@ -3,18 +3,25 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* This file is modified from the original Meta source to work in the
|
|
8
|
+
* `react-native-ci` project.
|
|
6
9
|
*/
|
|
10
|
+
/* groovylint-disable CompileStatic, DuplicateStringLiteral, LineLength, NestedBlockDepth, NoDef, UnusedVariable, VariableTypeRequired */
|
|
7
11
|
|
|
8
12
|
apply plugin: 'maven-publish'
|
|
9
13
|
apply plugin: 'signing'
|
|
10
14
|
|
|
11
|
-
def
|
|
12
|
-
|
|
13
|
-
def
|
|
15
|
+
def isSnapshot = false
|
|
16
|
+
// Rewritten when copying this to ReactAndroid/publish.gradle
|
|
17
|
+
def signingKey = findProperty('SIGNING_KEY')
|
|
18
|
+
def signingPwd = findProperty('SIGNING_PWD')
|
|
19
|
+
def sonatypeUsername = findProperty('SONATYPE_USERNAME')
|
|
20
|
+
def sonatypePassword = findProperty('SONATYPE_PASSWORD')
|
|
14
21
|
|
|
15
22
|
def reactAndroidProjectDir = project(':packages:react-native:ReactAndroid').projectDir
|
|
16
|
-
def
|
|
17
|
-
|
|
23
|
+
def mavenTempLocalUrl = 'file:///var/folders/xp/yw_lp59x05d2mp0g0n2f_d240000gn/T/eas-build-workingdir/build/maven_local'
|
|
24
|
+
// Rewritten when copying this to ReactAndroid/publish.gradle
|
|
18
25
|
|
|
19
26
|
publishing {
|
|
20
27
|
publications {
|
|
@@ -22,43 +29,43 @@ publishing {
|
|
|
22
29
|
afterEvaluate {
|
|
23
30
|
// We do a multi variant release, so for Android libraries
|
|
24
31
|
// we publish `components.release`
|
|
25
|
-
if (plugins.hasPlugin(
|
|
32
|
+
if (plugins.hasPlugin('com.android.library')) {
|
|
26
33
|
from components.default
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
// We populate the publishing version using the project version,
|
|
31
|
-
// appending -SNAPSHOT if on nightly.
|
|
32
|
-
if (
|
|
33
|
-
version = this.version +
|
|
38
|
+
// appending -SNAPSHOT if on nightly or prerelase.
|
|
39
|
+
if (isSnapshot) {
|
|
40
|
+
version = this.version + '-SNAPSHOT'
|
|
34
41
|
} else {
|
|
35
42
|
version = this.version
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
pom {
|
|
39
|
-
name =
|
|
40
|
-
description =
|
|
41
|
-
url =
|
|
46
|
+
name = 'react-native'
|
|
47
|
+
description = 'A framework for building native apps with React'
|
|
48
|
+
url = 'https://github.com/facebook/react-native'
|
|
42
49
|
|
|
43
50
|
developers {
|
|
44
51
|
developer {
|
|
45
|
-
id =
|
|
46
|
-
name =
|
|
52
|
+
id = 'facebook'
|
|
53
|
+
name = 'Facebook'
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
licenses {
|
|
51
58
|
license {
|
|
52
|
-
name =
|
|
53
|
-
url =
|
|
54
|
-
distribution =
|
|
59
|
+
name = 'MIT License'
|
|
60
|
+
url = 'https://github.com/facebook/react-native/blob/HEAD/LICENSE'
|
|
61
|
+
distribution = 'repo'
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
scm {
|
|
59
|
-
url =
|
|
60
|
-
connection =
|
|
61
|
-
developerConnection =
|
|
66
|
+
url = 'https://github.com/facebook/react-native.git'
|
|
67
|
+
connection = 'scm:git:https://github.com/facebook/react-native.git'
|
|
68
|
+
developerConnection = 'scm:git:git@github.com:facebook/react-native.git'
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -66,35 +73,34 @@ publishing {
|
|
|
66
73
|
|
|
67
74
|
repositories {
|
|
68
75
|
maven {
|
|
69
|
-
name =
|
|
70
|
-
url =
|
|
76
|
+
name = 'mavenTempLocal'
|
|
77
|
+
url = mavenTempLocalUrl
|
|
71
78
|
}
|
|
72
79
|
maven {
|
|
73
|
-
name =
|
|
74
|
-
url =
|
|
80
|
+
name = 'sonatypeRelease'
|
|
81
|
+
url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
|
|
82
|
+
credentials(PasswordCredentials) {
|
|
83
|
+
username = sonatypeUsername
|
|
84
|
+
password = sonatypePassword
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
maven {
|
|
88
|
+
name = 'sonatypeSnapshot'
|
|
89
|
+
url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
|
90
|
+
credentials(PasswordCredentials) {
|
|
91
|
+
username = sonatypeUsername
|
|
92
|
+
password = sonatypePassword
|
|
93
|
+
}
|
|
75
94
|
}
|
|
76
95
|
}
|
|
77
96
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// }
|
|
87
|
-
|
|
88
|
-
// For the TV repo, we sign manually for now, using the gpg command line tool.
|
|
89
|
-
// Properties that need to be set:
|
|
90
|
-
//
|
|
91
|
-
// signing.gnupg.executable=gpg
|
|
92
|
-
// signing.gnupg.useLegacyGpg=true
|
|
93
|
-
// signing.gnupg.keyName=(your key ID)
|
|
94
|
-
// signing.keyId=(your key ID)
|
|
95
|
-
// signing.secretKeyRingFile=(file with your exported secret keys)
|
|
96
|
-
signing {
|
|
97
|
-
useGpgCmd()
|
|
98
|
-
sign(publishing.publications.release)
|
|
97
|
+
if (signingKey && signingPwd) {
|
|
98
|
+
logger.info('PGP Key found - Signing enabled')
|
|
99
|
+
signing {
|
|
100
|
+
useInMemoryPgpKeys(signingKey, signingPwd)
|
|
101
|
+
sign(publishing.publications.release)
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
logger.info('Signing disabled as the PGP key was not found')
|
|
99
105
|
}
|
|
100
106
|
}
|
package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated by scripts/set-rn-version.js
|
|
3
|
-
*
|
|
4
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
3
|
*
|
|
6
4
|
* This source code is licensed under the MIT license found in the
|
|
7
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @generated by scripts/releases/set-rn-version.js
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
package com.facebook.react.modules.systeminfo;
|
|
@@ -18,5 +18,5 @@ public class ReactNativeVersion {
|
|
|
18
18
|
"major", 0,
|
|
19
19
|
"minor", 73,
|
|
20
20
|
"patch", 7,
|
|
21
|
-
"prerelease", "
|
|
21
|
+
"prerelease", "2");
|
|
22
22
|
}
|
package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java
CHANGED
|
@@ -76,6 +76,7 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
|
|
|
76
76
|
sActionIdMap.put("decrement", AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.getId());
|
|
77
77
|
sActionIdMap.put("expand", AccessibilityActionCompat.ACTION_EXPAND.getId());
|
|
78
78
|
sActionIdMap.put("collapse", AccessibilityActionCompat.ACTION_COLLAPSE.getId());
|
|
79
|
+
sActionIdMap.put("accessibilityFocus", AccessibilityActionCompat.ACTION_ACCESSIBILITY_FOCUS.getId());
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
private final View mView;
|
|
@@ -602,6 +603,7 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
|
|
|
602
603
|
final AccessibilityRole accessibilityRole =
|
|
603
604
|
(AccessibilityRole) host.getTag(R.id.accessibility_role);
|
|
604
605
|
final ReadableMap accessibilityValue = (ReadableMap) host.getTag(R.id.accessibility_value);
|
|
606
|
+
|
|
605
607
|
if (accessibilityRole == AccessibilityRole.ADJUSTABLE
|
|
606
608
|
&& (action == AccessibilityActionCompat.ACTION_SCROLL_FORWARD.getId()
|
|
607
609
|
|| action == AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.getId())) {
|
|
@@ -610,6 +612,13 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
|
|
|
610
612
|
}
|
|
611
613
|
return super.performAccessibilityAction(host, action, args);
|
|
612
614
|
}
|
|
615
|
+
|
|
616
|
+
// When checking the accessibility focus action, we don't want to intercept the native event
|
|
617
|
+
// otherwise it would intercept the change of focus
|
|
618
|
+
if (action == AccessibilityActionCompat.ACTION_ACCESSIBILITY_FOCUS.getId()) {
|
|
619
|
+
return super.performAccessibilityAction(host, action, args);
|
|
620
|
+
}
|
|
621
|
+
|
|
613
622
|
return true;
|
|
614
623
|
}
|
|
615
624
|
return super.performAccessibilityAction(host, action, args);
|
|
@@ -89,8 +89,6 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
|
|
89
89
|
private boolean mPropertyRequiresNewDialog;
|
|
90
90
|
private @Nullable DialogInterface.OnShowListener mOnShowListener;
|
|
91
91
|
private @Nullable OnRequestCloseListener mOnRequestCloseListener;
|
|
92
|
-
private final ReactAndroidHWInputDeviceHelper mAndroidHWInputDeviceHelper =
|
|
93
|
-
new ReactAndroidHWInputDeviceHelper();
|
|
94
92
|
|
|
95
93
|
public ReactModalHostView(ThemedReactContext context) {
|
|
96
94
|
super(context);
|
|
@@ -304,7 +302,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
|
|
304
302
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
|
305
303
|
// Modal needs to send the key event to its own TV event handler
|
|
306
304
|
// https://github.com/react-native-tvos/react-native-tvos/issues/609
|
|
307
|
-
mAndroidHWInputDeviceHelper.handleKeyEvent(event, mHostView.mReactContext);
|
|
305
|
+
mHostView.mAndroidHWInputDeviceHelper.handleKeyEvent(event, mHostView.mReactContext);
|
|
308
306
|
if (event.getAction() == KeyEvent.ACTION_UP) {
|
|
309
307
|
// We need to stop the BACK button and ESCAPE key from closing the dialog by default
|
|
310
308
|
// so we capture that event and instead inform JS so that it can make the decision as
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
package com.facebook.react.views.view;
|
|
9
9
|
|
|
10
10
|
import android.annotation.TargetApi;
|
|
11
|
+
import android.content.Context;
|
|
12
|
+
import android.content.pm.PackageManager;
|
|
11
13
|
import android.graphics.Rect;
|
|
12
14
|
import android.os.Build;
|
|
13
15
|
import android.util.Log;
|
|
@@ -81,6 +83,14 @@ public class ReactViewManager extends ReactClippingViewManager<ReactViewGroup> {
|
|
|
81
83
|
@ReactProp(name = "accessible")
|
|
82
84
|
public void setAccessible(ReactViewGroup view, boolean accessible) {
|
|
83
85
|
view.setFocusable(accessible);
|
|
86
|
+
// This is required to handle Android TV/ Fire TV Devices that are Touch Enabled as well as LeanBack
|
|
87
|
+
// https://developer.android.com/reference/android/view/View#requestFocus(int,%20android.graphics.Rect)
|
|
88
|
+
// ** A view will not actually take focus if it is not focusable (isFocusable() returns false), **
|
|
89
|
+
// ** or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode()) **
|
|
90
|
+
// ** while the device is in touch mode. **
|
|
91
|
+
if (hasTouchScreen(view.getContext())) {
|
|
92
|
+
view.setFocusableInTouchMode(accessible);
|
|
93
|
+
}
|
|
84
94
|
}
|
|
85
95
|
|
|
86
96
|
@ReactProp(name = "hasTVPreferredFocus")
|
|
@@ -432,6 +442,14 @@ public class ReactViewManager extends ReactClippingViewManager<ReactViewGroup> {
|
|
|
432
442
|
root.setFocusDestinations(fd);
|
|
433
443
|
}
|
|
434
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Utility function to help capture Android TV/ Fire TV Devices with Touch Support
|
|
447
|
+
*/
|
|
448
|
+
private boolean hasTouchScreen(Context context) {
|
|
449
|
+
PackageManager pm = context.getPackageManager();
|
|
450
|
+
return pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);
|
|
451
|
+
}
|
|
452
|
+
|
|
435
453
|
@ReactProp(name = "autoFocus")
|
|
436
454
|
public void setAutoFocusTV(ReactViewGroup view, boolean autoFocus) {
|
|
437
455
|
view.setAutoFocusTV(autoFocus);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @generated by scripts/set-rn-version.js
|
|
7
|
+
* @generated by scripts/releases/set-rn-version.js
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
#pragma once
|
|
@@ -18,7 +18,7 @@ constexpr struct {
|
|
|
18
18
|
int32_t Major = 0;
|
|
19
19
|
int32_t Minor = 73;
|
|
20
20
|
int32_t Patch = 7;
|
|
21
|
-
std::string_view Prerelease = "
|
|
21
|
+
std::string_view Prerelease = "2";
|
|
22
22
|
} ReactNativeVersion;
|
|
23
23
|
|
|
24
24
|
} // namespace facebook::react
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-tvos",
|
|
3
|
-
"version": "0.73.7-
|
|
3
|
+
"version": "0.73.7-2",
|
|
4
4
|
"description": "A framework for building native apps using React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@react-native/gradle-plugin": "0.73.4",
|
|
104
104
|
"@react-native/js-polyfills": "0.73.1",
|
|
105
105
|
"@react-native/normalize-colors": "0.73.2",
|
|
106
|
-
"@react-native-tvos/virtualized-lists": "0.73.7-
|
|
106
|
+
"@react-native-tvos/virtualized-lists": "0.73.7-2",
|
|
107
107
|
"abort-controller": "^3.0.0",
|
|
108
108
|
"anser": "^1.4.9",
|
|
109
109
|
"ansi-regex": "^5.0.0",
|
|
@@ -153,4 +153,4 @@
|
|
|
153
153
|
"devDependencies": {
|
|
154
154
|
"react-native-core": "npm:react-native@0.73.7"
|
|
155
155
|
}
|
|
156
|
-
}
|
|
156
|
+
}
|
package/sdks/.hermesversion
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
hermes-2024-
|
|
1
|
+
hermes-2024-02-20-RNv0.73.5-18f99ace4213052c5e7cdbcd39ee9766cd5df7e4
|
package/template/package.json
CHANGED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
package com.facebook.react;
|
|
9
|
-
|
|
10
|
-
import android.view.KeyEvent;
|
|
11
|
-
import android.view.View;
|
|
12
|
-
import com.facebook.react.bridge.WritableMap;
|
|
13
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
14
|
-
import com.facebook.react.common.MapBuilder;
|
|
15
|
-
import java.util.Map;
|
|
16
|
-
|
|
17
|
-
/** Responsible for dispatching events specific for hardware inputs. */
|
|
18
|
-
public class ReactAndroidHWInputDeviceHelper {
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Contains a mapping between handled KeyEvents and the corresponding navigation event that should
|
|
22
|
-
* be fired when the KeyEvent is received.
|
|
23
|
-
*/
|
|
24
|
-
private static final Map<Integer, String> KEY_EVENTS_ACTIONS =
|
|
25
|
-
MapBuilder.<Integer, String>builder()
|
|
26
|
-
.put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
|
|
27
|
-
.put(KeyEvent.KEYCODE_ENTER, "select")
|
|
28
|
-
.put(KeyEvent.KEYCODE_SPACE, "select")
|
|
29
|
-
.put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause")
|
|
30
|
-
.put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind")
|
|
31
|
-
.put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward")
|
|
32
|
-
.put(KeyEvent.KEYCODE_MEDIA_STOP, "stop")
|
|
33
|
-
.put(KeyEvent.KEYCODE_MEDIA_NEXT, "next")
|
|
34
|
-
.put(KeyEvent.KEYCODE_MEDIA_PREVIOUS, "previous")
|
|
35
|
-
.put(KeyEvent.KEYCODE_DPAD_UP, "up")
|
|
36
|
-
.put(KeyEvent.KEYCODE_DPAD_RIGHT, "right")
|
|
37
|
-
.put(KeyEvent.KEYCODE_DPAD_DOWN, "down")
|
|
38
|
-
.put(KeyEvent.KEYCODE_DPAD_LEFT, "left")
|
|
39
|
-
.put(KeyEvent.KEYCODE_INFO, "info")
|
|
40
|
-
.put(KeyEvent.KEYCODE_MENU, "menu")
|
|
41
|
-
.build();
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* We keep a reference to the last focused view id so that we can send it as a target for key
|
|
45
|
-
* events and be able to send a blur event when focus changes.
|
|
46
|
-
*/
|
|
47
|
-
private int mLastFocusedViewId = View.NO_ID;
|
|
48
|
-
|
|
49
|
-
private final ReactRootView mReactRootView;
|
|
50
|
-
|
|
51
|
-
ReactAndroidHWInputDeviceHelper(ReactRootView mReactRootView) {
|
|
52
|
-
this.mReactRootView = mReactRootView;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Called from {@link ReactRootView}. This is the main place the key events are handled. */
|
|
56
|
-
public void handleKeyEvent(KeyEvent ev) {
|
|
57
|
-
int eventKeyCode = ev.getKeyCode();
|
|
58
|
-
int eventKeyAction = ev.getAction();
|
|
59
|
-
if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN)
|
|
60
|
-
&& KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
|
|
61
|
-
dispatchEvent(KEY_EVENTS_ACTIONS.get(eventKeyCode), mLastFocusedViewId, eventKeyAction);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Called from {@link ReactRootView} when focused view changes. */
|
|
66
|
-
public void onFocusChanged(View newFocusedView) {
|
|
67
|
-
if (mLastFocusedViewId == newFocusedView.getId()) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (mLastFocusedViewId != View.NO_ID) {
|
|
71
|
-
dispatchEvent("blur", mLastFocusedViewId);
|
|
72
|
-
}
|
|
73
|
-
mLastFocusedViewId = newFocusedView.getId();
|
|
74
|
-
dispatchEvent("focus", newFocusedView.getId());
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Called from {@link ReactRootView} when the whole view hierarchy looses focus. */
|
|
78
|
-
public void clearFocus() {
|
|
79
|
-
if (mLastFocusedViewId != View.NO_ID) {
|
|
80
|
-
dispatchEvent("blur", mLastFocusedViewId);
|
|
81
|
-
}
|
|
82
|
-
mLastFocusedViewId = View.NO_ID;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private void dispatchEvent(String eventType, int targetViewId) {
|
|
86
|
-
dispatchEvent(eventType, targetViewId, -1);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private void dispatchEvent(String eventType, int targetViewId, int eventKeyAction) {
|
|
90
|
-
WritableMap event = new WritableNativeMap();
|
|
91
|
-
event.putString("eventType", eventType);
|
|
92
|
-
event.putInt("eventKeyAction", eventKeyAction);
|
|
93
|
-
if (targetViewId != View.NO_ID) {
|
|
94
|
-
event.putInt("tag", targetViewId);
|
|
95
|
-
}
|
|
96
|
-
mReactRootView.sendEvent("onHWKeyEvent", event);
|
|
97
|
-
}
|
|
98
|
-
}
|