Sfoglia il codice sorgente

[RN] Drop react-native-locale-detector dependency

The upstream package has been unmaintained for 2 years now, and making the litle
changes needed as React Native needs them is getting old. The actual
funcionality is a couple of one-liners plus tons of boliterplate, which gets
reduced by quite a bit if we just embed it. So here it goes.
j8
Saúl Ibarra Corretgé 6 anni fa
parent
commit
26ba974757

+ 0
- 1
android/sdk/build.gradle Vedi File

40
     implementation project(':react-native-immersive')
40
     implementation project(':react-native-immersive')
41
     implementation project(':react-native-keep-awake')
41
     implementation project(':react-native-keep-awake')
42
     implementation project(':react-native-linear-gradient')
42
     implementation project(':react-native-linear-gradient')
43
-    implementation project(':react-native-locale-detector')
44
     implementation project(':react-native-sound')
43
     implementation project(':react-native-sound')
45
     implementation project(':react-native-vector-icons')
44
     implementation project(':react-native-vector-icons')
46
     implementation project(':react-native-webrtc')
45
     implementation project(':react-native-webrtc')

+ 58
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/LocaleDetector.java Vedi File

1
+/*
2
+ * Copyright @ 2018-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+/*
18
+ * Based on https://github.com/DylanVann/react-native-locale-detector
19
+ */
20
+
21
+package org.jitsi.meet.sdk;
22
+
23
+import android.content.Context;
24
+
25
+import com.facebook.react.bridge.ReactApplicationContext;
26
+import com.facebook.react.bridge.ReactContextBaseJavaModule;
27
+
28
+import java.util.HashMap;
29
+import java.util.Map;
30
+
31
+/**
32
+ * Module which provides information about the system locale.
33
+ */
34
+class LocaleDetector extends ReactContextBaseJavaModule {
35
+
36
+    public LocaleDetector(ReactApplicationContext reactContext) {
37
+        super(reactContext);
38
+    }
39
+
40
+    /**
41
+     * Gets a {@code Map} of constants this module exports to JS. Supports JSON
42
+     * types.
43
+     *
44
+     * @return a {@link Map} of constants this module exports to JS
45
+     */
46
+    @Override
47
+    public Map<String, Object> getConstants() {
48
+        Context context = getReactApplicationContext();
49
+        HashMap<String,Object> constants = new HashMap<>();
50
+        constants.put("locale", context.getResources().getConfiguration().locale.toString());
51
+        return constants;
52
+    }
53
+
54
+    @Override
55
+    public String getName() {
56
+        return "LocaleDetector";
57
+    }
58
+}

+ 1
- 1
android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java Vedi File

42
             new AppInfoModule(reactContext),
42
             new AppInfoModule(reactContext),
43
             new AudioModeModule(reactContext),
43
             new AudioModeModule(reactContext),
44
             new ExternalAPIModule(reactContext),
44
             new ExternalAPIModule(reactContext),
45
+            new LocaleDetector(reactContext),
45
             new PictureInPictureModule(reactContext),
46
             new PictureInPictureModule(reactContext),
46
             new ProximityModule(reactContext),
47
             new ProximityModule(reactContext),
47
             new WiFiStatsModule(reactContext),
48
             new WiFiStatsModule(reactContext),
126
                 .addPackage(new com.corbt.keepawake.KCKeepAwakePackage())
127
                 .addPackage(new com.corbt.keepawake.KCKeepAwakePackage())
127
                 .addPackage(new com.dylanvann.fastimage.FastImageViewPackage())
128
                 .addPackage(new com.dylanvann.fastimage.FastImageViewPackage())
128
                 .addPackage(new com.facebook.react.shell.MainReactPackage())
129
                 .addPackage(new com.facebook.react.shell.MainReactPackage())
129
-                .addPackage(new com.i18n.reactnativei18n.ReactNativeI18n())
130
                 .addPackage(new com.oblador.vectoricons.VectorIconsPackage())
130
                 .addPackage(new com.oblador.vectoricons.VectorIconsPackage())
131
                 .addPackage(new com.ocetnik.timer.BackgroundTimerPackage())
131
                 .addPackage(new com.ocetnik.timer.BackgroundTimerPackage())
