diff --git a/NoCameraSound/NoCameraSound.xcodeproj/project.pbxproj b/NoCameraSound/NoCameraSound.xcodeproj/project.pbxproj index 0f30daa..1a489af 100644 --- a/NoCameraSound/NoCameraSound.xcodeproj/project.pbxproj +++ b/NoCameraSound/NoCameraSound.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ 3D16394B295C4ABF006D31D8 /* vm_unaligned_copy_switch_race.c in Sources */ = {isa = PBXBuildFile; fileRef = 3D16394A295C4ABF006D31D8 /* vm_unaligned_copy_switch_race.c */; }; 3D163953295C7029006D31D8 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3D163955295C7029006D31D8 /* Localizable.strings */; }; 3D163959295C7810006D31D8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3D163958295C7810006D31D8 /* Assets.xcassets */; }; - 3D2342AB295D31BD00A6E40D /* plist in Resources */ = {isa = PBXBuildFile; fileRef = 3D2342AA295D31BD00A6E40D /* plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -29,7 +28,6 @@ 3D16394A295C4ABF006D31D8 /* vm_unaligned_copy_switch_race.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vm_unaligned_copy_switch_race.c; sourceTree = ""; }; 3D163954295C7029006D31D8 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 3D163958295C7810006D31D8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 3D2342AA295D31BD00A6E40D /* plist */ = {isa = PBXFileReference; lastKnownFileType = folder; path = plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -71,7 +69,6 @@ 3D163917295B520E006D31D8 /* NoCameraSound.swift */, 3D163919295B5227006D31D8 /* NoCameraSound-Bridging-Header.h */, 3D163958295C7810006D31D8 /* Assets.xcassets */, - 3D2342AA295D31BD00A6E40D /* plist */, 3D16390D295B51DB006D31D8 /* Preview Content */, ); path = NoCameraSound; @@ -146,7 +143,6 @@ buildActionMask = 2147483647; files = ( 3D163953295C7029006D31D8 /* Localizable.strings in Resources */, - 3D2342AB295D31BD00A6E40D /* plist in Resources */, 3D163959295C7810006D31D8 /* Assets.xcassets in Resources */, 3D16390F295B51DB006D31D8 /* Preview Assets.xcassets in Resources */, ); @@ -318,7 +314,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.8; + MARKETING_VERSION = 4.9; PRODUCT_BUNDLE_IDENTIFIER = "com.straight-tamago.NoCameraSound"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -353,7 +349,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.8; + MARKETING_VERSION = 4.9; PRODUCT_BUNDLE_IDENTIFIER = "com.straight-tamago.NoCameraSound"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/NoCameraSound/NoCameraSound.xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate b/NoCameraSound/NoCameraSound.xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate index b3fc34d..4e7d3b0 100644 Binary files a/NoCameraSound/NoCameraSound.xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate and b/NoCameraSound/NoCameraSound.xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/NoCameraSound/NoCameraSound/ContentView.swift b/NoCameraSound/NoCameraSound/ContentView.swift index ca501c7..455eb70 100644 --- a/NoCameraSound/NoCameraSound/ContentView.swift +++ b/NoCameraSound/NoCameraSound/ContentView.swift @@ -10,20 +10,22 @@ import SwiftUI struct ContentView: View { private let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String @State private var LogMessage = "" - @State private var LogText = "" + @State var LogText = "" @State private var ViewLog = true @State private var SettingsShowing = false @State private var ios14Warning = false + @State private var Notcompatiblewithios14 = false var body: some View { VStack { if ViewLog { Text("") .frame(width: 300, height: 200) - .padding() + .padding(.top, 10) .disabled(true) } Text("NoCameraSound").font(.largeTitle).fontWeight(.bold) HStack { + //--------------------------------------------------------------------------- Button("Disable Shutter Sound") { if #available(iOS 15.0, *) { LogText = "" @@ -45,7 +47,7 @@ struct ContentView: View { secondaryButton: .default(Text("Cancel")) ) } - + //--------------------------------------------------------------------------- Button { SettingsShowing = true } label: { @@ -68,10 +70,15 @@ struct ContentView: View { } }, .default(Text("\(NSLocalizedString("Auto run when the app starts (Status: ", comment: ""))"+String(UserDefaults.standard.bool(forKey: "AutoRun"))+")")) { - if UserDefaults.standard.bool(forKey: "AutoRun") == true { - UserDefaults.standard.set(false, forKey: "AutoRun") - }else { - UserDefaults.standard.set(true, forKey: "AutoRun") + if #available(iOS 15.0, *) { + if UserDefaults.standard.bool(forKey: "AutoRun") == true { + UserDefaults.standard.set(false, forKey: "AutoRun") + }else { + UserDefaults.standard.set(true, forKey: "AutoRun") + } + } + else { + Notcompatiblewithios14 = true } }, .default(Text("\(NSLocalizedString("View Log (Status: ", comment: ""))"+String(UserDefaults.standard.bool(forKey: "ViewLog"))+")")) { @@ -81,24 +88,37 @@ struct ContentView: View { }else { UserDefaults.standard.set(true, forKey: "ViewLog") ViewLog = true - } }, .default(Text("\(NSLocalizedString("Camera silent + English notation (JP Only) (Status: ", comment: ""))"+String(UserDefaults.standard.bool(forKey: "Visibility"))+")")) { - if Locale.preferredLanguages.first! == "ja-JP" { - if UserDefaults.standard.bool(forKey: "Visibility") == true { - UserDefaults.standard.set(false, forKey: "Visibility") - }else { - UserDefaults.standard.set(true, forKey: "Visibility") + if #available(iOS 15.0, *) { + if Locale.preferredLanguages.first! == "ja-JP" { + if UserDefaults.standard.bool(forKey: "Visibility") == true { + UserDefaults.standard.set(false, forKey: "Visibility") + }else { + UserDefaults.standard.set(true, forKey: "Visibility") + } } } + else { + Notcompatiblewithios14 = true + } }, .cancel() ]) } + .alert(isPresented: $Notcompatiblewithios14) { + Alert(title: Text("Not compatible with ios14"), + primaryButton: .destructive(Text("OK")), + secondaryButton: .default(Text("Cancel")) + ) + } + //--------------------------------------------------------------------------- } if ViewLog { ScrollViewReader { reader in + Text(LogMessage) + .padding(.top, 10) ScrollView { Text(LogText) .frame(maxWidth: .infinity, alignment: .leading) @@ -112,15 +132,15 @@ struct ContentView: View { } .frame(width: 300, height: 200) .border(Color.black, width: 1) - .padding() + .padding(.top, 10) } - Text(LogMessage) - .padding() + }else { Text(LogMessage) .padding() } }.onAppear { + LogMessage = "v\(version)" LogText = "NoCameraSound v\(version) by straight-tamago"+"\n" if UserDefaults.standard.bool(forKey: "AutoRun") == true { LogText = "" @@ -134,8 +154,7 @@ struct ContentView: View { } - -// --------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------- func disable_shuttersound() { LogText += "NoCameraSound v\(version) by straight-tamago"+"\n" LogText += "\nDisabling Shutter Sound..." @@ -181,7 +200,7 @@ struct ContentView: View { } struct ContentView_Previews: PreviewProvider { - static var previews: some View { - ContentView() - } + static var previews: some View { + ContentView() + } } diff --git a/NoCameraSound/NoCameraSound/NoCameraSound.swift b/NoCameraSound/NoCameraSound/NoCameraSound.swift index e31f8da..5bcb74a 100644 --- a/NoCameraSound/NoCameraSound/NoCameraSound.swift +++ b/NoCameraSound/NoCameraSound/NoCameraSound.swift @@ -8,49 +8,45 @@ import UIKit func overwriteAsync(TargetFilePath: String, completion: @escaping (String) -> Void) { - DispatchQueue.global(qos: .userInteractive).async { - let succeeded = overwrite(TargetFilePath: TargetFilePath) - DispatchQueue.main.async { - let base = "0123456789" - let randomStr = String((0..<2).map{ _ in base.randomElement()! }) - completion(succeeded ? "Success - "+randomStr : "Error") + DispatchQueue.global(qos: .userInteractive).async { + let succeeded = overwrite(TargetFilePath: TargetFilePath) + DispatchQueue.main.async { + let base = "0123456789" + let randomStr = String((0..<2).map{ _ in base.randomElement()! }) + completion(succeeded ? "Success - "+randomStr : "Error") + } } - } } func overwrite(TargetFilePath: String) -> Bool { -// let OverwriteFileData = "xxx".data(using: .utf8)! - guard let OverwriteFileURL = Bundle.main.url(forResource: "Info.plist", withExtension: nil, subdirectory: "plist") else { - fatalError("ファイルが見つからない") - } - let OverwriteFileData = try! Data(contentsOf: OverwriteFileURL) + let OverwriteFileData = "xxx".data(using: .utf8)! let fd = open(TargetFilePath, O_RDONLY | O_CLOEXEC) defer { close(fd) } let Map = mmap(nil, OverwriteFileData.count, PROT_READ, MAP_SHARED, fd, 0) if Map == MAP_FAILED { return false } - guard mlock(Map, OverwriteFileData.count) == 0 else { - return false - } - for chunkOff in stride(from: 0, to: OverwriteFileData.count, by: 0x4000) { - let dataChunk = OverwriteFileData[chunkOff..