فهرست منبع

Fix splash screen cancels request photo auth

- When `requestAuthorization` is called, app resigns active and displays alert
  - if user selects limited access, photo select view is shown
  - bc app is *in bg* app displays splash window. behind the alert When user selects option, iOS displays select photos view. But then app will become active and dismiss both splash and select phot view
-> Solution: Keep track if app is requesting access and don't automatically dismiss splash if becomes active. Manually hide splash screen after authorisation completes

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 سال پیش
والد
کامیت
23c3d471b8
2فایلهای تغییر یافته به همراه13 افزوده شده و 5 حذف شده
  1. 6 5
      iOSClient/AppDelegate.swift
  2. 7 0
      iOSClient/Utility/NCAskAuthorization.swift

+ 6 - 5
iOSClient/AppDelegate.swift

@@ -189,8 +189,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     // L' applicazione entrerà in primo piano (attivo sempre)
     func applicationDidBecomeActive(_ application: UIApplication) {
         
-        // Privacy
-        hidePrivacyProtectionWindow()
+        if !NCAskAuthorization.shared.isRequesting {
+            // Privacy
+            hidePrivacyProtectionWindow()
+        }
         
         NCSettingsBundleHelper.setVersionAndBuildNumber()
         
@@ -693,7 +695,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
     // MARK: - Passcode
     
-    func presentPasscode(completion: @escaping ()->()) {
+    func presentPasscode(completion: @escaping () -> ()) {
 
         let laContext = LAContext()
         var error: NSError?
@@ -787,8 +789,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         privacyProtectionWindow?.makeKeyAndVisible()
     }
 
-    private func hidePrivacyProtectionWindow() {
-        
+    func hidePrivacyProtectionWindow() {
         privacyProtectionWindow?.isHidden = true
         privacyProtectionWindow = nil
     }

+ 7 - 0
iOSClient/Utility/NCAskAuthorization.swift

@@ -29,6 +29,8 @@ class NCAskAuthorization: NSObject {
         return instance
     }()
 
+    private(set) var isRequesting = false
+
     func askAuthorizationAudioRecord(viewController: UIViewController?, completion: @escaping (_ hasPermission: Bool) -> Void) {
 
         switch AVAudioSession.sharedInstance().recordPermission {
@@ -85,7 +87,12 @@ class NCAskAuthorization: NSObject {
             }
             break
         case PHAuthorizationStatus.notDetermined:
+            isRequesting = true
             PHPhotoLibrary.requestAuthorization { allowed in
+                self.isRequesting = false
+                DispatchQueue.main.async {
+                    (UIApplication.shared.delegate as? AppDelegate)?.hidePrivacyProtectionWindow()
+                }
                 DispatchQueue.main.async {
                     if allowed == PHAuthorizationStatus.authorized {
                         completion(true)