[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.
This commit is contained in:
Lyubo Marinov 2017-07-25 19:06:03 -05:00
parent 6c488cc613
commit f0ab835b46
5 changed files with 66 additions and 16 deletions

View File

@ -93,6 +93,10 @@ See JitsiMeetView.getWelcomePageEnabled.
See JitsiMeetView.loadURL.
#### loadURLString(String)
See JitsiMeetView.loadURLString.
#### setWelcomePageEnabled(boolean)
See JitsiMeetView.setWelcomePageEnabled.
@ -113,8 +117,13 @@ empty view will be rendered when not in a conference. Defaults to false.
#### loadURL(URL)
Loads the given URL and joins the room. If `null` is specified, the welcome page
is displayed instead.
Loads a specific URL which may identify a conference to join. If the specified
URL is null, the Welcome page is displayed instead.
#### loadURLString(String)
Loads a specific URL which may identify a conference to join. If the specified
URL is null, the Welcome page is displayed instead.
#### setListener(listener)
@ -126,7 +135,7 @@ interface) on the view.
Sets whether the Welcome page is enabled. See `getWelcomePageEnabled` for more
information.
NOTE: Must be called before `loadURL` for it to take effect.
NOTE: Must be called before `loadURL`/`loadURLString` for it to take effect.
#### onBackPressed()

View File

@ -221,19 +221,33 @@ public class JitsiMeetView extends FrameLayout {
}
/**
* Loads the given URL and displays the conference. If the specified URL is
* null, the welcome page is displayed instead.
* Loads a specific {@link URL} which may identify a conference to join. If
* the specified {@code URL} is {@code null}, the Welcome page is displayed
* instead.
*
* @param url - The conference URL.
* @param url - The {@code URL} to load which may identify a conference to
* join.
*/
public void loadURL(@Nullable URL url) {
loadURLString(url == null ? null : url.toString());
}
/**
* Loads a specific URL {@link String} which may identify a conference to
* join. If the specified URL {@code String} is {@code null}, the Welcome
* page is displayed instead.
*
* @param urlString - The URL {@code String} to load which may identify a
* conference to join.
*/
public void loadURLString(@Nullable String urlString) {
Bundle props = new Bundle();
// externalAPIScope
props.putString("externalAPIScope", externalAPIScope);
// url
if (url != null) {
props.putString("url", url.toString());
if (urlString != null) {
props.putString("url", urlString);
}
// welcomePageEnabled
props.putBoolean("welcomePageEnabled", welcomePageEnabled);

View File

@ -41,16 +41,25 @@ Property for getting / setting the `JitsiMeetViewDelegate` on `JitsiMeetView`.
Property for getting / setting whether the Welcome page is enabled. If NO, a
black empty view will be rendered when not in a conference. Defaults to NO.
NOTE: Must be set before calling `loadURL` for it to take effect.
NOTE: Must be set before `loadURL:`/`loadURLString:` for it to take effect.
#### loadURL(URL)
#### loadURL:NSURL
```objc
[meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
```
Loads the given URL and joins the room. If `null` is specified, the welcome page
is displayed instead.
Loads a specific URL which may identify a conference to join. If the specified
URL is `nil`, the Welcome page is displayed instead.
#### loadURLString:NSString
```objc
[meetView loadURLString:@"https://meet.jit.si/test123"];
```
Loads a specific URL which may identify a conference to join. If the specified
URL is `nil`, the Welcome page is displayed instead.
#### Universal / deep linking

View File

@ -39,4 +39,6 @@
- (void)loadURL:(NSURL * _Nullable)url;
- (void)loadURLString:(NSString * _Nullable)urlString;
@end

View File

@ -177,17 +177,33 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
#pragma mark API
/**
* Loads the given URL and joins the specified conference. If the specified URL
* is null, the welcome page is shown.
* Loads a specific {@link NSURL} which may identify a conference to join. If
* the specified {@code NSURL} is {@code nil}, the Welcome page is displayed
* instead.
*
* @param url - The {@code NSURL} to load which may identify a conference to
* join.
*/
- (void)loadURL:(NSURL *)url {
[self loadURLString:(url ? url.absoluteString : nil)];
}
/**
* Loads a specific URL {@link NSString} which may identify a conference to
* join. If the specified URL {@code NSString} is {@code nil}, the Welcome page
* is displayed instead.
*
* @param urlString - The URL {@code NSString} to load which may identify a
* conference to join.
*/
- (void)loadURLString:(NSString *)urlString {
NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
// externalAPIScope
[props setObject:externalAPIScope forKey:@"externalAPIScope"];
// url
if (url) {
[props setObject:url.absoluteString forKey:@"url"];
if (urlString) {
[props setObject:urlString forKey:@"url"];
}
// welcomePageEnabled
[props setObject:@(self.welcomePageEnabled) forKey:@"welcomePageEnabled"];