marinofaggiana 4 жил өмнө
parent
commit
c1dec96993

+ 12 - 6
iOSClient/AppDelegate.swift

@@ -208,6 +208,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         if account == "" { return}
 
         NCNetworking.shared.verifyUploadZombie()
+        
+        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterApplicationDidBecomeActive)
     }
     
     // L' applicazione entrerà in primo piano (attivo solo dopo il background)
@@ -606,7 +608,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     
     // MARK: - Account Request
     
-    func requestAccount() {
+    func requestAccount(startTimer: Bool) {
               
         let accounts = NCManageDatabase.shared.getAllAccount()
         
@@ -620,6 +622,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 popup.backgroundAlpha = 0.8
                              
                 UIApplication.shared.keyWindow?.rootViewController?.present(popup, animated: true)
+                
+                if startTimer {
+                    vcAccountRequest.startTimer()
+                }
             }
         }
     }
@@ -634,11 +640,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         if account == "" { return }
         
         guard let passcode = CCUtility.getPasscode() else {
-            requestAccount()
+            requestAccount(startTimer: false)
             return
         }
         if passcode.count == 0 || CCUtility.getNotPasscodeAtStart() {
-            requestAccount()
+            requestAccount(startTimer: false)
             return
         }
         
@@ -677,7 +683,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     func didInputCorrectPasscode(in passcodeViewController: TOPasscodeViewController) {
         passcodeViewController.dismiss(animated: true) {
             self.passcodeViewController = nil
-            self.requestAccount()
+            self.requestAccount(startTimer: true)
         }
     }
     
@@ -691,7 +697,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                     passcodeViewController.dismiss(animated: true) {
                         self.passcodeViewController = nil
-                        self.requestAccount()
+                        self.requestAccount(startTimer: true)
                     }
                 }
             }
@@ -705,7 +711,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                         self.passcodeViewController?.dismiss(animated: true) {
                             self.passcodeViewController = nil
-                            self.requestAccount()
+                            self.requestAccount(startTimer: true)
                         }
                     }
                 }

+ 2 - 0
iOSClient/Login/NCLoginWeb.swift

