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
feat(android): use Bundle to get data from actions
Calin-Teodor3e025c9f01a1
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.javaindex e370153c0a..81af3cdf71 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java@@ -3,12 +3,6 @@ package org.jitsi.meet.sdk;import android.content.Intent;import android.os.Bundle;-import com.facebook.react.bridge.WritableNativeMap;--import org.jitsi.meet.sdk.log.JitsiMeetLogger;--import java.util.HashMap;-/*** Wraps the name and extra data for events that were broadcasted locally.*/@@ -16,74 +10,21 @@ public class BroadcastAction {private static final String TAG = BroadcastAction.class.getSimpleName();private final Type type;- private final HashMap<String, Object> data;+ private final Bundle data;public BroadcastAction(Intent intent) {this.type = Type.buildTypeFromAction(intent.getAction());- this.data = buildDataFromBundle(intent.getExtras());+ this.data = intent.getExtras();}public Type getType() {return this.type;}- public HashMap<String, Object> getData() {+ public Bundle getData() {return this.data;}- public WritableNativeMap getDataAsWritableNativeMap() {- WritableNativeMap nativeMap = new WritableNativeMap();-- for (String key : this.data.keySet()) {- try {- if (this.data.get(key) instanceof Boolean) {- nativeMap.putBoolean(key, (Boolean) this.data.get(key));- } else if (this.data.get(key) instanceof Integer) {- nativeMap.putInt(key, (Integer) this.data.get(key));- } else if (this.data.get(key) instanceof Double) {- nativeMap.putDouble(key, (Double) this.data.get(key));- } else if (this.data.get(key) instanceof String) {- nativeMap.putString(key, (String) this.data.get(key));- } else if (this.data.get(key) instanceof Bundle) {- nativeMap.putMap(key, bundleToWritableMap((Bundle) this.data.get(key)));- } else {- throw new Exception("Unsupported extra data type");- }- } catch (Exception e) {- JitsiMeetLogger.w(TAG + " invalid extra data in event", e);- }- }-- return nativeMap;- }-- // Converts(only String values) an Android Bundle to a WritableNativeMap- // that can be consumed by React Native.- private WritableNativeMap bundleToWritableMap(Bundle bundle) {- WritableNativeMap map = new WritableNativeMap();-- for (String key : bundle.keySet()) {- Object value = bundle.get(key);- if (value instanceof String) {- map.putString(key, (String) value);- }- }-- return map;- }-- private static HashMap<String, Object> buildDataFromBundle(Bundle bundle) {- HashMap<String, Object> map = new HashMap<>();-- if (bundle != null) {- for (String key : bundle.keySet()) {- map.put(key, bundle.get(key));- }- }-- return map;- }-enum Type {SET_AUDIO_MUTED("org.jitsi.meet.SET_AUDIO_MUTED"),HANG_UP("org.jitsi.meet.HANG_UP"),diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastReceiver.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastReceiver.javaindex d5ac34ae6b..ea287bbc38 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastReceiver.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastReceiver.java@@ -3,6 +3,9 @@ package org.jitsi.meet.sdk;import android.content.Context;import android.content.Intent;import android.content.IntentFilter;+import android.os.Bundle;++import com.facebook.react.bridge.Arguments;import androidx.localbroadcastmanager.content.LocalBroadcastManager;@@ -28,7 +31,8 @@ public class BroadcastReceiver extends android.content.BroadcastReceiver {public void onReceive(Context context, Intent intent) {BroadcastAction action = new BroadcastAction(intent);String actionName = action.getType().getAction();+ Bundle data = action.getData();- ReactInstanceManagerHolder.emitEvent(actionName, action.getDataAsWritableNativeMap());+ ReactInstanceManagerHolder.emitEvent(actionName, Arguments.fromBundle(data));}}