Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the App Lock feature. #1990

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ElementX/Sources/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
return
}

if appSettings.appLockFlowEnabled,
appSettings.appLockIsMandatory,
!appLockFlowCoordinator.appLockService.isEnabled {
if appSettings.appLockIsMandatory, !appLockFlowCoordinator.appLockService.isEnabled {
stateMachine.processEvent(.startWithAppLockSetup)
} else {
stateMachine.processEvent(.startWithExistingSession)
Expand Down
4 changes: 0 additions & 4 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ final class AppSettings {
case userSuggestionsEnabled
case readReceiptsEnabled
case swiftUITimelineEnabled
case appLockFlowEnabled
case elementCallEnabled
case chatBackupEnabled
}
Expand Down Expand Up @@ -268,9 +267,6 @@ final class AppSettings {
@UserPreference(key: UserDefaultsKeys.swiftUITimelineEnabled, defaultValue: false, storageType: .volatile)
var swiftUITimelineEnabled

@UserPreference(key: UserDefaultsKeys.appLockFlowEnabled, defaultValue: false, storageType: .volatile)
var appLockFlowEnabled

@UserPreference(key: UserDefaultsKeys.elementCallEnabled, defaultValue: true, storageType: .userDefaults(store))
var elementCallEnabled

Expand Down
2 changes: 1 addition & 1 deletion ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.1.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

// swiftlint:disable all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
var userSuggestionsEnabled: Bool { get set }
var readReceiptsEnabled: Bool { get set }
var swiftUITimelineEnabled: Bool { get set }
var appLockFlowEnabled: Bool { get set }
var elementCallEnabled: Bool { get set }
var chatBackupEnabled: Bool { get set }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ struct DeveloperOptionsScreen: View {
Text("Chat backup")
Text("Requires app reboot")
}

Toggle(isOn: $context.appLockFlowEnabled) {
Text("PIN/Biometric lock")
Text("Resets on reboot")
}
}

Section("Timeline") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ struct SettingsScreenViewState: BindableState {
var isSessionVerified = false
var chatBackupEnabled = false
var showSecureBackupBadge = false
var showAppLockSettings: Bool
var showDeveloperOptions: Bool

/// The presentation anchor used to display the OIDC account URL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
userID: userSession.userID,
accountProfileURL: userSession.clientProxy.accountURL(action: .profile),
accountSessionsListURL: userSession.clientProxy.accountURL(action: .sessionsList),
showAppLockSettings: appSettings.appLockFlowEnabled,
showDeveloperOptions: appSettings.canShowDeveloperOptions),
imageProvider: userSession.mediaProvider)

Expand All @@ -50,10 +49,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
.receive(on: DispatchQueue.main)
.weakAssign(to: \.state.userDisplayName, on: self)
.store(in: &cancellables)

appSettings.$appLockFlowEnabled
.weakAssign(to: \.state.showAppLockSettings, on: self)
.store(in: &cancellables)

appSettings.$chatBackupEnabled
.weakAssign(to: \.state.chatBackupEnabled, on: self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,12 @@ struct SettingsScreen: View {
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.analytics)

if context.viewState.showAppLockSettings {
ListRow(label: .default(title: L10n.commonScreenLock,
systemIcon: .lock),
kind: .navigationLink {
context.send(viewAction: .appLock)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.screenLock)
}
ListRow(label: .default(title: L10n.commonScreenLock,
systemIcon: .lock),
kind: .navigationLink {
context.send(viewAction: .appLock)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.screenLock)

ListRow(label: .default(title: L10n.commonReportABug,
systemIcon: .ladybug),
Expand Down
1 change: 0 additions & 1 deletion ElementX/Sources/Services/AppLock/AppLockService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class AppLockService: AppLockServiceProtocol {

var isEnabled: Bool {
do {
guard appSettings.appLockFlowEnabled else { return false }
return try keychainController.containsPINCode()
} catch {
MXLog.error("Keychain access error: \(error)")
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion UnitTests/Sources/AppLock/AppLockServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class AppLockServiceTests: XCTestCase {
override func setUp() {
AppSettings.reset()
appSettings = AppSettings()
appSettings.appLockFlowEnabled = true

keychainController = KeychainController(service: .tests, accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier)
keychainController.resetSecrets()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,11 @@ class AppLockSetupSettingsScreenViewModelTests: XCTestCase {
}

override func setUpWithError() throws {
AppSettings.reset()
let appSettings = AppSettings()
appSettings.appLockFlowEnabled = true

keychainController = KeychainControllerMock()
appLockService = AppLockService(keychainController: keychainController, appSettings: appSettings)
appLockService = AppLockService(keychainController: keychainController, appSettings: AppSettings())

viewModel = AppLockSetupSettingsScreenViewModel(appLockService: AppLockServiceMock.mock())
}

override func tearDown() {
AppSettings.reset()
}

func testDisablingShowsAlert() {
// Given a fresh screen with the PIN code enabled.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions changelog.d/pr-1990.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow the app to be locked with a PIN code or Touch/Face ID.