Skip to content

Commit

Permalink
Add a cancel option when verifying device if no other verified device…
Browse files Browse the repository at this point in the history
… can be reached
  • Loading branch information
Nicolas Buquet committed Nov 16, 2023
1 parent fc059ac commit 8e022db
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?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="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="79A-qb-tmk">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -17,13 +18,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="47" width="375" height="731"/>
<rect key="frame" x="0.0" y="50" width="375" height="728"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tIM-sl-gwE">
<rect key="frame" x="0.0" y="0.0" width="375" height="606"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="750.33333333333337"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IlB-Ch-LEo">
<rect key="frame" x="0.0" y="0.0" width="375" height="606"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="750.33333333333337"/>
<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"/>
Expand Down Expand Up @@ -76,7 +77,7 @@ 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="373" width="335" height="233"/>
<rect key="frame" x="20" y="373" width="335" height="377.33333333333326"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dXT-cL-ukJ">
<rect key="frame" x="0.0" y="0.0" width="335" height="114.66666666666667"/>
Expand Down Expand Up @@ -136,6 +137,43 @@ Open Element on one of your other devices and follow the instructions.</string>
<constraint firstAttribute="trailing" secondItem="OEt-k0-vgM" secondAttribute="trailing" id="yQK-YS-7Yr"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ASw-ZP-05G" userLabel="Tchap No Recover Secrets Available Container View">
<rect key="frame" x="0.0" y="233" width="335" height="144.33333333333337"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="27d-sP-XVc">
<rect key="frame" x="20" y="10.000000000000004" width="295" height="50.333333333333343"/>
<string key="text">No Recover Secrets method available.

Try to activate crss-signing in Parameters.</string>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Zfz-WA-gr6" customClass="RoundedButton" customModule="Btchap" customModuleProvider="target">
<rect key="frame" x="0.0" y="70.333333333333371" width="335" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="Ejo-IX-CbV"/>
</constraints>
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
<state key="normal" title="Cancel">
<color key="titleColor" red="0.01176470588" green="0.70196078429999997" blue="0.50588235290000005" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="recoverSecretsButtonAction:" destination="79A-qb-tmk" eventType="touchUpInside" id="suH-d6-IHC"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Zfz-WA-gr6" secondAttribute="trailing" id="8Nf-aD-YHe"/>
<constraint firstItem="27d-sP-XVc" firstAttribute="top" secondItem="ASw-ZP-05G" secondAttribute="top" constant="10" id="AnY-YT-ioE"/>
<constraint firstItem="Zfz-WA-gr6" firstAttribute="top" secondItem="27d-sP-XVc" secondAttribute="bottom" constant="10" id="bfa-OU-vQC"/>
<constraint firstAttribute="bottom" secondItem="Zfz-WA-gr6" secondAttribute="bottom" constant="30" id="s4J-RO-aH1"/>
<constraint firstItem="27d-sP-XVc" firstAttribute="leading" secondItem="ASw-ZP-05G" secondAttribute="leading" constant="20" id="soC-RF-YGV"/>
<constraint firstItem="Zfz-WA-gr6" firstAttribute="leading" secondItem="ASw-ZP-05G" secondAttribute="leading" id="uiG-gF-Dyq"/>
<constraint firstAttribute="trailing" secondItem="27d-sP-XVc" secondAttribute="trailing" constant="20" id="v94-eP-kiY"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="nf8-Ye-b9r" firstAttribute="width" secondItem="8oJ-o6-DLK" secondAttribute="width" id="ZNi-0G-uDR"/>
Expand Down Expand Up @@ -200,6 +238,9 @@ Open Element on one of your other devices and follow the instructions.</string>
<outlet property="recoverSecretsAvailabilityLoadingLabel" destination="A4x-sK-d5C" id="n5k-IO-RkV"/>
<outlet property="recoverSecretsButton" destination="OEt-k0-vgM" id="RHU-ps-4m7"/>
<outlet property="recoverSecretsContainerView" destination="nf8-Ye-b9r" id="4az-pe-0Uc"/>
<outlet property="tchapNoRecoverSecretsMethodAvailableButton" destination="Zfz-WA-gr6" id="mEa-8G-uh7"/>
<outlet property="tchapNoRecoverSecretsMethodAvailableContainerView" destination="ASw-ZP-05G" id="sc4-0O-9Up"/>
<outlet property="tchapNoRecoverSecretsMethodAvailableInformationLabel" destination="27d-sP-XVc" id="lKw-4U-MPi"/>
<outlet property="titleLabel" destination="aOD-RJ-1qU" id="qvC-fk-TiU"/>
</connections>
</viewController>
Expand All @@ -211,5 +252,8 @@ Open Element on one of your other devices and follow the instructions.</string>
<resources>
<image name="monitor" width="48" height="48"/>
<image name="smartphone" width="48" height="48"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
@IBOutlet private weak var recoverSecretsButton: RoundedButton!
@IBOutlet private weak var recoverSecretsAdditionalInformationLabel: UILabel!

