Quellcode durchsuchen

#2221

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana vor 2 Jahren
Ursprung
Commit
7259ef1512

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -3961,8 +3961,8 @@
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/nextcloud/NextcloudKit";
 			requirement = {
-				kind = exactVersion;
-				version = 1.4.0;
+				branch = develop;
+				kind = branch;
 			};
 		};
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

+ 9 - 4
iOSClient/Account Request/NCTalkAccounts.storyboard

@@ -50,7 +50,8 @@
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="10" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="4cH-oC-YBd" userLabel="Avatar">
-                                                    <rect key="frame" x="0.0" y="15.999999999999998" width="30" height="28.666666666666664"/>
+                                                    <rect key="frame" x="0.0" y="16" width="30" height="28.666666666666664"/>
+                                                    <color key="tintColor" systemColor="systemGray2Color"/>
                                                     <constraints>
                                                         <constraint firstAttribute="height" constant="30" id="Efd-BU-u61"/>
                                                         <constraint firstAttribute="width" constant="30" id="qFy-Tu-ov6"/>
@@ -58,19 +59,20 @@
                                                     <imageReference key="image" image="person.circle" catalog="system" variableValue="0.80000000000000004"/>
                                                 </imageView>
                                                 <label opaque="NO" userInteractionEnabled="NO" tag="20" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pWI-iZ-BTy" userLabel="User">
-                                                    <rect key="frame" x="40" y="20.333333333333336" width="220" height="19.333333333333336"/>
-                                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
+                                                    <rect key="frame" x="40" y="21.666666666666668" width="220" height="17.000000000000004"/>
+                                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" tag="30" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sWT-NJ-ihR" userLabel="Url">
-                                                    <rect key="frame" x="40" y="40.666666666666664" width="220" height="16"/>
+                                                    <rect key="frame" x="40" y="39.666666666666664" width="220" height="16"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="13"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="40" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="chevron.right" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="x47-dQ-alI" userLabel="Active">
                                                     <rect key="frame" x="265" y="24.666666666666671" width="15" height="11.333333333333329"/>
+                                                    <color key="tintColor" systemColor="systemGray2Color"/>
                                                     <constraints>
                                                         <constraint firstAttribute="height" constant="15" id="SXt-LG-c5N"/>
                                                         <constraint firstAttribute="width" constant="15" id="vdZ-4R-gY5"/>
@@ -149,5 +151,8 @@
         <systemColor name="systemBlueColor">
             <color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
         </systemColor>
+        <systemColor name="systemGray2Color">
+            <color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
     </resources>
 </document>

+ 8 - 14
iOSClient/Account Request/NCTalkAccounts.swift

@@ -40,7 +40,7 @@ class NCTalkAccounts: UIViewController {
     @IBOutlet weak var tableView: UITableView!
     @IBOutlet weak var progressView: UIProgressView!
 
-    public var accounts: [dataAccountFile] = []
+    public var accounts: [NKDataAccountFile] = []
     public let heightCell: CGFloat = 60
     public var enableTimerProgress: Bool = true
     public var dismissDidEnterBackground: Bool = true
@@ -60,7 +60,7 @@ class NCTalkAccounts: UIViewController {
         closeButton.setImage(NCUtility.shared.loadImage(named: "xmark", color: .label), for: .normal)
 
         tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 1))
-        //tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
+        // tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
 
         view.backgroundColor = .secondarySystemBackground
         tableView.backgroundColor = .secondarySystemBackground
@@ -145,16 +145,6 @@ extension NCTalkAccounts: UITableViewDelegate {
         progressView.progress = 0
     }
 
-    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
-        if decelerate {
-//            startTimer()
-        }
-    }
-
-    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
-//        startTimer()
-    }
-
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
         return heightCell
     }
@@ -188,7 +178,7 @@ extension NCTalkAccounts: UITableViewDataSource {
 
         let account = accounts[indexPath.row]
 
-        if let avatarPath = account.avatar, let avatarImage = avatarImage {
+        if let avatarPath = account.avatar, !avatarPath.isEmpty, let avatarImage = avatarImage {
             do {
                 let data = try Data(contentsOf: URL(fileURLWithPath: avatarPath))
                 if let image = UIImage(data: data) {
@@ -197,7 +187,11 @@ extension NCTalkAccounts: UITableViewDataSource {
             } catch { print("Error: \(error)") }
         }
 
-        userLabel?.text = account.user.uppercased()
+        if let alias = account.alias, !alias.isEmpty {
+            userLabel?.text = alias.uppercased() + " (\(account.user))"
+        } else {
+            userLabel?.text = account.user.uppercased()
+        }
         urlLabel?.text = (URL(string: account.url)?.host ?? "")
 
         return cell

+ 20 - 0
iOSClient/AppDelegate.swift

@@ -250,6 +250,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCNetworkingProcessUpload.shared.invalidateObserveTableMetadata()
         NCNetworkingProcessUpload.shared.stopTimer()
 
+        // Create file account for Nextcloud Talk
+        if let error = createDataAccountFile() {
+            NKCommon.shared.writeLog("[ERROR] Create account file for Talk \(error.localizedDescription)")
+        }
+
         if CCUtility.getPrivacyScreenEnabled() {
             // Privacy
             showPrivacyProtectionWindow()
@@ -634,6 +639,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
     }
 
+    func createDataAccountFile() -> Error? {
+        guard !account.isEmpty else { return nil }
+
+        let url =  CCUtility.getDirectoryGroup().appendingPathComponent(NCGlobal.shared.appDatabaseNextcloud + "/" + NCGlobal.shared.fileAccounts)
+
+        let tableAccount = NCManageDatabase.shared.getAllAccount()
+        var accounts = [NKDataAccountFile]()
+        for account in tableAccount {
+            let userBaseUrl = account.user + "-" + (URL(string: account.urlBase)?.host ?? "")
+            let avatar = String(CCUtility.getDirectoryUserData()) + "/" +  userBaseUrl + "-\(account.user).png"
+            accounts.append(NKDataAccountFile(withUrl: account.urlBase, user: account.user, alias: account.alias, avatar: avatar))
+        }
+        return NKCommon.shared.createDataAccountFile(at: url, accounts: accounts)
+    }
+
     // MARK: - Account Request
 
     func accountRequestChangeAccount(account: String) {

+ 2 - 1
iOSClient/Brand/NCBrand.swift

@@ -59,7 +59,8 @@ import UIKit
     // BRAND ONLY
     @objc public var use_login_web_personalized:        Bool = false                                                // Don't touch me !!
     @objc public var use_AppConfig:                     Bool = false                                                // Don't touch me !!
-    
+    @objc public var use_talkDetect:                    Bool = true                                                 // Don't touch me !!
+
     // Options
     @objc public var use_default_auto_upload:           Bool = false
     @objc public var use_themingColor:                  Bool = true

+ 4 - 24
iOSClient/Login/NCLogin.swift

@@ -129,11 +129,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
         appDelegate.timerErrorNetworking?.invalidate()
 
-        // test
-        createTalkAccount()
-
-        if let talkAccounts = readTalkAccounts(), let image = UIImage(named: "talk"), let backgroundColor =  NCBrandColor.shared.brandElement.lighter(by: 10) {
-            NCContentPresenter.shared.alertAction(image: image, backgroundColor: backgroundColor, textColor: textColor, title: "Talk is intalled", description: "Hei I have fount talk user, ...", textCancelButton: "cancel", textOkButton: "ok", attributes: EKAttributes.topFloat) { identifier in
+        if NCBrandOptions.shared.use_talkDetect, let talkAccounts = readTalkAccounts(), let image = UIImage(named: "talk"), let backgroundColor =  NCBrandColor.shared.brandElement.lighter(by: 10) {
+            NCContentPresenter.shared.alertAction(image: image, backgroundColor: backgroundColor, textColor: textColor, title: "_talk_detect_", description: "_talk_add_account_", textCancelButton: "_cancel_", textOkButton: "_ok_", attributes: EKAttributes.topFloat) { identifier in
                 if identifier == "ok" {
                     if let vc = UIStoryboard(name: "NCTalkAccounts", bundle: nil).instantiateInitialViewController() as? NCTalkAccounts {
 
@@ -147,7 +144,6 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                         let height = min(CGFloat(numberCell * Int(vc.heightCell) + 45), screenHeighMax)
 
                         let popup = NCPopupViewController(contentController: vc, popupWidth: 300, popupHeight: height+20)
-                        popup.backgroundAlpha = 0.8
 
                         self.present(popup, animated: true)
                     }
@@ -419,32 +415,16 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         }
     }
 
-    func readTalkAccounts() -> [dataAccountFile]? {
+    func readTalkAccounts() -> [NKDataAccountFile]? {
 
         guard let dirGroupTalk = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroupsTalk) else { return nil }
         let url = dirGroupTalk.appendingPathComponent(NCGlobal.shared.appDatabaseTalk + "/" + NCGlobal.shared.fileAccounts)
 
         if FileManager.default.fileExists(atPath: url.path) {
-            return NCUtility.shared.readDataAccountFile(at: url)
+            return NKCommon.shared.readDataAccountFile(at: url)
         }
         return nil
     }
-
-    func createTalkAccount() -> Error? {
-
-        guard let dirGroupTalk = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroupsTalk) else { return nil }
-        let url = dirGroupTalk.appendingPathComponent(NCGlobal.shared.appDatabaseTalk + "/" + NCGlobal.shared.fileAccounts)
-
-        let tableAccount = NCManageDatabase.shared.getAllAccount()
-        var accounts = [dataAccountFile]()
-        for account in tableAccount {
-            let userBaseUrl = account.user + "-" + (URL(string: account.urlBase)?.host ?? "")
-            let avatar = String(CCUtility.getDirectoryUserData()) + "/" +  userBaseUrl + "-\(account.user).png"
-            let userData = dataAccountFile(withUrl: account.urlBase, user: account.user, alias: account.alias, avatar: avatar)
-            accounts.append(userData)
-        }
-        return NCUtility.shared.createDataAccountFile(at: url, accounts: accounts)
-    }
 }
 
 extension NCLogin: NCTalkAccountsDelegate {

+ 2 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -901,6 +901,8 @@
 "_no_items_"                = "No items";
 "_check_back_later_"        = "Check back later";
 "_exporting_video_"         = "Exporting video … Tap to cancel.";
+"_talk_detect_"             = "Detected Nextcloud Talk";
+"_talk_add_account_"        = "Nextcloud Talk has been detected, do you want to add an existing account ?";
 
 // Video
 "_select_trace_"            = "Select the trace";

+ 4 - 4
iOSClient/Utility/NCContentPresenter.swift

@@ -173,11 +173,11 @@ class NCContentPresenter: NSObject {
         }
 
         let simpleMessage = EKSimpleMessage(image: EKProperty.ImageContent(image: image, size: CGSize(width: 34, height: 34)),
-                                            title: EKProperty.LabelContent(text: title, style: .init(font: MainFont.medium.with(size: 15), color: EKColor(textColor)), accessibilityIdentifier: "title"),
-                                            description: EKProperty.LabelContent(text: description, style: .init( font: MainFont.light.with(size: 13), color: EKColor(textColor)), accessibilityIdentifier: "description"))
+                                            title: EKProperty.LabelContent(text: NSLocalizedString(title, comment: ""), style: .init(font: MainFont.medium.with(size: 15), color: EKColor(textColor)), accessibilityIdentifier: "title"),
+                                            description: EKProperty.LabelContent(text: NSLocalizedString(description, comment: ""), style: .init( font: MainFont.light.with(size: 13), color: EKColor(textColor)), accessibilityIdentifier: "description"))
 
         let cancelButton = EKProperty.ButtonContent(
-            label: EKProperty.LabelContent(text: textCancelButton, style: EKProperty.LabelStyle(font: MainFont.medium.with(size: 16), color: EKColor(textColor))),
+            label: EKProperty.LabelContent(text: NSLocalizedString(textCancelButton, comment: ""), style: EKProperty.LabelStyle(font: MainFont.medium.with(size: 16), color: EKColor(textColor))),
             backgroundColor: .clear,
             highlightedBackgroundColor: EKColor(UIColor.lightGray),
             accessibilityIdentifier: "close") {
@@ -186,7 +186,7 @@ class NCContentPresenter: NSObject {
             }
 
         let okButton = EKProperty.ButtonContent(
-            label: EKProperty.LabelContent(text: textOkButton,style: EKProperty.LabelStyle(font: MainFont.medium.with(size: 16), color: EKColor(textColor))),
+            label: EKProperty.LabelContent(text: NSLocalizedString(textOkButton, comment: ""),style: EKProperty.LabelStyle(font: MainFont.medium.with(size: 16), color: EKColor(textColor))),
             backgroundColor: .clear,
             highlightedBackgroundColor: EKColor(UIColor.lightGray),
             displayMode: EKAttributes.DisplayMode.inferred,

+ 0 - 35
iOSClient/Utility/NCUtility.swift

@@ -1074,41 +1074,6 @@ class NCUtility: NSObject {
 
         return false
     }
-
-    @objc func createDataAccountFile(at url: URL, accounts: [dataAccountFile]) -> Error? {
-
-        do {
-            let encode = try JSONEncoder().encode(accounts)
-            try encode.write(to: url)
-        } catch {
-            return error
-        }
-        return nil
-    }
-
-    @objc func readDataAccountFile(at url: URL) -> [dataAccountFile]? {
-
-        do {
-            let data = try Data(contentsOf: url)
-            let accounts: [dataAccountFile] = try JSONDecoder().decode([dataAccountFile].self, from: data)
-            return accounts
-        } catch {
-            return nil
-        }
-    }
 }
 
-class dataAccountFile: NSObject, Codable {
 
-    @objc var url: String
-    @objc var user: String
-    @objc var alias: String?
-    @objc var avatar: String?
-
-    init(withUrl url: String, user: String, alias: String? = nil, avatar: String? = nil) {
-        self.url = url
-        self.user = user
-        self.alias = alias
-        self.avatar = avatar
-    }
-}