132
                 .addPackage(new com.oney.WebRTCModule.WebRTCModulePackage())
132
                 .addPackage(new com.oney.WebRTCModule.WebRTCModulePackage())

+ 0
- 2
android/settings.gradle Vedi File

13
 project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android')
13
 project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android')
14
 include ':react-native-linear-gradient'
14
 include ':react-native-linear-gradient'
15
 project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
15
 project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
16
-include ':react-native-locale-detector'
17
-project(':react-native-locale-detector').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-locale-detector/android')
18
 include ':react-native-sound'
16
 include ':react-native-sound'
19
 project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')
17
 project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')
20
 include ':react-native-vector-icons'
18
 include ':react-native-vector-icons'

+ 0
- 2
ios/Podfile Vedi File

34
     :path => '../node_modules/react-native-fast-image'
34
     :path => '../node_modules/react-native-fast-image'
35
   pod 'react-native-keep-awake',
35
   pod 'react-native-keep-awake',
36
     :path => '../node_modules/react-native-keep-awake'
36
     :path => '../node_modules/react-native-keep-awake'
37
-  pod 'react-native-locale-detector',
38
-    :path => '../node_modules/react-native-locale-detector'
39
   pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc'
37
   pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc'
40
   pod 'RNGoogleSignin',
38
   pod 'RNGoogleSignin',
41
     :path => '../node_modules/react-native-google-signin'
39
     :path => '../node_modules/react-native-google-signin'

+ 1
- 7
ios/Podfile.lock Vedi File

41
     - SDWebImage/GIF
41
     - SDWebImage/GIF
42
   - react-native-keep-awake (2.0.6):
42
   - react-native-keep-awake (2.0.6):
43
     - React
43
     - React
44
-  - react-native-locale-detector (1.0.0):
45
-    - React
46
   - react-native-webrtc (1.67.1):
44
   - react-native-webrtc (1.67.1):
47
     - React
45
     - React
48
   - React/Core (0.57.6):
46
   - React/Core (0.57.6):
109
   - react-native-calendar-events (from `../node_modules/react-native-calendar-events`)
107
   - react-native-calendar-events (from `../node_modules/react-native-calendar-events`)
110
   - react-native-fast-image (from `../node_modules/react-native-fast-image`)
108
   - react-native-fast-image (from `../node_modules/react-native-fast-image`)
111
   - react-native-keep-awake (from `../node_modules/react-native-keep-awake`)
109
   - react-native-keep-awake (from `../node_modules/react-native-keep-awake`)
112
-  - react-native-locale-detector (from `../node_modules/react-native-locale-detector`)
113
   - react-native-webrtc (from `../node_modules/react-native-webrtc`)
110
   - react-native-webrtc (from `../node_modules/react-native-webrtc`)
114
   - React/Core (from `../node_modules/react-native`)
111
   - React/Core (from `../node_modules/react-native`)
115
   - React/CxxBridge (from `../node_modules/react-native`)
112
   - React/CxxBridge (from `../node_modules/react-native`)
154
     :path: "../node_modules/react-native-fast-image"
151
     :path: "../node_modules/react-native-fast-image"
155
   react-native-keep-awake:
152
   react-native-keep-awake:
156
     :path: "../node_modules/react-native-keep-awake"
153
     :path: "../node_modules/react-native-keep-awake"
157
-  react-native-locale-detector:
158
-    :path: "../node_modules/react-native-locale-detector"
159
   react-native-webrtc:
154
   react-native-webrtc:
160
     :path: "../node_modules/react-native-webrtc"
155
     :path: "../node_modules/react-native-webrtc"
161
   RNGoogleSignin:
156
   RNGoogleSignin:
183
   react-native-calendar-events: fe6fbc8ed337a7423c98f2c9012b25f20444de09
178
   react-native-calendar-events: fe6fbc8ed337a7423c98f2c9012b25f20444de09
184
   react-native-fast-image: cba3d9bf9c2cf8ddb643d887a686c53a5dd90a2c
179
   react-native-fast-image: cba3d9bf9c2cf8ddb643d887a686c53a5dd90a2c
185
   react-native-keep-awake: 0de4bd66de0c23178107dce0c2fcc3354b2a8e94
