Merge branch 'develop' into doug/2368_2_allow_silent_notifications

This commit is contained in:
Doug
2021-07-27 16:52:30 +01:00
124 changed files with 3853 additions and 592 deletions
+49 -61
View File
@@ -142,7 +142,8 @@ enum
enum
{
LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX = 0
LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX = 0,
LABS_ENABLE_VOICE_MESSAGES = 1
};
enum
@@ -487,6 +488,7 @@ TableViewSectionsDelegate>
{
Section *sectionLabs = [Section sectionWithTag:SECTION_TAG_LABS];
[sectionLabs addRowWithTag:LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX];
[sectionLabs addRowWithTag:LABS_ENABLE_VOICE_MESSAGES];
sectionLabs.headerTitle = NSLocalizedStringFromTable(@"settings_labs", @"Vector", nil);
if (sectionLabs.hasAnyRows)
{
@@ -2263,6 +2265,17 @@ TableViewSectionsDelegate>
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableRingingForGroupCalls:) forControlEvents:UIControlEventValueChanged];
cell = labelAndSwitchCell;
} else if (row == LABS_ENABLE_VOICE_MESSAGES)
{
MXKTableViewCellWithLabelAndSwitch *labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_labs_voice_messages", @"Vector", nil);
labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.enableVoiceMessages;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableVoiceMessages:) forControlEvents:UIControlEventValueChanged];
cell = labelAndSwitchCell;
}
}
@@ -2789,7 +2802,7 @@ TableViewSectionsDelegate>
}
}
- (void)togglePushNotifications:(id)sender
- (void)togglePushNotifications:(UISwitch *)sender
{
// Get the user's notification settings to check their authorization status.
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
@@ -2828,7 +2841,7 @@ TableViewSectionsDelegate>
[self presentViewController:currentAlert animated:YES completion:nil];
// Keep off the switch
((UISwitch*)sender).on = NO;
sender.on = NO;
}
else if ([MXKAccountManager sharedManager].activeAccounts.count)
{
@@ -2851,7 +2864,7 @@ TableViewSectionsDelegate>
[[AppDelegate theDelegate] registerForRemoteNotificationsWithCompletion:^(NSError * error) {
if (error)
{
[(UISwitch *)sender setOn:NO animated:YES];
[sender setOn:NO animated:YES];
[self stopActivityIndicator];
}
else
@@ -2867,49 +2880,42 @@ TableViewSectionsDelegate>
}
}
- (void)toggleCallKit:(id)sender
- (void)toggleCallKit:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
[MXKAppSettings standardAppSettings].enableCallKit = switchButton.isOn;
[MXKAppSettings standardAppSettings].enableCallKit = sender.isOn;
}
- (void)toggleStunServerFallback:(id)sender
- (void)toggleStunServerFallback:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.allowStunServerFallback = switchButton.isOn;
RiotSettings.shared.allowStunServerFallback = sender.isOn;
self.mainSession.callManager.fallbackSTUNServer = RiotSettings.shared.allowStunServerFallback ? BuildSettings.stunServerFallbackUrlString : nil;
}
- (void)toggleAllowIntegrations:(id)sender
- (void)toggleAllowIntegrations:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
MXSession *session = self.mainSession;
[self startActivityIndicator];
__block RiotSharedSettings *sharedSettings = [[RiotSharedSettings alloc] initWithSession:session];
[sharedSettings setIntegrationProvisioningWithEnabled:switchButton.on success:^{
[sharedSettings setIntegrationProvisioningWithEnabled:sender.isOn success:^{
sharedSettings = nil;
[self stopActivityIndicator];
} failure:^(NSError * _Nullable error) {
sharedSettings = nil;
[switchButton setOn:!switchButton.on animated:YES];
[sender setOn:!sender.isOn animated:YES];
[self stopActivityIndicator];
}];
}
- (void)toggleShowDecodedContent:(id)sender
- (void)toggleShowDecodedContent:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.showDecryptedContentInNotifications = switchButton.isOn;
RiotSettings.shared.showDecryptedContentInNotifications = sender.isOn;
}
- (void)toggleLocalContactsSync:(id)sender
- (void)toggleLocalContactsSync:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
if (switchButton.on)
if (sender.on)
{
[MXKContactManager requestUserConfirmationForLocalContactsSyncInViewController:self completionHandler:^(BOOL granted) {
@@ -2950,47 +2956,36 @@ TableViewSectionsDelegate>
}
}
- (void)toggleEnableRageShake:(id)sender
- (void)toggleEnableRageShake:(UISwitch *)sender
{
if (sender && [sender isKindOfClass:UISwitch.class])
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.enableRageShake = switchButton.isOn;
[self updateSections];
}
RiotSettings.shared.enableRageShake = sender.isOn;
[self updateSections];
}
- (void)toggleEnableRingingForGroupCalls:(UISwitch *)sender
{
if (sender)
{
RiotSettings.shared.enableRingingForGroupCalls = sender.isOn;
[self.tableView reloadData];
}
RiotSettings.shared.enableRingingForGroupCalls = sender.isOn;
}
- (void)togglePinRoomsWithMissedNotif:(id)sender
- (void)toggleEnableVoiceMessages:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.pinRoomsWithMissedNotificationsOnHome = switchButton.on;
RiotSettings.shared.enableVoiceMessages = sender.isOn;
}
- (void)togglePinRoomsWithUnread:(id)sender
- (void)togglePinRoomsWithMissedNotif:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.pinRoomsWithUnreadMessagesOnHome = switchButton.on;
RiotSettings.shared.pinRoomsWithMissedNotificationsOnHome = sender.isOn;
}
- (void)toggleCommunityFlair:(id)sender
- (void)togglePinRoomsWithUnread:(UISwitch *)sender
{
UISwitch *switchButton = (UISwitch*)sender;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:switchButton.tag inSection:groupsDataSource.joinedGroupsSection];
RiotSettings.shared.pinRoomsWithUnreadMessagesOnHome = sender.on;
}
- (void)toggleCommunityFlair:(UISwitch *)sender
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender.tag inSection:groupsDataSource.joinedGroupsSection];
id<MXKGroupCellDataStoring> groupCellData = [groupsDataSource cellDataAtIndex:indexPath];
MXGroup *group = groupCellData.group;
@@ -3000,7 +2995,7 @@ TableViewSectionsDelegate>
__weak typeof(self) weakSelf = self;
[self.mainSession updateGroupPublicity:group isPublicised:switchButton.on success:^{
[self.mainSession updateGroupPublicity:group isPublicised:sender.isOn success:^{
if (weakSelf)
{
@@ -3016,7 +3011,7 @@ TableViewSectionsDelegate>
[self stopActivityIndicator];
// Come back to previous state button
[switchButton setOn:!switchButton.isOn animated:YES];
[sender setOn:!sender.isOn animated:YES];
// Notify user
[[AppDelegate theDelegate] showErrorAsAlert:error];
@@ -3662,16 +3657,9 @@ TableViewSectionsDelegate>
animated:YES];
}
- (void)toggleNSFWPublicRoomsFiltering:(id)sender
- (void)toggleNSFWPublicRoomsFiltering:(UISwitch *)sender
{
if (sender && [sender isKindOfClass:UISwitch.class])
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.showNSFWPublicRooms = switchButton.isOn;
[self.tableView reloadData];
}
RiotSettings.shared.showNSFWPublicRooms = sender.isOn;
}
#pragma mark - TextField listener