diff --git a/CustomKeyboard/Model/KBKeyboardLayoutConfig.h b/CustomKeyboard/Model/KBKeyboardLayoutConfig.h index 19e4096..1f94480 100644 --- a/CustomKeyboard/Model/KBKeyboardLayoutConfig.h +++ b/CustomKeyboard/Model/KBKeyboardLayoutConfig.h @@ -74,6 +74,7 @@ NS_ASSUME_NONNULL_BEGIN @interface KBKeyboardLayout : NSObject @property (nonatomic, strong, nullable) NSArray *rows; +@property (nonatomic, strong, nullable) NSArray *shiftRows; @end @interface KBKeyboardLayoutConfig : NSObject diff --git a/CustomKeyboard/Model/KBKeyboardLayoutConfig.m b/CustomKeyboard/Model/KBKeyboardLayoutConfig.m index 589f26d..c8a2524 100644 --- a/CustomKeyboard/Model/KBKeyboardLayoutConfig.m +++ b/CustomKeyboard/Model/KBKeyboardLayoutConfig.m @@ -82,7 +82,7 @@ static NSString * const kKBKeyboardLayoutI18nFileName = @"kb_keyboard_layouts_i1 @implementation KBKeyboardLayout + (NSDictionary *)mj_objectClassInArray { - return @{ @"rows": [KBKeyboardRowConfig class] }; + return @{ @"rows": [KBKeyboardRowConfig class], @"shiftRows": [KBKeyboardRowConfig class] }; } @end diff --git a/CustomKeyboard/View/KBKeyboardView.m b/CustomKeyboard/View/KBKeyboardView.m index 34c0839..af9e478 100644 --- a/CustomKeyboard/View/KBKeyboardView.m +++ b/CustomKeyboard/View/KBKeyboardView.m @@ -127,7 +127,14 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5; } KBKeyboardLayout *layout = [self kb_currentLayout]; - NSArray *rows = layout.rows ?: @[]; + NSArray *rows = nil; + + if (self.shiftOn && layout.shiftRows.count > 0) { + rows = layout.shiftRows; + } else { + rows = layout.rows ?: @[]; + } + if (rows.count < 4) { [self kb_buildLegacyLayout]; return; diff --git a/keyBoard/AppDelegate.m b/keyBoard/AppDelegate.m index 415cf92..42455f4 100644 --- a/keyBoard/AppDelegate.m +++ b/keyBoard/AppDelegate.m @@ -25,6 +25,7 @@ #import "KBUserSessionManager.h" #import "KBLoginVC.h" #import "KBConfig.h" +#import "KBSkinInstallBridge.h" static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0; @@ -63,11 +64,9 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0; [KBNetworkManager shared].enabled = YES; /// 获取网络权限 [self getNetJudge]; - /// 触发一次简单网络请求,用于拉起系统的蜂窝数据权限弹窗 -// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self kb_fireStartupNetworkRequest]; -// }); -// + + // 安装默认皮肤(首次安装时) + [self kb_installDefaultSkinIfNeeded]; #if !DEBUG /// Bugly @@ -453,4 +452,37 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0; [rootVC presentViewController:alert animated:YES completion:nil]; } +- (void)kb_installDefaultSkinIfNeeded { + static NSString *const kKBDefaultSkinInstalledKey = @"KBDefaultSkinInstalled"; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + if ([ud boolForKey:kKBDefaultSkinInstalledKey]) { + NSLog(@"[AppDelegate] Default skin already installed, skip"); + return; + } + + NSLog(@"[AppDelegate] Installing default skin for first launch..."); + + NSString *skinId = @"bundle_skin_default_en"; + NSString *zipName = @"normal_them.zip"; + + NSDictionary *iconShortNames = [KBSkinInstallBridge iconShortNamesForLanguageCode:@"en"]; + + [KBSkinInstallBridge publishBundleSkinRequestWithId:skinId + name:skinId + zipName:zipName + iconShortNames:iconShortNames]; + + [KBSkinInstallBridge consumePendingRequestFromBundle:[NSBundle mainBundle] + completion:^(BOOL success, NSError * _Nullable error) { + if (success) { + NSLog(@"[AppDelegate] Default skin installed successfully"); + [ud setBool:YES forKey:kKBDefaultSkinInstalledKey]; + [ud synchronize]; + } else { + NSLog(@"[AppDelegate] Default skin install failed: %@", error); + } + }]; +} + @end