Browse Source

[RN] Add the ability to set the default URL in the SDK

master
Saúl Ibarra Corretgé 8 years ago
parent
commit
341e7e01aa

+ 20
- 0
android/README.md View File

105
 This class encapsulates a high level API in the form of an Android `Activity`
105
 This class encapsulates a high level API in the form of an Android `Activity`
106
 which displays a single `JitsiMeetView`.
106
 which displays a single `JitsiMeetView`.
107
 
107
 
108
+#### getDefaultURL()
109
+
110
+See JitsiMeetView.getDefaultURL.
111
+
108
 #### getWelcomePageEnabled()
112
 #### getWelcomePageEnabled()
109
 
113
 
110
 See JitsiMeetView.getWelcomePageEnabled.
114
 See JitsiMeetView.getWelcomePageEnabled.
113
 
117
 
114
 See JitsiMeetView.loadURL.
118
 See JitsiMeetView.loadURL.
115
 
119
 
120
+#### setDefaultURL(URL)
121
+
122
+See JitsiMeetView.setDefaultURL.
123
+
116
 #### setWelcomePageEnabled(boolean)
124
 #### setWelcomePageEnabled(boolean)
117
 
125
 
118
 See JitsiMeetView.setWelcomePageEnabled.
126
 See JitsiMeetView.setWelcomePageEnabled.
128
 when the Activity holding this view is going to be destroyed, usually in the
136
 when the Activity holding this view is going to be destroyed, usually in the
129
 `onDestroy()` method.
137
 `onDestroy()` method.
130
 
138
 
139
+#### getDefaultURL()
140
+
141
+Returns the default URL for joining a conference when a non-full URL is given,
142
+or null if it's not set. If not set, the builtin default (in JavaScript) is
143
+used: https://meet.jit.si.
144
+
131
 #### getListener()
145
 #### getListener()
132
 
146
 
133
 Returns the `JitsiMeetViewListener` instance attached to the view.
147
 Returns the `JitsiMeetViewListener` instance attached to the view.
169
 view.loadURLObject(urlBundle);
183
 view.loadURLObject(urlBundle);
170
 ```
184
 ```
171
 
185
 
186
+#### setDefaultURL(URL)
187
+
188
+Sets the default URL. See `getDefaultURL` for more information.
189
+
190
+NOTE: Must be called before `loadURL`/`loadURLString` for it to take effect.
191
+
172
 #### setListener(listener)
192
 #### setListener(listener)
173
 
193
 
