Skip to content

Commit 00529b8

Browse files
author
Marino Faggiana
authored
restore maintain original filename (#2972)
Signed-off-by: Marino Faggiana <[email protected]>
1 parent e97f47b commit 00529b8

File tree

5 files changed

+48
-13
lines changed

5 files changed

+48
-13
lines changed

Nextcloud.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -5348,7 +5348,7 @@
53485348
CLANG_WARN_UNREACHABLE_CODE = YES;
53495349
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
53505350
COPY_PHASE_STRIP = NO;
5351-
CURRENT_PROJECT_VERSION = 9;
5351+
CURRENT_PROJECT_VERSION = 0;
53525352
DEBUG_INFORMATION_FORMAT = dwarf;
53535353
DEVELOPMENT_TEAM = NKUJUXUJ3B;
53545354
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -5375,7 +5375,7 @@
53755375
"@executable_path/Frameworks",
53765376
"@executable_path/../../Frameworks",
53775377
);
5378-
MARKETING_VERSION = 5.4.0;
5378+
MARKETING_VERSION = 5.4.1;
53795379
ONLY_ACTIVE_ARCH = YES;
53805380
OTHER_CFLAGS = "-v";
53815381
OTHER_LDFLAGS = "";
@@ -5414,7 +5414,7 @@
54145414
CLANG_WARN_UNREACHABLE_CODE = YES;
54155415
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
54165416
COPY_PHASE_STRIP = NO;
5417-
CURRENT_PROJECT_VERSION = 9;
5417+
CURRENT_PROJECT_VERSION = 0;
54185418
DEVELOPMENT_TEAM = NKUJUXUJ3B;
54195419
ENABLE_STRICT_OBJC_MSGSEND = YES;
54205420
ENABLE_TESTABILITY = YES;
@@ -5438,7 +5438,7 @@
54385438
"@executable_path/Frameworks",
54395439
"@executable_path/../../Frameworks",
54405440
);
5441-
MARKETING_VERSION = 5.4.0;
5441+
MARKETING_VERSION = 5.4.1;
54425442
ONLY_ACTIVE_ARCH = YES;
54435443
OTHER_CFLAGS = "-v";
54445444
OTHER_LDFLAGS = "";

iOSClient/Settings/Advanced/File Name/NCFileNameModel.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class NCFileNameModel: ObservableObject, ViewOnAppearHandling {
3333
/// A shared global instance for managing application-wide settings.
3434
private let globalKey = NCGlobal.shared
3535
/// A boolean indicating whether to maintain the original file name.
36-
@Published var maintainFilename: Bool = false
36+
@Published var maintainFilenameOriginal: Bool = NCKeychain().fileNameOriginal
3737
/// A boolean indicating whether to specify a custom file name.
38-
@Published var specifyFilename: Bool = false
38+
@Published var addFileNameType: Bool = NCKeychain().fileNameType
3939
/// The changed file name.
4040
@Published var changedName: String = ""
4141
/// The complete new file name.
@@ -63,6 +63,11 @@ class NCFileNameModel: ObservableObject, ViewOnAppearHandling {
6363
keychain.fileNameType = newValue
6464
}
6565

66+
/// Toggles maintain original asset filename.
67+
func toggleMaintainFilenameOriginal(newValue: Bool) {
68+
keychain.fileNameOriginal = newValue
69+
}
70+
6671
/// Submits the changed file name.
6772
func submitChangedName() {
6873
let fileNameWithoutForbiddenChars = NCUtility().removeForbiddenCharacters(changedName)

iOSClient/Settings/Advanced/File Name/NCFileNameView.swift

+14-6
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,31 @@ struct NCFileNameView: View {
3030
Form {
3131
/// Specify Filename
3232
Section(header: Text(NSLocalizedString("_mode_filename_", comment: ""))) {
33+
///
34+
Toggle(NSLocalizedString("_maintain_original_filename_", comment: ""), isOn: $model.maintainFilenameOriginal)
35+
.font(.system(size: 16))
36+
.tint(Color(NCBrandColor.shared.brandElement))
37+
.onChange(of: model.maintainFilenameOriginal, perform: { newValue in
38+
model.toggleMaintainFilenameOriginal(newValue: newValue)
39+
model.getFileName()
40+
})
3341
/// Filename
34-
if !model.maintainFilename {
35-
Toggle(NSLocalizedString("_add_filenametype_", comment: ""), isOn: $model.specifyFilename)
42+
if !model.maintainFilenameOriginal {
43+
Toggle(NSLocalizedString("_add_filenametype_", comment: ""), isOn: $model.addFileNameType)
3644
.font(.system(size: 16))
3745
.tint(Color(NCBrandColor.shared.brandElement))
38-
.onChange(of: model.specifyFilename, perform: { newValue in
46+
.onChange(of: model.addFileNameType, perform: { newValue in
3947
model.toggleAddFilenameType(newValue: newValue)
4048
model.getFileName()
4149
})
4250
}
4351
}
4452
.transition(.slide)
45-
.animation(.easeInOut, value: model.maintainFilename)
53+
.animation(.easeInOut, value: model.maintainFilenameOriginal)
4654

4755
/// Filename Preview
4856
fileNamePreview
49-
.animation(.easeInOut, value: model.specifyFilename)
57+
.animation(.easeInOut, value: model.addFileNameType)
5058
}
5159
.navigationBarTitle(NSLocalizedString("_mode_filename_", comment: ""))
5260
.defaultViewModifier(model)
@@ -56,7 +64,7 @@ struct NCFileNameView: View {
5664

5765
@ViewBuilder
5866
var fileNamePreview: some View {
59-
if !model.maintainFilename {
67+
if !model.maintainFilenameOriginal {
6068
Section(content: {
6169
HStack {
6270
Text(NSLocalizedString("_filename_", comment: ""))

iOSClient/Settings/NCKeychain.swift

+12
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,18 @@ import KeychainAccess
391391
}
392392
}
393393

394+
var fileNameOriginal: Bool {
395+
get {
396+
if let value = try? keychain.get("fileNameOriginal"), let result = Bool(value) {
397+
return result
398+
}
399+
return false
400+
}
401+
set {
402+
keychain["fileNameOriginal"] = String(newValue)
403+
}
404+
}
405+
394406
var fileNameMask: String {
395407
get {
396408
if let value = try? keychain.get("fileNameMask") {

iOSClient/Utility/NCUtilityFileSystem.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,21 @@ class NCUtilityFileSystem: NSObject {
430430
func createFileName(_ fileName: String, fileDate: Date, fileType: PHAssetMediaType, notUseMask: Bool = false) -> String {
431431
var fileName = fileName
432432
let keychain = NCKeychain()
433-
let addFileNameType: Bool = keychain.fileNameType
433+
var addFileNameType: Bool = keychain.fileNameType
434+
let useFileNameOriginal: Bool = keychain.fileNameOriginal
434435
var numberFileName: String = ""
435436
var fileNameType = ""
436437
let fileNameExt = (fileName as NSString).pathExtension.lowercased()
437438

439+
/// Original FileName
440+
if useFileNameOriginal {
441+
addFileNameType = false
442+
if !notUseMask {
443+
return fileName
444+
}
445+
}
446+
447+
/// Get counter
438448
if fileName.count > 8 {
439449
let index = fileName.index(fileName.startIndex, offsetBy: 4)
440450
numberFileName = String(fileName[index..<fileName.index(index, offsetBy: 4)])

0 commit comments

Comments
 (0)