Browse Source

[RN] Alternative to JitsiMeetView.loadURL w/o URL

Introduces loadURLObject in JitsiMeetView on Android and iOS which
accepts a Bundle and NSDictionary, respectively, similar in structure to
the JS object accepted by the constructor of Web's ExternalAPI. At this
time, only the property url of the bundle/dictionary is supported.
However, it allows the public API of loadURLObject to be consumed. The
property url will be made optional in the future and other properties
will be supported from which a URL will be constructed.
master
Lyubo Marinov 8 years ago
parent
commit
a2c2d3bee1

+ 12
- 6
android/README.md View File

93
 
93
 
94
 See JitsiMeetView.loadURL.
94
 See JitsiMeetView.loadURL.
95
 
95
 
96
-#### loadURLString(String)
97
-
98
-See JitsiMeetView.loadURLString.
99
-
100
 #### setWelcomePageEnabled(boolean)
96
 #### setWelcomePageEnabled(boolean)
101
 
97
 
102
 See JitsiMeetView.setWelcomePageEnabled.
98
 See JitsiMeetView.setWelcomePageEnabled.
118
 #### loadURL(URL)
114
 #### loadURL(URL)
119
 
115
 
120
 Loads a specific URL which may identify a conference to join. If the specified
116
 Loads a specific URL which may identify a conference to join. If the specified
121
-URL is null, the Welcome page is displayed instead.
117
+URL is null and the Welcome page is enabled, the Welcome page is displayed
118
+instead.
122
 
119
 
123
 #### loadURLString(String)
120
 #### loadURLString(String)
124
 
121
 
125
 Loads a specific URL which may identify a conference to join. If the specified
122
 Loads a specific URL which may identify a conference to join. If the specified
126
-URL is null, the Welcome page is displayed instead.
123
+URL is null and the Welcome page is enabled, the Welcome page is displayed
124
+instead.
125
+
126
+#### loadURLObject(Bundle)
127
+
128
+Loads a specific URL which may identify a conference to join. The URL is
129
+specified in the form of a Bundle of properties which (1) internally are
130
+sufficient to construct a URL (string) while (2) abstracting the specifics of
131
+constructing the URL away from API clients/consumers. If the specified URL is
132
+null and the Welcome page is enabled, the Welcome page is displayed instead.
127
 
133
 
128
 #### setListener(listener)
134
 #### setListener(listener)
129
 
135
 

+ 31
- 8
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java View File

233
     }
233
     }
234
 
234
 
235
     /**
235
     /**
236
-     * Loads a specific URL {@link String} which may identify a conference to
237
-     * join. If the specified URL {@code String} is {@code null}, the Welcome
238
-     * page is displayed instead.
236
+     * Loads a specific URL which may identify a conference to join. The URL is
237
+     * specified in the form of a {@link Bundle} of properties which (1)
238
+     * internally are sufficient to construct a URL {@code String} while (2)
239
+     * abstracting the specifics of constructing the URL away from API
240
+     * clients/consumers. If the specified URL is {@code null} and the Welcome
241
+     * page is enabled, the Welcome page is displayed instead.
239
      *
242
      *
240
-     * @param urlString - The URL {@code String} to load which may identify a
241
-     * conference to join.
243
+     * @param urlObject - The URL to load which may identify a conference to
244
+     * join.
242
      */
245
      */
243
-    public void loadURLString(@Nullable String urlString) {
246
+    public void loadURLObject(@Nullable Bundle urlObject) {
244
         Bundle props = new Bundle();
247
         Bundle props = new Bundle();
245
 
248
 
246
         // externalAPIScope
249
         // externalAPIScope
247
         props.putString("externalAPIScope", externalAPIScope);
250
         props.putString("externalAPIScope", externalAPIScope);
248
         // url
251
         // url
249
-        if (urlString != null) {
250
-            props.putString("url", urlString);
252
+        if (urlObject != null) {
253
+            props.putBundle("url", urlObject);
251
         }
254
         }
252
         // welcomePageEnabled
255
         // welcomePageEnabled
253
         props.putBoolean("welcomePageEnabled", welcomePageEnabled);
256
         props.putBoolean("welcomePageEnabled", welcomePageEnabled);
266
         addView(reactRootView);
269
         addView(reactRootView);
267
     }
270
     }
