feat(rn,sdk) add setConfigOverride to JitsiMeetConferenceOptions

Allows for overriding any (overridable, of course) config option.
This commit is contained in:
tmoldovan8x8 2021-08-13 13:03:41 +03:00 committed by GitHub
parent bcc870daa7
commit ae33755913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 184 deletions

View File

@ -40,10 +40,6 @@ public class JitsiMeetConferenceOptions implements Parcelable {
* Room name.
*/
private String room;
/**
* Conference subject.
*/
private String subject;
/**
* JWT token used for authentication.
*/
@ -54,19 +50,16 @@ public class JitsiMeetConferenceOptions implements Parcelable {
*/
private Bundle colorScheme;
/**
* Config. See: https://github.com/jitsi/jitsi-meet/blob/master/config.js
*/
private Bundle config;
/**
* Feature flags. See: https://github.com/jitsi/jitsi-meet/blob/master/react/features/base/flags/constants.js
*/
private Bundle featureFlags;
/**
* Set to {@code true} to join the conference with audio / video muted or to start in audio
* only mode respectively.
*/
private Boolean audioMuted;
private Boolean audioOnly;
private Boolean videoMuted;
/**
* USer information, to be used when no token is specified.
*/
@ -80,10 +73,6 @@ public class JitsiMeetConferenceOptions implements Parcelable {
return room;
}
public String getSubject() {
return subject;
}
public String getToken() {
return token;
}
@ -96,18 +85,6 @@ public class JitsiMeetConferenceOptions implements Parcelable {
return featureFlags;
}
public boolean getAudioMuted() {
return audioMuted;
}
public boolean getAudioOnly() {
return audioOnly;
}
public boolean getVideoMuted() {
return videoMuted;
}
public JitsiMeetUserInfo getUserInfo() {
return userInfo;
}
@ -118,19 +95,16 @@ public class JitsiMeetConferenceOptions implements Parcelable {
public static class Builder {
private URL serverURL;
private String room;
private String subject;
private String token;
private Bundle colorScheme;
private Bundle config;
private Bundle featureFlags;
private Boolean audioMuted;
private Boolean audioOnly;
private Boolean videoMuted;
private JitsiMeetUserInfo userInfo;
public Builder() {
config = new Bundle();
featureFlags = new Bundle();
}
@ -162,7 +136,7 @@ public class JitsiMeetConferenceOptions implements Parcelable {
* @return - The {@link Builder} object itself so the method calls can be chained.
*/
public Builder setSubject(String subject) {
this.subject = subject;
setConfigOverride("subject", subject);
return this;
}
@ -193,11 +167,11 @@ public class JitsiMeetConferenceOptions implements Parcelable {
/**
* Indicates the conference will be joined with the microphone muted.
* @param muted - Muted indication.
* @param audioMuted - Muted indication.
* @return - The {@link Builder} object itself so the method calls can be chained.
*/
public Builder setAudioMuted(boolean muted) {
this.audioMuted = muted;
public Builder setAudioMuted(boolean audioMuted) {
setConfigOverride("startWithAudioMuted", audioMuted);
return this;
}
@ -209,7 +183,7 @@ public class JitsiMeetConferenceOptions implements Parcelable {
* @return - The {@link Builder} object itself so the method calls can be chained.
*/
public Builder setAudioOnly(boolean audioOnly) {
this.audioOnly = audioOnly;
setConfigOverride("startAudioOnly", audioOnly);
return this;
}
@ -219,7 +193,7 @@ public class JitsiMeetConferenceOptions implements Parcelable {
* @return - The {@link Builder} object itself so the method calls can be chained.
*/
public Builder setVideoMuted(boolean videoMuted) {
this.videoMuted = videoMuted;
setConfigOverride("startWithVideoMuted", videoMuted);
return this;
}
@ -261,6 +235,36 @@ public class JitsiMeetConferenceOptions implements Parcelable {
return this;
}
public Builder setConfigOverride(String config, String value) {
this.config.putString(config, value);
return this;
}
public Builder setConfigOverride(String config, int value) {
this.config.putInt(config, value);
return this;
}
public Builder setConfigOverride(String config, boolean value) {
this.config.putBoolean(config, value);
return this;
}
public Builder setConfigOverride(String config, Bundle bundle) {
this.config.putBundle(config, bundle);
return this;
}
public Builder setConfigOverride(String config, String[] list) {
this.config.putStringArray(config, list);
return this;
}
/**
* Builds the immutable {@link JitsiMeetConferenceOptions} object with the configuration
* that this {@link Builder} instance specified.
@ -271,13 +275,10 @@ public class JitsiMeetConferenceOptions implements Parcelable {
options.serverURL = this.serverURL;
options.room = this.room;
options.subject = this.subject;
options.token = this.token;
options.colorScheme = this.colorScheme;
options.config = this.config;
options.featureFlags = this.featureFlags;
options.audioMuted = this.audioMuted;
options.audioOnly = this.audioOnly;
options.videoMuted = this.videoMuted;
options.userInfo = this.userInfo;
return options;
@ -290,17 +291,12 @@ public class JitsiMeetConferenceOptions implements Parcelable {
private JitsiMeetConferenceOptions(Parcel in) {
serverURL = (URL) in.readSerializable();
room = in.readString();
subject = in.readString();
token = in.readString();
colorScheme = in.readBundle();
config = in.readBundle();
featureFlags = in.readBundle();
userInfo = new JitsiMeetUserInfo(in.readBundle());
byte tmpAudioMuted = in.readByte();
audioMuted = tmpAudioMuted == 0 ? null : tmpAudioMuted == 1;
byte tmpAudioOnly = in.readByte();
audioOnly = tmpAudioOnly == 0 ? null : tmpAudioOnly == 1;
byte tmpVideoMuted = in.readByte();
videoMuted = tmpVideoMuted == 0 ? null : tmpVideoMuted == 1;
}
Bundle asProps() {
@ -317,21 +313,6 @@ public class JitsiMeetConferenceOptions implements Parcelable {
props.putBundle("colorScheme", colorScheme);
}
Bundle config = new Bundle();
if (audioMuted != null) {
config.putBoolean("startWithAudioMuted", audioMuted);
}
if (audioOnly != null) {
config.putBoolean("startAudioOnly", audioOnly);
}
if (videoMuted != null) {
config.putBoolean("startWithVideoMuted", videoMuted);
}
if (subject != null) {
config.putString("subject", subject);
}
Bundle urlProps = new Bundle();
// The room is fully qualified
@ -379,14 +360,11 @@ public class JitsiMeetConferenceOptions implements Parcelable {
public void writeToParcel(Parcel dest, int flags) {
dest.writeSerializable(serverURL);
dest.writeString(room);
dest.writeString(subject);
dest.writeString(token);
dest.writeBundle(colorScheme);
dest.writeBundle(config);
dest.writeBundle(featureFlags);
dest.writeBundle(userInfo != null ? userInfo.asBundle() : new Bundle());
dest.writeByte((byte) (audioMuted == null ? 0 : audioMuted ? 1 : 2));
dest.writeByte((byte) (audioOnly == null ? 0 : audioOnly ? 1 : 2));
dest.writeByte((byte) (videoMuted == null ? 0 : videoMuted ? 1 : 2));
}
@Override

View File

@ -594,6 +594,9 @@ var config = {
},
analytics: {
// True if the analytics should be disabled
// disabled: false,
// The Google Analytics Tracking ID:
// googleAnalyticsTrackingId: 'your-tracking-id-UA-123456-1'

View File

@ -29,10 +29,6 @@
* Room name.
*/
@property (nonatomic, copy, nullable) NSString *room;
/**
* Conference subject.
*/
@property (nonatomic, copy, nullable) NSString *subject;
/**
* JWT token used for authentication.
*/
@ -49,13 +45,7 @@
*/
@property (nonatomic, readonly, nonnull) NSDictionary *featureFlags;
/**
* Set to YES to join the conference with audio / video muted or to start in audio
* only mode respectively.
*/
@property (nonatomic) BOOL audioOnly;
@property (nonatomic) BOOL audioMuted;
@property (nonatomic) BOOL videoMuted;
@property (nonatomic, readonly, nonnull) NSDictionary *config;
/**
* Set to YES to enable the welcome page. Typically SDK users won't need this enabled
@ -71,15 +61,17 @@
- (void)setFeatureFlag:(NSString *_Nonnull)flag withBoolean:(BOOL)value;
- (void)setFeatureFlag:(NSString *_Nonnull)flag withValue:(id _Nonnull)value;
/**
* CallKit call handle, to be used when implementing incoming calls.
*/
@property (nonatomic, copy, nullable) NSString *callHandle;
- (void)setConfigOverride:(NSString *_Nonnull)config withBoolean:(BOOL)value;
- (void)setConfigOverride:(NSString *_Nonnull)config withValue:(id _Nonnull)value;
- (void)setConfigOverride:(NSString *_Nonnull)config withDictionary:(NSDictionary * _Nonnull)dictionary;
- (void)setConfigOverride:(NSString *_Nonnull)config withArray:( NSArray * _Nonnull)array;
/**
* CallKit call UUID, to be used when implementing incoming calls.
*/
@property (nonatomic, copy, nullable) NSUUID *callUUID;
- (void)setAudioOnly:(BOOL)audioOnly;
- (void)setAudioMuted:(BOOL)audioMuted;
- (void)setVideoMuted:(BOOL)videoMuted;
- (void)setCallHandle:(NSString *_Nonnull)callHandle;
- (void)setCallUUID:(NSUUID *_Nonnull)callUUID;
- (void)setSubject:(NSString *_Nonnull)subject;
@end
@ -88,23 +80,15 @@
@property (nonatomic, copy, nullable, readonly) NSURL *serverURL;
@property (nonatomic, copy, nullable, readonly) NSString *room;
@property (nonatomic, copy, nullable, readonly) NSString *subject;
@property (nonatomic, copy, nullable, readonly) NSString *token;
@property (nonatomic, copy, nullable) NSDictionary *colorScheme;
@property (nonatomic, readonly, nonnull) NSDictionary *featureFlags;
@property (nonatomic, readonly) BOOL audioOnly;
@property (nonatomic, readonly) BOOL audioMuted;
@property (nonatomic, readonly) BOOL videoMuted;
@property (nonatomic, readonly) BOOL welcomePageEnabled;
@property (nonatomic, nullable) JitsiMeetUserInfo *userInfo;
@property (nonatomic, copy, nullable, readonly) NSString *callHandle;
@property (nonatomic, copy, nullable, readonly) NSUUID *callUUID;
+ (instancetype _Nonnull)fromBuilder:(void (^_Nonnull)(JitsiMeetConferenceOptionsBuilder *_Nonnull))initBlock;
- (instancetype _Nonnull)init NS_UNAVAILABLE;

View File

@ -26,35 +26,23 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
@implementation JitsiMeetConferenceOptionsBuilder {
NSNumber *_audioOnly;
NSNumber *_audioMuted;
NSNumber *_videoMuted;
NSMutableDictionary *_featureFlags;
NSMutableDictionary *_config;
}
@dynamic audioOnly;
@dynamic audioMuted;
@dynamic videoMuted;
@dynamic welcomePageEnabled;
- (instancetype)init {
if (self = [super init]) {
_serverURL = nil;
_room = nil;
_subject = nil;
_token = nil;
_colorScheme = nil;
_config = [[NSMutableDictionary alloc] init];
_featureFlags = [[NSMutableDictionary alloc] init];
_audioOnly = nil;
_audioMuted = nil;
_videoMuted = nil;
_userInfo = nil;
_callHandle = nil;
_callUUID = nil;
}
return self;
@ -68,32 +56,48 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
_featureFlags[flag] = value;
}
#pragma mark - Dynamic properties
- (void)setAudioOnly:(BOOL)audioOnly {
_audioOnly = [NSNumber numberWithBool:audioOnly];
}
- (BOOL)audioOnly {
return _audioOnly && [_audioOnly boolValue];
[self setConfigOverride:@"startAudioOnly" withBoolean:audioOnly];
}
- (void)setAudioMuted:(BOOL)audioMuted {
_audioMuted = [NSNumber numberWithBool:audioMuted];
}
- (BOOL)audioMuted {
return _audioMuted && [_audioMuted boolValue];
[self setConfigOverride:@"startWithAudioMuted" withBoolean:audioMuted];
}
- (void)setVideoMuted:(BOOL)videoMuted {
_videoMuted = [NSNumber numberWithBool:videoMuted];
[self setConfigOverride:@"startWithVideoMuted" withBoolean:videoMuted];
}
- (BOOL)videoMuted {
return _videoMuted && [_videoMuted boolValue];
- (void)setCallHandle:(NSString *_Nonnull)callHandle {
[self setConfigOverride:@"callHandle" withValue:callHandle];
}
- (void)setCallUUID:(NSUUID *_Nonnull)callUUID {
[self setConfigOverride:@"callUUID" withValue:[callUUID UUIDString]];
}
- (void)setSubject:(NSString *_Nonnull)subject {
[self setConfigOverride:@"subject" withValue:subject];
}
- (void)setConfigOverride:(NSString *_Nonnull)config withBoolean:(BOOL)value {
[self setConfigOverride:config withValue:[NSNumber numberWithBool:value]];
}
- (void)setConfigOverride:(NSString *_Nonnull)config withDictionary:(NSDictionary*)dictionary {
_config[config] = dictionary;
}
- (void)setConfigOverride:(NSString *_Nonnull)config withArray:( NSArray * _Nonnull)array {
_config[config] = array;
}
- (void)setConfigOverride:(NSString *_Nonnull)config withValue:(id _Nonnull)value {
_config[config] = value;
}
#pragma mark - Dynamic properties
- (void)setWelcomePageEnabled:(BOOL)welcomePageEnabled {
[self setFeatureFlag:WelcomePageEnabledFeatureFlag
withBoolean:welcomePageEnabled];
@ -105,48 +109,17 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
return n != nil ? [n boolValue] : NO;
}
#pragma mark - Private API
- (NSNumber *)getAudioOnly {
return _audioOnly;
}
- (NSNumber *)getAudioMuted {
return _audioMuted;
}
- (NSNumber *)getVideoMuted {
return _videoMuted;
}
@end
@implementation JitsiMeetConferenceOptions {
NSNumber *_audioOnly;
NSNumber *_audioMuted;
NSNumber *_videoMuted;
NSDictionary *_featureFlags;
NSDictionary *_config;
}
@dynamic audioOnly;
@dynamic audioMuted;
@dynamic videoMuted;
@dynamic welcomePageEnabled;
#pragma mark - Dynamic properties
- (BOOL)audioOnly {
return _audioOnly && [_audioOnly boolValue];
}
- (BOOL)audioMuted {
return _audioMuted && [_audioMuted boolValue];
}
- (BOOL)videoMuted {
return _videoMuted && [_videoMuted boolValue];
}
- (BOOL)welcomePageEnabled {
NSNumber *n = _featureFlags[WelcomePageEnabledFeatureFlag];
@ -159,21 +132,15 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
if (self = [super init]) {
_serverURL = builder.serverURL;
_room = builder.room;
_subject = builder.subject;
_token = builder.token;
_colorScheme = builder.colorScheme;
_audioOnly = [builder getAudioOnly];
_audioMuted = [builder getAudioMuted];
_videoMuted = [builder getVideoMuted];
_config = builder.config;
_featureFlags = [NSDictionary dictionaryWithDictionary:builder.featureFlags];
_userInfo = builder.userInfo;
_callHandle = builder.callHandle;
_callUUID = builder.callUUID;
}
return self;
@ -198,26 +165,6 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
props[@"colorScheme"] = self.colorScheme;
}
NSMutableDictionary *config = [[NSMutableDictionary alloc] init];
if (_audioOnly != nil) {
config[@"startAudioOnly"] = @(self.audioOnly);
}
if (_audioMuted != nil) {
config[@"startWithAudioMuted"] = @(self.audioMuted);
}
if (_videoMuted != nil) {
config[@"startWithVideoMuted"] = @(self.videoMuted);
}
if (_subject != nil) {
config[@"subject"] = self.subject;
}
if (_callHandle != nil) {
config[@"callHandle"] = self.callHandle;
}
if (_callUUID != nil) {
config[@"callUUID"] = [self.callUUID UUIDString];
}
NSMutableDictionary *urlProps = [[NSMutableDictionary alloc] init];
// The room is fully qualified.
@ -241,7 +188,7 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
props[@"userInfo"] = [self.userInfo asDict];
}
urlProps[@"config"] = config;
urlProps[@"config"] = _config;
props[@"url"] = urlProps;
return props;