180
   react-native-keep-awake: 0de4bd66de0c23178107dce0c2fcc3354b2a8e94
186
-  react-native-locale-detector: d1b2c6fe5abb56e3a1efb6c2d6f308c05c4251f1
187
   react-native-webrtc: 31b6d3f1e3e2ce373aa43fd682b04367250f807d
181
   react-native-webrtc: 31b6d3f1e3e2ce373aa43fd682b04367250f807d
188
   RNGoogleSignin: 44debd8c359a662c0e2d585952e88b985bf78008
182
   RNGoogleSignin: 44debd8c359a662c0e2d585952e88b985bf78008
189
   RNSound: b360b3862d3118ed1c74bb9825696b5957686ac4
183
   RNSound: b360b3862d3118ed1c74bb9825696b5957686ac4
191
   SDWebImage: 624d6e296c69b244bcede364c72ae0430ac14681
185
   SDWebImage: 624d6e296c69b244bcede364c72ae0430ac14681
192
   yoga: b1ce48b6cf950b98deae82838f5173ea7cf89e85
186
   yoga: b1ce48b6cf950b98deae82838f5173ea7cf89e85
193
 
187
 
194
-PODFILE CHECKSUM: cf8276ba4b0933b24c6082a25a5f4eabe0ba4ea6
188
+PODFILE CHECKSUM: 9b67ed66d62ca004caa7952c3bbfe2693c115333
195
 
189
 
196
 COCOAPODS: 1.5.3
190
 COCOAPODS: 1.5.3

+ 4
- 0
ios/sdk/sdk.xcodeproj/project.pbxproj Vedi File

49
 		C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425E204EF76800E062DD /* DragGestureController.swift */; };
49
 		C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425E204EF76800E062DD /* DragGestureController.swift */; };
50
 		C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */; };
50
 		C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */; };
51
 		C6F99C15204DB63E0001F710 /* JitsiMeetView+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */; };
51
 		C6F99C15204DB63E0001F710 /* JitsiMeetView+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */; };
52
+		DEFC743F21B178FA00E4DD96 /* LocaleDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */; };
52
 /* End PBXBuildFile section */
53
 /* End PBXBuildFile section */
53
 
54
 
54
 /* Begin PBXFileReference section */
55
 /* Begin PBXFileReference section */
104
 		C6A3425E204EF76800E062DD /* DragGestureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragGestureController.swift; sourceTree = "<group>"; };
105
 		C6A3425E204EF76800E062DD /* DragGestureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragGestureController.swift; sourceTree = "<group>"; };
105
 		C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiPViewCoordinator.swift; sourceTree = "<group>"; };
106
 		C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiPViewCoordinator.swift; sourceTree = "<group>"; };
106
 		C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetView+Private.h"; sourceTree = "<group>"; };
107
 		C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetView+Private.h"; sourceTree = "<group>"; };
108
+		DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocaleDetector.m; sourceTree = "<group>"; };
107
 /* End PBXFileReference section */
109
 /* End PBXFileReference section */
108
 
110
 
109
 /* Begin PBXFrameworksBuildPhase section */
111
 /* Begin PBXFrameworksBuildPhase section */
173
 				C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */,
175
 				C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */,
174
 				0B412F1B1EDEC80100B1A0A6 /* JitsiMeetViewDelegate.h */,
176
 				0B412F1B1EDEC80100B1A0A6 /* JitsiMeetViewDelegate.h */,
175
 				0B7C2CFC200F51D60060D076 /* LaunchOptions.m */,
177
 				0B7C2CFC200F51D60060D076 /* LaunchOptions.m */,
178
+				DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */,
176
 				0B44A0181F902126009D1D64 /* MPVolumeViewManager.m */,
179
 				0B44A0181F902126009D1D64 /* MPVolumeViewManager.m */,
177
 				C6A3426B204F127900E062DD /* picture-in-picture */,
180
 				C6A3426B204F127900E062DD /* picture-in-picture */,
178
 				0BCA495D1EC4B6C600B793EE /* POSIX.m */,
181
 				0BCA495D1EC4B6C600B793EE /* POSIX.m */,
