This commit is contained in:
2026-03-02 09:19:06 +08:00
parent da4649101e
commit 781e557e80
34 changed files with 3926 additions and 87 deletions

View File

@@ -18,6 +18,7 @@
#import "KBLocalizationManager.h"
#import "KBSkinManager.h"
#import "KBSuggestionEngine.h"
#import "KBKeyboardLayoutResolver.h"
#import <SDWebImage/SDWebImage.h>
#if DEBUG
@@ -48,6 +49,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
{
BOOL _kb_didTriggerLoginDeepLinkOnce;
NSString *_kb_lastLoadedProfileId; // profileId
#if DEBUG
BOOL _kb_debugDidCountAlive;
#endif
@@ -97,6 +99,9 @@ static NSString *KBFormatMB(uint64_t bytes) {
[self kb_registerDarwinSkinInstallObserver];
[self kb_consumePendingShopSkin];
[self kb_applyDefaultSkinIfNeeded];
// App Group
[self kb_checkAndApplyLayoutIfNeeded];
}
- (void)didReceiveMemoryWarning {
@@ -198,6 +203,9 @@ static NSString *KBFormatMB(uint64_t bytes) {
if (self.kb_defaultGradientLayer) {
self.kb_defaultGradientLayer.frame = self.bgImageView.bounds;
}
//
[self kb_checkAndApplyLayoutIfNeeded];
}
- (void)viewWillTransitionToSize:(CGSize)size
@@ -238,4 +246,39 @@ static NSString *KBFormatMB(uint64_t bytes) {
#endif
}
#pragma mark - Layout Switching
- (void)kb_checkAndApplyLayoutIfNeeded {
NSString *currentProfileId = [[KBKeyboardLayoutResolver sharedResolver] currentProfileId];
if (currentProfileId.length == 0) {
currentProfileId = @"en_US_qwerty"; // 退
}
// profileId
if ([currentProfileId isEqualToString:_kb_lastLoadedProfileId]) {
return;
}
NSLog(@"[KeyboardViewController] Detected profileId change: %@ -> %@", _kb_lastLoadedProfileId, currentProfileId);
_kb_lastLoadedProfileId = currentProfileId;
// KBKeyBoardMainView
if (self.keyBoardMainView && [self.keyBoardMainView respondsToSelector:@selector(reloadLayoutWithProfileId:)]) {
[self.keyBoardMainView performSelector:@selector(reloadLayoutWithProfileId:) withObject:currentProfileId];
}
//
NSString *suggestionEngine = [[KBKeyboardLayoutResolver sharedResolver] suggestionEngineForProfileId:currentProfileId];
if (suggestionEngine.length > 0) {
[self kb_updateSuggestionEngineType:suggestionEngine];
}
}
- (void)kb_updateSuggestionEngineType:(NSString *)engineType {
// engineType
// latin, pinyin_traditional, pinyin_simplified, bopomofo
NSLog(@"[KeyboardViewController] Switching suggestion engine to: %@", engineType);
[[KBSuggestionEngine shared] setEngineTypeFromString:engineType];
}
@end