Эх сурвалжийг харах

Fix share permission l18n & icons

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 жил өмнө
parent
commit
195a34c4ba

+ 0 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -281,7 +281,6 @@
 		F77B0F611D118A16002130FE /* Acknowledgements.rtf in Resources */ = {isa = PBXBuildFile; fileRef = F7ACE42B1BAC0268006C0017 /* Acknowledgements.rtf */; };
 		F77B0F631D118A16002130FE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F7E70DE91A24DE4100E1B66A /* Localizable.strings */; };
 		F77B0F7D1D118A16002130FE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7F67BB81A24D27800EE80DA /* Images.xcassets */; };
-		F77EFC0C26D6751F00806ED6 /* NCShareQuickStatusMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F77EFC0B26D6751F00806ED6 /* NCShareQuickStatusMenu.swift */; };
 		F78071091EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */ = {isa = PBXBuildFile; fileRef = F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */; };
 		F780710A1EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */ = {isa = PBXBuildFile; fileRef = F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */; };
 		F78295311F962EFA00A572F5 /* NCEndToEndEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = F70CAE391F8CF31A008125FD /* NCEndToEndEncryption.m */; };
@@ -768,7 +767,6 @@
 		F77910A425DD517B00CEDB9E /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
 		F77910AA25DD53C700CEDB9E /* NCSettingsBundleHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSettingsBundleHelper.swift; sourceTree = "<group>"; };
 		F77A697C250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+Menu.swift"; sourceTree = "<group>"; };
-		F77EFC0B26D6751F00806ED6 /* NCShareQuickStatusMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCShareQuickStatusMenu.swift; sourceTree = "<group>"; };
 		F78071071EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+MainThread.h"; sourceTree = "<group>"; };
 		F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNotificationCenter+MainThread.m"; sourceTree = "<group>"; };
 		F785EE9C246196DF00B3F945 /* NCNetworkingE2EE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EE.swift; sourceTree = "<group>"; };
@@ -1226,7 +1224,6 @@
 				AF2D7C7B2742556F00ADF566 /* NCShareLinkCell.swift */,
 				F769454722E9F20D000A798A /* NCShareNetworking.swift */,
 				F769453F22E9F077000A798A /* NCSharePaging.swift */,
-				F77EFC0B26D6751F00806ED6 /* NCShareQuickStatusMenu.swift */,
 				F774264822EB4D0000B23912 /* NCSearchUserDropDownCell.xib */,
 				F769453B22E9CFFF000A798A /* NCShareUserCell.xib */,
 				AF2D7C7D2742559100ADF566 /* NCShareUserCell.swift */,
@@ -2628,7 +2625,6 @@
 				F738D4902756740100CD1D38 /* NCLoginNavigationController.swift in Sources */,
 				F77B0E981D118A16002130FE /* CCManageAccount.m in Sources */,
 				AF93474C27E34120002537EE /* NCUtility+Image.swift in Sources */,
-				F77EFC0C26D6751F00806ED6 /* NCShareQuickStatusMenu.swift in Sources */,
 				F702F30125EE5D2C008F8E80 /* NYMnemonic.m in Sources */,
 				AF93474E27E3F212002537EE /* NCShareNewUserAddComment.swift in Sources */,
 				AF93471227E2341B002537EE /* NCShare+Menu.swift in Sources */,

+ 54 - 5
iOSClient/Menu/NCShare+Menu.swift

