From 20a0653f915c09727deb71e283ff9c313cdf8fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20H=C3=BChne?= Date: Wed, 21 Sep 2022 22:55:34 +0200 Subject: [PATCH] [fix/share-extension-passcode-lock-interval] Share Extension Passcode Lock Interval (#1156) --- CHANGELOG.md | 7 ++++++ changelog/unreleased/1156 | 5 ++++ .../ShareViewController.swift | 23 +++++++++++++++---- .../AppLock/AppLockManager.swift | 21 +++++++++++------ 4 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 changelog/unreleased/1156 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f4d2bb25..cfdd91bfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Summary ------- * Bugfix - Enabling Markup Mode on iOS 16, Updating Theme: [#1141](https://github.com/owncloud/ios-app/issues/1141) +* Bugfix - Share Extension Passcode Lock Interval: [#1156](https://github.com/owncloud/ios-app/issues/1156) * Bugfix - Video Metadata Image: [#5296](https://github.com/owncloud/enterprise/issues/5296) * Change - New Dark Mode Themes: [#1146](https://github.com/owncloud/ios-app/issues/1146) @@ -23,6 +24,12 @@ Details https://github.com/owncloud/ios-app/issues/1141 +* Bugfix - Share Extension Passcode Lock Interval: [#1156](https://github.com/owncloud/ios-app/issues/1156) + + The passcode lock interval was not taken into use in the share extension. + + https://github.com/owncloud/ios-app/issues/1156 + * Bugfix - Video Metadata Image: [#5296](https://github.com/owncloud/enterprise/issues/5296) If a video file includes a metadata image, the video file was not visible, because the metadata diff --git a/changelog/unreleased/1156 b/changelog/unreleased/1156 new file mode 100644 index 000000000..b330c6dc0 --- /dev/null +++ b/changelog/unreleased/1156 @@ -0,0 +1,5 @@ +Bugfix: Share Extension Passcode Lock Interval + +The passcode lock interval was not taken into use in the share extension. + +https://github.com/owncloud/ios-app/issues/1156 diff --git a/ownCloud Share Extension/ShareViewController.swift b/ownCloud Share Extension/ShareViewController.swift index e78b7e133..10dfe51c9 100644 --- a/ownCloud Share Extension/ShareViewController.swift +++ b/ownCloud Share Extension/ShareViewController.swift @@ -58,13 +58,14 @@ class ShareViewController: MoreStaticTableViewController { // Share extension allowed if !willAppearInitial { willAppearInitial = true - - if AppLockManager.supportedOnDevice { - AppLockManager.shared.showLockscreenIfNeeded() - } + + if AppLockManager.supportedOnDevice { + AppLockManager.shared.showLockscreenIfNeeded() + } if let appexNavigationController = self.navigationController as? AppExtensionNavigationController { appexNavigationController.dismissalAction = { [weak self] (_) in + AppLockManager.shared.appDidEnterBackground() self?.returnCores(completion: { Log.debug("Returned all cores (share sheet was closed / dismissed)") }) @@ -96,6 +97,18 @@ class ShareViewController: MoreStaticTableViewController { didAppearInitial = true } } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + if didAppearInitial { + AppLockManager.shared.appDidEnterBackground() + } + } + + @objc open override func dismissAnimated() { + AppLockManager.shared.appDidEnterBackground() + super.dismissAnimated() + } private var requestedCoreBookmarks : [OCBookmark] = [] @@ -146,6 +159,7 @@ class ShareViewController: MoreStaticTableViewController { } @objc private func cancelAction () { + AppLockManager.shared.appDidEnterBackground() self.returnCores(completion: { let error = NSError(domain: NSErrorDomain.ShareViewErrorDomain, code: 0, userInfo: [NSLocalizedDescriptionKey: "Canceled by user"]) self.extensionContext?.cancelRequest(withError: error) @@ -172,6 +186,7 @@ class ShareViewController: MoreStaticTableViewController { for (bookmark) in bookmarks { let row = StaticTableViewRow(buttonWithAction: { (_ row, _ sender) in + self.didAppearInitial = false self.openDirectoryPicker(for: bookmark, withBackButton: true) }, title: bookmark.shortName, style: .plain, image: UIImage(named: "bookmark-icon")?.scaledImageFitting(in: CGSize(width: 25.0, height: 25.0)), imageWidth: 25, alignment: .left) actionsRows.append(row) diff --git a/ownCloudAppShared/AppLock/AppLockManager.swift b/ownCloudAppShared/AppLock/AppLockManager.swift index 4e4b169f8..b82592168 100644 --- a/ownCloudAppShared/AppLock/AppLockManager.swift +++ b/ownCloudAppShared/AppLock/AppLockManager.swift @@ -173,12 +173,19 @@ public class AppLockManager: NSObject { lockscreenOpenForced = forceShow lockscreenOpen = true - // Show biometrical - if !forceShow, !self.shouldDisplayCountdown, self.biometricalAuthenticationSucceeded { - showBiometricalAuthenticationInterface(context: context) - } else if setupMode { - showBiometricalAuthenticationInterface(context: context) - } + // The following code needs to be executed after a short delay, because in the share sheet the biometrical unlock UI can block adding the PasscodeViewController UI + var delay = 0.0 + if self.passwordViewHostViewController != nil { + delay = 0.5 + } + OnMainThread(after: delay) { + // Show biometrical + if !forceShow, !self.shouldDisplayCountdown, self.biometricalAuthenticationSucceeded { + self.showBiometricalAuthenticationInterface(context: context) + } else if setupMode { + self.showBiometricalAuthenticationInterface(context: context) + } + } } else { dismissLockscreen(animated: true) } @@ -333,7 +340,7 @@ public class AppLockManager: NSObject { } // MARK: - App Events - @objc func appDidEnterBackground() { + @objc public func appDidEnterBackground() { if unlocked { lastApplicationBackgroundedDate = Date() } else {