refs #584, add operation to clear QuickType suggestion in settings

This commit is contained in:
Tony Wang 2023-01-26 23:00:32 +08:00 committed by Mingshen Sun
parent 3ab334dd00
commit f6f862a6b0
3 changed files with 40 additions and 3 deletions

View file

@ -1141,17 +1141,38 @@ Secret Question 1: What is your childhood best friend's most bizarre superhero f
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="QuickType Bar" id="qGk-hy-LH3">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="BDw-4m-VXK" style="IBUITableViewCellStyleDefault" id="lOa-VO-aoM" userLabel="Clear Saved Suggestions">
<rect key="frame" x="0.0" y="255.33333015441895" width="390" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="lOa-VO-aoM" id="YYg-VZ-WdW">
<rect key="frame" x="0.0" y="0.0" width="390" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Clear Saved Suggetions" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="BDw-4m-VXK">
<rect key="frame" x="8" y="0.0" width="374" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Password Store Data" id="aVR-FE-jMg">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="zrl-v3-fxg" style="IBUITableViewCellStyleDefault" id="Jm8-B5-wKx" userLabel="Discard Changes Table View Cell">
<rect key="frame" x="0.0" y="236.33333206176758" width="390" height="44"/>
<rect key="frame" x="0.0" y="355.33333015441895" width="390" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Jm8-B5-wKx" id="tjS-Q6-y2M">
<rect key="frame" x="0.0" y="0.0" width="390" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Discard All Local Changes" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="zrl-v3-fxg">
<rect key="frame" x="20" y="0.0" width="350" height="44"/>
<rect key="frame" x="8" y="0.0" width="374" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" systemColor="systemRedColor"/>
@ -1187,6 +1208,7 @@ Secret Question 1: What is your childhood best friend's most bizarre superhero f
</tableView>
<navigationItem key="navigationItem" title="Advanced" largeTitleDisplayMode="never" id="tc7-wf-hG7"/>
<connections>
<outlet property="clearSuggestionsTableViewCell" destination="lOa-VO-aoM" id="geo-dv-0mN"/>
<outlet property="discardChangesTableViewCell" destination="Jm8-B5-wKx" id="rfA-G3-2OE"/>
<outlet property="encryptInASCIIArmoredTableViewCell" destination="tHt-Ro-0HF" id="tOi-Sj-mLJ"/>
<outlet property="eraseDataTableViewCell" destination="NI1-Kd-hyH" id="NtJ-f4-oxb"/>

View file

@ -6,6 +6,7 @@
// Copyright © 2017 Bob Sun. All rights reserved.
//
import AuthenticationServices
import passKit
import SVProgressHUD
import UIKit
@ -15,6 +16,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
@IBOutlet var gitSignatureTableViewCell: UITableViewCell!
@IBOutlet var eraseDataTableViewCell: UITableViewCell!
@IBOutlet var discardChangesTableViewCell: UITableViewCell!
@IBOutlet var clearSuggestionsTableViewCell: UITableViewCell!
let passwordStore = PasswordStore.shared
private lazy var encryptInASCIIArmoredSwitch: UISwitch = {
@ -76,6 +78,16 @@ class AdvancedSettingsTableViewController: UITableViewController {
)
alert.addAction(UIAlertAction.dismiss())
present(alert, animated: true, completion: nil)
} else if tableView.cellForRow(at: indexPath) == clearSuggestionsTableViewCell {
ASCredentialIdentityStore.shared.removeAllCredentialIdentities { _, error in
if let error = error {
SVProgressHUD.showError(withStatus: "FailedToClearQuickTypeSuggestions".localize(error))
SVProgressHUD.dismiss(withDelay: 1)
} else {
SVProgressHUD.showSuccess(withStatus: "Done".localize())
SVProgressHUD.dismiss(withDelay: 1)
}
}
}
}

View file

@ -1,4 +1,4 @@
/*
/*
Localizable.strings
pass
@ -165,6 +165,9 @@
"NotSet" = "Not Set";
"InvalidNameOrEmail" = "Invalid name or e-mail";
// Clear suggestions
"FailedToClearQuickTypeSuggestions" = "Failed to clear QuickType suggestions: %@";
// Erase password store
"ErasePasswordStoreData?" = "Erase password store data?";
"ErasePasswordStoreData" = "Erase Password Store Data";