From 380a577fefb8e46ad7aea00128c195013a07ca63 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:37:14 +0530 Subject: [PATCH 1/5] nmc 2157 - move copy customisation --- .../NextcloudUnitTests/MoveAndCopyTests.swift | 106 ++++++++++++++++ .../Collection Common/Cell/NCListCell.swift | 2 - .../Select/NCSelectCommandViewCopyMove.xib | 113 +++++++++--------- 3 files changed, 164 insertions(+), 57 deletions(-) create mode 100644 Tests/NextcloudUnitTests/MoveAndCopyTests.swift diff --git a/Tests/NextcloudUnitTests/MoveAndCopyTests.swift b/Tests/NextcloudUnitTests/MoveAndCopyTests.swift new file mode 100644 index 0000000000..bd674a472f --- /dev/null +++ b/Tests/NextcloudUnitTests/MoveAndCopyTests.swift @@ -0,0 +1,106 @@ +// +// MoveAndCopyTests.swift +// NextcloudTests +// +// Created by A200073704 on 05/06/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +@testable import Nextcloud +import XCTest +import NextcloudKit + + + class MoveAndCopyTests: XCTestCase { + + var view : NCSelectCommandView? + var viewController : NCSelect? + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + let storyboard = UIStoryboard(name: "NCSelect", bundle: nil) + if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController { + let viewController = navigationController.topViewController as? NCSelect + + let _ = viewController?.view + viewController?.loadViewIfNeeded() + } + view = NCSelectCommandView() + + } + + override func setUp() { + super.setUp() + let nib = Bundle.main.loadNibNamed("NCSelectCommandViewCopyMove", owner: nil, options: nil) + view = nib?.first as? NCSelectCommandView + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + + viewController = nil + view = nil + + } + + func testCreateFolderButton() { + + let image: Void? = view?.createFolderButton?.setImage(UIImage(named: "addFolder")?.withTintColor(UIColor.label), for: .normal) + + XCTAssertNotNil(image) + } + + func testOverwriteSwitch() { + + let mySwitch = view?.overwriteSwitch + + XCTAssertNotNil(mySwitch) + + } + + func testCopyButton() { + + let copy = view?.copyButton + + XCTAssertNotNil(copy) + } + + + func testOverwriteSwitchAlwaysOn() { + + XCTAssertTrue(view?.overwriteSwitch?.isOn ?? false, "Overwrite Switch should always be on") + } + + func testCopyButtonandMoveButtonCondition() { + + // Disable copy and move + view?.copyButton?.isEnabled = false + view?.moveButton?.isEnabled = false + + // Creating a test item + let item = tableMetadata() + item.serverUrl = "serverUrl" // Set the serverUrl property of the item + + let items: [tableMetadata] = [item] + + // Update the items in the view controller + viewController?.items = items + + // Verify that the copy and move buttons are still disabled + XCTAssertFalse(view?.copyButton?.isEnabled ?? true, "Copy Button should remain disabled when items.first matches the condition") + XCTAssertFalse(view?.moveButton?.isEnabled ?? true, "Move Button should remain disabled when items.first matches the condition") + + // Enable copy and move + view?.copyButton?.isEnabled = true + view?.moveButton?.isEnabled = true + + // Update the items in the view controller + viewController?.items = [] // Empty items + + // Verify that the copyButton is still enabled + XCTAssertTrue(view?.copyButton?.isEnabled ?? false, "Copy Button should remain enabled when items.first doesn't match the condition") + XCTAssertTrue(view?.moveButton?.isEnabled ?? false, "Move Button should remain enabled when items.first doesn't match the condition") + } + +} diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 8a7f0e3b74..470cf45003 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -215,7 +215,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto if isEditMode { imageItemLeftConstraint.constant = 45 imageSelect.isHidden = false - imageShared.isHidden = true imageMore.isHidden = true buttonShared.isHidden = true buttonMore.isHidden = true @@ -223,7 +222,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } else { imageItemLeftConstraint.constant = 10 imageSelect.isHidden = true - imageShared.isHidden = false imageMore.isHidden = false buttonShared.isHidden = false buttonMore.isHidden = false diff --git a/iOSClient/Select/NCSelectCommandViewCopyMove.xib b/iOSClient/Select/NCSelectCommandViewCopyMove.xib index ddf3475d85..4941320594 100644 --- a/iOSClient/Select/NCSelectCommandViewCopyMove.xib +++ b/iOSClient/Select/NCSelectCommandViewCopyMove.xib @@ -1,9 +1,9 @@ - - + + - + @@ -11,115 +11,118 @@ - - + + - - + + - + - - + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - + + + + + + - - - - - - - + + + + + + + + From 6c7ab3386456cae8f918a77877f578ac5aa3721b Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:07:35 +0530 Subject: [PATCH 2/5] NMC 2157 - size lable upated after nextcloud 5.2.2 release --- iOSClient/Main/Collection Common/Cell/NCListCell.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 470cf45003..ac3e276147 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -248,6 +248,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto func writeInfoDateSize(date: NSDate, size: Int64) { labelInfo.text = NCUtility().getRelativeDateTitle(date as Date) labelSubinfo.text = NCUtilityFileSystem().transformedSize(size) +// labelSubinfo.text = "" } func setAccessibility(label: String, value: String) { From db4b7e12ea6de6823d982235dd7094622410f79a Mon Sep 17 00:00:00 2001 From: harshada-15-tsys Date: Fri, 11 Apr 2025 12:31:00 +0530 Subject: [PATCH 3/5] NMC 2157 - Move copy customisation chnages --- Nextcloud.xcodeproj/project.pbxproj | 8 ++ .../Collection Common/Cell/NCListCell.swift | 75 +++++++++++++++---- 2 files changed, 67 insertions(+), 16 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 8dd4c5545f..04a55e7779 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -85,6 +85,10 @@ AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */; }; AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; }; AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; }; + AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; }; + B52FAED32DA8F22F001AB1BD /* MoveAndCopyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52FAED22DA8F22F001AB1BD /* MoveAndCopyTests.swift */; }; + C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; }; + D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; }; D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; }; F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; }; F321DA8A2B71205A00DDA0E6 /* NCTrashSelectTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F321DA892B71205A00DDA0E6 /* NCTrashSelectTabBar.swift */; }; @@ -1221,6 +1225,8 @@ AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Extension.swift"; sourceTree = ""; }; AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCells.swift; sourceTree = ""; }; AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = ""; }; + AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCShare+Helper.swift"; sourceTree = ""; }; + B52FAED22DA8F22F001AB1BD /* MoveAndCopyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoveAndCopyTests.swift; sourceTree = ""; }; C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = ""; }; @@ -2024,6 +2030,8 @@ isa = PBXGroup; children = ( AA52EB452D42AC5A0089C348 /* Placeholder.swift */, + B52FAED22DA8F22F001AB1BD /* MoveAndCopyTests.swift */, + AF8ED1FB2757821000B8DBC4 /* NextcloudUnitTests.swift */, ); path = NextcloudUnitTests; sourceTree = ""; diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index ac3e276147..f074060c16 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -40,6 +40,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto @IBOutlet weak var separator: UIView! @IBOutlet weak var tag0: UILabel! @IBOutlet weak var tag1: UILabel! + @IBOutlet weak var progressView: UIProgressView! @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint! @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint! @@ -50,6 +51,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto var user = "" weak var listCellDelegate: NCListCellDelegate? + var namedButtonMore = "" var fileAvatarImageView: UIImageView? { return imageShared @@ -131,6 +133,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func initCell() { + + imageItem.layer.cornerRadius = 6 + imageItem.layer.masksToBounds = true + accessibilityHint = nil accessibilityLabel = nil accessibilityValue = nil @@ -148,8 +154,8 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto imageShared.image = nil imageMore.image = nil separatorHeightConstraint.constant = 0.5 - tag0.text = "" - tag1.text = "" +// tag0.text = "" +// tag1.text = "" titleInfoTrailingDefault() let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress(gestureRecognizer:))) @@ -157,6 +163,19 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto longPressedGesture.delegate = self longPressedGesture.delaysTouchesBegan = true self.addGestureRecognizer(longPressedGesture) + + separator.backgroundColor = .separator + separatorHeightConstraint.constant = 0.5 + + labelTitle.text = "" + labelInfo.text = "" + labelSubinfo.text = "" + labelTitle.textColor = .label + labelInfo.textColor = .systemGray + labelSubinfo.textColor = .systemGray + setButtonMore(named: NCGlobal.shared.buttonMoreMore, image: NCImageCache.images.buttonMore) + imageMore.isHidden = false + buttonMore.isHidden = false } override func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? { @@ -168,11 +187,15 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } @IBAction func touchUpInsideMore(_ sender: Any) { - listCellDelegate?.tapMoreListItem(with: ocId, ocIdTransfer: ocIdTransfer, image: imageItem.image, sender: sender) + listCellDelegate?.tapMoreListItem(with: ocId, ocIdTransfer: ocIdTransfer, namedButtonMore: namedButtonMore, image: imageItem.image, sender: sender) } @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) { - listCellDelegate?.longPressListItem(with: ocId, ocIdTransfer: ocIdTransfer, gestureRecognizer: gestureRecognizer) + listCellDelegate?.longPressListItem(with: ocId, ocIdTransfer: ocIdTransfer, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer) + } + + @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) { + listCellDelegate?.longPressMoreListItem(with: ocId, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer) } fileprivate func setA11yActions() { @@ -211,8 +234,8 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto buttonShared.isHidden = status } - func selected(_ status: Bool, isEditMode: Bool) { - if isEditMode { + func selectMode(_ status: Bool) { + if status { imageItemLeftConstraint.constant = 45 imageSelect.isHidden = false imageMore.isHidden = true @@ -228,27 +251,46 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto backgroundView = nil setA11yActions() } + } + + func selected(_ status: Bool, isEditMode: Bool) { + // NMC-1190 - iOS - Files - Deleting files while files are still uploading won't delete properly : to fix this issue remove check for !metadata.isInTransfer in below line + guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), !metadata.isInTransfer, !metadata.e2eEncrypted else { +// guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), !metadata.e2eEncrypted else { + backgroundView = nil + separator.isHidden = false + imageSelect.isHidden = true + + return + } + if status { + var blurEffect: UIVisualEffect? var blurEffectView: UIView? - blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial)) - blurEffectView?.backgroundColor = .lightGray + if traitCollection.userInterfaceStyle == .dark { + blurEffect = UIBlurEffect(style: .dark) + blurEffectView = UIVisualEffectView(effect: blurEffect) + blurEffectView?.backgroundColor = .black + } else { + blurEffect = UIBlurEffect(style: .extraLight) + blurEffectView = UIVisualEffectView(effect: blurEffect) + blurEffectView?.backgroundColor = .lightGray + } blurEffectView?.frame = self.bounds blurEffectView?.autoresizingMask = [.flexibleWidth, .flexibleHeight] - imageSelect.image = NCImageCache.shared.getImageCheckedYes() backgroundView = blurEffectView + imageSelect.image = NCImageCache.images.checkedYes separator.isHidden = true } else { - imageSelect.image = NCImageCache.shared.getImageCheckedNo() + imageSelect.image = NCImageCache.images.checkedNo backgroundView = nil separator.isHidden = false } - } func writeInfoDateSize(date: NSDate, size: Int64) { - labelInfo.text = NCUtility().getRelativeDateTitle(date as Date) - labelSubinfo.text = NCUtilityFileSystem().transformedSize(size) -// labelSubinfo.text = "" + labelInfo.text = NCUtility().dateDiff(date as Date) + " · " + NCUtilityFileSystem().transformedSize(size) + labelSubinfo.text = "" } func setAccessibility(label: String, value: String) { @@ -322,8 +364,9 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto protocol NCListCellDelegate: AnyObject { func tapShareListItem(with ocId: String, ocIdTransfer: String, sender: Any) - func tapMoreListItem(with ocId: String, ocIdTransfer: String, image: UIImage?, sender: Any) - func longPressListItem(with ocId: String, ocIdTransfer: String, gestureRecognizer: UILongPressGestureRecognizer) + func tapMoreListItem(with ocId: String, ocIdTransfer: String, namedButtonMore: String, image: UIImage?, sender: Any) + func longPressMoreListItem(with ocId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) + func longPressListItem(with ocId: String, ocIdTransfer: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) } // MARK: - List Layout From 52dfab82086fd0a6d634c18ccdd7f079a9da3eda Mon Sep 17 00:00:00 2001 From: harshada-15-tsys Date: Fri, 3 Oct 2025 11:56:17 +0530 Subject: [PATCH 4/5] NMC 2157 - Move copy customisation changes --- .../Collection Common/Cell/NCListCell.swift | 109 ++++++++++++------ 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index f074060c16..ec3a521414 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -37,18 +37,21 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto @IBOutlet weak var buttonShared: UIButton! @IBOutlet weak var imageMore: UIImageView! @IBOutlet weak var buttonMore: UIButton! + @IBOutlet weak var progressView: UIProgressView! @IBOutlet weak var separator: UIView! + @IBOutlet weak var labelShared: UILabel! @IBOutlet weak var tag0: UILabel! @IBOutlet weak var tag1: UILabel! - @IBOutlet weak var progressView: UIProgressView! @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint! @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint! - @IBOutlet weak var titleTrailingConstraint: NSLayoutConstraint! - - var ocId = "" - var ocIdTransfer = "" - var user = "" + @IBOutlet weak var subInfoTrailingConstraint: NSLayoutConstraint! + @IBOutlet weak var iPadLabelTitleTrailingConstraint: NSLayoutConstraint! + @IBOutlet weak var iPhoneLabelTitleTrailingConstraint: NSLayoutConstraint! + + private var ocId = "" + private var ocIdTransfer = "" + private var user = "" weak var listCellDelegate: NCListCellDelegate? var namedButtonMore = "" @@ -56,6 +59,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto var fileAvatarImageView: UIImageView? { return imageShared } + var fileOcId: String? { get { return ocId } set { ocId = newValue ?? "" } @@ -84,6 +88,14 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto get { return labelSubinfo } set { labelSubinfo = newValue } } + var fileProgressView: UIProgressView? { + get { return progressView } + set { progressView = newValue } + } + var fileSelectImage: UIImageView? { + get { return imageSelect } + set { imageSelect = newValue } + } var fileStatusImage: UIImageView? { get { return imageStatus } set { imageStatus = newValue } @@ -109,33 +121,31 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto set { separator = newValue } } - override var accessibilityIdentifier: String? { - get { - super.accessibilityIdentifier - } - set { - super.accessibilityIdentifier = newValue - - if let newValue { - buttonShared.accessibilityIdentifier = "\(newValue)/shareButton" - } - } + var fileSharedLabel: UILabel? { + get { return labelShared } + set { labelShared = newValue } } override func awakeFromNib() { super.awakeFromNib() initCell() } - - override func prepareForReuse() { - super.prepareForReuse() - initCell() - } - + func initCell() { imageItem.layer.cornerRadius = 6 imageItem.layer.masksToBounds = true + imageStatus.image = nil + imageFavorite.image = nil + imageFavoriteBackground.isHidden = true + imageLocal.image = nil + labelTitle.text = "" + labelInfo.text = "" + labelSubinfo.text = "" + imageShared.image = nil + imageMore.image = nil + + // use entire cell as accessibility element accessibilityHint = nil accessibilityLabel = nil @@ -154,8 +164,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto imageShared.image = nil imageMore.image = nil separatorHeightConstraint.constant = 0.5 -// tag0.text = "" -// tag1.text = "" titleInfoTrailingDefault() let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress(gestureRecognizer:))) @@ -163,25 +171,46 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto longPressedGesture.delegate = self longPressedGesture.delaysTouchesBegan = true self.addGestureRecognizer(longPressedGesture) - + separator.backgroundColor = .separator separatorHeightConstraint.constant = 0.5 + titleInfoTrailingDefault() - labelTitle.text = "" - labelInfo.text = "" - labelSubinfo.text = "" labelTitle.textColor = .label labelInfo.textColor = .systemGray labelSubinfo.textColor = .systemGray setButtonMore(named: NCGlobal.shared.buttonMoreMore, image: NCImageCache.images.buttonMore) imageMore.isHidden = false buttonMore.isHidden = false + updateConstraintsForCurrentDevice() + } + + override func prepareForReuse() { + super.prepareForReuse() + initCell() } override func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? { return nil } + + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + updateConstraintsForCurrentDevice() + } + func updateConstraintsForCurrentDevice() { + if labelShared?.isHidden == false { + iPhoneLabelTitleTrailingConstraint.isActive = false + iPadLabelTitleTrailingConstraint.isActive = true + } else { + iPhoneLabelTitleTrailingConstraint.isActive = true + iPadLabelTitleTrailingConstraint.isActive = false + } +// iPhoneLabelTitleTrailingConstraint.isActive = UIDevice.current.userInterfaceIdiom == .pad ? false : true +// iPadLabelTitleTrailingConstraint.isActive = UIDevice.current.userInterfaceIdiom == .pad ? true : false + } + @IBAction func touchUpInsideShare(_ sender: Any) { listCellDelegate?.tapShareListItem(with: ocId, ocIdTransfer: ocIdTransfer, sender: sender) } @@ -199,28 +228,31 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } fileprivate func setA11yActions() { + let moreName = namedButtonMore == NCGlobal.shared.buttonMoreStop ? "_cancel_" : "_more_" self.accessibilityCustomActions = [ UIAccessibilityCustomAction( name: NSLocalizedString("_share_", comment: ""), target: self, - selector: #selector(touchUpInsideShare(_:))), + selector: #selector(touchUpInsideShare)), UIAccessibilityCustomAction( - name: NSLocalizedString("_more_", comment: ""), + name: NSLocalizedString(moreName, comment: ""), target: self, - selector: #selector(touchUpInsideMore(_:))) + selector: #selector(touchUpInsideMore)) ] } func titleInfoTrailingFull() { - titleTrailingConstraint.constant = 10 + subInfoTrailingConstraint.constant = 10 } func titleInfoTrailingDefault() { - titleTrailingConstraint.constant = 90 + subInfoTrailingConstraint.constant = 90 } - func setButtonMore(image: UIImage) { + func setButtonMore(named: String, image: UIImage) { + namedButtonMore = named imageMore.image = image + setA11yActions() } @@ -234,6 +266,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto buttonShared.isHidden = status } + func hideSeparator(_ status: Bool) { + separator.isHidden = status + } + func selectMode(_ status: Bool) { if status { imageItemLeftConstraint.constant = 45 @@ -278,6 +314,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } blurEffectView?.frame = self.bounds blurEffectView?.autoresizingMask = [.flexibleWidth, .flexibleHeight] + imageSelect.image = NCImageCache.images.checkedYes backgroundView = blurEffectView imageSelect.image = NCImageCache.images.checkedYes separator.isHidden = true @@ -289,7 +326,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } func writeInfoDateSize(date: NSDate, size: Int64) { - labelInfo.text = NCUtility().dateDiff(date as Date) + " · " + NCUtilityFileSystem().transformedSize(size) + labelInfo.text = NCUtility().getRelativeDateTitle(date as Date) + " · " + NCUtilityFileSystem().transformedSize(size) labelSubinfo.text = "" } From 5836ac3201628ee3a5d9d01f4f896e71e57d1f64 Mon Sep 17 00:00:00 2001 From: harshada-15-tsys Date: Tue, 16 Dec 2025 14:57:00 +0530 Subject: [PATCH 5/5] NMC 2157 - Move copy customisation changes --- .../Collection Common/Cell/NCListCell.swift | 190 ++++++------------ .../Select/NCSelectCommandViewCopyMove.xib | 113 +++++------ 2 files changed, 118 insertions(+), 185 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index ec3a521414..5ca11e9bd3 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -28,6 +28,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto @IBOutlet weak var imageSelect: UIImageView! @IBOutlet weak var imageStatus: UIImageView! @IBOutlet weak var imageFavorite: UIImageView! +// @IBOutlet weak var imageFavoriteBackground: UIImageView! @IBOutlet weak var imageLocal: UIImageView! @IBOutlet weak var labelTitle: UILabel! @IBOutlet weak var labelInfo: UILabel! @@ -37,29 +38,23 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto @IBOutlet weak var buttonShared: UIButton! @IBOutlet weak var imageMore: UIImageView! @IBOutlet weak var buttonMore: UIButton! - @IBOutlet weak var progressView: UIProgressView! @IBOutlet weak var separator: UIView! - @IBOutlet weak var labelShared: UILabel! @IBOutlet weak var tag0: UILabel! @IBOutlet weak var tag1: UILabel! @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint! @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint! - @IBOutlet weak var subInfoTrailingConstraint: NSLayoutConstraint! - @IBOutlet weak var iPadLabelTitleTrailingConstraint: NSLayoutConstraint! - @IBOutlet weak var iPhoneLabelTitleTrailingConstraint: NSLayoutConstraint! - - private var ocId = "" - private var ocIdTransfer = "" - private var user = "" + @IBOutlet weak var titleTrailingConstraint: NSLayoutConstraint! + + var ocId = "" + var ocIdTransfer = "" + var user = "" weak var listCellDelegate: NCListCellDelegate? - var namedButtonMore = "" var fileAvatarImageView: UIImageView? { return imageShared } - var fileOcId: String? { get { return ocId } set { ocId = newValue ?? "" } @@ -88,14 +83,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto get { return labelSubinfo } set { labelSubinfo = newValue } } - var fileProgressView: UIProgressView? { - get { return progressView } - set { progressView = newValue } - } - var fileSelectImage: UIImageView? { - get { return imageSelect } - set { imageSelect = newValue } - } var fileStatusImage: UIImageView? { get { return imageStatus } set { imageStatus = newValue } @@ -121,32 +108,30 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto set { separator = newValue } } - var fileSharedLabel: UILabel? { - get { return labelShared } - set { labelShared = newValue } + override var accessibilityIdentifier: String? { + get { + super.accessibilityIdentifier + } + set { + super.accessibilityIdentifier = newValue + + if let newValue { + buttonShared.accessibilityIdentifier = "\(newValue)/shareButton" + } + } } override func awakeFromNib() { super.awakeFromNib() initCell() } - - func initCell() { - - imageItem.layer.cornerRadius = 6 - imageItem.layer.masksToBounds = true - imageStatus.image = nil - imageFavorite.image = nil - imageFavoriteBackground.isHidden = true - imageLocal.image = nil - labelTitle.text = "" - labelInfo.text = "" - labelSubinfo.text = "" - imageShared.image = nil - imageMore.image = nil - // use entire cell as accessibility element - + override func prepareForReuse() { + super.prepareForReuse() + initCell() + } + + func initCell() { accessibilityHint = nil accessibilityLabel = nil accessibilityValue = nil @@ -157,6 +142,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto imageItem.layer.masksToBounds = true imageStatus.image = nil imageFavorite.image = nil +// imageFavoriteBackground.isHidden = true imageLocal.image = nil labelTitle.text = "" labelInfo.text = "" @@ -164,6 +150,8 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto imageShared.image = nil imageMore.image = nil separatorHeightConstraint.constant = 0.5 + tag0.text = "" + tag1.text = "" titleInfoTrailingDefault() let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress(gestureRecognizer:))) @@ -171,88 +159,47 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto longPressedGesture.delegate = self longPressedGesture.delaysTouchesBegan = true self.addGestureRecognizer(longPressedGesture) - - separator.backgroundColor = .separator - separatorHeightConstraint.constant = 0.5 - titleInfoTrailingDefault() - - labelTitle.textColor = .label - labelInfo.textColor = .systemGray - labelSubinfo.textColor = .systemGray - setButtonMore(named: NCGlobal.shared.buttonMoreMore, image: NCImageCache.images.buttonMore) - imageMore.isHidden = false - buttonMore.isHidden = false - updateConstraintsForCurrentDevice() - } - - override func prepareForReuse() { - super.prepareForReuse() - initCell() } override func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? { return nil } - - override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { - super.traitCollectionDidChange(previousTraitCollection) - updateConstraintsForCurrentDevice() - } - func updateConstraintsForCurrentDevice() { - if labelShared?.isHidden == false { - iPhoneLabelTitleTrailingConstraint.isActive = false - iPadLabelTitleTrailingConstraint.isActive = true - } else { - iPhoneLabelTitleTrailingConstraint.isActive = true - iPadLabelTitleTrailingConstraint.isActive = false - } -// iPhoneLabelTitleTrailingConstraint.isActive = UIDevice.current.userInterfaceIdiom == .pad ? false : true -// iPadLabelTitleTrailingConstraint.isActive = UIDevice.current.userInterfaceIdiom == .pad ? true : false - } - @IBAction func touchUpInsideShare(_ sender: Any) { listCellDelegate?.tapShareListItem(with: ocId, ocIdTransfer: ocIdTransfer, sender: sender) } @IBAction func touchUpInsideMore(_ sender: Any) { - listCellDelegate?.tapMoreListItem(with: ocId, ocIdTransfer: ocIdTransfer, namedButtonMore: namedButtonMore, image: imageItem.image, sender: sender) + listCellDelegate?.tapMoreListItem(with: ocId, ocIdTransfer: ocIdTransfer, image: imageItem.image, sender: sender) } @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) { - listCellDelegate?.longPressListItem(with: ocId, ocIdTransfer: ocIdTransfer, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer) - } - - @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) { - listCellDelegate?.longPressMoreListItem(with: ocId, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer) + listCellDelegate?.longPressListItem(with: ocId, ocIdTransfer: ocIdTransfer, gestureRecognizer: gestureRecognizer) } fileprivate func setA11yActions() { - let moreName = namedButtonMore == NCGlobal.shared.buttonMoreStop ? "_cancel_" : "_more_" self.accessibilityCustomActions = [ UIAccessibilityCustomAction( name: NSLocalizedString("_share_", comment: ""), target: self, - selector: #selector(touchUpInsideShare)), + selector: #selector(touchUpInsideShare(_:))), UIAccessibilityCustomAction( - name: NSLocalizedString(moreName, comment: ""), + name: NSLocalizedString("_more_", comment: ""), target: self, - selector: #selector(touchUpInsideMore)) + selector: #selector(touchUpInsideMore(_:))) ] } func titleInfoTrailingFull() { - subInfoTrailingConstraint.constant = 10 + titleTrailingConstraint.constant = 10 } func titleInfoTrailingDefault() { - subInfoTrailingConstraint.constant = 90 + titleTrailingConstraint.constant = 90 } - func setButtonMore(named: String, image: UIImage) { - namedButtonMore = named + func setButtonMore(image: UIImage) { imageMore.image = image - setA11yActions() } @@ -266,68 +213,58 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto buttonShared.isHidden = status } - func hideSeparator(_ status: Bool) { - separator.isHidden = status - } - - func selectMode(_ status: Bool) { - if status { + func selected(_ status: Bool, isEditMode: Bool) { + // E2EE - remove encrypt folder selection + if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), metadata.e2eEncrypted { + imageSelect.isHidden = true + } else { + imageSelect.isHidden = isEditMode ? false : true + } +// guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), !metadata.e2eEncrypted else { +//// guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), !metadata.e2eEncrypted else { +// backgroundView = nil +// separator.isHidden = false +// imageSelect.isHidden = true +// return +// } + if isEditMode { imageItemLeftConstraint.constant = 45 - imageSelect.isHidden = false +// imageSelect.isHidden = false + imageShared.isHidden = true imageMore.isHidden = true buttonShared.isHidden = true buttonMore.isHidden = true accessibilityCustomActions = nil } else { imageItemLeftConstraint.constant = 10 - imageSelect.isHidden = true +// imageSelect.isHidden = true + imageShared.isHidden = false imageMore.isHidden = false buttonShared.isHidden = false buttonMore.isHidden = false backgroundView = nil setA11yActions() } - } - - func selected(_ status: Bool, isEditMode: Bool) { - // NMC-1190 - iOS - Files - Deleting files while files are still uploading won't delete properly : to fix this issue remove check for !metadata.isInTransfer in below line - guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), !metadata.isInTransfer, !metadata.e2eEncrypted else { -// guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), !metadata.e2eEncrypted else { - backgroundView = nil - separator.isHidden = false - imageSelect.isHidden = true - - return - } - if status { - var blurEffect: UIVisualEffect? var blurEffectView: UIView? - if traitCollection.userInterfaceStyle == .dark { - blurEffect = UIBlurEffect(style: .dark) - blurEffectView = UIVisualEffectView(effect: blurEffect) - blurEffectView?.backgroundColor = .black - } else { - blurEffect = UIBlurEffect(style: .extraLight) - blurEffectView = UIVisualEffectView(effect: blurEffect) - blurEffectView?.backgroundColor = .lightGray - } + blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial)) + blurEffectView?.backgroundColor = .lightGray blurEffectView?.frame = self.bounds blurEffectView?.autoresizingMask = [.flexibleWidth, .flexibleHeight] - imageSelect.image = NCImageCache.images.checkedYes + imageSelect.image = NCImageCache.shared.getImageCheckedYes() backgroundView = blurEffectView - imageSelect.image = NCImageCache.images.checkedYes separator.isHidden = true } else { - imageSelect.image = NCImageCache.images.checkedNo + imageSelect.image = NCImageCache.shared.getImageCheckedNo() backgroundView = nil separator.isHidden = false } + } func writeInfoDateSize(date: NSDate, size: Int64) { - labelInfo.text = NCUtility().getRelativeDateTitle(date as Date) + " · " + NCUtilityFileSystem().transformedSize(size) - labelSubinfo.text = "" + labelInfo.text = NCUtility().getRelativeDateTitle(date as Date) + labelSubinfo.text = NCUtilityFileSystem().transformedSize(size) } func setAccessibility(label: String, value: String) { @@ -386,7 +323,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } } - + override func layoutSubviews() { super.layoutSubviews() // Keep the shadow path in sync with current bounds @@ -401,9 +338,8 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto protocol NCListCellDelegate: AnyObject { func tapShareListItem(with ocId: String, ocIdTransfer: String, sender: Any) - func tapMoreListItem(with ocId: String, ocIdTransfer: String, namedButtonMore: String, image: UIImage?, sender: Any) - func longPressMoreListItem(with ocId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) - func longPressListItem(with ocId: String, ocIdTransfer: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) + func tapMoreListItem(with ocId: String, ocIdTransfer: String, image: UIImage?, sender: Any) + func longPressListItem(with ocId: String, ocIdTransfer: String, gestureRecognizer: UILongPressGestureRecognizer) } // MARK: - List Layout diff --git a/iOSClient/Select/NCSelectCommandViewCopyMove.xib b/iOSClient/Select/NCSelectCommandViewCopyMove.xib index 4941320594..ddf3475d85 100644 --- a/iOSClient/Select/NCSelectCommandViewCopyMove.xib +++ b/iOSClient/Select/NCSelectCommandViewCopyMove.xib @@ -1,9 +1,9 @@ - - + + - + @@ -11,118 +11,115 @@ - - + + - - + + - + - - + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - + + + + + + - - - - - - - - + + + + + + +