Skip to content

Commit

Permalink
[fix/share-extension-passcode-lock-interval] Share Extension Passcode…
Browse files Browse the repository at this point in the history
… Lock Interval (#1156)
  • Loading branch information
hosy authored Sep 21, 2022
1 parent 723a069 commit 20a0653
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/1156
Original file line number Diff line number Diff line change
@@ -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
23 changes: 19 additions & 4 deletions ownCloud Share Extension/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
})
Expand Down Expand Up @@ -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] = []

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
21 changes: 14 additions & 7 deletions ownCloudAppShared/AppLock/AppLockManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -333,7 +340,7 @@ public class AppLockManager: NSObject {
}

// MARK: - App Events
@objc func appDidEnterBackground() {
@objc public func appDidEnterBackground() {
if unlocked {
lastApplicationBackgroundedDate = Date()
} else {
Expand Down

0 comments on commit 20a0653

Please sign in to comment.