268
 
271
 
272
+    /**
273
+     * Loads a specific URL {@link String} which may identify a conference to
274
+     * join. If the specified URL {@code String} is {@code null}, the Welcome
275
+     * page is displayed instead.
276
+     *
277
+     * @param urlString - The URL {@code String} to load which may identify a
278
+     * conference to join.
279
+     */
280
+    public void loadURLString(@Nullable String urlString) {
281
+        Bundle urlObject;
282
+
283
+        if (urlString == null) {
284
+            urlObject = null;
285
+        } else {
286
+            urlObject = new Bundle();
287
+            urlObject.putString("url", urlString);
288
+        }
289
+        loadURLObject(urlObject);
290
+    }
291
+
269
     /**
292
     /**
270
      * Sets a specific {@link JitsiMeetViewListener} on this
293
      * Sets a specific {@link JitsiMeetViewListener} on this
271
      * {@code JitsiMeetView}.
294
      * {@code JitsiMeetView}.

+ 27
- 7
ios/README.md View File

20
 - (void)viewDidLoad {
20
 - (void)viewDidLoad {
21
   [super viewDidLoad];
21
   [super viewDidLoad];
22
 
22
 
23
-  JitsiMeetView *view = (JitsiMeetView *) self.view;
23
+  JitsiMeetView *jitsiMeetView = (JitsiMeetView *) self.view;
24
 
24
 
25
-  view.delegate = self;
26
-  [view loadURL:nil];
25
+  jitsiMeetView.delegate = self;
26
+  [jitsiMeetView loadURL:nil];
27
 }
27
 }
28
 ```
28
 ```
29
 
29
 
46
 #### loadURL:NSURL
46
 #### loadURL:NSURL
47
 
47
 
48
 ```objc
48
 ```objc
49
-[meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
49
+[jitsiMeetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
50
 ```
50
 ```
51
 
51
 
52
 Loads a specific URL which may identify a conference to join. If the specified
52
 Loads a specific URL which may identify a conference to join. If the specified
53
-URL is `nil`, the Welcome page is displayed instead.
53
+URL is `nil` and the Welcome page is enabled, the Welcome page is displayed
54
+instead.
55
+
56
+#### loadURLObject:NSDictionary
57
+
58
+```objc
59
+[jitsiMeetView loadURLObject:@{
60
+    @"url": @"https://meet.jit.si/test123",
61
+    @"configOverwrite": @{
62
+        @"startWithAudioMuted": @YES,
63
+        @"startWithVideoMuted": @NO
64
+    }
65
+}];
66
+```
67
+
68
+Loads a specific URL which may identify a conference to join. The URL is
69
+specified in the form of an `NSDictionary` of properties which (1) internally
70
+are sufficient to construct a URL (string) while (2) abstracting the specifics
71
+of constructing the URL away from API clients/consumers. If the specified URL is
72
+`nil` and the Welcome page is enabled, the Welcome page is displayed instead.
54
 
73
 
55
 #### loadURLString:NSString
74
 #### loadURLString:NSString
56
 
75
 
57
 ```objc
76
 ```objc
58
-[meetView loadURLString:@"https://meet.jit.si/test123"];
77
+[jitsiMeetView loadURLString:@"https://meet.jit.si/test123"];
59
 ```
78
 ```
60
 
79
 
61
 Loads a specific URL which may identify a conference to join. If the specified
80
 Loads a specific URL which may identify a conference to join. If the specified
62
-URL is `nil`, the Welcome page is displayed instead.
81
+URL is `nil` and the Welcome page is enabled, the Welcome page is displayed
82
+instead.
63
 
83
 
64
 #### Universal / deep linking
84
 #### Universal / deep linking
65
 
85
 

+ 2
- 0
ios/sdk/src/JitsiMeetView.h View File

39
 
39
 
40
 - (void)loadURL:(NSURL * _Nullable)url;
40
 - (void)loadURL:(NSURL * _Nullable)url;
41
 
41
 
42
+- (void)loadURLObject:(NSDictionary * _Nullable)urlObject;
43
+
42
 - (void)loadURLString:(NSString * _Nullable)urlString;
44
 - (void)loadURLString:(NSString * _Nullable)urlString;
43
 
45
 
44
 @end
46
 @end

+ 26
- 17
ios/sdk/src/JitsiMeetView.m View File

185
  * join.
185
  * join.
186
  */
