Jelajahi Sumber

Merge pull request #2089 from nextcloud/411/tip

411/tip
Marino Faggiana 2 tahun lalu
induk
melakukan
a9a952d010

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -1090,7 +1090,6 @@
 		F70211F31BAC56E9003FC03E /* Main */ = {
 		F70211F31BAC56E9003FC03E /* Main */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
-				F7CA213725F1372B00826ABB /* Account Request */,
 				F702F2E325EE5C82008F8E80 /* AudioRecorder */,
 				F702F2E325EE5C82008F8E80 /* AudioRecorder */,
 				F7DFB7E9219C5A0500680748 /* Create cloud */,
 				F7DFB7E9219C5A0500680748 /* Create cloud */,
 				F78ACD50219046AC0088454D /* Section Header Footer */,
 				F78ACD50219046AC0088454D /* Section Header Footer */,
@@ -1764,6 +1763,7 @@
 				F7F67BB81A24D27800EE80DA /* Images.xcassets */,
 				F7F67BB81A24D27800EE80DA /* Images.xcassets */,
 				F7C1CDD91E6DFC6F005D92BE /* Brand */,
 				F7C1CDD91E6DFC6F005D92BE /* Brand */,
 				F70211F31BAC56E9003FC03E /* Main */,
 				F70211F31BAC56E9003FC03E /* Main */,
+				F7CA213725F1372B00826ABB /* Account Request */,
 				F7A321621E9E37960069AD1B /* Activity */,
 				F7A321621E9E37960069AD1B /* Activity */,
 				F70B866A2642A21300ED5349 /* BackgroundImageColor */,
 				F70B866A2642A21300ED5349 /* BackgroundImageColor */,
 				F7AE00F6230E8191007ACF8A /* BrowserWeb */,
 				F7AE00F6230E8191007ACF8A /* BrowserWeb */,

+ 0 - 0
iOSClient/Main/Account Request/NCAccountRequest.storyboard → iOSClient/Account Request/NCAccountRequest.storyboard


+ 0 - 0
iOSClient/Main/Account Request/NCAccountRequest.swift → iOSClient/Account Request/NCAccountRequest.swift


+ 60 - 7
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -24,6 +24,7 @@
 import UIKit
 import UIKit
 import Realm
 import Realm
 import NCCommunication
 import NCCommunication
+import EasyTipView
 
 
 class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCSectionFooterDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate, UIContextMenuInteractionDelegate, NCAccountRequestDelegate, NCBackgroundImageColorDelegate, NCSelectableNavigationView {
 class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCSectionFooterDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate, UIContextMenuInteractionDelegate, NCAccountRequestDelegate, NCBackgroundImageColorDelegate, NCSelectableNavigationView {
 
 
@@ -64,6 +65,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
 
     private var pushed: Bool = false
     private var pushed: Bool = false
 
 
+    private var tipView: EasyTipView?
+
     // DECLARE
     // DECLARE
     internal var layoutKey = ""
     internal var layoutKey = ""
     internal var titleCurrentFolder = ""
     internal var titleCurrentFolder = ""
@@ -131,8 +134,23 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         longPressedGesture.delaysTouchesBegan = true
         longPressedGesture.delaysTouchesBegan = true
         collectionView.addGestureRecognizer(longPressedGesture)
         collectionView.addGestureRecognizer(longPressedGesture)
 
 
-        // Notification
+        // TIP
+        var preferences = EasyTipView.Preferences()
+        preferences.drawing.foregroundColor = .white
+        preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
+        preferences.drawing.textAlignment = .left
+        preferences.drawing.arrowPosition = .top
+        preferences.drawing.cornerRadius = 10
+
+        preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
+        preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
+        preferences.animating.showInitialAlpha = 0
+        preferences.animating.showDuration = 1.5
+        preferences.animating.dismissDuration = 1.5
 
 
+        tipView = EasyTipView(text: NSLocalizedString("_tip_accountrequest_", comment: ""), preferences: preferences, delegate: self)
+
+        // Notification
         NotificationCenter.default.addObserver(self, selector: #selector(initialize(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(initialize(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeThemingWithReloadData), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeThemingWithReloadData), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
     }
     }
@@ -190,6 +208,17 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
         }
     }
     }
 
 
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+
+        // TIP
+        if self is NCFiles, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account, self.serverUrl == NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account), let view = self.navigationItem.leftBarButtonItem?.customView {
+            if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest), NCManageDatabase.shared.getAllAccountOrderAlias().count > 0 {
+                self.tipView?.show(forView: view)
+            }
+        }
+    }
+
     override func viewWillDisappear(_ animated: Bool) {
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         super.viewWillDisappear(animated)
 
 
@@ -213,6 +242,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
 
         // REQUEST
         // REQUEST
         NCNetworking.shared.cancelUnifiedSearchFiles()
         NCNetworking.shared.cancelUnifiedSearchFiles()
+
+        // TIP
+        self.tipView?.dismiss()
     }
     }
 
 
     func presentationControllerDidDismiss( _ presentationController: UIPresentationController) {
     func presentationControllerDidDismiss( _ presentationController: UIPresentationController) {
@@ -685,6 +717,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     
                     
                     UIApplication.shared.keyWindow?.rootViewController?.present(popup, animated: true)
                     UIApplication.shared.keyWindow?.rootViewController?.present(popup, animated: true)
                 }
                 }