@@ -202,6 +202,8 @@ extension NCLoginWeb: WKNavigationDelegate {
         activityIndicator.stopAnimating()
         print("didFinishProvisionalNavigation");
         
+        let url = webView.url?.absoluteString
+        
         if loginFlowV2Available {
             DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                 NCCommunication.shared.getLoginFlowV2Poll(token: self.loginFlowV2Token, endpoint: self.loginFlowV2Endpoint) { (server, loginName, appPassword, errorCode, errorDescription) in

+ 16 - 5
iOSClient/Main/Account Request/NCAccountRequest.storyboard

@@ -14,24 +14,24 @@
             <objects>
                 <viewController id="V0q-CP-xMJ" customClass="NCAccountRequest" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="gzh-6E-hc4">
-                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <rect key="frame" x="0.0" y="0.0" width="300" height="400"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ouH-gK-Guv" userLabel="Separator">
-                                <rect key="frame" x="0.0" y="102" width="414" height="1"/>
+                                <rect key="frame" x="0.0" y="102" width="300" height="1"/>
                                 <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="1" id="2OQ-Mt-Gnh"/>
                                 </constraints>
                             </view>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Accounts" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZr-nE-ths">
-                                <rect key="frame" x="20" y="64" width="374" height="18"/>
+                                <rect key="frame" x="20" y="64" width="260" height="18"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W5y-aT-UlI">
-                                <rect key="frame" x="157" y="333" width="100" height="30"/>
+                                <rect key="frame" x="100" y="333" width="100" height="30"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="30" id="APQ-0x-b1G"/>
                                     <constraint firstAttribute="width" constant="100" id="Amv-Gj-xDj"/>
@@ -43,7 +43,7 @@
                                 </connections>
                             </button>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Pdo-MB-AhU">
-                                <rect key="frame" x="10" y="113" width="394" height="200"/>
+                                <rect key="frame" x="10" y="113" width="280" height="200"/>
                                 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="200" id="ZUy-pC-C0i"/>
@@ -53,16 +53,25 @@
                                     <outlet property="delegate" destination="V0q-CP-xMJ" id="j64-3x-N2u"/>
                                 </connections>
                             </tableView>
+                            <progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="e8R-j7-ObS">
+                                <rect key="frame" x="0.0" y="398" width="300" height="2"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="2" id="G3U-2x-imL"/>
+                                </constraints>
+                            </progressView>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="1c1-7Q-WMG"/>
                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
+                            <constraint firstItem="e8R-j7-ObS" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" id="1gS-Ca-1Ov"/>
                             <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="Pdo-MB-AhU" secondAttribute="trailing" constant="10" id="819-yV-vz7"/>
                             <constraint firstItem="ouH-gK-Guv" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" id="A6T-ed-97T"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="bottom" secondItem="e8R-j7-ObS" secondAttribute="bottom" id="Cko-PC-TiW"/>
                             <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="nZr-nE-ths" secondAttribute="trailing" constant="20" id="DPW-MV-oKc"/>
                             <constraint firstItem="Pdo-MB-AhU" firstAttribute="top" secondItem="ouH-gK-Guv" secondAttribute="bottom" constant="10" id="HnJ-03-7W5"/>
                             <constraint firstItem="nZr-nE-ths" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" constant="20" id="SI9-xL-6s8"/>
                             <constraint firstItem="Pdo-MB-AhU" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" constant="10" id="Y5n-ju-hts"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="e8R-j7-ObS" secondAttribute="trailing" id="chh-t9-vJN"/>
                             <constraint firstItem="W5y-aT-UlI" firstAttribute="centerX" secondItem="1c1-7Q-WMG" secondAttribute="centerX" id="nhM-cg-paa"/>
                             <constraint firstItem="nZr-nE-ths" firstAttribute="top" secondItem="1c1-7Q-WMG" secondAttribute="top" constant="20" id="oyJ-sj-j5N"/>
                             <constraint firstItem="W5y-aT-UlI" firstAttribute="top" secondItem="Pdo-MB-AhU" secondAttribute="bottom" constant="20" id="pfI-HG-ci4"/>
@@ -71,8 +80,10 @@
                         </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="Zon-2j-rsc"/>
+                    <size key="freeformSize" width="300" height="400"/>
                     <connections>
                         <outlet property="okButton" destination="W5y-aT-UlI" id="59a-ck-kGF"/>
+                        <outlet property="progressView" destination="e8R-j7-ObS" id="2gM-MB-IhE"/>
                         <outlet property="tableView" destination="Pdo-MB-AhU" id="AcD-SW-2ga"/>
                         <outlet property="titleLabel" destination="nZr-nE-ths" id="UbA-Dl-0Ad"/>
                     </connections>

+ 34 - 4
iOSClient/Main/Account Request/NCAccountRequest.swift

@@ -29,9 +29,13 @@ class NCAccountRequest: UIViewController {
     @IBOutlet weak var titleLabel: UILabel!
     @IBOutlet weak var tableView: UITableView!
     @IBOutlet weak var okButton: UIButton!
+    @IBOutlet weak var progressView: UIProgressView!
+    
+    public var accounts: [tableAccount] = []
+    
+    private var timer: Timer?
+    private var time: Float = 0
     
-    var accounts: [tableAccount] = []
-
     // MARK: - Life Cycle
     
     override func viewDidLoad() {
@@ -44,21 +48,47 @@ class NCAccountRequest: UIViewController {
         okButton.layer.cornerRadius = 15
         okButton.layer.masksToBounds = true
         okButton.layer.backgroundColor = NCBrandColor.shared.brand.cgColor
+        
+        progressView.tintColor = NCBrandColor.shared.brandElement
+        progressView.trackTintColor = .clear
+        progressView.progress = 1
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(startTimer), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
     }
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
-
     }
     
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
     }
     
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+    }
+     
+    // MARK: - Progress
+    
+    @objc func startTimer() {
+        timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(updateProgress), userInfo: nil, repeats: true)
+    }
+    
+    @objc func updateProgress() {
+        
+        time += 0.1
+        
+        if time >= 3 {
+            timer?.invalidate()
+            dismiss(animated: true)
+        } else {
+            progressView.progress = 1 - (time / 3)
+        }
+    }
+    
     // MARK: - Action
     
     @IBAction func ok(_ sender: Any) {
-        
         dismiss(animated: true)
     }
 }

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -233,6 +233,7 @@ class NCGlobal: NSObject {
 
     @objc let notificationCenterApplicationDidEnterBackground   = "applicationDidEnterBackground"
     let notificationCenterApplicationWillEnterForeground        = "applicationWillEnterForeground"
+    let notificationCenterApplicationDidBecomeActive            = "applicationDidBecomeActive"
 
     @objc let notificationCenterInitializeMain                  = "initializeMain"
     @objc let notificationCenterChangeTheming                   = "changeTheming"