186
  */
187
 - (void)loadURL:(NSURL *)url {
187
 - (void)loadURL:(NSURL *)url {
188
-    [self loadURLString:(url ? url.absoluteString : nil)];
188
+    [self loadURLString:url ? url.absoluteString : nil];
189
 }
189
 }
190
 
190
 
191
 /**
191
 /**
192
- * Loads a specific URL {@link NSString} which may identify a conference to
193
- * join. If the specified URL {@code NSString} is {@code nil}, the Welcome page
194
- * is displayed instead.
192
+ * Loads a specific URL which may identify a conference to join. The URL is
193
+ * specified in the form of an {@link NSDictionary} of properties which (1)
194
+ * internally are sufficient to construct a URL {@code NSString} while (2)
195
+ * abstracting the specifics of constructing the URL away from API
196
+ * clients/consumers. If the specified URL is {@code nil} and the Welcome page
197
+ * is enabled, the Welcome page is displayed instead.
195
  *
198
  *
196
- * @param urlString - The URL {@code NSString} to load which may identify a
197
- * conference to join.
199
+ * @param urlObject - The URL to load which may identify a conference to join.
198
  */
200
  */
199
-- (void)loadURLString:(NSString *)urlString {
200
-    NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
201
-
202
-    // externalAPIScope
203
-    [props setObject:externalAPIScope forKey:@"externalAPIScope"];
204
-    // url
205
-    if (urlString) {
206
-        [props setObject:urlString forKey:@"url"];
207
-    }
208
-    // welcomePageEnabled
209
-    [props setObject:@(self.welcomePageEnabled) forKey:@"welcomePageEnabled"];
201
+- (void)loadURLObject:(NSDictionary *)urlObject {
202
+    NSDictionary *props = @{
203
+        @"externalAPIScope": externalAPIScope,
204
+        @"url": urlObject,
205
+        @"welcomePageEnabled": @(self.welcomePageEnabled)
206
+    };
210
 
207
 
211
     if (rootView == nil) {
208
     if (rootView == nil) {
212
         rootView
209
         rootView
224
     }
221
     }
225
 }
222
 }
226
 
223
 
224
+/**
225
+ * Loads a specific URL {@link NSString} which may identify a conference to
226
+ * join. If the specified URL {@code NSString} is {@code nil}, the Welcome page
227
+ * is displayed instead.
228
+ *
229
+ * @param urlString - The URL {@code NSString} to load which may identify a
230
+ * conference to join.
231
+ */
232
+- (void)loadURLString:(NSString *)urlString {
233
+    [self loadURLObject:urlString ? @{ @"url": urlString } : nil];
234
+}
235
+
227
 #pragma mark Private methods
236
 #pragma mark Private methods
228
 
237
 
229
 + (instancetype)viewForExternalAPIScope:(NSString *)externalAPIScope {
238
 + (instancetype)viewForExternalAPIScope:(NSString *)externalAPIScope {

+ 12
- 7
react/features/app/components/AbstractApp.js View File

11
 } from '../../base/participants';
11
 } from '../../base/participants';
12
 import { RouteRegistry } from '../../base/react';
12
 import { RouteRegistry } from '../../base/react';
13
 import { MiddlewareRegistry, ReducerRegistry } from '../../base/redux';
13
 import { MiddlewareRegistry, ReducerRegistry } from '../../base/redux';
14
+import { toURLString } from '../../base/util';
14
 
15
 
