浏览代码

[Android] Use loadURL in the app

master
Lyubo Marinov 7 年前
父节点
当前提交
1ad8436cb5
共有 2 个文件被更改,包括 54 次插入4 次删除
  1. 46
    4
      android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
  2. 8
    0
      ios/sdk/src/JitsiMeetView.m

+ 46
- 4
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java 查看文件

20
 import android.app.Application;
20
 import android.app.Application;
21
 import android.content.Context;
21
 import android.content.Context;
22
 import android.content.Intent;
22
 import android.content.Intent;
23
+import android.net.Uri;
23
 import android.os.Bundle;
24
 import android.os.Bundle;
24
 import android.support.annotation.NonNull;
25
 import android.support.annotation.NonNull;
25
 import android.support.annotation.Nullable;
26
 import android.support.annotation.Nullable;
53
 
54
 
54
     public static JitsiMeetView findViewByExternalAPIScope(
55
     public static JitsiMeetView findViewByExternalAPIScope(
55
             String externalAPIScope) {
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
                 .build();
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
      * Activity lifecycle method which should be called from
122
      * Activity lifecycle method which should be called from
96
      * <tt>Activity.onBackPressed</tt> so we can do the required internal
123
      * <tt>Activity.onBackPressed</tt> so we can do the required internal
156
      * @param intent - <tt>Intent</tt> instance which was received.
183
      * @param intent - <tt>Intent</tt> instance which was received.
157
      */
184
      */
158
     public static void onNewIntent(Intent intent) {
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
         if (reactInstanceManager != null) {
199
         if (reactInstanceManager != null) {
160
             reactInstanceManager.onNewIntent(intent);
200
             reactInstanceManager.onNewIntent(intent);
161
         }
201
         }
196
 
236
 
197
         // Hook this JitsiMeetView into ExternalAPI.
237
         // Hook this JitsiMeetView into ExternalAPI.
198
         externalAPIScope = UUID.randomUUID().toString();
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 查看文件

269
 
269
 
270
 #pragma mark Private methods
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
 + (BOOL)loadURLInViews:(NSURL *)url {
280
 + (BOOL)loadURLInViews:(NSURL *)url {
273
     BOOL handled = NO;
281
     BOOL handled = NO;
274
 
282
 

正在加载...
取消
保存