mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Security settings: Display section description at the bottom
as before
This commit is contained in:
parent
82639fcca0
commit
5d526fdb82
2 changed files with 65 additions and 82 deletions
|
@ -21,6 +21,7 @@ import UIKit
|
||||||
func settingsSecureBackupTableViewSectionDidUpdate(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection)
|
func settingsSecureBackupTableViewSectionDidUpdate(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection)
|
||||||
|
|
||||||
func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, textCellForRow: Int) -> MXKTableViewCellWithTextView
|
func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, textCellForRow: Int) -> MXKTableViewCellWithTextView
|
||||||
|
func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, descriptionCellForRow: Int) -> MXKTableViewCell
|
||||||
func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, buttonCellForRow: Int) -> MXKTableViewCellWithButton
|
func settingsSecureBackupTableViewSection(_ settingsSecureBackupTableViewSection: SettingsSecureBackupTableViewSection, buttonCellForRow: Int) -> MXKTableViewCellWithButton
|
||||||
|
|
||||||
// Secure backup
|
// Secure backup
|
||||||
|
@ -38,6 +39,7 @@ import UIKit
|
||||||
|
|
||||||
private enum BackupRows {
|
private enum BackupRows {
|
||||||
case info(text: String)
|
case info(text: String)
|
||||||
|
case description(text: String)
|
||||||
case resetSecureBackupAction
|
case resetSecureBackupAction
|
||||||
case createKeyBackupAction
|
case createKeyBackupAction
|
||||||
case restoreFromKeyBackupAction(keyBackupVersion: MXKeyBackupVersion, title: String)
|
case restoreFromKeyBackupAction(keyBackupVersion: MXKeyBackupVersion, title: String)
|
||||||
|
@ -83,18 +85,14 @@ private enum BackupRows {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func cellForRow(atRow row: Int) -> UITableViewCell {
|
@objc func cellForRow(atRow row: Int) -> UITableViewCell {
|
||||||
guard let delegate = self.delegate else {
|
|
||||||
return UITableViewCell()
|
|
||||||
}
|
|
||||||
|
|
||||||
let backupRow = self.backupRows[row]
|
let backupRow = self.backupRows[row]
|
||||||
|
|
||||||
var cell: UITableViewCell
|
var cell: UITableViewCell
|
||||||
switch backupRow {
|
switch backupRow {
|
||||||
case .info(let infoText):
|
case .info(let text):
|
||||||
let infoCell: MXKTableViewCellWithTextView = delegate.settingsSecureBackupTableViewSection(self, textCellForRow: row)
|
cell = self.textCell(atRow: row, text: text)
|
||||||
infoCell.mxkTextView.text = infoText
|
case .description(let text):
|
||||||
cell = infoCell
|
cell = self.descriptionCell(atRow: row, text: text)
|
||||||
case .resetSecureBackupAction:
|
case .resetSecureBackupAction:
|
||||||
cell = self.buttonCellForResetSecureBackup(atRow: row)
|
cell = self.buttonCellForResetSecureBackup(atRow: row)
|
||||||
case .createKeyBackupAction:
|
case .createKeyBackupAction:
|
||||||
|
@ -124,95 +122,33 @@ private enum BackupRows {
|
||||||
|
|
||||||
switch self.viewState {
|
switch self.viewState {
|
||||||
case .checkingBackup:
|
case .checkingBackup:
|
||||||
|
|
||||||
let info = VectorL10n.securitySettingsSecureBackupDescription
|
|
||||||
let checking = VectorL10n.securitySettingsSecureBackupInfoChecking
|
|
||||||
let strings = [info, "", checking]
|
|
||||||
let text = strings.joined(separator: "\n")
|
|
||||||
|
|
||||||
backupRows = [
|
backupRows = [
|
||||||
.info(text: text)
|
.info(text: VectorL10n.securitySettingsSecureBackupInfoChecking),
|
||||||
|
.description(text: VectorL10n.securitySettingsSecureBackupDescription)
|
||||||
]
|
]
|
||||||
|
|
||||||
case .noKeyBackup:
|
case .noKeyBackup:
|
||||||
|
|
||||||
let noBackup = VectorL10n.settingsKeyBackupInfoNone
|
let noBackup = VectorL10n.settingsKeyBackupInfoNone
|
||||||
let signoutWarning = VectorL10n.settingsKeyBackupInfoSignoutWarning
|
let signoutWarning = VectorL10n.settingsKeyBackupInfoSignoutWarning
|
||||||
let strings = [noBackup, "", signoutWarning]
|
let infoText = [noBackup, signoutWarning].joined(separator: "\n")
|
||||||
let backupInfoText = strings.joined(separator: "\n")
|
|
||||||
|
|
||||||
backupRows = [
|
backupRows = [
|
||||||
.info(text: VectorL10n.securitySettingsSecureBackupDescription),
|
.info(text: infoText),
|
||||||
.info(text: backupInfoText),
|
|
||||||
.createKeyBackupAction,
|
.createKeyBackupAction,
|
||||||
.resetSecureBackupAction
|
.resetSecureBackupAction,
|
||||||
|
.description(text: VectorL10n.securitySettingsSecureBackupDescription)
|
||||||
]
|
]
|
||||||
|
|
||||||
case .keyBackup(let keyBackupVersion, let keyBackupVersionTrust),
|
case .keyBackup(let keyBackupVersion, let keyBackupVersionTrust),
|
||||||
.keyBackupAndRunning(let keyBackupVersion, let keyBackupVersionTrust, _):
|
.keyBackupAndRunning(let keyBackupVersion, let keyBackupVersionTrust, _):
|
||||||
|
backupRows = [
|
||||||
let info = VectorL10n.securitySettingsSecureBackupDescription
|
.info(text: VectorL10n.securitySettingsSecureBackupInfoValid),
|
||||||
let backupStatus = VectorL10n.securitySettingsSecureBackupInfoValid
|
.restoreFromKeyBackupAction(keyBackupVersion: keyBackupVersion, title: VectorL10n.securitySettingsSecureBackupRestore),
|
||||||
let backupStrings = [info, "", backupStatus]
|
.deleteKeyBackupAction(keyBackupVersion: keyBackupVersion),
|
||||||
let backupInfoText = backupStrings.joined(separator: "\n")
|
.resetSecureBackupAction,
|
||||||
|
.description(text: VectorL10n.securitySettingsSecureBackupDescription)
|
||||||
// let version = VectorL10n.settingsSecureBackupInfoVersion(keyBackupVersion.version ?? "")
|
|
||||||
// let algorithm = VectorL10n.settingsSecureBackupInfoAlgorithm(keyBackupVersion.algorithm)
|
|
||||||
// let uploadStatus = VectorL10n.settingsSecureBackupInfoProgressDone
|
|
||||||
// let additionalStrings = [version, algorithm, uploadStatus]
|
|
||||||
// let additionalInfoText = additionalStrings.joined(separator: "\n")
|
|
||||||
//
|
|
||||||
// let backupTrust = self.stringForKeyBackupTrust(keyBackupVersionTrust)
|
|
||||||
// let backupTrustInfoText = backupTrust.joined(separator: "\n")
|
|
||||||
|
|
||||||
var backupViewStateRows: [BackupRows] = [
|
|
||||||
.info(text: backupInfoText),
|
|
||||||
// .info(text: additionalInfoText),
|
|
||||||
// .info(text: backupTrustInfoText)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
// TODO: Do not display restore button if all keys are stored on the device
|
|
||||||
if true {
|
|
||||||
backupViewStateRows.append(.restoreFromKeyBackupAction(keyBackupVersion: keyBackupVersion, title: VectorL10n.securitySettingsSecureBackupRestore))
|
|
||||||
}
|
|
||||||
|
|
||||||
backupViewStateRows.append(.deleteKeyBackupAction(keyBackupVersion: keyBackupVersion))
|
|
||||||
backupViewStateRows.append(.resetSecureBackupAction)
|
|
||||||
|
|
||||||
backupRows = backupViewStateRows
|
|
||||||
|
|
||||||
// case .backupAndRunning(let keyBackupVersion, let keyBackupVersionTrust, let backupProgress):
|
|
||||||
//
|
|
||||||
// let info = VectorL10n.securitySettingsSecureBackupDescription
|
|
||||||
// let backupStatus = VectorL10n.securitySettingsSecureBackupInfoValid
|
|
||||||
// let backupStrings = [info, "", backupStatus]
|
|
||||||
// let backupInfoText = backupStrings.joined(separator: "\n")
|
|
||||||
//
|
|
||||||
// let remaining = backupProgress.totalUnitCount - backupProgress.completedUnitCount
|
|
||||||
// let version = VectorL10n.settingsSecureBackupInfoVersion(keyBackupVersion.version ?? "")
|
|
||||||
// let algorithm = VectorL10n.settingsSecureBackupInfoAlgorithm(keyBackupVersion.algorithm)
|
|
||||||
// let uploadStatus = VectorL10n.settingsSecureBackupInfoProgress(String(remaining))
|
|
||||||
// let additionalStrings = [version, algorithm, uploadStatus]
|
|
||||||
// let additionalInfoText = additionalStrings.joined(separator: "\n")
|
|
||||||
//
|
|
||||||
// let backupTrust = self.stringForKeyBackupTrust(keyBackupVersionTrust)
|
|
||||||
// let backupTrustInfoText = backupTrust.joined(separator: "\n")
|
|
||||||
//
|
|
||||||
// var backupAndRunningViewStateRows: [BackupRows] = [
|
|
||||||
// .info(text: backupInfoText),
|
|
||||||
// .info(text: additionalInfoText),
|
|
||||||
// .info(text: backupTrustInfoText)
|
|
||||||
// ]
|
|
||||||
//
|
|
||||||
// // TODO: Do not display restore button if all keys are stored on the device
|
|
||||||
// if true {
|
|
||||||
// backupAndRunningViewStateRows.append(.restoreAction(keyBackupVersion: keyBackupVersion, title: VectorL10n.settingsSecureBackupButtonRestore))
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// backupAndRunningViewStateRows.append(.deleteAction(keyBackupVersion: keyBackupVersion))
|
|
||||||
//
|
|
||||||
// backupRows = backupAndRunningViewStateRows
|
|
||||||
|
|
||||||
case .keyBackupNotTrusted(let keyBackupVersion, let keyBackupVersionTrust):
|
case .keyBackupNotTrusted(let keyBackupVersion, let keyBackupVersionTrust):
|
||||||
|
|
||||||
// TODO: What?
|
// TODO: What?
|
||||||
|
@ -254,6 +190,28 @@ private enum BackupRows {
|
||||||
self.backupRows = backupRows
|
self.backupRows = backupRows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Cells -
|
||||||
|
|
||||||
|
private func textCell(atRow row: Int, text: String) -> UITableViewCell {
|
||||||
|
guard let delegate = self.delegate else {
|
||||||
|
return UITableViewCell()
|
||||||
|
}
|
||||||
|
|
||||||
|
let cell = delegate.settingsSecureBackupTableViewSection(self, textCellForRow: row)
|
||||||
|
cell.mxkTextView.text = text
|
||||||
|
return cell
|
||||||
|
}
|
||||||
|
|
||||||
|
private func descriptionCell(atRow row: Int, text: String) -> UITableViewCell {
|
||||||
|
guard let delegate = self.delegate else {
|
||||||
|
return UITableViewCell()
|
||||||
|
}
|
||||||
|
|
||||||
|
let cell = delegate.settingsSecureBackupTableViewSection(self, descriptionCellForRow: row)
|
||||||
|
cell.textLabel?.text = text
|
||||||
|
return cell
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Button cells
|
// MARK: - Button cells
|
||||||
|
|
||||||
private func buttonCellForResetSecureBackup(atRow row: Int) -> UITableViewCell {
|
private func buttonCellForResetSecureBackup(atRow row: Int) -> UITableViewCell {
|
||||||
|
|
|
@ -1231,6 +1231,17 @@ TableViewSectionsDelegate>
|
||||||
return textViewCell;
|
return textViewCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (MXKTableViewCell*)descriptionCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
MXKTableViewCell *cell = [self getDefaultTableViewCell:tableView];
|
||||||
|
cell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
|
||||||
|
cell.textLabel.numberOfLines = 0;
|
||||||
|
cell.contentView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor;
|
||||||
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||||
|
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
- (MXKTableViewCellWithButton *)buttonCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath
|
- (MXKTableViewCellWithButton *)buttonCellForTableView:(UITableView*)tableView atIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
MXKTableViewCellWithButton *cell = [self.tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier] forIndexPath:indexPath];
|
MXKTableViewCellWithButton *cell = [self.tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier] forIndexPath:indexPath];
|
||||||
|
@ -1706,6 +1717,20 @@ TableViewSectionsDelegate>
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (MXKTableViewCellWithTextView *)settingsSecureBackupTableViewSection:(SettingsSecureBackupTableViewSection *)settingsSecureBackupTableViewSection descriptionCellForRow:(NSInteger)textCellForRow
|
||||||
|
{
|
||||||
|
MXKTableViewCellWithTextView *cell;
|
||||||
|
|
||||||
|
NSIndexPath *indexPath = [self.tableViewSections exactIndexPathForRowTag:textCellForRow sectionTag:SECTION_SECURE_BACKUP];
|
||||||
|
|
||||||
|
if (indexPath)
|
||||||
|
{
|
||||||
|
cell = [self descriptionCellForTableView:self.tableView atIndexPath:indexPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
- (MXKTableViewCellWithButton *)settingsSecureBackupTableViewSection:(SettingsSecureBackupTableViewSection *)settingsSecureBackupTableViewSection buttonCellForRow:(NSInteger)buttonCellForRow
|
- (MXKTableViewCellWithButton *)settingsSecureBackupTableViewSection:(SettingsSecureBackupTableViewSection *)settingsSecureBackupTableViewSection buttonCellForRow:(NSInteger)buttonCellForRow
|
||||||
{
|
{
|
||||||
MXKTableViewCellWithButton *cell;
|
MXKTableViewCellWithButton *cell;
|
||||||
|
|
Loading…
Reference in a new issue