+
+                // TIP
+                self.dismissTip()
             }
             }
         }
         }
         navigationItem.setLeftBarButton(UIBarButtonItem(customView: button), animated: true)
         navigationItem.setLeftBarButton(UIBarButtonItem(customView: button), animated: true)
@@ -759,6 +794,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         self.dataSource.clearDataSource()
         self.dataSource.clearDataSource()
         self.collectionView.reloadData()
         self.collectionView.reloadData()
 
 
+        // TIP
+        self.tipView?.dismiss()
     }
     }
 
 
     func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
     func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
@@ -1551,12 +1588,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.fileInfoLabel?.text = metadata.subline
                 cell.fileInfoLabel?.text = metadata.subline
                 cell.titleInfoTrailingFull()
                 cell.titleInfoTrailingFull()
             }
             }
-            if let literalSearch = self.literalSearch {
-                let longestWordRange = (metadata.fileName.lowercased() as NSString).range(of: literalSearch)
-                let attributedString = NSMutableAttributedString(string: metadata.fileName, attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 15)])
-                attributedString.setAttributes([NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor : NCBrandColor.shared.annotationColor], range: longestWordRange)
-                cell.fileTitleLabel?.attributedText = attributedString
-            }
         } else {
         } else {
             cell.fileTitleLabel?.text = metadata.fileNameView
             cell.fileTitleLabel?.text = metadata.fileNameView
             cell.fileTitleLabel?.lineBreakMode = .byTruncatingMiddle
             cell.fileTitleLabel?.lineBreakMode = .byTruncatingMiddle
@@ -1724,6 +1755,13 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         // Accessibility
         // Accessibility
         cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.fileInfoLabel?.text ?? ""), value: a11yValues.joined(separator: ", "))
         cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.fileInfoLabel?.text ?? ""), value: a11yValues.joined(separator: ", "))
 
 
+        // Color string find in search
+        if isSearching, let literalSearch = self.literalSearch, let title = cell.fileTitleLabel?.text {
+            let longestWordRange = (title.lowercased() as NSString).range(of: literalSearch)
+            let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 15)])
+            attributedString.setAttributes([NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor : NCBrandColor.shared.annotationColor], range: longestWordRange)
+            cell.fileTitleLabel?.attributedText = attributedString
+        }
         return cell
         return cell
     }
     }
 
 
@@ -1894,3 +1932,18 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
         return size
         return size
     }
     }
 }
 }
+
+extension NCCollectionViewCommon: EasyTipViewDelegate {
+
+    func easyTipViewDidTap(_ tipView: EasyTipView) {
+        NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest)
+    }
+
+    func easyTipViewDidDismiss(_ tipView: EasyTipView) { }
+
+    func dismissTip() {
+        NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest)
+        self.tipView?.dismiss()
+    }
+}
+

+ 2 - 0
iOSClient/NCGlobal.swift

@@ -374,4 +374,6 @@ class NCGlobal: NSObject {
     // Tip
     // Tip
     //
     //
     let tipNCViewerPDFThumbnail                                 = "tipncviewerpdfthumbnail"
     let tipNCViewerPDFThumbnail                                 = "tipncviewerpdfthumbnail"
+    let tipNCCollectionViewCommonAccountRequest                 = "tipnccollectionviewcommonaccountrequest"
+    let tipNCScanAddImage                                       = "tipncscanaddimage"
 }
 }