465
 				0B7C2CFD200F51D60060D076 /* LaunchOptions.m in Sources */,
468
 				0B7C2CFD200F51D60060D076 /* LaunchOptions.m in Sources */,
466
 				C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */,
469
 				C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */,
467
 				B386B85720981A75000DEF7A /* InviteController.m in Sources */,
470
 				B386B85720981A75000DEF7A /* InviteController.m in Sources */,
471
+				DEFC743F21B178FA00E4DD96 /* LocaleDetector.m in Sources */,
468
 				B386B85820981A75000DEF7A /* AddPeopleController.m in Sources */,
472
 				B386B85820981A75000DEF7A /* AddPeopleController.m in Sources */,
469
 				0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */,
473
 				0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */,
470
 				0B44A0191F902126009D1D64 /* MPVolumeViewManager.m in Sources */,
474
 				0B44A0191F902126009D1D64 /* MPVolumeViewManager.m in Sources */,

+ 40
- 0
ios/sdk/src/LocaleDetector.m Vedi File

1
+/*
2
+ * Copyright @ 2018-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+/*
18
+ * Based on https://github.com/DylanVann/react-native-locale-detector
19
+ */
20
+
21
+#import <Foundation/Foundation.h>
22
+
23
+#import <React/RCTBridgeModule.h>
24
+
25
+@interface LocaleDetector : NSObject <RCTBridgeModule>
26
+@end
27
+
28
+@implementation LocaleDetector
29
+
30
+RCT_EXPORT_MODULE();
31
+
32
++ (BOOL)requiresMainQueueSetup {
33
+    return NO;
34
+}
35
+
36
+- (NSDictionary *)constantsToExport {
37
+    return @{ @"locale": [[NSLocale preferredLanguages] objectAtIndex:0] };
38
+}
39
+
40
+@end

+ 0
- 4
package-lock.json Vedi File

11225
         "prop-types": "^15.5.10"
11225
         "prop-types": "^15.5.10"
11226
       }
11226
       }
11227
     },
11227
     },
11228
-    "react-native-locale-detector": {
11229
-      "version": "github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9",
11230
-      "from": "github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9"
11231
-    },
11232
     "react-native-prompt": {
11228
     "react-native-prompt": {
11233
       "version": "1.0.0",
11229
       "version": "1.0.0",
11234
       "resolved": "https://registry.npmjs.org/react-native-prompt/-/react-native-prompt-1.0.0.tgz",
11230
       "resolved": "https://registry.npmjs.org/react-native-prompt/-/react-native-prompt-1.0.0.tgz",

+ 0
- 1
package.json Vedi File

69
     "react-native-immersive": "1.1.0",
69
     "react-native-immersive": "1.1.0",
70
     "react-native-keep-awake": "2.0.6",
70
     "react-native-keep-awake": "2.0.6",
71
     "react-native-linear-gradient": "2.4.0",
71
     "react-native-linear-gradient": "2.4.0",
72
-    "react-native-locale-detector": "github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9",
73
     "react-native-prompt": "1.0.0",
72
     "react-native-prompt": "1.0.0",
74
     "react-native-sound": "0.10.9",
73
     "react-native-sound": "0.10.9",
75
     "react-native-swipeout": "2.3.6",
74
     "react-native-swipeout": "2.3.6",

+ 5
- 3
react/features/base/i18n/languageDetector.native.js Vedi File

1
-/* @flow */
1
+// @flow
2
 
2
 
3
-import locale from 'react-native-locale-detector';
3
+import { NativeModules } from 'react-native';
4
 
4
 
5
 /**
5
 /**
6
  * The singleton language detector for React Native which uses the system-wide
6
  * The singleton language detector for React Native which uses the system-wide
15
     cacheUserLanguage: Function.prototype,
15
     cacheUserLanguage: Function.prototype,
16
 
16
 
17
     detect() {
17
     detect() {
18
-        return locale;
18
+        const { LocaleDetector } = NativeModules;
19
+
20
+        return LocaleDetector.locale.replace(/_/, '-');
19
     },
21
     },
20
 
22
 
21
     init: Function.prototype,
23
     init: Function.prototype,

Loading…
Annulla
Salva