mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Jitsi widget: Add Settings > LABS > Use jitsi for conference calls
This commit is contained in:
parent
e73cea2892
commit
c7e2ca6de2
5 changed files with 62 additions and 4 deletions
|
@ -341,6 +341,7 @@
|
|||
|
||||
"settings_labs_e2e_encryption" = "End-to-End Encryption";
|
||||
"settings_labs_e2e_encryption_prompt_message" = "To finish setting up encryption you must log in again.";
|
||||
"settings_labs_jitsi_conference" = "Use jitsi for conference calls";
|
||||
|
||||
"settings_version" = "Version %@";
|
||||
"settings_olm_version" = "Olm Version %@";
|
||||
|
|
|
@ -48,13 +48,18 @@ extern NSString *const kMXKWidgetManagerDidUpdateWidgetNotification;
|
|||
*/
|
||||
+ (instancetype)sharedManager;
|
||||
|
||||
/**
|
||||
A [NSUserDefaults standardUserDefaults] setting to enable scalar widgets.
|
||||
*/
|
||||
@property (nonatomic) BOOL enabled;
|
||||
|
||||
/**
|
||||
List all active widgets in a room.
|
||||
|
||||
@param room the room to check.
|
||||
@return a list of widgets.
|
||||
*/
|
||||
-(NSArray<Widget*> *)widgetsInRoom:(MXRoom*)room;
|
||||
- (NSArray<Widget*> *)widgetsInRoom:(MXRoom*)room;
|
||||
|
||||
/**
|
||||
Add/remove matrix session.
|
||||
|
|
|
@ -46,6 +46,17 @@ NSString *const kMXKWidgetManagerDidUpdateWidgetNotification = @"kMXKWidgetManag
|
|||
return sharedManager;
|
||||
}
|
||||
|
||||
- (BOOL)enabled
|
||||
{
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"MatrixApps"];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"MatrixApps"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
@ -58,6 +69,11 @@ NSString *const kMXKWidgetManagerDidUpdateWidgetNotification = @"kMXKWidgetManag
|
|||
|
||||
- (NSArray<Widget *> *)widgetsInRoom:(MXRoom *)room
|
||||
{
|
||||
if (!self.enabled)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Widget id -> widget
|
||||
NSMutableDictionary <NSString*, Widget *> *widgets = [NSMutableDictionary dictionary];
|
||||
|
||||
|
@ -112,9 +128,13 @@ NSString *const kMXKWidgetManagerDidUpdateWidgetNotification = @"kMXKWidgetManag
|
|||
|
||||
- (void)addMatrixSession:(MXSession *)mxSession
|
||||
{
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
|
||||
id listener = [mxSession listenToEventsOfTypes:@[kWidgetEventTypeString] onEvent:^(MXEvent *event, MXTimelineDirection direction, id customObject) {
|
||||
|
||||
if (direction == MXTimelineDirectionForwards)
|
||||
typeof(self) self = weakSelf;
|
||||
|
||||
if (self.enabled && direction == MXTimelineDirectionForwards)
|
||||
{
|
||||
Widget *widget = [[Widget alloc] initWithWidgetEvent:event inMatrixSession:mxSession];
|
||||
if (widget)
|
||||
|
|
|
@ -95,7 +95,8 @@ enum
|
|||
|
||||
enum
|
||||
{
|
||||
LABS_CRYPTO_INDEX = 0,
|
||||
LABS_MATRIX_APPS_INDEX = 0,
|
||||
LABS_CRYPTO_INDEX,
|
||||
LABS_COUNT
|
||||
};
|
||||
|
||||
|
@ -1865,7 +1866,22 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
|||
}
|
||||
else if (section == SETTINGS_SECTION_LABS_INDEX)
|
||||
{
|
||||
if (row == LABS_CRYPTO_INDEX)
|
||||
if (row == LABS_MATRIX_APPS_INDEX)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
|
||||
// In the future, the text will be "Matrix Apps".
|
||||
// As we support only jitsi widget at the moment, [WidgetManager sharedManager].enabled
|
||||
// conditions the activation of "Use jitsi for conference call"
|
||||
labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_labs_jitsi_conference", @"Vector", nil);
|
||||
labelAndSwitchCell.mxkSwitch.on = [WidgetManager sharedManager].enabled;
|
||||
|
||||
[labelAndSwitchCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
|
||||
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleLabsMatrixApps:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
cell = labelAndSwitchCell;
|
||||
}
|
||||
else if (row == LABS_CRYPTO_INDEX)
|
||||
{
|
||||
MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
|
||||
|
||||
|
@ -2554,6 +2570,19 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
|
|||
}
|
||||
}
|
||||
|
||||
- (void)toggleLabsMatrixApps:(id)sender
|
||||
{
|
||||
if (sender && [sender isKindOfClass:UISwitch.class])
|
||||
{
|
||||
UISwitch *switchButton = (UISwitch*)sender;
|
||||
if (switchButton.isOn != [WidgetManager sharedManager].enabled)
|
||||
{
|
||||
[WidgetManager sharedManager].enabled = switchButton.isOn;
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)toggleLabsEndToEndEncryption:(id)sender
|
||||
{
|
||||
if (sender && [sender isKindOfClass:UISwitch.class])
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
/**
|
||||
The `JitsiViewController` is a specific VC for handling a jitsi widget using
|
||||
jitsi-meet iOS SDK instead of displaying it in a webview like other scalar widgets.
|
||||
|
||||
https://github.com/jitsi/jitsi-meet/tree/master/ios
|
||||
|
||||
*/
|
||||
@interface JitsiViewController : MXKViewController <JitsiMeetViewDelegate>
|
||||
|
||||
|
|
Loading…
Reference in a new issue