mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-04 23:17:43 +02:00
Merge branch 'feature/5271_crosssigning_with_button' into 'develop'
MESSENGER-5271 crosssigning - verification request on button click See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!267
This commit is contained in:
+2
-1
@@ -49,8 +49,9 @@ final class KeyVerificationSelfVerifyWaitCoordinator: KeyVerificationSelfVerifyW
|
||||
|
||||
// MARK: - Public methods
|
||||
|
||||
func start() {
|
||||
func start() {
|
||||
self.keyVerificationSelfVerifyWaitViewModel.coordinatorDelegate = self
|
||||
self.keyVerificationSelfVerifyWaitViewModel.checkCrosssigningDevices()
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
|
||||
+30
-16
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="79A-qb-tmk">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="79A-qb-tmk">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -17,13 +17,13 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="asO-rj-82y">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tIM-sl-gwE">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="562"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="555.5"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IlB-Ch-LEo">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="562"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="555.5"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Open Element on your other device" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="aOD-RJ-1qU">
|
||||
<rect key="frame" x="20" y="20" width="335" height="67"/>
|
||||
@@ -32,16 +32,16 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="d5Y-pj-XsI">
|
||||
<rect key="frame" x="20" y="117" width="335" height="84"/>
|
||||
<string key="text">You need to verify this session in order to read your secure message history.
|
||||
|
||||
Open Element on one of your other devices and follow the instructions.</string>
|
||||
<rect key="frame" x="20" y="117" width="335" height="33.5"/>
|
||||
<string key="text" base64-UTF8="YES">
|
||||
Cg
|
||||
</string>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="ANK-XS-dY7">
|
||||
<rect key="frame" x="27.5" y="241" width="320" height="48"/>
|
||||
<rect key="frame" x="27.5" y="190.5" width="320" height="48"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="14" translatesAutoresizingMaskIntoConstraints="NO" id="3at-ql-vhb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="160" height="48"/>
|
||||
@@ -73,12 +73,25 @@ Open Element on one of your other devices and follow the instructions.</string>
|
||||
</constraints>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="8oJ-o6-DLK">
|
||||
<rect key="frame" x="20" y="329" width="335" height="233"/>
|
||||
<rect key="frame" x="20" y="278.5" width="335" height="277"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PGj-76-CCf" customClass="RoundedButton" customModule="Element" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="335" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="Yqo-MP-G3l"/>
|
||||
</constraints>
|
||||
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
|
||||
<state key="normal">
|
||||
<color key="titleColor" red="0.01176470588" green="0.70196078429999997" blue="0.50588235290000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="crossSigningButtonAction:" destination="79A-qb-tmk" eventType="touchUpInside" id="QTT-hh-LDs"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dXT-cL-ukJ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="335" height="114.5"/>
|
||||
<rect key="frame" x="0.0" y="44" width="335" height="114.5"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Checking for other verification capabilities ..." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A4x-sK-d5C">
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A4x-sK-d5C">
|
||||
<rect key="frame" x="20" y="10" width="295" height="38.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
@@ -100,9 +113,9 @@ Open Element on one of your other devices and follow the instructions.</string>
|
||||
</constraints>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nf8-Ye-b9r">
|
||||
<rect key="frame" x="0.0" y="114.5" width="335" height="118.5"/>
|
||||
<rect key="frame" x="0.0" y="158.5" width="335" height="118.5"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="If you can't accessing an existing session" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Ou-cM-K9C">
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Ou-cM-K9C">
|
||||
<rect key="frame" x="20" y="10" width="295" height="24.5"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="12"/>
|
||||
<color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
@@ -114,7 +127,7 @@ Open Element on one of your other devices and follow the instructions.</string>
|
||||
<constraint firstAttribute="height" constant="44" id="7ws-Nc-I7y"/>
|
||||
</constraints>
|
||||
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
|
||||
<state key="normal" title="Use a recovery passphrase or key">
|
||||
<state key="normal">
|
||||
<color key="titleColor" red="0.01176470588" green="0.70196078429999997" blue="0.50588235290000005" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</state>
|
||||
<connections>
|
||||
@@ -188,6 +201,7 @@ Open Element on one of your other devices and follow the instructions.</string>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="crosssigningButton" destination="PGj-76-CCf" id="k9I-6N-4Bm"/>
|
||||
<outlet property="desktopClientImageView" destination="nrB-Kj-4zE" id="yl0-Ju-luK"/>
|
||||
<outlet property="informationLabel" destination="d5Y-pj-XsI" id="TMb-bc-58a"/>
|
||||
<outlet property="mobileClientImageView" destination="P0P-X4-uSQ" id="WtT-ix-yq8"/>
|
||||
|
||||
+56
-4
@@ -41,6 +41,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
@IBOutlet private weak var recoverSecretsAvailabilityActivityIndicatorView: UIActivityIndicatorView!
|
||||
@IBOutlet private weak var recoverSecretsContainerView: UIView!
|
||||
@IBOutlet private weak var recoverSecretsButton: RoundedButton!
|
||||
// bwi #5271 don't do crosssigning request at view start but as action on button click
|
||||
@IBOutlet private weak var crosssigningButton: RoundedButton!
|
||||
@IBOutlet private weak var recoverSecretsAdditionalInformationLabel: UILabel!
|
||||
|
||||
// MARK: Private
|
||||
@@ -53,6 +55,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
|
||||
private weak var cancelBarButtonItem: UIBarButtonItem?
|
||||
|
||||
private var verificationAlert: UIAlertController?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
class func instantiate(with viewModel: KeyVerificationSelfVerifyWaitViewModelType, cancellable: Bool) -> KeyVerificationSelfVerifyWaitViewController {
|
||||
@@ -75,14 +79,13 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
|
||||
self.registerThemeServiceDidChangeThemeNotification()
|
||||
self.update(theme: self.theme)
|
||||
|
||||
self.viewModel.viewDelegate = self
|
||||
}
|
||||
|
||||
// BWI resend verificationrequest after cancling QR Code crosssigning
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
self.viewModel.viewDelegate = self
|
||||
self.viewModel.process(viewAction: .loadData)
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +93,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
return self.theme.statusBarStyle
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func update(theme: Theme) {
|
||||
@@ -109,6 +114,7 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
self.recoverSecretsAvailabilityActivityIndicatorView.color = theme.tintColor
|
||||
// BWI: #4966
|
||||
self.recoverSecretsButton.update(theme: theme)
|
||||
self.crosssigningButton.update(theme: theme)
|
||||
}
|
||||
|
||||
private func registerThemeServiceDidChangeThemeNotification() {
|
||||
@@ -140,8 +146,15 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
self.mobileClientImageView.image = Asset.Images.smartphone.image.withRenderingMode(.alwaysTemplate)
|
||||
|
||||
self.recoverSecretsAdditionalInformationLabel.text = BWIL10n.deviceVerificationSelfVerifyWaitRecoverSecretsAdditionalInformation
|
||||
|
||||
self.recoverSecretsButton.setTitle(BWIL10n.deviceVerificationSelfVerifyWaitRecoverSecretsWithPassphrase, for: .normal)
|
||||
self.crosssigningButton.setTitle(BWIL10n.deviceVerificationCrosssigningWaitRecoverSecrets, for: .normal)
|
||||
|
||||
self.recoverSecretsAvailabilityLoadingContainerView.isHidden = true
|
||||
|
||||
self.crosssigningButton.isHidden = true
|
||||
}
|
||||
|
||||
|
||||
private func render(viewState: KeyVerificationSelfVerifyWaitViewState) {
|
||||
switch viewState {
|
||||
case .loading:
|
||||
@@ -156,6 +169,10 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
self.renderCancelledByMe(reason: reason)
|
||||
case .error(let error):
|
||||
self.render(error: error)
|
||||
case .verificationAccepted:
|
||||
self.verificationAccepted()
|
||||
case .crosssigningPossible(let possible):
|
||||
self.showCrosssigningButton(possible)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +215,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
self.recoverSecretsAvailabilityActivityIndicatorView.stopAnimating()
|
||||
self.recoverSecretsContainerView.isHidden = hideRecoverSecrets
|
||||
self.recoverSecretsButton.setTitle(recoverSecretsButtonTitle, for: .normal)
|
||||
|
||||
self.showCrosssigningAlert()
|
||||
}
|
||||
|
||||
private func renderCancelled(reason: MXTransactionCancelCode) {
|
||||
@@ -228,6 +247,35 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
private func verificationAccepted() {
|
||||
if let alert = self.verificationAlert {
|
||||
alert.dismiss(animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
private func showCrosssigningButton(_ show: Bool) {
|
||||
self.crosssigningButton.isHidden = !show
|
||||
self.informationLabel.isHidden = !show
|
||||
self.desktopClientImageView.isHidden = !show
|
||||
self.mobileClientImageView.isHidden = !show
|
||||
}
|
||||
|
||||
// bwi: show an alert when corsssigning button is pressed. This makes it clearer to the user what to do next
|
||||
private func showCrosssigningAlert() {
|
||||
self.verificationAlert = UIAlertController(title: BWIL10n.secretsRecoveryVerificationAlertTitle,
|
||||
message: BWIL10n.secretsRecoveryVerificationAlertMessage,
|
||||
preferredStyle: .alert)
|
||||
|
||||
if let alert = self.verificationAlert {
|
||||
let cancelActionTitle = BWIL10n.secretsRecoveryVerificationAlertCancel
|
||||
let cancelAction = UIAlertAction(title: cancelActionTitle, style: .cancel)
|
||||
|
||||
alert.addAction(cancelAction)
|
||||
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
private func cancelButtonAction() {
|
||||
@@ -237,6 +285,10 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
@IBAction private func recoverSecretsButtonAction(_ sender: Any) {
|
||||
self.viewModel.process(viewAction: .recoverSecrets)
|
||||
}
|
||||
|
||||
@IBAction private func crossSigningButtonAction(_ sender: Any) {
|
||||
self.viewModel.process(viewAction: .loadData)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
@@ -83,6 +83,18 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai
|
||||
}
|
||||
}
|
||||
|
||||
// bwi: only show corsssigning button when there is more than one device in your account
|
||||
func checkCrosssigningDevices() {
|
||||
self.session.matrixRestClient.devices { [weak self] response in
|
||||
switch response {
|
||||
case .success(let devices):
|
||||
self?.update(viewState: .crosssigningPossible(devices.count > 1))
|
||||
case .failure:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func loadData() {
|
||||
@@ -258,6 +270,8 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai
|
||||
}
|
||||
|
||||
if keyVerificationRequest.state == MXKeyVerificationRequestStateReady {
|
||||
self.update(viewState: .verificationAccepted)
|
||||
|
||||
self.unregisterKeyVerificationRequestChangeNotification()
|
||||
self.coordinatorDelegate?.keyVerificationSelfVerifyWaitViewModel(self,
|
||||
didAcceptKeyVerificationRequest: keyVerificationRequest)
|
||||
|
||||
+2
@@ -36,4 +36,6 @@ protocol KeyVerificationSelfVerifyWaitViewModelType {
|
||||
var coordinatorDelegate: KeyVerificationSelfVerifyWaitViewModelCoordinatorDelegate? { get set }
|
||||
|
||||
func process(viewAction: KeyVerificationSelfVerifyWaitViewAction)
|
||||
|
||||
func checkCrosssigningDevices()
|
||||
}
|
||||
|
||||
+2
@@ -36,4 +36,6 @@ enum KeyVerificationSelfVerifyWaitViewState {
|
||||
case cancelled(MXTransactionCancelCode)
|
||||
case cancelledByMe(MXTransactionCancelCode)
|
||||
case error(Error)
|
||||
case verificationAccepted
|
||||
case crosssigningPossible(Bool)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user