Jitsi widget: Create a specific [NSUserDefaults standardUserDefaults] key for useJitsiForConferenceCalls

This commit is contained in:
manuroe 2017-08-16 11:51:56 +02:00
parent 40995c9663
commit 1e62fcadaa
2 changed files with 11 additions and 18 deletions

View file

@ -394,14 +394,10 @@
{
Widget *jitsiWidget;
NSArray<Widget*> *widgets = [[WidgetManager sharedManager] widgetsInRoom:self.room];
for (Widget *widget in widgets)
// Manage only one jitsi widget at a time for the moment
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"useJitsiForConferenceCalls"])
{
if ([widget.type isEqualToString:kWidgetTypeJitsi])
{
jitsiWidget = widget;
break;
}
jitsiWidget = [[WidgetManager sharedManager] widgetsOfTypes:@[kWidgetTypeJitsi] inRoom:self.room].firstObject;
}
return jitsiWidget;

View file

@ -1870,14 +1870,11 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
{
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.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"useJitsiForConferenceCalls"];
[labelAndSwitchCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleLabsMatrixApps:) forControlEvents:UIControlEventTouchUpInside];
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleJitsiForConference:) forControlEvents:UIControlEventTouchUpInside];
cell = labelAndSwitchCell;
}
@ -2570,17 +2567,17 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
}
}
- (void)toggleLabsMatrixApps:(id)sender
- (void)toggleJitsiForConference:(id)sender
{
if (sender && [sender isKindOfClass:UISwitch.class])
{
UISwitch *switchButton = (UISwitch*)sender;
if (switchButton.isOn != [WidgetManager sharedManager].enabled)
{
[WidgetManager sharedManager].enabled = switchButton.isOn;
[[NSUserDefaults standardUserDefaults] setBool:switchButton.isOn forKey:@"useJitsiForConferenceCalls"];
[[NSUserDefaults standardUserDefaults] synchronize];
[self.tableView reloadData];
}
}
}
- (void)toggleLabsEndToEndEncryption:(id)sender