Browse Source

[Android] Use loadURL in the app

master
Lyubo Marinov 7 years ago
parent
commit
1ad8436cb5

+ 46
- 4
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java View File

@@ -20,6 +20,7 @@ import android.app.Activity;
20 20
 import android.app.Application;
21 21
 import android.content.Context;
22 22
 import android.content.Intent;
23
+import android.net.Uri;
23 24
 import android.os.Bundle;
24 25
 import android.support.annotation.NonNull;
25 26
 import android.support.annotation.Nullable;
@@ -53,9 +54,11 @@ public class JitsiMeetView extends FrameLayout {
53 54
 
54 55
     public static JitsiMeetView findViewByExternalAPIScope(
55 56
             String externalAPIScope) {
56
-        for (JitsiMeetView view : views) {
57
-            if (view.externalAPIScope.equals(externalAPIScope)) {
58
-                return view;
57
+        synchronized (views) {
58
+            for (JitsiMeetView view : views) {
59
+                if (view.externalAPIScope.equals(externalAPIScope)) {
60
+                    return view;
61
+                }
59 62
             }
60 63
         }
61 64
 
@@ -91,6 +94,30 @@ public class JitsiMeetView extends FrameLayout {
91 94
                 .build();
92 95
     }
93 96
 
97
+    /**
98
+     * Loads a specific URL {@code String} in all existing
99
+     * {@code JitsiMeetView}s.
100
+     *
101
+     * @param urlString - The URL {@code String} to load in all existing
102
+     * {@code JitsiMeetView}s.
103
+     * @return If the specified {@code urlString} was submitted for loading in
104
+     * at least one {@code JitsiMeetView}, then {@code true}; otherwise,
105
+     * {@code false}.
106
+     */
107
+    private static boolean loadURLStringInViews(String urlString) {
108
+        synchronized (views) {
109
+            if (!views.isEmpty()) {
110
+                for (JitsiMeetView view : views) {
111
+                    view.loadURLString(urlString);
112
+                }
113
+
114
+                return true;
115
+            }
116
+        }
117
+
118
+        return false;
119
+    }
120
+
94 121
     /**
95 122
      * Activity lifecycle method which should be called from
96 123
      * <tt>Activity.onBackPressed</tt> so we can do the required internal
@@ -156,6 +183,19 @@ public class JitsiMeetView extends FrameLayout {
156 183
      * @param intent - <tt>Intent</tt> instance which was received.
157 184
      */
158 185
     public static void onNewIntent(Intent intent) {
186
+        // XXX At least twice we received bug reports about malfunctioning
187
+        // loadURL in the Jitsi Meet SDK while the Jitsi Meet app seemed to
188
+        // functioning as expected in our testing. But that was to be expected
189
+        // because the app does not exercise loadURL. In order to increase the
190
+        // test coverage of loadURL, channel deep linking through loadURL.
191
+        Uri uri;
192
+
193
+        if (Intent.ACTION_VIEW.equals(intent.getAction())
194
+                && (uri = intent.getData()) != null
195
+                && loadURLStringInViews(uri.toString())) {
196
+            return;
197
+        }
198
+
159 199
         if (reactInstanceManager != null) {
160 200
             reactInstanceManager.onNewIntent(intent);
161 201
         }
@@ -196,7 +236,9 @@ public class JitsiMeetView extends FrameLayout {
196 236
 
197 237
         // Hook this JitsiMeetView into ExternalAPI.
198 238
         externalAPIScope = UUID.randomUUID().toString();
199
-        views.add(this);
239
+        synchronized (views) {
240
+            views.add(this);
241
+        }
200 242
     }
201 243
 
202 244
     /**

+ 8
- 0
ios/sdk/src/JitsiMeetView.m View File

@@ -269,6 +269,14 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
269 269
 
270 270
 #pragma mark Private methods
271 271
 
272
+/**
273
+ * Loads a specific {@link NSURL} in all existing {@code JitsiMeetView}s.
274
+ *
275
+ * @param url - The {@code NSURL} to load in all existing
276
+ * {@code JitsiMeetView}s.
277
+ * @return {@code YES} if the specified {@code url} was submitted for loading
278
+ * in at least one {@code JitsiMeetView}; otherwise, {@code NO}.
279
+ */
272 280
 + (BOOL)loadURLInViews:(NSURL *)url {
273 281
     BOOL handled = NO;
274 282
 

Loading…
Cancel
Save