Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[Android] Reduce boilerplate/duplication
Lyubo Marinov2356238887a2
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModeModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.javasimilarity index 99%rename from android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModeModule.javarename to android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.javaindex 491c86234f..26e949bebf 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModeModule.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java@@ -14,7 +14,7 @@* limitations under the License.*/-package org.jitsi.meet.sdk.audiomode;+package org.jitsi.meet.sdk;import android.annotation.TargetApi;import android.content.BroadcastReceiver;@@ -51,7 +51,7 @@ import java.util.Map;* Before a call has started and after it has ended the* <tt>AudioModeModule.DEFAULT</tt> mode should be used.*/-public class AudioModeModule extends ReactContextBaseJavaModule {+class AudioModeModule extends ReactContextBaseJavaModule {/*** Constants representing the audio mode.* - DEFAULT: Used before and after every call. It represents the defaultdiff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/BluetoothHeadsetMonitor.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/BluetoothHeadsetMonitor.javasimilarity index 98%rename from android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/BluetoothHeadsetMonitor.javarename to android/sdk/src/main/java/org/jitsi/meet/sdk/BluetoothHeadsetMonitor.javaindex 124754e30d..52d83f0e8f 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/BluetoothHeadsetMonitor.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/BluetoothHeadsetMonitor.java@@ -14,7 +14,7 @@* limitations under the License.*/-package org.jitsi.meet.sdk.audiomode;+package org.jitsi.meet.sdk;import android.bluetooth.BluetoothAdapter;import android.bluetooth.BluetoothHeadset;@@ -33,7 +33,7 @@ import android.util.Log;* Bluetooth headsets being connected / disconnected and notifies the module* about device changes when this occurs.*/-public class BluetoothHeadsetMonitor {+class BluetoothHeadsetMonitor {/*** {@link AudioModeModule} where this monitor reports.*/diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.javasimilarity index 97%rename from android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.javarename to android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.javaindex 698663818d..0382af98e6 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java@@ -14,7 +14,7 @@* limitations under the License.*/-package org.jitsi.meet.sdk.externalapi;+package org.jitsi.meet.sdk;import com.facebook.react.bridge.ReactApplicationContext;import com.facebook.react.bridge.ReactContextBaseJavaModule;@@ -32,7 +32,7 @@ import java.util.HashMap;* object it will dim the screen and disable touch controls. The functionality* is used with the conference audio-only mode.*/-public class ExternalAPIModule extends ReactContextBaseJavaModule {+class ExternalAPIModule extends ReactContextBaseJavaModule {/*** React Native module name.*/diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.javaindex 94773ac5b4..1ecff365b5 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java@@ -28,10 +28,14 @@ import android.widget.FrameLayout;import com.facebook.react.ReactInstanceManager;import com.facebook.react.ReactRootView;+import com.facebook.react.bridge.NativeModule;+import com.facebook.react.bridge.ReactApplicationContext;import com.facebook.react.common.LifecycleState;import java.net.URL;+import java.util.Arrays;import java.util.Collections;+import java.util.List;import java.util.Set;import java.util.UUID;import java.util.WeakHashMap;@@ -52,6 +56,15 @@ public class JitsiMeetView extends FrameLayout {private static final Set<JitsiMeetView> views= Collections.newSetFromMap(new WeakHashMap<JitsiMeetView, Boolean>());+ private static List<NativeModule> createNativeModules(+ ReactApplicationContext reactContext) {+ return Arrays.<NativeModule>asList(+ new AudioModeModule(reactContext),+ new ExternalAPIModule(reactContext),+ new ProximityModule(reactContext)+ );+ }+public static JitsiMeetView findViewByExternalAPIScope(String externalAPIScope) {synchronized (views) {@@ -86,10 +99,13 @@ public class JitsiMeetView extends FrameLayout {.addPackage(new com.oney.WebRTCModule.WebRTCModulePackage()).addPackage(new com.RNFetchBlob.RNFetchBlobPackage()).addPackage(new com.rnimmersive.RNImmersivePackage())- .addPackage(new org.jitsi.meet.sdk.audiomode.AudioModePackage())- .addPackage(- new org.jitsi.meet.sdk.externalapi.ExternalAPIPackage())- .addPackage(new org.jitsi.meet.sdk.proximity.ProximityPackage())+ .addPackage(new ReactPackageAdapter() {+ @Override+ public List<NativeModule> createNativeModules(+ ReactApplicationContext reactContext) {+ return JitsiMeetView.createNativeModules(reactContext);+ }+ }).setUseDeveloperSupport(BuildConfig.DEBUG).setInitialLifecycleState(LifecycleState.RESUMED).build();diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/ProximityModule.javasimilarity index 97%rename from android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityModule.javarename to android/sdk/src/main/java/org/jitsi/meet/sdk/ProximityModule.javaindex e605243ee9..0dad3d16f3 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityModule.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/ProximityModule.java@@ -14,7 +14,7 @@* limitations under the License.*/-package org.jitsi.meet.sdk.proximity;+package org.jitsi.meet.sdk;import android.content.Context;import android.os.PowerManager;@@ -31,7 +31,7 @@ import com.facebook.react.bridge.UiThreadUtil;* object it will dim the screen and disable touch controls. The functionality* is used with the conference audio-only mode.*/-public class ProximityModule extends ReactContextBaseJavaModule {+class ProximityModule extends ReactContextBaseJavaModule {/*** React Native module name.*/diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModePackage.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactPackageAdapter.javasimilarity index 77%rename from android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModePackage.javarename to android/sdk/src/main/java/org/jitsi/meet/sdk/ReactPackageAdapter.javaindex c2f311cfa6..8b5becc9dd 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/audiomode/AudioModePackage.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactPackageAdapter.java@@ -14,7 +14,7 @@* limitations under the License.*/-package org.jitsi.meet.sdk.audiomode;+package org.jitsi.meet.sdk;import com.facebook.react.ReactPackage;import com.facebook.react.bridge.JavaScriptModule;@@ -22,14 +22,10 @@ import com.facebook.react.bridge.NativeModule;import com.facebook.react.bridge.ReactApplicationContext;import com.facebook.react.uimanager.ViewManager;-import java.util.ArrayList;import java.util.Collections;import java.util.List;-/**- * Implements {@link ReactPackage} for {@link AudioModeModule}.- */-public class AudioModePackage implements ReactPackage {+public class ReactPackageAdapter implements ReactPackage {/*** {@inheritDoc}*/@@ -40,17 +36,11 @@ public class AudioModePackage implements ReactPackage {/*** {@inheritDoc}- *- * @return List of native modules to be exposed by React Native.*/@Overridepublic List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {- List<NativeModule> modules = new ArrayList<>();-- modules.add(new AudioModeModule(reactContext));-- return modules;+ return Collections.emptyList();}/**diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIPackage.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIPackage.javadeleted file mode 100644index 446680d9b9..0000000000--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIPackage.java+++ /dev/null@@ -1,64 +0,0 @@-/*- * Copyright @ 2017-present Atlassian Pty Ltd- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.jitsi.meet.sdk.externalapi;--import com.facebook.react.ReactPackage;-import com.facebook.react.bridge.JavaScriptModule;-import com.facebook.react.bridge.NativeModule;-import com.facebook.react.bridge.ReactApplicationContext;-import com.facebook.react.uimanager.ViewManager;--import java.util.ArrayList;-import java.util.Collections;-import java.util.List;--/**- * Implements {@link ReactPackage} for {@link ExternalAPIModule}.- */-public class ExternalAPIPackage implements ReactPackage {- /**- * {@inheritDoc}- */- @Override- public List<Class<? extends JavaScriptModule>> createJSModules() {- return Collections.emptyList();- }-- /**- * {@inheritDoc}- *- * @return List of native modules to be exposed by React Native.- */- @Override- public List<NativeModule> createNativeModules(- ReactApplicationContext reactContext) {- List<NativeModule> modules = new ArrayList<>();-- modules.add(new ExternalAPIModule(reactContext));-- return modules;- }-- /**- * {@inheritDoc}- */- @Override- public List<ViewManager> createViewManagers(- ReactApplicationContext reactContext) {- return Collections.emptyList();- }-}diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityPackage.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityPackage.javadeleted file mode 100644index 42544cbbb6..0000000000--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/proximity/ProximityPackage.java+++ /dev/null@@ -1,64 +0,0 @@-/*- * Copyright @ 2017-present Atlassian Pty Ltd- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.jitsi.meet.sdk.proximity;--import com.facebook.react.ReactPackage;-import com.facebook.react.bridge.JavaScriptModule;-import com.facebook.react.bridge.NativeModule;-import com.facebook.react.bridge.ReactApplicationContext;-import com.facebook.react.uimanager.ViewManager;--import java.util.ArrayList;-import java.util.Collections;-import java.util.List;--/**- * Implements {@link ReactPackage} for {@link ProximityModule}.- */-public class ProximityPackage implements ReactPackage {- /**- * {@inheritDoc}- */- @Override- public List<Class<? extends JavaScriptModule>> createJSModules() {- return Collections.emptyList();- }-- /**- * {@inheritDoc}- *- * @return List of native modules to be exposed by React Native.- */- @Override- public List<NativeModule> createNativeModules(- ReactApplicationContext reactContext) {- List<NativeModule> modules = new ArrayList<>();-- modules.add(new ProximityModule(reactContext));-- return modules;- }-- /**- * {@inheritDoc}- */- @Override- public List<ViewManager> createViewManagers(- ReactApplicationContext reactContext) {- return Collections.emptyList();- }-}