mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-11-26 00:49:20 +00:00
also load keyboard layouts from Documents/Keyboard Layouts
This commit is contained in:
parent
097ac4e64d
commit
a6e6014220
@ -16,6 +16,7 @@ extern NSString *DocumentsChangedNotification;
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@property (nonatomic, readonly) NSString *documentsPath;
|
||||
@property (nonatomic, readonly) NSString *userKeyboardLayoutsPath;
|
||||
@property (nonatomic, readonly) NSArray<NSString*> *diskImageExtensions;
|
||||
@property (nonatomic, readonly) NSArray<NSBundle*> *emulatorBundles;
|
||||
@property (readonly, nonatomic, getter = isSandboxed) BOOL sandboxed;
|
||||
|
@ -45,6 +45,10 @@ NSString *DocumentsChangedNotification = @"documentsChanged";
|
||||
[application btcMouseSetRawMode:YES];
|
||||
[application btcMouseSetDelegate:self];
|
||||
}
|
||||
|
||||
// populate documents directory so it shows up in Files
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:self.userKeyboardLayoutsPath withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -280,6 +284,15 @@ NSString *DocumentsChangedNotification = @"documentsChanged";
|
||||
return documentsPath;
|
||||
}
|
||||
|
||||
- (NSString *)userKeyboardLayoutsPath {
|
||||
static dispatch_once_t onceToken;
|
||||
static NSString *userKeyboardLayoutsPath;
|
||||
dispatch_once(&onceToken, ^{
|
||||
userKeyboardLayoutsPath = [self.documentsPath stringByAppendingPathComponent:@"Keyboard Layouts"];
|
||||
});
|
||||
return userKeyboardLayoutsPath;
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
|
||||
if (url.fileURL) {
|
||||
// opening file
|
||||
|
@ -37,6 +37,11 @@ typedef enum : NSInteger {
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
keyboardLayouts = [[NSBundle mainBundle] pathsForResourcesOfType:@"nfkeyboardlayout" inDirectory:@"Keyboard Layouts"];
|
||||
NSString *userKeyboardLayoutsPath = [AppDelegate sharedInstance].userKeyboardLayoutsPath;
|
||||
NSArray *userKeyboardLayouts = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:userKeyboardLayoutsPath error:nil] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"pathExtension.lowercaseString = %@", @"nfkeyboardlayout"]];
|
||||
if (userKeyboardLayouts.count > 0) {
|
||||
keyboardLayouts = [keyboardLayouts arrayByAddingObjectsFromArray:userKeyboardLayouts];
|
||||
}
|
||||
[self loadEmulatorBundles];
|
||||
[self loadCredits];
|
||||
}
|
||||
|
@ -220,7 +220,10 @@
|
||||
- (KBKeyboardLayout*)keyboardLayout {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString *layoutName = [defaults stringForKey:@"keyboardLayout"];
|
||||
NSString *layoutPath = [[NSBundle mainBundle] pathForResource:layoutName ofType:nil inDirectory:@"Keyboard Layouts"];
|
||||
NSString *layoutPath = [[[AppDelegate sharedInstance] userKeyboardLayoutsPath] stringByAppendingPathComponent:layoutName];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:layoutPath]) {
|
||||
layoutPath = [[NSBundle mainBundle] pathForResource:layoutName ofType:nil inDirectory:@"Keyboard Layouts"];
|
||||
}
|
||||
if (layoutPath == nil) {
|
||||
NSLog(@"Layout not found: %@", layoutPath);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user