Merge branch 'privacy' into identity_server_v2

# Conflicts:
#	CHANGES.rst
#	Riot/Modules/Authentication/Views/AuthInputsView.m
This commit is contained in:
SBiOSoftWhare 2019-08-30 16:11:22 +02:00
commit 6488dd39cb
11 changed files with 346 additions and 99 deletions

View file

@ -2,11 +2,19 @@ Changes in 0.9.3 (2019-08-)
===============================================
Improvements:
* Prompt to accept integration manager policies on use (#2600).
* Use MXIdentityService to perform identity server requests (#2647).
* Support identity server v2 API authentication (#2603).
* Use the hashed v2 lookup API for 3PIDs (#2652).
* Prompt to accept identity server policies on firt use (#2602).
* Upgrade MatrixKit version ([v0.11.0](https://github.com/matrix-org/matrix-ios-kit/releases/tag/v0.11.0)).
* Widgets: Whitelist [MSC1961](https://github.com/matrix-org/matrix-doc/pull/1961) widget urls.
* Settings: CALLS section: Always display the CallKit option but grey it out when not available (only on China).
* VoIP: Fallback to matrix.org STUN server with a confirmation dialog (#2646).
* Privacy: Prompt to accept integration manager policies on use (#2600).
* Privacy: Make clear that device names are publicly readable (#2662).
* Privacy: Remove the bind true flag from 3PID calls on registration (#2648).
* Privacy: Remove the bind true flag from 3PID adds in settings (#2650).
* Privacy: Email help text on registration should be updated without binding (#2675).
* Privacy: Use MXIdentityService to perform identity server requests (#2647).
* Privacy: Support identity server v2 API authentication (#2603).
* Privacy: Use the hashed v2 lookup API for 3PIDs (#2652).
* Privacy: Prompt to accept identity server policies on firt use (#2602).
Changes in 0.9.2 (2019-08-08)
===============================================

View file

@ -2628,6 +2628,11 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
// Let's call invite be valid for 1 minute
mxSession.callManager.inviteLifetime = 60000;
if (RiotSettings.shared.allowStunServerFallback)
{
mxSession.callManager.fallbackSTUNServer = RiotSettings.shared.stunServerFallback;
}
// Setup CallKit
if ([MXCallKitAdapter callKitAvailable])
{
@ -3873,6 +3878,12 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
NSString *btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"active_call_details", @"Vector", nil), callViewController.callerNameLabel.text];
[self addCallStatusBar:btnTitle];
}
if ([callViewController isKindOfClass:[CallViewController class]]
&& ((CallViewController*)callViewController).shouldPromptForStunServerFallback)
{
[self promptForStunServerFallback];
}
if (completion)
{
@ -3906,6 +3917,52 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
}
}
- (void)promptForStunServerFallback
{
[_errorNotification dismissViewControllerAnimated:NO completion:nil];
NSString *stunFallbackHost = RiotSettings.shared.stunServerFallback;
// Remove "stun:"
stunFallbackHost = [stunFallbackHost componentsSeparatedByString:@":"].lastObject;
MXSession *mainSession = self.mxSessions.firstObject;
NSString *homeServerName = mainSession.matrixRestClient.credentials.homeServerName;
NSString *message = [NSString stringWithFormat:@"%@\n\n%@",
[NSString stringWithFormat:NSLocalizedStringFromTable(@"call_no_stun_server_error_message_1", @"Vector", nil), homeServerName],
[NSString stringWithFormat: NSLocalizedStringFromTable(@"call_no_stun_server_error_message_2", @"Vector", nil), stunFallbackHost]];
_errorNotification = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"call_no_stun_server_error_title", @"Vector", nil)
message:message
preferredStyle:UIAlertControllerStyleAlert];
[_errorNotification addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat: NSLocalizedStringFromTable(@"call_no_stun_server_error_use_fallback_button", @"Vector", nil), stunFallbackHost]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
RiotSettings.shared.allowStunServerFallback = YES;
mainSession.callManager.fallbackSTUNServer = RiotSettings.shared.stunServerFallback;
[AppDelegate theDelegate].errorNotification = nil;
}]];
[_errorNotification addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
RiotSettings.shared.allowStunServerFallback = NO;
[AppDelegate theDelegate].errorNotification = nil;
}]];
// Display the error notification
if (!isErrorNotificationSuspended)
{
[_errorNotification mxk_setAccessibilityIdentifier:@"AppDelegateErrorAlert"];
[self showNotificationAlert:_errorNotification];
}
}
#pragma mark - Jitsi call
- (void)displayJitsiViewControllerWithWidget:(Widget*)jitsiWidget andVideo:(BOOL)video

View file

@ -32,9 +32,11 @@
<string>https://jitsi.riot.im</string>
<key>integrationsWidgetsUrls</key>
<array>
<string>https://scalar-staging.riot.im/scalar/api</string>
<string>https://scalar-staging.vector.im/api</string>
<string>https://scalar.vector.im/_matrix/integrations/v1</string>
<string>https://scalar.vector.im/api</string>
<string>https://scalar-staging.vector.im/_matrix/integrations/v1</string>
<string>https://scalar-staging.vector.im/api</string>
<string>https://scalar-staging.riot.im/scalar/api</string>
</array>
<key>piwik</key>
<dict>
@ -57,6 +59,8 @@
<false/>
<key>createConferenceCallsWithJitsi</key>
<true/>
<key>stunServerFallback</key>
<string>stun:turn.matrix.org</string>
<key>enableRageShake</key>
<true/>
<key>maxAllowedMediaCacheSize</key>

View file

@ -84,10 +84,9 @@
"auth_invalid_email" = "This doesn't look like a valid email address";
"auth_invalid_phone" = "This doesn't look like a valid phone number";
"auth_missing_password" = "Missing password";
"auth_add_email_message" = "Add an email address to your account to let users discover you, and to reset your password.";
"auth_add_phone_message" = "Add a phone number to your account to let users discover you.";
"auth_add_email_phone_message" = "Add an email address and/or a phone number to your account to let users discover you. Email address will also let you reset your password.";
"auth_add_email_and_phone_message" = "Add an email address and a phone number to your account to let users discover you. Email address will also let you reset your password.";
"auth_add_email_message_2" = "Set an email for account recovery, and later to be optionally discoverable by people who know you.";
"auth_add_phone_message_2" = "Set a phone, and later to be optionally discoverable by people who know you.";
"auth_add_email_phone_message_2" = "Set an email for account recovery. Use later email or phone to be optionally discoverable by people who know you.";
"auth_missing_email" = "Missing email address";
"auth_missing_phone" = "Missing phone number";
"auth_missing_email_or_phone" = "Missing email address or phone number";
@ -405,6 +404,9 @@
"settings_enable_callkit" = "Integrated calling";
"settings_callkit_info" = "Receive incoming calls on your lock screen. See your Riot calls in the system's call history. If iCloud is enabled, this call history will be shared with Apple.";
"settings_calls_stun_server_fallback_button" = "Allow fallback call assist server";
"settings_calls_stun_server_fallback_description" = "Allow fallback call assist server %@ when your homeserver does not offer one (your IP address would be shared during a call).";
"settings_ui_language" = "Language";
"settings_ui_theme" = "Theme";
"settings_ui_theme_auto" = "Auto";
@ -446,9 +448,9 @@
"settings_fail_to_update_password" = "Fail to update password";
"settings_password_updated" = "Your password has been updated";
"settings_crypto_device_name" = "Device name: ";
"settings_crypto_device_name" = "Device Public Name: ";
"settings_crypto_device_id" = "\nDevice ID: ";
"settings_crypto_device_key" = "\nDevice key: ";
"settings_crypto_device_key" = "\nDevice key:\n";
"settings_crypto_export" = "Export keys";
"settings_crypto_blacklist_unverified_devices" = "Encrypt to verified devices only";
@ -479,6 +481,8 @@
"settings_key_backup_delete_confirmation_prompt_title" = "Delete Backup";
"settings_key_backup_delete_confirmation_prompt_msg" = "Are you sure? You will lose your encrypted messages if your keys are not backed up properly.";
"settings_devices_description" = "A device's public name is visible to people you communicate with";
// Room Details
"room_details_title" = "Room Details";
"room_details_people" = "Members";
@ -629,6 +633,11 @@
"call_already_displayed" = "There is already a call in progress.";
"call_jitsi_error" = "Failed to join the conference call.";
"call_no_stun_server_error_title" ="Call failed due to misconfigured server";
"call_no_stun_server_error_message_1" ="Please ask the administrator of your homeserver %@ to configure a TURN server in order for calls to work reliably.";
"call_no_stun_server_error_message_2" ="Alternatively, you can try to use the public server at %@, but this will not be as reliable, and it will share your IP address with that server. You can also manage this in Settings";
"call_no_stun_server_error_use_fallback_button" = "Try using %@";
// No VoIP support
"no_voip_title" = "Incoming call";
"no_voip" = "%@ is calling you but %@ does not support calls yet.\nYou can ignore this notification and answer the call from another device or you can reject it.";

View file

@ -39,6 +39,7 @@ internal enum RiotDefaults {
internal static let showRedactionsInRoomHistory: Bool = _document["showRedactionsInRoomHistory"]
internal static let showUnsupportedEventsInRoomHistory: Bool = _document["showUnsupportedEventsInRoomHistory"]
internal static let sortRoomMembersUsingLastSeenTime: Bool = _document["sortRoomMembersUsingLastSeenTime"]
internal static let stunServerFallback: String = _document["stunServerFallback"]
internal static let syncLocalContacts: Bool = _document["syncLocalContacts"]
internal static let webAppUrl: String = _document["webAppUrl"]
internal static let webAppUrlBeta: String = _document["webAppUrlBeta"]

View file

@ -30,25 +30,21 @@ internal enum VectorL10n {
internal static var authAcceptPolicies: String {
return VectorL10n.tr("Vector", "auth_accept_policies")
}
/// Add an email address and a phone number to your account to let users discover you. Email address will also let you reset your password.
internal static var authAddEmailAndPhoneMessage: String {
return VectorL10n.tr("Vector", "auth_add_email_and_phone_message")
}
/// Registration with email and phone number at once is not supported yet until the api exists. Only the phone number will be taken into account. You may add your email to your profile in settings.
internal static var authAddEmailAndPhoneWarning: String {
return VectorL10n.tr("Vector", "auth_add_email_and_phone_warning")
}
/// Add an email address to your account to let users discover you, and to reset your password.
internal static var authAddEmailMessage: String {
return VectorL10n.tr("Vector", "auth_add_email_message")
/// Set an email for account recovery, and later to be optionally discoverable by people who know you.
internal static var authAddEmailMessage2: String {
return VectorL10n.tr("Vector", "auth_add_email_message_2")
}
/// Add an email address and/or a phone number to your account to let users discover you. Email address will also let you reset your password.
internal static var authAddEmailPhoneMessage: String {
return VectorL10n.tr("Vector", "auth_add_email_phone_message")
/// Set an email for account recovery. Use later email or phone to be optionally discoverable by people who know you.
internal static var authAddEmailPhoneMessage2: String {
return VectorL10n.tr("Vector", "auth_add_email_phone_message_2")
}
/// Add a phone number to your account to let users discover you.
internal static var authAddPhoneMessage: String {
return VectorL10n.tr("Vector", "auth_add_phone_message")
/// Set a phone, and later to be optionally discoverable by people who know you.
internal static var authAddPhoneMessage2: String {
return VectorL10n.tr("Vector", "auth_add_phone_message_2")
}
/// Invalid homeserver discovery response
internal static var authAutodiscoverInvalidResponse: String {
@ -370,6 +366,22 @@ internal enum VectorL10n {
internal static var callJitsiError: String {
return VectorL10n.tr("Vector", "call_jitsi_error")
}
/// Please ask the administrator of your homeserver %@ to configure a TURN server in order for calls to work reliably.
internal static func callNoStunServerErrorMessage1(_ p1: String) -> String {
return VectorL10n.tr("Vector", "call_no_stun_server_error_message_1", p1)
}
/// Alternatively, you can try to use the public server at %@, but this will not be as reliable, and it will share your IP address with that server. You can also manage this in Settings
internal static func callNoStunServerErrorMessage2(_ p1: String) -> String {
return VectorL10n.tr("Vector", "call_no_stun_server_error_message_2", p1)
}
/// Call failed due to misconfigured server
internal static var callNoStunServerErrorTitle: String {
return VectorL10n.tr("Vector", "call_no_stun_server_error_title")
}
/// Try using %@
internal static func callNoStunServerErrorUseFallbackButton(_ p1: String) -> String {
return VectorL10n.tr("Vector", "call_no_stun_server_error_use_fallback_button", p1)
}
/// Camera
internal static var camera: String {
return VectorL10n.tr("Vector", "camera")
@ -2394,6 +2406,14 @@ internal enum VectorL10n {
internal static var settingsCallsSettings: String {
return VectorL10n.tr("Vector", "settings_calls_settings")
}
/// Allow fallback call assist server
internal static var settingsCallsStunServerFallbackButton: String {
return VectorL10n.tr("Vector", "settings_calls_stun_server_fallback_button")
}
/// Allow fallback call assist server %@ when your homeserver does not offer one (your IP address would be shared during a call).
internal static func settingsCallsStunServerFallbackDescription(_ p1: String) -> String {
return VectorL10n.tr("Vector", "settings_calls_stun_server_fallback_description", p1)
}
/// Change password
internal static var settingsChangePassword: String {
return VectorL10n.tr("Vector", "settings_change_password")
@ -2450,11 +2470,11 @@ internal enum VectorL10n {
internal static var settingsCryptoDeviceId: String {
return VectorL10n.tr("Vector", "settings_crypto_device_id")
}
/// \nDevice key:
/// \nDevice key:\n
internal static var settingsCryptoDeviceKey: String {
return VectorL10n.tr("Vector", "settings_crypto_device_key")
}
/// Device name:
/// Device Public Name:
internal static var settingsCryptoDeviceName: String {
return VectorL10n.tr("Vector", "settings_crypto_device_name")
}
@ -2478,6 +2498,10 @@ internal enum VectorL10n {
internal static var settingsDevices: String {
return VectorL10n.tr("Vector", "settings_devices")
}
/// A device's public name is visible to people you communicate with
internal static var settingsDevicesDescription: String {
return VectorL10n.tr("Vector", "settings_devices_description")
}
/// Display Name
internal static var settingsDisplayName: String {
return VectorL10n.tr("Vector", "settings_display_name")

View file

@ -30,6 +30,8 @@ final class RiotSettings: NSObject {
static let notificationsShowDecryptedContent = "showDecryptedContent"
static let pinRoomsWithMissedNotifications = "pinRoomsWithMissedNotif"
static let pinRoomsWithUnreadMessages = "pinRoomsWithUnread"
static let allowStunServerFallback = "allowStunServerFallback"
static let stunServerFallback = "stunServerFallback"
}
/// Riot Standard Room Member Power Level
@ -119,4 +121,24 @@ final class RiotSettings: NSObject {
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.createConferenceCallsWithJitsi)
}
}
// MARK: Calls
/// Indicate if `allowStunServerFallback` settings has been set once.
var isAllowStunServerFallbackHasBeenSetOnce: Bool {
return UserDefaults.standard.object(forKey: UserDefaultsKeys.allowStunServerFallback) != nil
}
var allowStunServerFallback: Bool {
get {
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.allowStunServerFallback)
} set {
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.allowStunServerFallback)
}
}
var stunServerFallback: String? {
return UserDefaults.standard.string(forKey: UserDefaultsKeys.stunServerFallback)
}
}

View file

@ -631,11 +631,16 @@
NSURL *identServerURL = [NSURL URLWithString:identityServer];
NSDictionary *parameters;
parameters = @{
@"auth": @{@"session":currentSession.session, @"threepid_creds": @{@"client_secret": submittedEmail.clientSecret, @"id_server": identServerURL.host, @"sid": submittedEmail.sid}, @"type": kMXLoginFlowTypeEmailIdentity},
@"auth": @{
@"session":currentSession.session,
@"threepid_creds": @{
@"client_secret": submittedEmail.clientSecret,
@"id_server": identServerURL.host,
@"sid": submittedEmail.sid
},
@"type": kMXLoginFlowTypeEmailIdentity},
@"username": self.userLoginTextField.text,
@"password": self.passWordTextField.text,
@"bind_msisdn": @([self isFlowCompleted:kMXLoginFlowTypeMSISDN]),
@"bind_email": @(YES)
};
[self hideInputsContainer];
@ -704,11 +709,13 @@
if (response.length)
{
NSDictionary *parameters = @{
@"auth": @{@"session":currentSession.session, @"response": response, @"type": kMXLoginFlowTypeRecaptcha},
@"auth": @{
@"session":currentSession.session,
@"response": response,
@"type": kMXLoginFlowTypeRecaptcha
},
@"username": self.userLoginTextField.text,
@"password": self.passWordTextField.text,
@"bind_msisdn": @([self isFlowCompleted:kMXLoginFlowTypeMSISDN]),
@"bind_email": @([self isFlowCompleted:kMXLoginFlowTypeEmailIdentity])
};
callback(parameters, nil);
@ -727,11 +734,12 @@
else if ([self isFlowSupported:kMXLoginFlowTypeDummy] && ![self isFlowCompleted:kMXLoginFlowTypeDummy])
{
parameters = @{
@"auth": @{@"session":currentSession.session, @"type": kMXLoginFlowTypeDummy},
@"auth": @{
@"session":currentSession.session,
@"type": kMXLoginFlowTypeDummy
},
@"username": self.userLoginTextField.text,
@"password": self.passWordTextField.text,
@"bind_msisdn": @(NO),
@"bind_email": @(NO)
};
}
else if ([self isFlowSupported:kMXLoginFlowTypePassword] && ![self isFlowCompleted:kMXLoginFlowTypePassword])
@ -760,9 +768,7 @@
@"type": kMXLoginFlowTypeTerms
},
@"username": self.userLoginTextField.text,
@"password": self.passWordTextField.text,
@"bind_msisdn": @([self isFlowCompleted:kMXLoginFlowTypeMSISDN]),
@"bind_email": @([self isFlowCompleted:kMXLoginFlowTypeEmailIdentity])
@"password": self.passWordTextField.text
};
callback(parameters, nil);
}];
@ -1174,7 +1180,7 @@
self.emailContainer.hidden = NO;
self.messageLabel.hidden = NO;
self.messageLabel.text = NSLocalizedStringFromTable(@"auth_add_email_message", @"Vector", nil);
self.messageLabel.text = NSLocalizedStringFromTable(@"auth_add_email_message_2", @"Vector", nil);
lastViewContainer = self.emailContainer;
}
@ -1203,22 +1209,14 @@
self.emailTextField.returnKeyType = UIReturnKeyNext;
self.phoneContainerTopConstraint.constant = 50;
if (self.areAllThirdPartyIdentifiersRequired)
{
self.messageLabel.text = NSLocalizedStringFromTable(@"auth_add_email_and_phone_message", @"Vector", nil);
}
else
{
self.messageLabel.text = NSLocalizedStringFromTable(@"auth_add_email_phone_message", @"Vector", nil);
}
self.messageLabel.text = NSLocalizedStringFromTable(@"auth_add_email_phone_message_2", @"Vector", nil);
}
else
{
self.phoneContainerTopConstraint.constant = 0;
self.messageLabel.hidden = NO;
self.messageLabel.text = NSLocalizedStringFromTable(@"auth_add_phone_message", @"Vector", nil);
self.messageLabel.text = NSLocalizedStringFromTable(@"auth_add_phone_message_2", @"Vector", nil);
}
lastViewContainer = self.phoneContainer;
@ -1663,11 +1661,17 @@
NSURL *identServerURL = [NSURL URLWithString:identityServer];
NSDictionary *parameters;
parameters = @{
@"auth": @{@"session":self->currentSession.session, @"threepid_creds": @{@"client_secret": self->submittedMSISDN.clientSecret, @"id_server": identServerURL.host, @"sid": self->submittedMSISDN.sid}, @"type": kMXLoginFlowTypeMSISDN},
@"auth": @{
@"session":self->currentSession.session,
@"threepid_creds": @{
@"client_secret": self->submittedMSISDN.clientSecret,
@"id_server": identServerURL.host,
@"sid": self->submittedMSISDN.sid
},
@"type": kMXLoginFlowTypeMSISDN
},
@"username": self.userLoginTextField.text,
@"password": self.passWordTextField.text,
@"bind_msisdn": @(YES),
@"bind_email": @([self isFlowCompleted:kMXLoginFlowTypeEmailIdentity])
@"password": self.passWordTextField.text
};
callback(parameters, nil);

View file

@ -26,4 +26,7 @@
@property (unsafe_unretained, nonatomic) IBOutlet NSLayoutConstraint *callerImageViewWidthConstraint;
// At the end of call, this flag indicates if the prompt to use the fallback should be displayed
@property (nonatomic) BOOL shouldPromptForStunServerFallback;
@end

View file

@ -39,6 +39,9 @@
// Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change.
id kThemeServiceDidChangeThemeNotificationObserver;
// Flag to compute self.shouldPromptForStunServerFallback
BOOL promptForStunServerFallback;
}
@end
@ -52,6 +55,9 @@
// Setup `MXKViewControllerHandling` properties
self.enableBarTintColorStatusChange = NO;
self.rageShakeManager = [RageShakeManager sharedManager];
promptForStunServerFallback = NO;
_shouldPromptForStunServerFallback = NO;
}
- (void)viewDidLoad
@ -229,6 +235,13 @@
#pragma mark - MXCallDelegate
- (void)call:(MXCall *)call stateDidChange:(MXCallState)state reason:(MXEvent *)event
{
[super call:call stateDidChange:state reason:event];
[self checkStunServerFallbackWithCallState:state];
}
- (void)call:(MXCall *)call didEncounterError:(NSError *)error
{
if ([error.domain isEqualToString:MXEncryptingErrorDomain]
@ -333,6 +346,41 @@
}
}
#pragma mark - Fallback STUN server
- (void)checkStunServerFallbackWithCallState:(MXCallState)callState
{
// Detect if we should display the prompt to fallback to the STUN server defined
// in the app plist if the homeserver does not provide STUN or TURN servers.
// We should if the call ends while we were in connecting state
if (!self.mainSession.callManager.turnServers
&& !self.mainSession.callManager.fallbackSTUNServer
&& !RiotSettings.shared.isAllowStunServerFallbackHasBeenSetOnce)
{
switch (callState)
{
case MXCallStateConnecting:
promptForStunServerFallback = YES;
break;
case MXCallStateConnected:
promptForStunServerFallback = NO;
break;
case MXCallStateEnded:
if (promptForStunServerFallback)
{
_shouldPromptForStunServerFallback = YES;
}
default:
break;
}
}
}
#pragma mark - Properties
- (UIImage*)picturePlaceholder

View file

@ -86,7 +86,9 @@ enum
enum
{
CALLS_ENABLE_CALLKIT_INDEX = 0,
CALLS_DESCRIPTION_INDEX,
CALLS_CALLKIT_DESCRIPTION_INDEX,
CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX,
CALLS_STUN_SERVER_FALLBACK_DESCRIPTION_INDEX,
CALLS_COUNT
};
@ -128,6 +130,11 @@ enum {
CRYPTOGRAPHY_COUNT
};
enum
{
DEVICES_DESCRIPTION_INDEX = 0
};
#define SECTION_TITLE_PADDING_WHEN_HIDDEN 0.01f
typedef void (^blockSettingsViewController_onReadyToDestroy)(void);
@ -693,8 +700,8 @@ SingleImagePickerPresenterDelegate>
typeof(self) self = weakSelf;
self->is3PIDBindingInProgress = YES;
// We always bind emails when registering, so let's do the same here
[threePID add3PIDToUser:YES success:^{
// We do not bind anymore emails when registering, so let's do the same here
[threePID add3PIDToUser:NO success:^{
if (weakSelf)
{
@ -816,8 +823,8 @@ SingleImagePickerPresenterDelegate>
[threePID submitValidationToken:smsCode success:^{
// We always bind the phone numbers when registering, so let's do the same here
[threePID add3PIDToUser:YES success:^{
// We do not bind anymore the phone numbers when registering, so let's do the same here
[threePID add3PIDToUser:NO success:^{
if (weakSelf)
{
@ -1008,6 +1015,10 @@ SingleImagePickerPresenterDelegate>
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.textPrimaryColor,
NSFontAttributeName: [UIFont systemFontOfSize:17]}]];
NSString *fingerprint = account.mxSession.crypto.deviceEd25519Key;
if (fingerprint)
{
fingerprint = [MXTools addWhiteSpacesToString:fingerprint every:4];
}
[cryptoInformationString appendAttributedString:[[NSMutableAttributedString alloc]
initWithString:fingerprint ? fingerprint : @""
attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.textPrimaryColor,
@ -1256,9 +1267,11 @@ SingleImagePickerPresenterDelegate>
}
else if (section == SETTINGS_SECTION_CALLS_INDEX)
{
if ([MXCallKitAdapter callKitAvailable])
count = CALLS_COUNT;
if (!RiotSettings.shared.stunServerFallback)
{
count = CALLS_COUNT;
count -= 2;
}
}
else if (section == SETTINGS_SECTION_USER_INTERFACE_INDEX)
@ -1316,6 +1329,11 @@ SingleImagePickerPresenterDelegate>
else if (section == SETTINGS_SECTION_DEVICES_INDEX)
{
count = devicesArray.count;
if (count)
{
// For some description (DEVICES_DESCRIPTION_INDEX)
count++;
}
}
else if (section == SETTINGS_SECTION_CRYPTOGRAPHY_INDEX)
{
@ -1402,6 +1420,7 @@ SingleImagePickerPresenterDelegate>
cell.textLabel.accessibilityIdentifier = nil;
cell.textLabel.font = [UIFont systemFontOfSize:17];
cell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
cell.contentView.backgroundColor = UIColor.clearColor;
return cell;
}
@ -1812,16 +1831,52 @@ SingleImagePickerPresenterDelegate>
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleCallKit:) forControlEvents:UIControlEventTouchUpInside];
if (![MXCallKitAdapter callKitAvailable])
{
labelAndSwitchCell.mxkSwitch.on = NO;
labelAndSwitchCell.mxkSwitch.enabled = NO;
labelAndSwitchCell.mxkLabel.enabled = NO;
}
cell = labelAndSwitchCell;
}
else if (row == CALLS_DESCRIPTION_INDEX)
else if (row == CALLS_CALLKIT_DESCRIPTION_INDEX)
{
MXKTableViewCell *globalInfoCell = [self getDefaultTableViewCell:tableView];
globalInfoCell.textLabel.text = NSLocalizedStringFromTable(@"settings_callkit_info", @"Vector", nil);
globalInfoCell.textLabel.numberOfLines = 0;
globalInfoCell.selectionStyle = UITableViewCellSelectionStyleNone;
if (![MXCallKitAdapter callKitAvailable])
{
globalInfoCell.textLabel.enabled = NO;
}
cell = globalInfoCell;
}
else if (row == CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX)
{
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_calls_stun_server_fallback_button", @"Vector", nil);
labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.allowStunServerFallback;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleStunServerFallback:) forControlEvents:UIControlEventTouchUpInside];
cell = labelAndSwitchCell;
}
else if (row == CALLS_STUN_SERVER_FALLBACK_DESCRIPTION_INDEX)
{
NSString *stunFallbackHost = RiotSettings.shared.stunServerFallback;
// Remove "stun:"
stunFallbackHost = [stunFallbackHost componentsSeparatedByString:@":"].lastObject;
MXKTableViewCell *globalInfoCell = [self getDefaultTableViewCell:tableView];
globalInfoCell.textLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_calls_stun_server_fallback_description", @"Vector", nil), stunFallbackHost];
globalInfoCell.textLabel.numberOfLines = 0;
globalInfoCell.selectionStyle = UITableViewCellSelectionStyleNone;
cell = globalInfoCell;
}
}
@ -2194,22 +2249,39 @@ SingleImagePickerPresenterDelegate>
}
else if (section == SETTINGS_SECTION_DEVICES_INDEX)
{
MXKTableViewCell *deviceCell = [self getDefaultTableViewCell:tableView];
if (row < devicesArray.count)
if (row == DEVICES_DESCRIPTION_INDEX)
{
NSString *name = devicesArray[row].displayName;
NSString *deviceId = devicesArray[row].deviceId;
deviceCell.textLabel.text = (name.length ? [NSString stringWithFormat:@"%@ (%@)", name, deviceId] : [NSString stringWithFormat:@"(%@)", deviceId]);
deviceCell.textLabel.numberOfLines = 0;
if ([deviceId isEqualToString:self.mainSession.matrixRestClient.credentials.deviceId])
{
deviceCell.textLabel.font = [UIFont boldSystemFontOfSize:17];
}
MXKTableViewCell *descriptionCell = [self getDefaultTableViewCell:tableView];
descriptionCell.textLabel.text = NSLocalizedStringFromTable(@"settings_devices_description", @"Vector", nil);
descriptionCell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
descriptionCell.textLabel.font = [UIFont systemFontOfSize:15];
descriptionCell.textLabel.numberOfLines = 0;
descriptionCell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor;
descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone;
cell = descriptionCell;
}
cell = deviceCell;
else
{
NSUInteger deviceIndex = row - 1;
MXKTableViewCell *deviceCell = [self getDefaultTableViewCell:tableView];
if (deviceIndex < devicesArray.count)
{
NSString *name = devicesArray[deviceIndex].displayName;
NSString *deviceId = devicesArray[deviceIndex].deviceId;
deviceCell.textLabel.text = (name.length ? [NSString stringWithFormat:@"%@ (%@)", name, deviceId] : [NSString stringWithFormat:@"(%@)", deviceId]);
deviceCell.textLabel.numberOfLines = 0;
if ([deviceId isEqualToString:self.mainSession.matrixRestClient.credentials.deviceId])
{
deviceCell.textLabel.font = [UIFont boldSystemFontOfSize:17];
}
}
cell = deviceCell;
}
}
else if (section == SETTINGS_SECTION_CRYPTOGRAPHY_INDEX)
{
@ -2305,10 +2377,7 @@ SingleImagePickerPresenterDelegate>
}
else if (section == SETTINGS_SECTION_CALLS_INDEX)
{
if ([MXCallKitAdapter callKitAvailable])
{
return NSLocalizedStringFromTable(@"settings_calls_settings", @"Vector", nil);
}
return NSLocalizedStringFromTable(@"settings_calls_settings", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_USER_INTERFACE_INDEX)
{
@ -2454,13 +2523,6 @@ SingleImagePickerPresenterDelegate>
}
}
}
else if (section == SETTINGS_SECTION_CALLS_INDEX)
{
if (![MXCallKitAdapter callKitAvailable])
{
return SECTION_TITLE_PADDING_WHEN_HIDDEN;
}
}
else if (section == SETTINGS_SECTION_FLAIR_INDEX)
{
if (groupsDataSource.joinedGroupsSection == -1)
@ -2486,13 +2548,6 @@ SingleImagePickerPresenterDelegate>
}
}
}
else if (section == SETTINGS_SECTION_CALLS_INDEX)
{
if (![MXCallKitAdapter callKitAvailable])
{
return SECTION_TITLE_PADDING_WHEN_HIDDEN;
}
}
else if (section == SETTINGS_SECTION_FLAIR_INDEX)
{
if (groupsDataSource.joinedGroupsSection == -1)
@ -2696,9 +2751,13 @@ SingleImagePickerPresenterDelegate>
}
else if (section == SETTINGS_SECTION_DEVICES_INDEX)
{
if (row < devicesArray.count)
if (row > DEVICES_DESCRIPTION_INDEX)
{
[self showDeviceDetails:devicesArray[row]];
NSUInteger deviceIndex = row - 1;
if (deviceIndex < devicesArray.count)
{
[self showDeviceDetails:devicesArray[deviceIndex]];
}
}
}
else if (section == SETTINGS_SECTION_CONTACTS_INDEX)
@ -2917,6 +2976,14 @@ SingleImagePickerPresenterDelegate>
[MXKAppSettings standardAppSettings].enableCallKit = switchButton.isOn;
}
- (void)toggleStunServerFallback:(id)sender
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.allowStunServerFallback = switchButton.isOn;
self.mainSession.callManager.fallbackSTUNServer = RiotSettings.shared.allowStunServerFallback ? RiotSettings.shared.stunServerFallback : nil;
}
- (void)toggleShowDecodedContent:(id)sender
{
UISwitch *switchButton = (UISwitch*)sender;