15
 import {
16
 import {
16
     appNavigate,
17
     appNavigate,
52
         /**
53
         /**
53
          * The URL, if any, with which the app was launched.
54
          * The URL, if any, with which the app was launched.
54
          */
55
          */
55
-        url: React.PropTypes.string
56
+        url: React.PropTypes.oneOfType([
57
+            React.PropTypes.object,
58
+            React.PropTypes.string
59
+        ])
56
     };
60
     };
57
 
61
 
58
     /**
62
     /**
110
 
114
 
111
         // If a URL was explicitly specified to this React Component, then open
115
         // If a URL was explicitly specified to this React Component, then open
112
         // it; otherwise, use a default.
116
         // it; otherwise, use a default.
113
-        this._openURL(this.props.url || this._getDefaultURL());
117
+        this._openURL(toURLString(this.props.url) || this._getDefaultURL());
114
     }
118
     }
115
 
119
 
116
     /**
120
     /**
139
         }
143
         }
140
 
144
 
141
         // Deal with URL changes.
145
         // Deal with URL changes.
142
-        const { url } = nextProps;
146
+        let { url } = nextProps;
143
 
147
 
144
-        if (this.props.url !== url) {
148
+        url = toURLString(url);
149
+        if (toURLString(this.props.url) !== url) {
145
             this._openURL(url || this._getDefaultURL());
150
             this._openURL(url || this._getDefaultURL());
146
         }
151
         }
147
     }
152
     }
391
     /**
396
     /**
392
      * Navigates this AbstractApp to (i.e. opens) a specific URL.
397
      * Navigates this AbstractApp to (i.e. opens) a specific URL.
393
      *
398
      *
394
-     * @param {string} url - The URL to which to navigate this AbstractApp (i.e.
395
-     * the URL to open).
399
+     * @param {string|Object} url - The URL to navigate this AbstractApp to
400
+     * (i.e. the URL to open).
396
      * @protected
401
      * @protected
397
      * @returns {void}
402
      * @returns {void}
398
      */
403
      */
399
     _openURL(url) {
404
     _openURL(url) {
400
-        this._getStore().dispatch(appNavigate(url));
405
+        this._getStore().dispatch(appNavigate(toURLString(url)));
401
     }
406
     }
402
 }
407
 }

+ 50
- 0
react/features/base/util/uri.js View File

262
 
262
 
263
     return obj;
263
     return obj;
264
 }
264
 }
265
+
266
+/**
267
+ * Attempts to return a {@code String} representation of a specific
268
+ * {@code Object} which is supposed to represent a URL. Obviously, if a
269
+ * {@code String} is specified, it is returned. If a {@code URL} is specified,
270
+ * its {@code URL#href} is returned. Additionally, an {@code Object} similar to
271
+ * the one accepted by the constructor of Web's ExternalAPI is supported on both
272
+ * mobile/React Native and Web/React.
273
+ *
274
+ * @param {string|Object} obj - The URL to return a {@code String}
275
+ * representation of.
276
+ * @returns {string} - A {@code String} representation of the specified
277
+ * {@code obj} which is supposed to represent a URL.
278
+ */
279
+export function toURLString(obj: ?(string | Object)): ?string {
280
+    let str;
281
+
282
+    switch (typeof obj) {
283
+    case 'object':
284
+        if (obj) {
285
+            if (obj instanceof URL) {
286
+                str = obj.href;
287
+            } else {
288
+                str = _urlObjectToString(obj);
289
+            }
290
+        }
291
+        break;
292
+
293
+    case 'string':
294
+        str = String(obj);
295
+        break;
296
+    }
297
+
298
+    return str;
299
+}
300
+
301
+/**
302
+ * Attempts to return a {@code String} representation of a specific
303
+ * {@code Object} similar to the one accepted by the constructor
304
+ * of Web's ExternalAPI.
305
+ *
306
+ * @param {Object} obj - The URL to return a {@code String} representation of.
307
+ * @returns {string} - A {@code String} representation of the specified
308
+ * {@code obj}.
309
+ */
310
+function _urlObjectToString({ url }: Object): ?string {
311
+    // TODO Support properties other than url. Support (pretty much) all
312
+    // properties accepted by the constructor of Web's ExternalAPI.
313
+    return url;
314
+}

Loading…
Cancel
Save