1
This commit is contained in:
69
CustomKeyboard/Manager/KBKeyboardLayoutResolver.m
Normal file
69
CustomKeyboard/Manager/KBKeyboardLayoutResolver.m
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// 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
|
||||
Reference in New Issue
Block a user