@@ -16,8 +16,8 @@ extension NCShare {
         if share.shareType == 3 {
             actions.append(
                 NCMenuAction(
-                    title: NSLocalizedString("_share_add_link_", comment: ""),
-                    icon: NCUtility.shared.loadImage(named: "rename").imageColor(NCBrandColor.shared.brandElement),
+                    title: NSLocalizedString("_share_add_sharelink_", comment: ""),
+                    icon: NCUtility.shared.loadImage(named: "shareAdd"),
                     action: { _ in
                         self.makeNewLinkShare()
                     }
@@ -38,8 +38,8 @@ extension NCShare {
 
         actions.append(
             NCMenuAction(
-                title: NSLocalizedString("_advance_permissions_", comment: ""),
-                icon: NCUtility.shared.loadImage(named: "rename").imageColor(NCBrandColor.shared.brandElement),
+                title: NSLocalizedString("_share_advanced_permissions_", comment: ""),
+                icon: NCUtility.shared.loadImage(named: "edit"),
                 action: { _ in
                     guard
                         let advancePermission = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "NCShareAdvancePermission") as? NCShareAdvancePermission,
@@ -68,7 +68,7 @@ extension NCShare {
         actions.append(
             NCMenuAction(
                 title: NSLocalizedString("_share_unshare_", comment: ""),
-                icon: NCUtility.shared.loadImage(named: "delete").imageColor(NCBrandColor.shared.brandElement),
+                icon: NCUtility.shared.loadImage(named: "trash"),
                 action: { _ in
                     self.networking?.unShare(idShare: share.idShare)
                 }
@@ -77,4 +77,53 @@ extension NCShare {
 
         self.presentMenu(with: actions)
     }
+
+    func toggleUserPermissionMenu(isDirectory: Bool, tableShare: tableShare) {
+        var actions = [NCMenuAction]()
+
+        actions.append(
+            NCMenuAction(
+                title: NSLocalizedString("_share_read_only_", comment: ""),
+                icon: UIImage(),
+                selected: tableShare.permissions == (NCGlobal.shared.permissionReadShare + NCGlobal.shared.permissionShareShare) || tableShare.permissions == NCGlobal.shared.permissionReadShare,
+                on: false,
+                action: { _ in
+                    let canShare = CCUtility.isPermission(toCanShare: tableShare.permissions)
+                    let permissions = CCUtility.getPermissionsValue(byCanEdit: false, andCanCreate: false, andCanChange: false, andCanDelete: false, andCanShare: canShare, andIsFolder: isDirectory)
+                    self.updateSharePermissions(share: tableShare, permissions: permissions)
+                }
+            )
+        )
+
+        actions.append(
+            NCMenuAction(
+                title: isDirectory ? NSLocalizedString("_share_allow_upload_", comment: "") : NSLocalizedString("_share_editing_", comment: ""),
+                icon: UIImage(),
+                selected: hasUploadPermission(tableShare: tableShare),
+                on: false,
+                action: { _ in
+                    let canShare = CCUtility.isPermission(toCanShare: tableShare.permissions)
+                    let permissions = CCUtility.getPermissionsValue(byCanEdit: true, andCanCreate: true, andCanChange: true, andCanDelete: true, andCanShare: canShare, andIsFolder: isDirectory)
+                    self.updateSharePermissions(share: tableShare, permissions: permissions)
+                }
+            )
+        )
+
+        self.presentMenu(with: actions)
+    }
+
+    fileprivate func hasUploadPermission(tableShare: tableShare) -> Bool {
+        let uploadPermissions = [
+            NCGlobal.shared.permissionMaxFileShare,
+            NCGlobal.shared.permissionMaxFolderShare,
+            NCGlobal.shared.permissionDefaultFileRemoteShareNoSupportShareOption,
+            NCGlobal.shared.permissionDefaultFolderRemoteShareNoSupportShareOption]
+        return uploadPermissions.contains(tableShare.permissions)
+    }
+
+    func updateSharePermissions(share: tableShare, permissions: Int) {
+        let updatedShare = tableShare(value: share)
+        updatedShare.permissions = permissions
+        networking?.updateShare(option: updatedShare)
+    }
 }

+ 4 - 9
iOSClient/Share/Advanced/NCShareAdvancePermission.swift

@@ -57,7 +57,7 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
 
     func setupFooterView() {
         guard let footerView = (Bundle.main.loadNibNamed("NCShareAdvancePermissionFooter", owner: self, options: nil)?.first as? NCShareAdvancePermissionFooter) else { return }
-        footerView.setupUI(with: share, delegate: self)
+        footerView.setupUI(delegate: self)
 
         footerView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 100)
         tableView.tableFooterView = footerView
@@ -80,9 +80,7 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
     }
 
     override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
-        if section == 0 { return NSLocalizedString("_advanced_", comment: "") }
-        else if section == 1 { return NSLocalizedString("_misc_", comment: "") }
-        else { return nil }
+        if section == 0 { return NSLocalizedString("_advanced_", comment: "") } else if section == 1 { return NSLocalizedString("_misc_", comment: "") } else { return nil }
     }
 
     override func numberOfSections(in tableView: UITableView) -> Int {
@@ -90,9 +88,7 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
     }
 
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        if section == 0 { return shareConfig.permissions.count }
-        else if section == 1 { return shareConfig.advanced.count }
-        else { return 0 }
+        if section == 0 { return shareConfig.permissions.count } else if section == 1 { return shareConfig.advanced.count } else { return 0 }
     }
 
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -318,7 +314,6 @@ enum Advanced: CaseIterable, ShareCellConfig {
 }
 
 struct ShareConfig {
-
     let permissions: [Permission]
     let advanced: [Advanced]
     let share: TableShareable
@@ -399,7 +394,7 @@ open class DatePickerTableViewCell: UITableViewCell {
 
         let toolbar = UIToolbar()
         toolbar.sizeToFit()
-        let doneButton = UIBarButtonItem(title: "_done_", style: .done) {
+        let doneButton = UIBarButtonItem(title: NSLocalizedString("_done_", comment: ""), style: .done) {
             self.resignFirstResponder()
             share.expirationDate = self.picker.date as NSDate
             self.onReload?()

+ 3 - 8
iOSClient/Share/Advanced/NCShareAdvancePermissionFooter.swift

@@ -16,8 +16,8 @@ class NCShareAdvancePermissionFooter: UIView {
     @IBOutlet weak var buttonCancel: UIButton!
     @IBOutlet weak var buttonNext: UIButton!
     weak var delegate: NCShareAdvanceFotterDelegate?
-    
-    func setupUI(with share: TableShareable, delegate: NCShareAdvanceFotterDelegate?) {
+
+    func setupUI(delegate: NCShareAdvanceFotterDelegate?) {
         self.delegate = delegate
 
         backgroundColor = .clear
@@ -27,13 +27,8 @@ class NCShareAdvancePermissionFooter: UIView {
         buttonCancel.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
         buttonCancel.layer.cornerRadius = 10
         buttonCancel.layer.masksToBounds = true
-        buttonCancel.layer.borderWidth = 1
 
-        if NCManageDatabase.shared.getTableShare(account: share.account, idShare: share.idShare) == nil {
-            buttonNext.setTitle(NSLocalizedString("_next_", comment: ""), for: .normal)
-        } else {
-            buttonNext.setTitle(NSLocalizedString("_apply_changes_", comment: ""), for: .normal)
-        }
+        buttonNext.setTitle(NSLocalizedString("_save_", comment: ""), for: .normal)
         buttonNext.layer.cornerRadius = 10
         buttonNext.layer.masksToBounds = true
         buttonNext.backgroundColor = NCBrandColor.shared.brand

+ 1 - 1
iOSClient/Share/NCShare+NCCellDelegate.swift

@@ -49,6 +49,6 @@ extension NCShare: NCShareLinkCellDelegate, NCShareUserCellDelegate {
         guard let tableShare = tableShare,
               let metadata = metadata,
               tableShare.shareType != NCGlobal.shared.permissionDefaultFileRemoteShareNoSupportShareOption else { return }
-        self.toggleMenu(isDirectory: metadata.directory, tableShare: tableShare)
+        self.toggleUserPermissionMenu(isDirectory: metadata.directory, tableShare: tableShare)
     }
 }

+ 0 - 60
iOSClient/Share/NCShareQuickStatusMenu.swift

@@ -1,60 +0,0 @@
-//
-//  NCShareQuickStatusMenu.swift
-//  Nextcloud
-//
-//  Created by TSI-mc on 30/06/21.
-//  Copyright © 2021 Marino Faggiana. All rights reserved.
-//
-
-import UIKit
-
-extension NCShare {
-    func toggleMenu(isDirectory: Bool, tableShare: tableShare) {
-        var actions = [NCMenuAction]()
-
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_share_read_only_", comment: ""),
-                icon: UIImage(),
-                selected: tableShare.permissions == (NCGlobal.shared.permissionReadShare + NCGlobal.shared.permissionShareShare) || tableShare.permissions == NCGlobal.shared.permissionReadShare,
-                on: false,
-                action: { _ in
-                    let canShare = CCUtility.isPermission(toCanShare: tableShare.permissions)
-                    let permissions = CCUtility.getPermissionsValue(byCanEdit: false, andCanCreate: false, andCanChange: false, andCanDelete: false, andCanShare: canShare, andIsFolder: isDirectory)
-                    self.updateSharePermissions(share: tableShare, permissions: permissions)
-                }
-            )
-        )
-
-        actions.append(
-            NCMenuAction(
-                title: isDirectory ? NSLocalizedString("_share_allow_upload_", comment: "") : NSLocalizedString("_share_editing_", comment: ""),
-                icon: UIImage(),
-                selected: hasUploadPermission(tableShare: tableShare),
-                on: false,
-                action: { _ in
-                    let canShare = CCUtility.isPermission(toCanShare: tableShare.permissions)
-                    let permissions = CCUtility.getPermissionsValue(byCanEdit: true, andCanCreate: true, andCanChange: true, andCanDelete: true, andCanShare: canShare, andIsFolder: isDirectory)
-                    self.updateSharePermissions(share: tableShare, permissions: permissions)
-                }
-            )
-        )
-
-        self.presentMenu(with: actions)
-    }
-
-    fileprivate func hasUploadPermission(tableShare: tableShare) -> Bool {
-        let uploadPermissions = [
-            NCGlobal.shared.permissionMaxFileShare,
-            NCGlobal.shared.permissionMaxFolderShare,
-            NCGlobal.shared.permissionDefaultFileRemoteShareNoSupportShareOption,
-            NCGlobal.shared.permissionDefaultFolderRemoteShareNoSupportShareOption]
-        return uploadPermissions.contains(tableShare.permissions)
-    }
-    
-    func updateSharePermissions(share: tableShare, permissions: Int) {
-        let updatedShare = tableShare(value: share)
-        updatedShare.permissions = permissions
-        networking?.updateShare(option: updatedShare)
-    }
-}

+ 4 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -62,6 +62,7 @@
 "_beta_version_"            = "Beta version";
 "_function_in_testing_"     = "Function in testing, please send information about any problems you run into.";
 "_done_"                    = "Done";
+"_clear_"                   = "Clear";
 "_passcode_too_short_"      = "Passcode too short, at least 4 characters required";
 "_selected_"                = "Selected";
 "_scan_fingerprint_"        = "Scan fingerprint to authenticate";
@@ -144,6 +145,7 @@
 "_recent_"                  = "Recent";
 "_view_in_folder_"          = "View in folder";
 "_leave_share_"             = "Leave this share";
+"_misc_"                    = "Miscellaneous";
 
 /* Remove a file from a list, don't delete it entirely */
 "_remove_file_"             = "Remove file";
@@ -564,7 +566,7 @@
 "_error_download_photobrowser_" = "Error: Unable to download photo";
 "_share_link_"                  = "Share link";
 "_share_link_button_"           = "Send link to …";
-"_share_link_name_"                   = "Link name";
+"_share_link_name_"             = "Link name";
 "_password_"                    = "Password";
 "_share_password_"              = "Password protected link";
 "_share_expirationdate_"        = "Set expiration date for link";
@@ -591,6 +593,7 @@
 "_new_comment_"                 = "New comment …";
 "_edit_comment_"                = "Edit comment";
 "_delete_comment_"              = "Delete comment";
+"_share_advanced_permissions_"  = "Advanced permissions";
 "_share_allow_editing_"         = "Allow editing";
 "_share_read_only_"             = "View only";
 "_share_editing_"               = "Editing";