Explorar el Código

[Android] Reduce boilerplate/duplication

master
Lyubo Marinov hace 8 años
padre
commit
2356238887

android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModeModule.java → android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java Ver fichero

@@ -14,7 +14,7 @@
14 14
  * limitations under the License.
15 15
  */
16 16
 
17
-package org.jitsi.meet.sdk.audiomode;
17
+package org.jitsi.meet.sdk;
18 18
 
19 19
 import android.annotation.TargetApi;
20 20
 import android.content.BroadcastReceiver;
@@ -51,7 +51,7 @@ import java.util.Map;
51 51
  * Before a call has started and after it has ended the
52 52
  * <tt>AudioModeModule.DEFAULT</tt> mode should be used.
53 53
  */
54
-public class AudioModeModule extends ReactContextBaseJavaModule {
54
+class AudioModeModule extends ReactContextBaseJavaModule {
55 55
     /**
56 56
      * Constants representing the audio mode.
57 57
      * - DEFAULT: Used before and after every call. It represents the default

android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/BluetoothHeadsetMonitor.java → android/sdk/src/main/java/org/jitsi/meet/sdk/BluetoothHeadsetMonitor.java Ver fichero

@@ -14,7 +14,7 @@
14 14
  * limitations under the License.
15 15
  */
16 16
 
17
-package org.jitsi.meet.sdk.audiomode;
17
+package org.jitsi.meet.sdk;
18 18
 
19 19
 import android.bluetooth.BluetoothAdapter;
20 20
 import android.bluetooth.BluetoothHeadset;
@@ -33,7 +33,7 @@ import android.util.Log;
33 33
  * Bluetooth headsets being connected / disconnected and notifies the module
34 34
  * about device changes when this occurs.
35 35
  */
36
-public class BluetoothHeadsetMonitor {
36
+class BluetoothHeadsetMonitor {
37 37
     /**
38 38
      * {@link AudioModeModule} where this monitor reports.
39 39
      */

android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java → android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java Ver fichero

@@ -14,7 +14,7 @@
14 14
  * limitations under the License.
15 15
  */
16 16
 
17
-package org.jitsi.meet.sdk.externalapi;
17
+package org.jitsi.meet.sdk;
18 18
 
19 19
 import com.facebook.react.bridge.ReactApplicationContext;
20 20
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
@@ -32,7 +32,7 @@ import java.util.HashMap;
32 32
  * object it will dim the screen and disable touch controls. The functionality
33 33
  * is used with the conference audio-only mode.
34 34
  */
35
-public class ExternalAPIModule extends ReactContextBaseJavaModule {
35
+class ExternalAPIModule extends ReactContextBaseJavaModule {
36 36
     /**
37 37
      * React Native module name.
38 38
      */

+ 20
- 4
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java Ver fichero

@@ -28,10 +28,14 @@ import android.widget.FrameLayout;
28 28
 
29 29
 import com.facebook.react.ReactInstanceManager;
30 30
 import com.facebook.react.ReactRootView;
31
+import com.facebook.react.bridge.NativeModule;
32
+import com.facebook.react.bridge.ReactApplicationContext;
31 33
 import com.facebook.react.common.LifecycleState;
32 34
 
33 35
 import java.net.URL;
36
+import java.util.Arrays;
34 37
 import java.util.Collections;
38
+import java.util.List;
35 39
 import java.util.Set;
36 40
 import java.util.UUID;
37 41
 import java.util.WeakHashMap;
@@ -52,6 +56,15 @@ public class JitsiMeetView extends FrameLayout {
52 56
     private static final Set<JitsiMeetView> views
53 57
         = Collections.newSetFromMap(new WeakHashMap<JitsiMeetView, Boolean>());
54 58
 
59
+    private static List<NativeModule> createNativeModules(
60
+            ReactApplicationContext reactContext) {
61
+        return Arrays.<NativeModule>asList(
62
+            new AudioModeModule(reactContext),
63
+            new ExternalAPIModule(reactContext),
64
+            new ProximityModule(reactContext)
65
+        );
66
+    }
67
+
55 68
     public static JitsiMeetView findViewByExternalAPIScope(
56 69
             String externalAPIScope) {
57 70
         synchronized (views) {
@@ -86,10 +99,13 @@ public class JitsiMeetView extends FrameLayout {
86 99
                 .addPackage(new com.oney.WebRTCModule.WebRTCModulePackage())
87 100
                 .addPackage(new com.RNFetchBlob.RNFetchBlobPackage())
88 101
                 .addPackage(new com.rnimmersive.RNImmersivePackage())
89
-                .addPackage(new org.jitsi.meet.sdk.audiomode.AudioModePackage())
90
-                .addPackage(
91
-                    new org.jitsi.meet.sdk.externalapi.ExternalAPIPackage())
92
-                .addPackage(new org.jitsi.meet.sdk.proximity.ProximityPackage())
102
+                .addPackage(new ReactPackageAdapter() {
103
+                    @Override
104
+                    public List<NativeModule> createNativeModules(
105
+                            ReactApplicationContext reactContext) {
106
+                        return JitsiMeetView.createNativeModules(reactContext);
107
+                    }
108
+                })
93 109
                 .setUseDeveloperSupport(BuildConfig.DEBUG)
94 110
                 .setInitialLifecycleState(LifecycleState.RESUMED)
95 111
                 .build();

android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityModule.java → android/sdk/src/main/java/org/jitsi/meet/sdk/ProximityModule.java Ver fichero

@@ -14,7 +14,7 @@
14 14
  * limitations under the License.
15 15
  */
16 16
 
17
-package org.jitsi.meet.sdk.proximity;
17
+package org.jitsi.meet.sdk;
18 18
 
19 19
 import android.content.Context;
20 20
 import android.os.PowerManager;
@@ -31,7 +31,7 @@ import com.facebook.react.bridge.UiThreadUtil;
31 31
  * object it will dim the screen and disable touch controls. The functionality
32 32
  * is used with the conference audio-only mode.
33 33
  */
34
-public class ProximityModule extends ReactContextBaseJavaModule {
34
+class ProximityModule extends ReactContextBaseJavaModule {
35 35
     /**
36 36
      * React Native module name.
37 37
      */

android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModePackage.java → android/sdk/src/main/java/org/jitsi/meet/sdk/ReactPackageAdapter.java Ver fichero

@@ -14,7 +14,7 @@
14 14
  * limitations under the License.
15 15
  */
16 16
 
17
-package org.jitsi.meet.sdk.audiomode;
17
+package org.jitsi.meet.sdk;
18 18
 
19 19
 import com.facebook.react.ReactPackage;
20 20
 import com.facebook.react.bridge.JavaScriptModule;
@@ -22,14 +22,10 @@ import com.facebook.react.bridge.NativeModule;
22 22
 import com.facebook.react.bridge.ReactApplicationContext;
23 23
 import com.facebook.react.uimanager.ViewManager;
24 24
 
25
-import java.util.ArrayList;
26 25
 import java.util.Collections;
27 26
 import java.util.List;
28 27
 
29
-/**
30
- * Implements {@link ReactPackage} for {@link AudioModeModule}.
31
- */
32
-public class AudioModePackage implements ReactPackage {
28
+public class ReactPackageAdapter implements ReactPackage {
33 29
     /**
34 30
      * {@inheritDoc}
35 31
      */
@@ -40,17 +36,11 @@ public class AudioModePackage implements ReactPackage {
40 36
 
41 37
     /**
42 38
      * {@inheritDoc}
43
-     *
44
-     * @return List of native modules to be exposed by React Native.
45 39
      */
46 40
     @Override
47 41
     public List<NativeModule> createNativeModules(
48 42
             ReactApplicationContext reactContext) {
49
-        List<NativeModule> modules = new ArrayList<>();
50
-
51
-        modules.add(new AudioModeModule(reactContext));
52
-
53
-        return modules;
43
+        return Collections.emptyList();
54 44
     }
55 45
 
56 46
     /**

+ 0
- 64
android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIPackage.java Ver fichero

@@ -1,64 +0,0 @@
1
-/*
2
- * Copyright @ 2017-present Atlassian Pty Ltd
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
-package org.jitsi.meet.sdk.externalapi;
18
-
19
-import com.facebook.react.ReactPackage;
20
-import com.facebook.react.bridge.JavaScriptModule;
21
-import com.facebook.react.bridge.NativeModule;
22
-import com.facebook.react.bridge.ReactApplicationContext;
23
-import com.facebook.react.uimanager.ViewManager;
24
-
25
-import java.util.ArrayList;
26
-import java.util.Collections;
27
-import java.util.List;
28
-
29
-/**
30
- * Implements {@link ReactPackage} for {@link ExternalAPIModule}.
31
- */
32
-public class ExternalAPIPackage implements ReactPackage {
33
-    /**
34
-     * {@inheritDoc}
35
-     */
36
-    @Override
37
-    public List<Class<? extends JavaScriptModule>> createJSModules() {
38
-        return Collections.emptyList();
39
-    }
40
-
41
-    /**
42
-     * {@inheritDoc}
43
-     *
44
-     * @return List of native modules to be exposed by React Native.
45
-     */
46
-    @Override
47
-    public List<NativeModule> createNativeModules(
48
-            ReactApplicationContext reactContext) {
49
-        List<NativeModule> modules = new ArrayList<>();
50
-
51
-        modules.add(new ExternalAPIModule(reactContext));
52
-
53
-        return modules;
54
-    }
55
-
56
-    /**
57
-     * {@inheritDoc}
58
-     */
59
-    @Override
60
-    public List<ViewManager> createViewManagers(
61
-            ReactApplicationContext reactContext) {
62
-        return Collections.emptyList();
63
-    }
64
-}

+ 0
- 64
android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityPackage.java Ver fichero

@@ -1,64 +0,0 @@
1
-/*
2
- * Copyright @ 2017-present Atlassian Pty Ltd
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
-package org.jitsi.meet.sdk.proximity;
18
-
19
-import com.facebook.react.ReactPackage;
20
-import com.facebook.react.bridge.JavaScriptModule;
21
-import com.facebook.react.bridge.NativeModule;
22
-import com.facebook.react.bridge.ReactApplicationContext;
23
-import com.facebook.react.uimanager.ViewManager;
24
-
25
-import java.util.ArrayList;
26
-import java.util.Collections;
27
-import java.util.List;
28
-
29
-/**
30
- * Implements {@link ReactPackage} for {@link ProximityModule}.
31
- */
32
-public class ProximityPackage implements ReactPackage {
33
-    /**
34
-     * {@inheritDoc}
35
-     */
36
-    @Override
37
-    public List<Class<? extends JavaScriptModule>> createJSModules() {
38
-        return Collections.emptyList();
39
-    }
40
-
41
-    /**
42
-     * {@inheritDoc}
43
-     *
44
-     * @return List of native modules to be exposed by React Native.
45
-     */
46
-    @Override
47
-    public List<NativeModule> createNativeModules(
48
-            ReactApplicationContext reactContext) {
49
-        List<NativeModule> modules = new ArrayList<>();
50
-
51
-        modules.add(new ProximityModule(reactContext));
52
-
53
-        return modules;
54
-    }
55
-
56
-    /**
57
-     * {@inheritDoc}
58
-     */
59
-    @Override
60
-    public List<ViewManager> createViewManagers(
61
-            ReactApplicationContext reactContext) {
62
-        return Collections.emptyList();
63
-    }
64
-}

Loading…
Cancelar
Guardar