Merge branch 'develop' into ismail/5068_start_thread

This commit is contained in:
ismailgulek
2021-11-19 00:23:24 +03:00
38 changed files with 808 additions and 381 deletions
+131 -84
View File
@@ -542,13 +542,8 @@ TableViewSectionsDelegate>
sectionAbout.headerTitle = VectorL10n.settingsAbout;
if (BuildSettings.settingsScreenShowAdvancedSettings)
{
sectionAbout.footerTitle = [NSString stringWithFormat:@"Element %@ (%@) / Olm %@\n%@\n%@",
AppInfo.current.appVersion.bundleShortVersion,
AppInfo.current.appVersion.bundleVersion,
[OLMKit versionString],
[MatrixKitL10n settingsConfigUserId:account.mxCredentials.userId],
[MatrixKitL10n settingsConfigHomeServer:account.mxCredentials.homeServer]];
{
sectionAbout.footerTitle = [self buildAboutSectionFooterTitleWithAccount:account];
}
[tmpSections addObject:sectionAbout];
@@ -993,9 +988,11 @@ TableViewSectionsDelegate>
{
MXWeakify(self);
[currentAlert dismissViewControllerAnimated:NO completion:nil];
currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountEmailValidationTitle] message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *validationAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountEmailValidationTitle]
message:message
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
[self stopActivityIndicator];
@@ -1004,14 +1001,15 @@ TableViewSectionsDelegate>
self.newEmailEditingEnabled = NO;
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n continue] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n continue] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
[self tryFinaliseAddEmailSession:threePidAddSession withAuthenticationParameters:authenticationParameters
threePidAddManager:threePidAddManager];
}]];
[currentAlert mxk_setAccessibilityIdentifier:@"SettingsVCEmailValidationAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
[validationAlert mxk_setAccessibilityIdentifier:@"SettingsVCEmailValidationAlert"];
[self presentViewController:validationAlert animated:YES completion:nil];
currentAlert = validationAlert;
}
- (void)tryFinaliseAddEmailSession:(MX3PidAddSession*)threePidAddSession withAuthenticationParameters:(NSDictionary*)authParams threePidAddManager:(MX3PidAddManager*)threePidAddManager
@@ -1051,11 +1049,13 @@ TableViewSectionsDelegate>
MXLogDebug(@"[SettingsViewController] tryFinaliseAddEmailSession: Wrong credentials");
// Ask password again
self->currentAlert = [UIAlertController alertControllerWithTitle:nil
message:[VectorL10n settingsAdd3pidInvalidPasswordMessage]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *passwordPrompt = [UIAlertController alertControllerWithTitle:nil
message:[VectorL10n settingsAdd3pidInvalidPasswordMessage]
preferredStyle:UIAlertControllerStyleAlert];
[self->currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXWeakify(self);
[passwordPrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
[self showAuthenticationIfNeededForAdding:kMX3PIDMediumEmail withSession:self.mainSession completion:^(NSDictionary *authParams) {
@@ -1063,7 +1063,8 @@ TableViewSectionsDelegate>
}];
}]];
[self presentViewController:self->currentAlert animated:YES completion:nil];
[self presentViewController:passwordPrompt animated:YES completion:nil];
self->currentAlert = passwordPrompt;
return;
}
@@ -1104,9 +1105,11 @@ TableViewSectionsDelegate>
MXWeakify(self);
[currentAlert dismissViewControllerAnimated:NO completion:nil];
currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountMsisdnValidationTitle] message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *validationAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountMsisdnValidationTitle]
message:message
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
@@ -1117,13 +1120,13 @@ TableViewSectionsDelegate>
self.newPhoneEditingEnabled = NO;
}]];
[currentAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
[validationAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.secureTextEntry = NO;
textField.placeholder = nil;
textField.keyboardType = UIKeyboardTypeDecimalPad;
}];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n submit] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n submit] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
@@ -1142,8 +1145,9 @@ TableViewSectionsDelegate>
}
}]];
[currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCMsisdnValidationAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
[validationAlert mxk_setAccessibilityIdentifier: @"SettingsVCMsisdnValidationAlert"];
[self presentViewController:validationAlert animated:YES completion:nil];
currentAlert = validationAlert;
}
- (void)finaliseAddPhoneNumberSession:(MX3PidAddSession*)threePidAddSession withToken:(NSString*)token andAuthenticationParameters:(NSDictionary*)authParams message:(NSString*)message threePidAddManager:(MX3PidAddManager*)threePidAddManager
@@ -1182,11 +1186,13 @@ TableViewSectionsDelegate>
MXLogDebug(@"[SettingsViewController] finaliseAddPhoneNumberSession: Wrong authentication credentials");
// Ask password again
self->currentAlert = [UIAlertController alertControllerWithTitle:nil
message:[VectorL10n settingsAdd3pidInvalidPasswordMessage]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *passwordPrompt = [UIAlertController alertControllerWithTitle:nil
message:[VectorL10n settingsAdd3pidInvalidPasswordMessage]
preferredStyle:UIAlertControllerStyleAlert];
[self->currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXWeakify(self);
[passwordPrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
[self showAuthenticationIfNeededForAdding:kMX3PIDMediumMSISDN withSession:self.mainSession completion:^(NSDictionary *authParams) {
@@ -1194,7 +1200,8 @@ TableViewSectionsDelegate>
}];
}]];
[self presentViewController:self->currentAlert animated:YES completion:nil];
[self presentViewController:passwordPrompt animated:YES completion:nil];
self->currentAlert = passwordPrompt;
return;
}
@@ -1234,17 +1241,20 @@ TableViewSectionsDelegate>
}
self->currentAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
[self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXWeakify(self);
[errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
// Ask again the sms token
[self showValidationMsisdnDialogWithMessage:message for3PidAddSession:threePidAddSession threePidAddManager:threePidAddManager authenticationParameters:authParams];
}]];
[self->currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCErrorAlert"];
[self presentViewController:self->currentAlert animated:YES completion:nil];
[errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCErrorAlert"];
[self presentViewController:errorAlert animated:YES completion:nil];
self->currentAlert = errorAlert;
}
}];
}
@@ -1412,6 +1422,35 @@ TableViewSectionsDelegate>
}
}
- (NSString*)buildAboutSectionFooterTitleWithAccount:(MXKAccount*)account
{
NSMutableString *footerText = [NSMutableString new];
AppInfo *appInfo = AppInfo.current;
NSString *appName = appInfo.displayName;
NSString *appVersion = appInfo.appVersion.bundleShortVersion;
NSString *buildVersion = appInfo.appVersion.bundleVersion;
NSString *appVersionInfo = [NSString stringWithFormat:@"%@ %@ (%@)", appName, appVersion, buildVersion];
NSString *loggedUserInfo = [MatrixKitL10n settingsConfigUserId:account.mxCredentials.userId];
NSString *homeserverInfo = [MatrixKitL10n settingsConfigHomeServer:account.mxCredentials.homeServer];
NSString *sdkVersionInfo = [NSString stringWithFormat:@"Matrix SDK %@", MatrixSDKVersion];
NSString *olmVersionInfo = [NSString stringWithFormat:@"OLM %@", [OLMKit versionString]];
[footerText appendFormat:@"%@\n", loggedUserInfo];
[footerText appendFormat:@"%@\n", homeserverInfo];
[footerText appendFormat:@"%@\n", appVersionInfo];
[footerText appendFormat:@"%@\n", sdkVersionInfo];
[footerText appendFormat:@"%@", olmVersionInfo];
return [footerText copy];
}
#pragma mark - 3Pid Add
- (void)showAuthenticationIfNeededForAdding:(MX3PIDMedium)medium withSession:(MXSession*)session completion:(void (^)(NSDictionary* authParams))completion
@@ -2620,11 +2659,11 @@ TableViewSectionsDelegate>
__weak typeof(self) weakSelf = self;
currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n settingsUnignoreUser:ignoredUserId] message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *unignorePrompt = [UIAlertController alertControllerWithTitle:[VectorL10n settingsUnignoreUser:ignoredUserId] message:nil preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[unignorePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
@@ -2653,9 +2692,9 @@ TableViewSectionsDelegate>
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[unignorePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
@@ -2665,8 +2704,9 @@ TableViewSectionsDelegate>
}]];
[currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCUnignoreAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
[unignorePrompt mxk_setAccessibilityIdentifier: @"SettingsVCUnignoreAlert"];
[self presentViewController:unignorePrompt animated:YES completion:nil];
currentAlert = unignorePrompt;
}
}
else if (section == SECTION_TAG_ABOUT)
@@ -2852,9 +2892,9 @@ TableViewSectionsDelegate>
}
// Remove ?
currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n settingsRemovePromptTitle] message:promptMsg preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *removePrompt = [UIAlertController alertControllerWithTitle:[VectorL10n settingsRemovePromptTitle] message:promptMsg preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
[removePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -2866,7 +2906,7 @@ TableViewSectionsDelegate>
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n remove]
[removePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n remove]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -2906,8 +2946,9 @@ TableViewSectionsDelegate>
}]];
[currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCRemove3PIDAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
[removePrompt mxk_setAccessibilityIdentifier: @"SettingsVCRemove3PIDAlert"];
[self presentViewController:removePrompt animated:YES completion:nil];
currentAlert = removePrompt;
}
}
}
@@ -2929,9 +2970,9 @@ TableViewSectionsDelegate>
NSString *title = [VectorL10n settingsNotificationsDisabledAlertTitle];
NSString *message = [VectorL10n settingsNotificationsDisabledAlertMessage];
currentAlert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *showSettingsPrompt = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
[showSettingsPrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -2955,13 +2996,14 @@ TableViewSectionsDelegate>
}
}];
[currentAlert addAction:settingsAction];
currentAlert.preferredAction = settingsAction;
[showSettingsPrompt addAction:settingsAction];
showSettingsPrompt.preferredAction = settingsAction;
[currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCPushNotificationsAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
[showSettingsPrompt mxk_setAccessibilityIdentifier: @"SettingsVCPushNotificationsAlert"];
[self presentViewController:showSettingsPrompt animated:YES completion:nil];
currentAlert = showSettingsPrompt;
// Keep off the switch
// Keep the the switch off.
sender.on = NO;
}
else if ([MXKAccountManager sharedManager].activeAccounts.count)
@@ -3356,11 +3398,11 @@ TableViewSectionsDelegate>
[currentAlert dismissViewControllerAnimated:NO completion:nil];
currentAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
@@ -3381,9 +3423,9 @@ TableViewSectionsDelegate>
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n retry]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n retry]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
@@ -3397,8 +3439,9 @@ TableViewSectionsDelegate>
}]];
[currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCSaveChangesFailedAlert"];
[rootViewController presentViewController:currentAlert animated:YES completion:nil];
[errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCSaveChangesFailedAlert"];
[rootViewController presentViewController:errorAlert animated:YES completion:nil];
currentAlert = errorAlert;
}
}
@@ -3419,13 +3462,13 @@ TableViewSectionsDelegate>
[currentAlert dismissViewControllerAnimated:NO completion:nil];
currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorEmailWrongTitle]
message:[MatrixKitL10n accountErrorEmailWrongDescription]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorEmailWrongTitle]
message:[MatrixKitL10n accountErrorEmailWrongDescription]
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
@@ -3436,8 +3479,9 @@ TableViewSectionsDelegate>
}]];
[currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddEmailAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
[errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddEmailAlert"];
[self presentViewController:errorAlert animated:YES completion:nil];
currentAlert = errorAlert;
return;
}
@@ -3529,11 +3573,11 @@ TableViewSectionsDelegate>
[currentAlert dismissViewControllerAnimated:NO completion:nil];
__weak typeof(self) weakSelf = self;
currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorMsisdnWrongTitle]
message:[MatrixKitL10n accountErrorMsisdnWrongDescription]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorMsisdnWrongTitle]
message:[MatrixKitL10n accountErrorMsisdnWrongDescription]
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
[errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -3545,8 +3589,9 @@ TableViewSectionsDelegate>
}]];
[currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddMsisdnAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
[errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddMsisdnAlert"];
[self presentViewController:errorAlert animated:YES completion:nil];
currentAlert = errorAlert;
return;
}
@@ -3902,9 +3947,9 @@ TableViewSectionsDelegate>
{
[self->currentAlert dismissViewControllerAnimated:NO completion:nil];
self->currentAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsPasswordUpdated] preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *successAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsPasswordUpdated] preferredStyle:UIAlertControllerStyleAlert];
[self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
[successAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -3924,8 +3969,9 @@ TableViewSectionsDelegate>
}]];
[self->currentAlert mxk_setAccessibilityIdentifier:@"SettingsVCOnPasswordUpdatedAlert"];
[self presentViewController:self->currentAlert animated:YES completion:nil];
[successAlert mxk_setAccessibilityIdentifier:@"SettingsVCOnPasswordUpdatedAlert"];
[self presentViewController:successAlert animated:YES completion:nil];
self->currentAlert = successAlert;
}
else
{
@@ -3950,9 +3996,9 @@ TableViewSectionsDelegate>
{
[self->currentAlert dismissViewControllerAnimated:NO completion:nil];
self->currentAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsFailToUpdatePassword] preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsFailToUpdatePassword] preferredStyle:UIAlertControllerStyleAlert];
[self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
[errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -3973,8 +4019,9 @@ TableViewSectionsDelegate>
}]];
[self->currentAlert mxk_setAccessibilityIdentifier:@"SettingsVCPasswordChangeFailedAlert"];
[rootViewController presentViewController:self->currentAlert animated:YES completion:nil];
[errorAlert mxk_setAccessibilityIdentifier:@"SettingsVCPasswordChangeFailedAlert"];
[rootViewController presentViewController:errorAlert animated:YES completion:nil];
self->currentAlert = errorAlert;
}
}