+ 50 - 0
iOSClient/ScanDocument/NCScan.swift

@@ -23,6 +23,7 @@
 
 
 import UIKit
 import UIKit
 import Photos
 import Photos
+import EasyTipView
 
 
 @available(iOS 13.0, *)
 @available(iOS 13.0, *)
 class NCScan: UIViewController, NCScanCellCellDelegate {
 class NCScan: UIViewController, NCScanCellCellDelegate {
@@ -45,6 +46,8 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
 
 
     internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
 
+    private var tipView: EasyTipView?
+
     enum TypeFilter {
     enum TypeFilter {
         case original
         case original
         case grayScale
         case grayScale
@@ -90,12 +93,37 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
         let longPressRecognizerPlus = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressGesture(recognizer:)))
         let longPressRecognizerPlus = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressGesture(recognizer:)))
         add.addGestureRecognizer(longPressRecognizerPlus)
         add.addGestureRecognizer(longPressRecognizerPlus)
 
 
+        // TIP
+        var preferences = EasyTipView.Preferences()
+        preferences.drawing.foregroundColor = .white
+        preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
+        preferences.drawing.textAlignment = .left
+        preferences.drawing.arrowPosition = .left
+        preferences.drawing.cornerRadius = 10
+
+        preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
+        preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
+        preferences.animating.showInitialAlpha = 0
+        preferences.animating.showDuration = 1.5
+        preferences.animating.dismissDuration = 1.5
+
+        tipView = EasyTipView(text: NSLocalizedString("_tip_addcopyimage_", comment: ""), preferences: preferences, delegate: self)
+
         collectionViewSource.reloadData()
         collectionViewSource.reloadData()
         collectionViewDestination.reloadData()
         collectionViewDestination.reloadData()
 
 
         loadImage()
         loadImage()
     }
     }
 
 
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+
+        // TIP
+        if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCScanAddImage) {
+            self.tipView?.show(forView: add, withinSuperview: self.view)
+        }
+    }
+
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
         super.traitCollectionDidChange(previousTraitCollection)
         super.traitCollectionDidChange(previousTraitCollection)
 
 
@@ -134,6 +162,9 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
 
 
     @IBAction func add(sender: UIButton) {
     @IBAction func add(sender: UIButton) {
 
 
+        // TIP
+        dismissTip()
+
         NCCreateScanDocument.shared.openScannerDocument(viewController: self)
         NCCreateScanDocument.shared.openScannerDocument(viewController: self)
     }
     }
 
 
@@ -315,6 +346,9 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
                 UIMenuController.shared.setTargetRect(recognizerView.frame, in: recognizerSuperView)
                 UIMenuController.shared.setTargetRect(recognizerView.frame, in: recognizerSuperView)
                 UIMenuController.shared.setMenuVisible(true, animated: true)
                 UIMenuController.shared.setMenuVisible(true, animated: true)
             }
             }
+
+            // TIP
+            dismissTip()
         }
         }
     }
     }
 
 
@@ -371,3 +405,19 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
         }
         }
     }
     }
 }
 }
+
+@available(iOS 13.0, *)
+extension NCScan: EasyTipViewDelegate {
+
+    // TIP
+    func easyTipViewDidTap(_ tipView: EasyTipView) {
+        NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCScanAddImage)
+    }
+
+    func easyTipViewDidDismiss(_ tipView: EasyTipView) { }
+
+    func dismissTip() {
+        NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCScanAddImage)
+        self.tipView?.dismiss()
+    }
+}

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

@@ -900,6 +900,8 @@
 
 
 // Tip
 // Tip
 "_tip_pdf_thumbnails_"      = "Swipe left from the right edge of the screen to show the thumbnails.";
 "_tip_pdf_thumbnails_"      = "Swipe left from the right edge of the screen to show the thumbnails.";
+"_tip_accountrequest_"      = "Touch here to change account or to add a new one";
+"_tip_addcopyimage_"        = "Long press to paste a copied image";
 
 
 // MARK: Accessibility
 // MARK: Accessibility