Skip to content
Open
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
4 changes: 4 additions & 0 deletions OpenSim.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
312A27FD21A753E600699668 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 312A27FC21A753E600699668 /* Constants.swift */; };
31A79B15219B81660024DF7B /* Simulator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A79B14219B81660024DF7B /* Simulator.swift */; };
31C4BF3221A8AC56008B97A1 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 31C4BF3021A8AC56008B97A1 /* Localizable.strings */; };
78C2C79B2450FE5E007E4560 /* OpenUserDefaultsAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78C2C79A2450FE5E007E4560 /* OpenUserDefaultsAction.swift */; };
AF9D003A1D110E750065AFD0 /* Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF9D00391D110E750065AFD0 /* Helper.swift */; };
B20671202353ECAA00D6ED0D /* SimulatorShutdownMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B206711F2353ECAA00D6ED0D /* SimulatorShutdownMenuItem.swift */; };
B20671222353ECB600D6ED0D /* SimulatorResetMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B20671212353ECB600D6ED0D /* SimulatorResetMenuItem.swift */; };
Expand Down Expand Up @@ -50,6 +51,7 @@
31A79B14219B81660024DF7B /* Simulator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Simulator.swift; sourceTree = "<group>"; };
31C4BF3121A8AC56008B97A1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
31C4BF3421A8AC72008B97A1 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
78C2C79A2450FE5E007E4560 /* OpenUserDefaultsAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenUserDefaultsAction.swift; sourceTree = "<group>"; };
AF9D00391D110E750065AFD0 /* Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = "<group>"; };
B206711F2353ECAA00D6ED0D /* SimulatorShutdownMenuItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimulatorShutdownMenuItem.swift; sourceTree = "<group>"; };
B20671212353ECB600D6ED0D /* SimulatorResetMenuItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimulatorResetMenuItem.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -170,6 +172,7 @@
B39B2B741EBF58EC00CDD74C /* OpenInItermAction.swift */,
B39B2B781EBF614400CDD74C /* OpenRealmAction.swift */,
256B782B2278A08500052809 /* LaunchAction.swift */,
78C2C79A2450FE5E007E4560 /* OpenUserDefaultsAction.swift */,
);
name = Actions;
sourceTree = "<group>";
Expand Down Expand Up @@ -299,6 +302,7 @@
B3E67B5E1CA412BD00744B38 /* MenuManager.swift in Sources */,
B39B2B671EBF0D0600CDD74C /* LaunchAtLoginHelper.swift in Sources */,
B39B2B631EBEFFB700CDD74C /* AppInfoView.swift in Sources */,
78C2C79B2450FE5E007E4560 /* OpenUserDefaultsAction.swift in Sources */,
B3A1E3301BF05F980090EC58 /* DeviceManager.swift in Sources */,
312A27FD21A753E600699668 /* Constants.swift in Sources */,
B3A1E3231BF049690090EC58 /* AppDelegate.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions OpenSim/ActionMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class ActionMenu: NSMenu {
]

private static let extraActions: [ApplicationActionable.Type] = [
OpenUserDefaultsAction.self,
OpenInItermAction.self,
OpenRealmAction.self
]
Expand Down
15 changes: 15 additions & 0 deletions OpenSim/Assets.xcassets/userDefaults.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "UserDefaults.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
3 changes: 3 additions & 0 deletions OpenSim/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
"Action.EraseSimulatorAlertConfirmButton" = "Erase Simulator";
"Action.EraseSimulatorAlertCancelButton" = "Cancel";
"Action.EraseSimulatorAlertMessage" = "Are you sure you want to erase the %@ Simulator? This will remove the simulator from your system, but a new simulator can still be created.";
"Action.OpenUserDefaults" = "Open UserDefaults";
"Extension.OpenInIterm" = "Open Sandbox in iTerm";
"Extension.OpenRealmDatabase" = "Open Realm Database";
"AppInfo.Version" = "Version";
"AppInfo.Size" = "Size";
"MenuHeader.Actions" = "Actions";
"MenuHeader.Extensions" = "Extensions";
"MenuHeader.AppInformation" = "App Information";
"Action.Dismiss" = "Dismiss";
"Action.DismissMessage" = "No user defaults file detected";
3 changes: 3 additions & 0 deletions OpenSim/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ struct UIConstants {
static let actionFactoryResetAlertMessage = NSLocalizedString("Action.FactoryResetAlertMessage", comment: "Factory reset confirmation message")
static let actionFactoryResetAllSimulatorsMessage = NSLocalizedString("Action.FactoryResetAllSimulatorsMessage", comment: "Factory Reset All Simulators")
static let actionFactoryResetAllShutdownSimulatorsMessage = NSLocalizedString("Action.FactoryResetAllShutdownSimulatorsMessage", comment: "Factory Reset All Shutdown Simulators")
static let actionOpenUserDefaults = NSLocalizedString("Action.OpenUserDefaults", comment: "Open UserDefaults")
static let actionDismissUserDefaultsTitle = NSLocalizedString("Action.DismissMessage", comment: "Dismiss title")
static let actionDismissUserDefaultsButton = NSLocalizedString("Action.Dismiss", comment: "Dismiss menu")
static let extensionOpenInIterm = NSLocalizedString("Extension.OpenInIterm", comment: "Open in iTerm label")
static let extensionOpenRealmDatabase = NSLocalizedString("Extension.OpenRealmDatabase", comment: "Open Realm Database label")
static let appInfoVersion = NSLocalizedString("AppInfo.Version", comment: "App Info Version Label")
Expand Down
49 changes: 49 additions & 0 deletions OpenSim/OpenUserDefaultsAction.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Created for OpenSim in 2020
// Using Swift 5.2
// Created by Gene Crucean on 4/20/20
//

import Cocoa

final class OpenUserDefaultsAction: ApplicationActionable {

var application: Application?

let title = UIConstants.strings.actionOpenUserDefaults

let icon = templatize(#imageLiteral(resourceName: "userDefaults"))

var isAvailable: Bool {
return Bundle.main.bundleIdentifier != nil
}

var userDefaultsPath: String?

init(application: Application) {
self.application = application

// There is probably a better way of doing this. I need to do a bit of research.
if let pathUrl = application.sandboxUrl?.appendingPathComponent("Library").appendingPathComponent("Preferences"), let enumerator = FileManager.default.enumerator(at: pathUrl, includingPropertiesForKeys: nil) {
while let fileUrl = enumerator.nextObject() as? URL {
if fileUrl.lastPathComponent == "\(application.bundleID).plist" {
userDefaultsPath = fileUrl.path
}
}
}
}

func perform() {
if let userDefaultsPath = userDefaultsPath {
NSWorkspace.shared.openFile(userDefaultsPath, withApplication: nil)
} else {
print("No user defaults file detected.")

let alert: NSAlert = NSAlert()
alert.messageText = String(format: UIConstants.strings.actionDismissUserDefaultsTitle)
alert.alertStyle = .informational
alert.addButton(withTitle: UIConstants.strings.actionDismissUserDefaultsButton)
alert.runModal()
}
}
}