Skip to content

[stable-6.1.3] NMC/2267 - Rename file/folder customisation #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions Tests/NextcloudUnitTests/RenameFileTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//
// RenameFileTests.swift
// NextcloudTests
//
// Created by A200073704 on 14/06/23.
// Copyright © 2023 Marino Faggiana. All rights reserved.
//

@testable import Nextcloud
import XCTest
import NextcloudKit

class RenameFileTests: XCTestCase {


override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}


func testStoryboardPresence() {

let storyboard = UIStoryboard(name: "NCRenameFile", bundle: nil)
XCTAssertNotNil(storyboard, "Storyboard 'NCRenameFile' should be present")

}

func testRenameButtonPresence() {
let storyboard = UIStoryboard(name: "NCRenameFile", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? NCRenameFile else {
XCTFail("Failed to instantiate view controller from storyboard")
return
}

_ = viewController.view // Load the view

let renameButton = viewController.renameButton
XCTAssertNotNil(renameButton, "Rename button should be present")
}

func testRenameButtonBackgroundColor() {

let storyboard = UIStoryboard(name: "NCRenameFile", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? NCRenameFile else {
XCTFail("Failed to instantiate view controller from storyboard")
return
}

_ = viewController.view // Load the view

let color = NCBrandColor.shared.brand.cgColor
let renameButton = viewController.renameButton.layer.backgroundColor

XCTAssertEqual(renameButton,color, "Rename Button Bcakground Color should be brand")
}

func testCancelButtonPresence() {
let storyboard = UIStoryboard(name: "NCRenameFile", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? NCRenameFile else {
XCTFail("Failed to instantiate view controller from storyboard")
return
}

_ = viewController.view // Load the view

let cancelButton = viewController.cancelButton
XCTAssertNotNil(cancelButton, "Cancel button should be present")
}

func testImageViewPresence() {

let storyboard = UIStoryboard(name: "NCRenameFile", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? NCRenameFile else {
XCTFail("Failed to instantiate view controller from storyboard")
return
}

_ = viewController.view // Load the view

let imageView = viewController.previewFile
XCTAssertNotNil(imageView, "UIImageView should be present on the storyboard")
}

func testTextFiledPresence() {

let storyboard = UIStoryboard(name: "NCRenameFile", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? NCRenameFile else {
XCTFail("Failed to instantiate view controller from storyboard")
return
}

_ = viewController.view // Load the view

let textField = viewController.fileNameNoExtension
let textFieldExt = viewController.ext

XCTAssertNotNil(textField, "FileNameNoExtention TextFiled should be present on the storyboard")
XCTAssertNotNil(textFieldExt, "Extension TextFiled should be present on the storyboard")

}



}
2 changes: 2 additions & 0 deletions iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS

NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: global.notificationCenterDeleteFile), object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: global.notificationCenterCopyMoveFile), object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: global.notificationCenterCopyFile), object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: global.notificationCenterMoveFile), object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: global.notificationCenterRenameFile), object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: global.notificationCenterCreateFolder), object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: global.notificationCenterFavoriteFile), object: nil)
Expand Down
2 changes: 2 additions & 0 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ class NCGlobal: NSObject {
let notificationCenterCreateFolder = "createFolder" // userInfo: ocId, serverUrl, account, withPush, sceneIdentifier
let notificationCenterDeleteFile = "deleteFile" // userInfo: [ocId], error
let notificationCenterCopyMoveFile = "copyMoveFile" // userInfo: [ocId] serverUrl, account, dragdrop, type (copy, move)
let notificationCenterMoveFile = "moveFile" // userInfo: [ocId], [indexPath], error
let notificationCenterCopyFile = "copyFile" // userInfo: [ocId], [indexPath], error
let notificationCenterRenameFile = "renameFile" // userInfo: serverUrl, account, error
let notificationCenterFavoriteFile = "favoriteFile" // userInfo: ocId, serverUrl
let notificationCenterFileExists = "fileExists" // userInfo: ocId, fileExists
Expand Down
135 changes: 135 additions & 0 deletions iOSClient/Rename file/NCRenameFile.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="3Ci-bK-Pn5">
<device id="retina6_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Rename File-->
<scene sceneID="eVN-aa-0Eg">
<objects>
<viewController id="3Ci-bK-Pn5" customClass="NCRenameFile" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="pNP-Dp-u4c">
<rect key="frame" x="0.0" y="0.0" width="390" height="844"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tif-ai-uJe" userLabel="Separator">
<rect key="frame" x="0.0" y="109" width="390" height="1"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="jZN-8E-5MP"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Rename" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2qc-0Q-Een">
<rect key="frame" x="20" y="71" width="350" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="QnI-P3-hKx">
<rect key="frame" x="135" y="125" width="120" height="120"/>
<constraints>
<constraint firstAttribute="height" constant="120" id="Su2-JI-Uoc"/>
<constraint firstAttribute="width" constant="120" id="v1h-OB-mWW"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3AA-Zw-Mbn">
<rect key="frame" x="310" y="284.66666666666669" width="10" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="10" id="Xsm-wD-AfE"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="z9B-1j-KVn">
<rect key="frame" x="16" y="275" width="284" height="40"/>
<rect key="contentStretch" x="1" y="0.0" width="1" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="WCs-Qj-hwW"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="kQK-Oy-Mv4">
<rect key="frame" x="330" y="278" width="44" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4th-jl-atB">
<rect key="frame" x="16" y="339" width="169" height="32"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="Z8i-K0-qgn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Cancel"/>
<connections>
<action selector="cancel:" destination="3Ci-bK-Pn5" eventType="touchUpInside" id="HnX-Fu-0O1"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4db-CJ-Zb9">
<rect key="frame" x="205" y="339" width="169" height="32"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Rename"/>
<connections>
<action selector="renameFile:" destination="3Ci-bK-Pn5" eventType="touchUpInside" id="fQ1-MZ-acX"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="FYE-sV-CZv"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="FYE-sV-CZv" firstAttribute="trailing" secondItem="2qc-0Q-Een" secondAttribute="trailing" constant="20" id="0aw-Vn-DYw"/>
<constraint firstItem="FYE-sV-CZv" firstAttribute="trailing" secondItem="tif-ai-uJe" secondAttribute="trailing" id="2VP-en-hGt"/>
<constraint firstItem="2qc-0Q-Een" firstAttribute="leading" secondItem="FYE-sV-CZv" secondAttribute="leading" constant="20" id="60W-Gs-rFD"/>
<constraint firstItem="FYE-sV-CZv" firstAttribute="trailing" secondItem="kQK-Oy-Mv4" secondAttribute="trailing" constant="16" id="7QP-CQ-pxs"/>
<constraint firstItem="kQK-Oy-Mv4" firstAttribute="centerY" secondItem="z9B-1j-KVn" secondAttribute="centerY" id="7vb-X7-s1w"/>
<constraint firstItem="4db-CJ-Zb9" firstAttribute="leading" secondItem="4th-jl-atB" secondAttribute="trailing" constant="20" id="AWv-tb-pNP"/>
<constraint firstItem="4db-CJ-Zb9" firstAttribute="width" secondItem="4th-jl-atB" secondAttribute="width" id="Dzm-jy-LCE"/>
<constraint firstItem="3AA-Zw-Mbn" firstAttribute="leading" secondItem="z9B-1j-KVn" secondAttribute="trailing" constant="10" id="FXb-G1-pLz"/>
<constraint firstItem="tif-ai-uJe" firstAttribute="top" secondItem="2qc-0Q-Een" secondAttribute="bottom" constant="20" id="Ifn-jK-laD"/>
<constraint firstItem="kQK-Oy-Mv4" firstAttribute="leading" secondItem="3AA-Zw-Mbn" secondAttribute="trailing" constant="10" id="Lio-wY-qmz"/>
<constraint firstItem="4db-CJ-Zb9" firstAttribute="trailing" secondItem="kQK-Oy-Mv4" secondAttribute="trailing" id="M7f-Ki-7dF"/>
<constraint firstItem="z9B-1j-KVn" firstAttribute="top" secondItem="QnI-P3-hKx" secondAttribute="bottom" constant="30" id="MmT-am-1vK"/>
<constraint firstItem="tif-ai-uJe" firstAttribute="leading" secondItem="FYE-sV-CZv" secondAttribute="leading" id="O5u-qY-fvv"/>
<constraint firstItem="FYE-sV-CZv" firstAttribute="trailing" secondItem="z9B-1j-KVn" secondAttribute="trailing" constant="90" id="PEm-Ru-cTh"/>
<constraint firstItem="4th-jl-atB" firstAttribute="top" secondItem="z9B-1j-KVn" secondAttribute="bottom" constant="24" id="V7S-y4-t7I"/>
<constraint firstItem="2qc-0Q-Een" firstAttribute="top" secondItem="FYE-sV-CZv" secondAttribute="top" constant="24" id="auD-EM-utl"/>
<constraint firstItem="3AA-Zw-Mbn" firstAttribute="centerY" secondItem="z9B-1j-KVn" secondAttribute="centerY" id="ciW-gI-Zz5"/>
<constraint firstItem="4th-jl-atB" firstAttribute="leading" secondItem="z9B-1j-KVn" secondAttribute="leading" id="hbq-m2-uAn"/>
<constraint firstItem="4db-CJ-Zb9" firstAttribute="centerY" secondItem="4th-jl-atB" secondAttribute="centerY" id="nAr-cQ-eOm"/>
<constraint firstItem="QnI-P3-hKx" firstAttribute="centerX" secondItem="FYE-sV-CZv" secondAttribute="centerX" id="prV-a3-lHF"/>
<constraint firstItem="QnI-P3-hKx" firstAttribute="top" secondItem="tif-ai-uJe" secondAttribute="bottom" constant="15" id="qTq-dy-OZq"/>
<constraint firstItem="4db-CJ-Zb9" firstAttribute="height" secondItem="4th-jl-atB" secondAttribute="height" id="wyw-pz-1Wy"/>
<constraint firstItem="z9B-1j-KVn" firstAttribute="leading" secondItem="FYE-sV-CZv" secondAttribute="leading" constant="16" id="yj1-hf-9R4"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="45y-Wo-Tn4"/>
<connections>
<outlet property="cancelButton" destination="4th-jl-atB" id="9tS-WS-dDZ"/>
<outlet property="ext" destination="kQK-Oy-Mv4" id="eeH-Os-8ee"/>
<outlet property="fileNameNoExtension" destination="z9B-1j-KVn" id="Zbo-gq-mU6"/>
<outlet property="fileNameNoExtensionTrailingContraint" destination="PEm-Ru-cTh" id="Ojg-Rm-gWs"/>
<outlet property="point" destination="3AA-Zw-Mbn" id="FzS-Ox-8Gq"/>
<outlet property="previewFile" destination="QnI-P3-hKx" id="9m7-ql-3yF"/>
<outlet property="renameButton" destination="4db-CJ-Zb9" id="phv-YM-XeD"/>
<outlet property="separatorHeightContraint" destination="jZN-8E-5MP" id="9PH-Y7-yez"/>
<outlet property="seperator" destination="tif-ai-uJe" id="pl7-E9-Dji"/>
<outlet property="titleLabel" destination="2qc-0Q-Een" id="cca-ax-g6d"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="gIB-1B-fCp" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1453.6231884057972" y="134.59821428571428"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading