Przeglądaj źródła

[Android] Reduce boilerplate/duplication

master
Lyubo Marinov 8 lat temu
rodzic
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 Wyświetl plik

14
  * limitations under the License.
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
 import android.annotation.TargetApi;
19
 import android.annotation.TargetApi;
20
 import android.content.BroadcastReceiver;
20
 import android.content.BroadcastReceiver;
51
  * Before a call has started and after it has ended the
51
  * Before a call has started and after it has ended the
52
  * <tt>AudioModeModule.DEFAULT</tt> mode should be used.
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
      * Constants representing the audio mode.
56
      * Constants representing the audio mode.
57
      * - DEFAULT: Used before and after every call. It represents the default
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 Wyświetl plik

14
  * limitations under the License.
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
 import android.bluetooth.BluetoothAdapter;
19
 import android.bluetooth.BluetoothAdapter;
20
 import android.bluetooth.BluetoothHeadset;
20
 import android.bluetooth.BluetoothHeadset;
33
  * Bluetooth headsets being connected / disconnected and notifies the module
33
  * Bluetooth headsets being connected / disconnected and notifies the module
34
  * about device changes when this occurs.
34
  * about device changes when this occurs.
35
  */
35
  */
36
-public class BluetoothHeadsetMonitor {
36
+class BluetoothHeadsetMonitor {
37
     /**
37
     /**
38
      * {@link AudioModeModule} where this monitor reports.
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 Wyświetl plik

14
  * limitations under the License.
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
 import com.facebook.react.bridge.ReactApplicationContext;
19
 import com.facebook.react.bridge.ReactApplicationContext;
20
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
20
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
32
  * object it will dim the screen and disable touch controls. The functionality
32
  * object it will dim the screen and disable touch controls. The functionality
33
  * is used with the conference audio-only mode.
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
      * React Native module name.
37
      * React Native module name.
38
      */
38
      */

+ 20
- 4
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java Wyświetl plik

28
 
28
 
29
 import com.facebook.react.ReactInstanceManager;
29
 import com.facebook.react.ReactInstanceManager;
30
 import com.facebook.react.ReactRootView;
30
 import com.facebook.react.ReactRootView;
31
+import com.facebook.react.bridge.NativeModule;
32
+import com.facebook.react.bridge.ReactApplicationContext;
31
 import com.facebook.react.common.LifecycleState;
33
 import com.facebook.react.common.LifecycleState;
32
 
34
 
33
 import java.net.URL;
35
 import java.net.URL;
36
+import java.util.Arrays;
34
 import java.util.Collections;
37
 import java.util.Collections;
38
+import java.util.List;
35
 import java.util.Set;
39
 import java.util.Set;
36
 import java.util.UUID;
40
 import java.util.UUID;
37
 import java.util.WeakHashMap;
41
 import java.util.WeakHashMap;
52
     private static final Set<JitsiMeetView> views
56
     private static final Set<JitsiMeetView> views
53
         = Collections.newSetFromMap(new WeakHashMap<JitsiMeetView, Boolean>());
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
     public static JitsiMeetView findViewByExternalAPIScope(
68
     public static JitsiMeetView findViewByExternalAPIScope(
56
             String externalAPIScope) {
69
             String externalAPIScope) {
57
         synchronized (views) {
70
         synchronized (views) {
86
                 .addPackage(new com.oney.WebRTCModule.WebRTCModulePackage())
99
                 .addPackage(new com.oney.WebRTCModule.WebRTCModulePackage())
87
                 .addPackage(new com.RNFetchBlob.RNFetchBlobPackage())
100
                 .addPackage(new com.RNFetchBlob.RNFetchBlobPackage())
88
                 .addPackage(new com.rnimmersive.RNImmersivePackage())
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
                 .setUseDeveloperSupport(BuildConfig.DEBUG)
109
                 .setUseDeveloperSupport(BuildConfig.DEBUG)
94
                 .setInitialLifecycleState(LifecycleState.RESUMED)
110
                 .setInitialLifecycleState(LifecycleState.RESUMED)
95
                 .build();
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 Wyświetl plik

14
  * limitations under the License.
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
 import android.content.Context;
19
 import android.content.Context;
20
 import android.os.PowerManager;
20
 import android.os.PowerManager;
31
  * object it will dim the screen and disable touch controls. The functionality
31
  * object it will dim the screen and disable touch controls. The functionality
32
  * is used with the conference audio-only mode.
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
      * React Native module name.
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 Wyświetl plik

14
  * limitations under the License.
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
 import com.facebook.react.ReactPackage;
19
 import com.facebook.react.ReactPackage;
20
 import com.facebook.react.bridge.JavaScriptModule;
20
 import com.facebook.react.bridge.JavaScriptModule;
22
 import com.facebook.react.bridge.ReactApplicationContext;
22
 import com.facebook.react.bridge.ReactApplicationContext;
23
 import com.facebook.react.uimanager.ViewManager;
23
 import com.facebook.react.uimanager.ViewManager;
24
 
24
 
25
-import java.util.ArrayList;
26
 import java.util.Collections;
25
 import java.util.Collections;
27
 import java.util.List;
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
      * {@inheritDoc}
30
      * {@inheritDoc}
35
      */
31
      */
40
 
36
 
41
     /**
37
     /**
42
      * {@inheritDoc}
38
      * {@inheritDoc}
43
-     *
44
-     * @return List of native modules to be exposed by React Native.
45
      */
39
      */
46
     @Override
40
     @Override
47
     public List<NativeModule> createNativeModules(
41
     public List<NativeModule> createNativeModules(
48
             ReactApplicationContext reactContext) {
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 Wyświetl plik

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 Wyświetl plik

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
-}

Ładowanie…
Anuluj
Zapisz