Browse Source

[RN] Add loadURLString to JitsiMeetView

Initializing a new URL/NSURL instance is a chore especially when one
takes into account that the JavaScript side (1) is loading the URL
asynchronously and (2) is capable of parsing strings that may or may not
be represented as URL/NSURL.

The Android method loadURLString(String) may have been called
loadURL(String) to overload loadURL(URL) but I didn't want to do that
because:

1. It would not be compatible with existing source code such as
loadURL(null) which would have become ambiguous.

2. I wanted to achieve better convergence with the iOS API.
master
Lyubo Marinov 8 years ago
parent
commit
f0ab835b46

+ 12
- 3
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
+
96
 #### setWelcomePageEnabled(boolean)
100
 #### setWelcomePageEnabled(boolean)
97
 
101
 
98
 See JitsiMeetView.setWelcomePageEnabled.
102
 See JitsiMeetView.setWelcomePageEnabled.
113
 
117
 
114
 #### loadURL(URL)
118
 #### loadURL(URL)
115
 
119
 
116
-Loads the given URL and joins the room. If `null` is specified, the welcome page
117
-is displayed instead.
120
+Loads a specific URL which may identify a conference to join. If the specified
121
+URL is null, the Welcome page is displayed instead.
122
+
123
+#### loadURLString(String)
124
+
125
+Loads a specific URL which may identify a conference to join. If the specified
126
+URL is null, the Welcome page is displayed instead.
118
 
127
 
119
 #### setListener(listener)
128
 #### setListener(listener)
120
 
129
 
126
 Sets whether the Welcome page is enabled. See `getWelcomePageEnabled` for more
135
 Sets whether the Welcome page is enabled. See `getWelcomePageEnabled` for more
127
 information.
136
 information.
128
 
137
 
129
-NOTE: Must be called before `loadURL` for it to take effect.
138
+NOTE: Must be called before `loadURL`/`loadURLString` for it to take effect.
130
 
139
 
131
 #### onBackPressed()
140
 #### onBackPressed()
132
 
141
 

+ 19
- 5
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java View File

221
     }
221
     }
222
 
222
 
223
     /**
223
     /**
224
-     * Loads the given URL and displays the conference. If the specified URL is
225
-     * null, the welcome page is displayed instead.
224
+     * Loads a specific {@link URL} which may identify a conference to join. If
225
+     * the specified {@code URL} is {@code null}, the Welcome page is displayed
226
+     * instead.
226
      *
227
      *
227
-     * @param url - The conference URL.
228
+     * @param url - The {@code URL} to load which may identify a conference to
229
+     * join.
228
      */
230
      */
229
     public void loadURL(@Nullable URL url) {
231
     public void loadURL(@Nullable URL url) {
232
+        loadURLString(url == null ? null : url.toString());
233
+    }
234
+
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.
239
+     *
240
+     * @param urlString - The URL {@code String} to load which may identify a
241
+     * conference to join.
242
+     */
243
+    public void loadURLString(@Nullable String urlString) {
230
         Bundle props = new Bundle();
244
         Bundle props = new Bundle();
231
 
245
 
232
         // externalAPIScope
246
         // externalAPIScope
233
         props.putString("externalAPIScope", externalAPIScope);
247
         props.putString("externalAPIScope", externalAPIScope);
234
         // url
248
         // url
235
-        if (url != null) {
236
-            props.putString("url", url.toString());
249
+        if (urlString != null) {
250
+            props.putString("url", urlString);
237
         }
251
         }
238
         // welcomePageEnabled
252
         // welcomePageEnabled
239
         props.putBoolean("welcomePageEnabled", welcomePageEnabled);
253
         props.putBoolean("welcomePageEnabled", welcomePageEnabled);

+ 13
- 4
ios/README.md View File

41
 Property for getting / setting whether the Welcome page is enabled. If NO, a
41
 Property for getting / setting whether the Welcome page is enabled. If NO, a
42
 black empty view will be rendered when not in a conference. Defaults to NO.
42
 black empty view will be rendered when not in a conference. Defaults to NO.
43
 
43
 
44
-NOTE: Must be set before calling `loadURL` for it to take effect.
44
+NOTE: Must be set before `loadURL:`/`loadURLString:` for it to take effect.
45
 
45
 
46
-#### loadURL(URL)
46
+#### loadURL:NSURL
47
 
47
 
48
 ```objc
48
 ```objc
49
 [meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
49
 [meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
50
 ```
50
 ```
51
 
51
 
52
-Loads the given URL and joins the room. If `null` is specified, the welcome page
53
-is displayed instead.
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.
54
+
55
+#### loadURLString:NSString
56
+
57
+```objc
58
+[meetView loadURLString:@"https://meet.jit.si/test123"];
59
+```
60
+
61
+Loads a specific URL which may identify a conference to join. If the specified
62
+URL is `nil`, the Welcome page is displayed instead.
54
 
63
 
55
 #### Universal / deep linking
64
 #### Universal / deep linking
56
 
65
 

+ 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)loadURLString:(NSString * _Nullable)urlString;
43
+
42
 @end
44
 @end

+ 20
- 4
ios/sdk/src/JitsiMeetView.m View File

177
 #pragma mark API
177
 #pragma mark API
178
 
178
 
179
 /**
179
 /**
180
- * Loads the given URL and joins the specified conference. If the specified URL
181
- * is null, the welcome page is shown.
180
+ * Loads a specific {@link NSURL} which may identify a conference to join. If
181
+ * the specified {@code NSURL} is {@code nil}, the Welcome page is displayed
182
+ * instead.
183
+ *
184
+ * @param url - The {@code NSURL} to load which may identify a conference to
185
+ * join.
182
  */
186
  */
183
 - (void)loadURL:(NSURL *)url {
187
 - (void)loadURL:(NSURL *)url {
188
+    [self loadURLString:(url ? url.absoluteString : nil)];
189
+}
190
+
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.
195
+ *
196
+ * @param urlString - The URL {@code NSString} to load which may identify a
197
+ * conference to join.
198
+ */
199
+- (void)loadURLString:(NSString *)urlString {
184
     NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
200
     NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
185
 
201
 
186
     // externalAPIScope
202
     // externalAPIScope
187
     [props setObject:externalAPIScope forKey:@"externalAPIScope"];
203
     [props setObject:externalAPIScope forKey:@"externalAPIScope"];
188
     // url
204
     // url
189
-    if (url) {
190
-        [props setObject:url.absoluteString forKey:@"url"];
205
+    if (urlString) {
206
+        [props setObject:urlString forKey:@"url"];
191
     }
207
     }
192
     // welcomePageEnabled
208
     // welcomePageEnabled
193
     [props setObject:@(self.welcomePageEnabled) forKey:@"welcomePageEnabled"];
209
     [props setObject:@(self.welcomePageEnabled) forKey:@"welcomePageEnabled"];

Loading…
Cancel
Save