70 lines
2.1 KiB
Objective-C
70 lines
2.1 KiB
Objective-C
//
|
|
// KBKeyboardLayoutResolver.m
|
|
// CustomKeyboard
|
|
//
|
|
|
|
#import "KBKeyboardLayoutResolver.h"
|
|
#import "KBInputProfileManager.h"
|
|
#import "KBConfig.h"
|
|
|
|
@implementation KBKeyboardLayoutResolver
|
|
|
|
+ (instancetype)sharedResolver {
|
|
static KBKeyboardLayoutResolver *instance = nil;
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
instance = [[self alloc] init];
|
|
});
|
|
return instance;
|
|
}
|
|
|
|
- (NSString *)layoutJsonIdForProfileId:(NSString *)profileId {
|
|
if (profileId.length == 0) {
|
|
return @"letters";
|
|
}
|
|
|
|
NSString *layoutJsonId = [[KBInputProfileManager sharedManager] layoutJsonIdForProfileId:profileId];
|
|
if (layoutJsonId.length > 0) {
|
|
return layoutJsonId;
|
|
}
|
|
|
|
// 回退到默认布局
|
|
NSLog(@"[KBKeyboardLayoutResolver] No layoutJsonId found for profileId: %@, using default 'letters'", profileId);
|
|
return @"letters";
|
|
}
|
|
|
|
- (NSString *)suggestionEngineForProfileId:(NSString *)profileId {
|
|
if (profileId.length == 0) {
|
|
return @"latin";
|
|
}
|
|
|
|
NSString *engine = [[KBInputProfileManager sharedManager] suggestionEngineForProfileId:profileId];
|
|
if (engine.length > 0) {
|
|
return engine;
|
|
}
|
|
|
|
// 回退到默认引擎
|
|
NSLog(@"[KBKeyboardLayoutResolver] No suggestionEngine found for profileId: %@, using default 'latin'", profileId);
|
|
return @"latin";
|
|
}
|
|
|
|
- (nullable NSString *)currentProfileId {
|
|
NSUserDefaults *appGroup = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
|
|
NSString *profileId = [appGroup stringForKey:AppGroup_SelectedKeyboardProfileId];
|
|
return profileId;
|
|
}
|
|
|
|
- (nullable NSString *)currentLanguageCode {
|
|
NSUserDefaults *appGroup = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
|
|
NSString *languageCode = [appGroup stringForKey:AppGroup_SelectedKeyboardLanguageCode];
|
|
return languageCode;
|
|
}
|
|
|
|
- (nullable NSString *)currentLayoutVariant {
|
|
NSUserDefaults *appGroup = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
|
|
NSString *layoutVariant = [appGroup stringForKey:AppGroup_SelectedKeyboardLayoutVariant];
|
|
return layoutVariant;
|
|
}
|
|
|
|
@end
|