174
 Sets the given listener (class implementing the `JitsiMeetViewListener`
194
 Sets the given listener (class implementing the `JitsiMeetViewListener`

+ 29
- 1
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java View File

60
      */
60
      */
61
     private JitsiMeetView view;
61
     private JitsiMeetView view;
62
 
62
 
63
+    /**
64
+     * Default URL to be used when joining a conference. The value is used only
65
+     * while {@link #view} equals {@code null}.
66
+     */
67
+    private URL defaultURL;
68
+
63
     /**
69
     /**
64
      * Whether the Welcome page is enabled. The value is used only while
70
      * Whether the Welcome page is enabled. The value is used only while
65
      * {@link #view} equals {@code null}.
71
      * {@link #view} equals {@code null}.
74
                     >= Build.VERSION_CODES.M;
80
                     >= Build.VERSION_CODES.M;
75
     }
81
     }
76
 
82
 
83
+    /**
84
+     *
85
+     * @see JitsiMeetView#getDefaultURL
86
+     */
87
+    public URL getDefaultURL() {
88
+        return view == null ? defaultURL : view.getDefaultURL();
89
+    }
90
+
77
     /**
91
     /**
78
      *
92
      *
79
      * @see JitsiMeetView#getWelcomePageEnabled
93
      * @see JitsiMeetView#getWelcomePageEnabled
104
         JitsiMeetView view = new JitsiMeetView(this);
118
         JitsiMeetView view = new JitsiMeetView(this);
105
 
119
 
106
         // In order to have the desired effect
120
         // In order to have the desired effect
107
-        // JitsiMeetView#setWelcomePageEnabled(boolean) must be invoked before
121
+        // JitsiMeetView#setWelcomePageEnabled(boolean) or
122
+        // JitsiMeetView#setDefaultURL(URL) must be invoked before
108
         // JitsiMeetView#loadURL(URL).
123
         // JitsiMeetView#loadURL(URL).
124
+        view.setDefaultURL(defaultURL);
109
         view.setWelcomePageEnabled(welcomePageEnabled);
125
         view.setWelcomePageEnabled(welcomePageEnabled);
110
         view.loadURL(null);
126
         view.loadURL(null);
111
 
127
 
225
         JitsiMeetView.onHostResume(this, defaultBackButtonImpl);
241
         JitsiMeetView.onHostResume(this, defaultBackButtonImpl);
226
     }
242
     }
227
 
243
 
244
+    /**
245
+     *
246
+     * @see JitsiMeetView#setDefaultURL
247
+     */
248
+    public void setDefaultURL(URL url) {
249
+        if (view == null) {
250
+            defaultURL = url;
251
+        } else {
252
+            view.setDefaultURL(url);
253
+        }
254
+    }
255
+
228
     /**
256
     /**
229
      *
257
      *
230
      * @see JitsiMeetView#setWelcomePageEnabled
258
      * @see JitsiMeetView#setWelcomePageEnabled

+ 30
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java View File

236
         }
236
         }
237
     }
237
     }
238
 
238
 
239
+    /**
240
+     * Default base URL to use when joining a conference without a full URL.
241
+     */
242
+    private URL defaultURL;
243
+
239
     /**
244
     /**
240
      * The unique identifier of this {@code JitsiMeetView} within the process
245
      * The unique identifier of this {@code JitsiMeetView} within the process
241
      * for the purposes of {@link ExternalAPI}. The name scope was inspired by
246
      * for the purposes of {@link ExternalAPI}. The name scope was inspired by
291
         }
296
         }
292
     }
297
     }
293
 
298
 
299
+    /**
300
+     * Gets the default base URL. If set, it will be preferred over the builtin
301
+     * default (https://meet.jit.si) in JavaScript. When set, it will be used
302
+     * to compose the full URL for a conference, when no full URL is provided.
303
+     *
304
+     * @return {@URL} the default URL or {@null} if none was set.
305
+     */
306
+    public URL getDefaultURL() {
307
+        return defaultURL;
308
+    }
309
+
294
     /**
310
     /**
295
      * Gets the {@link JitsiMeetViewListener} set on this {@code JitsiMeetView}.
311
      * Gets the {@link JitsiMeetViewListener} set on this {@code JitsiMeetView}.
296
      *
312
      *
338
     public void loadURLObject(@Nullable Bundle urlObject) {
354
     public void loadURLObject(@Nullable Bundle urlObject) {
339
         Bundle props = new Bundle();
355
         Bundle props = new Bundle();
340
 
356
 
357
+        // defaultURL
358
+        if (defaultURL != null) {
359
+            props.putString("defaultURL", defaultURL.toString());
360
+        }
341
         // externalAPIScope
361
         // externalAPIScope
342
         props.putString("externalAPIScope", externalAPIScope);
362
         props.putString("externalAPIScope", externalAPIScope);
343
         // url
363
         // url
377
         loadURLObject(urlObject);
397
         loadURLObject(urlObject);
378
     }
398
     }
379
 
399
 
400
+    /**
401
+     * Sets the default base URL. Must be called before {@link #loadURL(URL)}
402
+     * for it to take effect.
403
+     *
404
+     * @param url - The {@URL} to be set as the new default URL.
405
+     */
406
+    public void setDefaultURL(URL url) {
407
+        defaultURL = url;
408
+    }
409
+
380
     /**
410
     /**
381
      * Sets a specific {@link JitsiMeetViewListener} on this
411
      * Sets a specific {@link JitsiMeetViewListener} on this
382
      * {@code JitsiMeetView}.
412
      * {@code JitsiMeetView}.

+ 8
- 0
ios/README.md View File

46
 
46
 
47
 Property for getting / setting the `JitsiMeetViewDelegate` on `JitsiMeetView`.
47
 Property for getting / setting the `JitsiMeetViewDelegate` on `JitsiMeetView`.
48
 
48
 
49
+#### defaultURL
50
+
51
+Property for getting / setting the base default URL. The default URL is used for
52
+joining a conference when a non-full URL is given. If not set (or nil), the
53
+builtin default (in JavaScript) is used: https://meet.jit.si.
54
+
55
+NOTE: Must be set before `loadURL:`/`loadURLString:` for it to take effect.
56
+
49
 #### welcomePageEnabled
57
 #### welcomePageEnabled
50
 
58
 
51
 Property for getting / setting whether the Welcome page is enabled. If NO, a
59
 Property for getting / setting whether the Welcome page is enabled. If NO, a

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

23
 
23
 
24
 @property (nonatomic, nullable, weak) id<JitsiMeetViewDelegate> delegate;
24
 @property (nonatomic, nullable, weak) id<JitsiMeetViewDelegate> delegate;
25
 
25
 
26
+@property (copy, nonatomic) NSURL *defaultURL;
27
+
26
 @property (nonatomic) BOOL welcomePageEnabled;
28
 @property (nonatomic) BOOL welcomePageEnabled;
27
 
29
 
28
 +             (BOOL)application:(UIApplication *_Nonnull)application
30
 +             (BOOL)application:(UIApplication *_Nonnull)application

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

231
 - (void)loadURLObject:(NSDictionary *)urlObject {
231
 - (void)loadURLObject:(NSDictionary *)urlObject {
232
     NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
232
     NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
233
 
233
 
234
+    if (self.defaultURL) {
235
+        props[@"defaultURL"] = [self.defaultURL absoluteString];
236
+    }
237
+
234
     props[@"externalAPIScope"] = externalAPIScope;
238
     props[@"externalAPIScope"] = externalAPIScope;
235
     props[@"welcomePageEnabled"] = @(self.welcomePageEnabled);
239
     props[@"welcomePageEnabled"] = @(self.welcomePageEnabled);
236
 
240
 

Loading…
Cancel
Save