Selaa lähdekoodia

Add modify save alert message

Tell the user why he can't override the file

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 vuotta sitten
vanhempi
commit
f6cc1dc473

+ 5 - 3
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -147,10 +147,12 @@
 "_view_in_folder_"          = "View in folder";
 "_leave_share_"             = "Leave this share";
 
-/* Files lock */
-"_lock_action_"             = "Lock";
-"_unlock_action_"           = "Unlock";
+/* MARK: Files lock */
+
+"_lock_file_"               = "Lock";
+"_unlock_file_"             = "Unlock";
 "_locked_by_"               = "Locked by %@";
+"_file_locked_no_override_" = "This file is locked. It cannot be overridden.";
 
 /* Remove a file from a list, don't delete it entirely */
 "_remove_file_"             = "Remove file";

+ 9 - 3
iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift

@@ -85,15 +85,21 @@ import NCCommunication
         // called after `previewController(:didSaveEditedCopyOf:)`
         super.viewDidDisappear(animated)
 
-        guard isEditingEnabled, hasChanges else { return }
+        guard isEditingEnabled, hasChanges, let metadata = metadata else { return }
 
-        let alertController = UIAlertController(title: NSLocalizedString("_save_", comment: ""), message: "", preferredStyle: .alert)
+        let alertController = UIAlertController(title: NSLocalizedString("_save_", comment: ""), message: nil, preferredStyle: .alert)
+        var message: String?
         let userId = (UIApplication.shared.delegate as? AppDelegate)?.userId ?? ""
-        if metadata?.livePhoto == false, metadata?.canUnlock(as: userId) != false {
+        if metadata.livePhoto {
+            message = NSLocalizedString("_message_disable_overwrite_livephoto_", comment: "")
+        } else if !metadata.canUnlock(as: userId) {
+            message = NSLocalizedString("_file_locked_no_override_", comment: "")
+        } else {
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_overwrite_original_", comment: ""), style: .default) { _ in
                 self.saveModifiedFile(override: true)
             })
         }
+        alertController.message = message
 
         alertController.addAction(UIAlertAction(title: NSLocalizedString("_save_as_copy_", comment: ""), style: .default) { _ in
             self.saveModifiedFile(override: false)