// Tchap: UI to enable user to cancel this view if no recover secrets method is available
// It can happen on an account created before setting `secureBackupRequired` to true.
// This account can have cross-signing activated but no more session connected (all devices disconnected).
// The application will ask the user to verifiy the session with another device because cross-signing is activated.
// But as no other device is still connected, the user has no way to perform the verification,
// because SecureBackup is not activated: we are in the process of activating it.
@IBOutlet weak var tchapNoRecoverSecretsMethodAvailableContainerView: UIView!
@IBOutlet weak var tchapNoRecoverSecretsMethodAvailableInformationLabel: UILabel!
@IBOutlet weak var tchapNoRecoverSecretsMethodAvailableButton: RoundedButton!

// MARK: Private

private var viewModel: KeyVerificationSelfVerifyWaitViewModelType!
Expand Down Expand Up @@ -101,6 +111,10 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
self.mobileClientImageView.tintColor = theme.tintColor
self.recoverSecretsAvailabilityLoadingLabel.textColor = theme.textSecondaryColor
self.recoverSecretsAvailabilityActivityIndicatorView.color = theme.tintColor

// Tchap:
self.tchapNoRecoverSecretsMethodAvailableInformationLabel.textColor = theme.textSecondaryColor

}

private func registerThemeServiceDidChangeThemeNotification() {
Expand Down Expand Up @@ -188,6 +202,19 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
self.recoverSecretsAvailabilityActivityIndicatorView.stopAnimating()
self.recoverSecretsContainerView.isHidden = hideRecoverSecrets
self.recoverSecretsButton.setTitle(recoverSecretsButtonTitle, for: .normal)

// Tchap: show no recovery secrets method available only if hideRecoverSecrets is true.
// The UI will propose the user to verify is session with another device.
// Offer the user to cancel if no device is available to him.
self.tchapNoRecoverSecretsMethodAvailableContainerView.isHidden = !hideRecoverSecrets
self.tchapNoRecoverSecretsMethodAvailableInformationLabel.text = TchapL10n.deviceVerificationSelfVerifyNoOtherVerifiedSessionAvailable
self.tchapNoRecoverSecretsMethodAvailableButton.setTitle(VectorL10n.cancel, for: .normal)

if (hideRecoverSecrets)
{
self.tchapNoRecoverSecretsMethodAvailableButton.addTarget(self, action: #selector(cancelButtonAction), for: .touchUpInside)
}

}

private func renderCancelled(reason: MXTransactionCancelCode) {
Expand Down Expand Up @@ -217,7 +244,7 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {

// MARK: - Actions

private func cancelButtonAction() {
@objc private func cancelButtonAction() {
self.viewModel.process(viewAction: .cancel)
}

Expand Down
6 changes: 5 additions & 1 deletion Tchap/Assets/Localizations/fr.lproj/Tchap.strings
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@
////////////////////////////////////////////////////////////////////////////////
// MARK: Secret Setup Recovery Key
"secrets_setup_recovery_key_export_action_done" = "Clé copiée";
"secrets_setup_recovery_key_warning" = "Attention : c'est la seule fois que votre code est affiché !"; // Tchap
"secrets_setup_recovery_key_warning" = "Attention : c'est la seule fois que votre code est affiché !";

////////////////////////////////////////////////////////////////////////////////
// MARK: Key Verification Self Verify
"device_verification_self_verify_no_other_verified_session_available" = "Si vous n'avez accès à aucun autre appareil vérifié de votre compte, vous pouvez essayer d'activer la signature croisée dans vos paramètres.";

////////////////////////////////////////////////////////////////////////////////
// MARK: Room Decryption error
Expand Down

0 comments on commit 8e022db

Please sign in to comment.