diff --git a/CustomKeyboard/View/KBKeyboardView.m b/CustomKeyboard/View/KBKeyboardView.m index af9e478..a8bc77e 100644 --- a/CustomKeyboard/View/KBKeyboardView.m +++ b/CustomKeyboard/View/KBKeyboardView.m @@ -127,6 +127,9 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5; } KBKeyboardLayout *layout = [self kb_currentLayout]; + NSLog(@"[KBKeyboardView] reloadKeys: layoutName=%@ rows=%lu shiftRows=%lu shiftOn=%d", + self.currentLayoutJsonId, (unsigned long)layout.rows.count, (unsigned long)layout.shiftRows.count, self.shiftOn); + NSArray *rows = nil; if (self.shiftOn && layout.shiftRows.count > 0) { @@ -135,7 +138,10 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5; rows = layout.rows ?: @[]; } + NSLog(@"[KBKeyboardView] reloadKeys: usingRows=%lu", (unsigned long)rows.count); + if (rows.count < 4) { + NSLog(@"[KBKeyboardView] reloadKeys: rows.count < 4, fallback to legacy"); [self kb_buildLegacyLayout]; return; } @@ -146,6 +152,7 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5; [self buildRow:self.row4 withRowConfig:rows[3]]; NSUInteger totalButtons = [self kb_totalKeyButtonCount]; + NSLog(@"[KBKeyboardView] reloadKeys: totalButtons=%lu", (unsigned long)totalButtons); if (totalButtons == 0) { NSLog(@"[KBKeyboardView] config layout produced no keys, fallback to legacy."); for (UIView *row in @[self.row1, self.row2, self.row3, self.row4]) { @@ -376,7 +383,7 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5; // 字母键工厂:根据 shiftOn 决定显示与输出大小写 - (KBKey *)kb_letterKeyWithChar:(NSString *)charString { - NSParameterAssert(charString.length == 1); + if (charString.length == 0) { return nil; } NSString *lower = charString.lowercaseString; NSString *upper = charString.uppercaseString; @@ -1151,7 +1158,7 @@ edgeSpacerMultiplier:(CGFloat)edgeSpacerMultiplier { NSString *prefix = [itemId substringToIndex:range.location]; NSString *value = [itemId substringFromIndex:range.location + 1]; if ([prefix isEqualToString:@"letter"]) { - if (value.length == 1) { + if (value.length >= 1) { return [self kb_letterKeyWithChar:value]; } return nil; diff --git a/Shared/KBInputProfileManager.m b/Shared/KBInputProfileManager.m index 91fda4a..ddfe579 100644 --- a/Shared/KBInputProfileManager.m +++ b/Shared/KBInputProfileManager.m @@ -117,26 +117,22 @@ }, @{ @"code": @"es", - @"name": @"Español", + @"name": @"Español (Latinoamérica)", @"defaultSkinZip": @"西班牙初始皮肤.zip", - @"layouts": @[ - @{@"variant": @"qwerty", @"title": @"QWERTY", @"profileId": @"es_ES_qwerty", @"layoutJsonId": @"letters", @"suggestionEngine": @"latin"}, - @{@"variant": @"azerty", @"title": @"AZERTY", @"profileId": @"es_ES_azerty", @"layoutJsonId": @"letters_azerty", @"suggestionEngine": @"latin"}, - @{@"variant": @"qwertz", @"title": @"QWERTZ", @"profileId": @"es_ES_qwertz", @"layoutJsonId": @"letters_qwertz", @"suggestionEngine": @"latin"} - ] + @"layouts": @[@{@"variant": @"qwerty", @"title": @"QWERTY", @"profileId": @"es_419_qwerty", @"layoutJsonId": @"letters_es", @"suggestionEngine": @"spanish"}] }, @{ @"code": @"pt", @"name": @"Português", @"defaultSkinZip": @"", - @"layouts": @[@{@"variant": @"qwerty", @"title": @"QWERTY", @"profileId": @"pt_PT_qwerty", @"layoutJsonId": @"letters", @"suggestionEngine": @"latin"}] + @"layouts": @[@{@"variant": @"qwerty", @"title": @"QWERTY", @"profileId": @"pt_PT_qwerty", @"layoutJsonId": @"letters_pt", @"suggestionEngine": @"latin"}] }, @{ @"code": @"zh-Hant", @"name": @"繁體中文(台灣)", @"defaultSkinZip": @"", @"layouts": @[ - @{@"variant": @"pinyin", @"title": @"拼音(繁體)", @"profileId": @"zh_Hant_TW_pinyin", @"layoutJsonId": @"letters", @"suggestionEngine": @"pinyin_traditional"}, + @{@"variant": @"pinyin", @"title": @"拼音(繁體)", @"profileId": @"zh_Hant_TW_pinyin", @"layoutJsonId": @"letters_zh_hant_pinyin", @"suggestionEngine": @"pinyin_traditional"}, @{@"variant": @"bopomofo_full", @"title": @"注音全鍵盤", @"profileId": @"zh_Hant_TW_bopomofo_full", @"layoutJsonId": @"letters_bopomofo_full", @"suggestionEngine": @"bopomofo"}, @{@"variant": @"bopomofo_standard", @"title": @"注音標準", @"profileId": @"zh_Hant_TW_bopomofo_standard", @"layoutJsonId": @"letters_bopomofo_standard", @"suggestionEngine": @"bopomofo"} ] @@ -145,13 +141,7 @@ @"code": @"id", @"name": @"Bahasa Indonesia", @"defaultSkinZip": @"", - @"layouts": @[@{@"variant": @"qwerty", @"title": @"QWERTY", @"profileId": @"id_ID_qwerty", @"layoutJsonId": @"letters", @"suggestionEngine": @"latin"}] - }, - @{ - @"code": @"zh-Hans", - @"name": @"简体中文", - @"defaultSkinZip": @"", - @"layouts": @[@{@"variant": @"qwerty", @"title": @"QWERTY", @"profileId": @"zh_Hans_CN_qwerty", @"layoutJsonId": @"letters", @"suggestionEngine": @"pinyin_simplified"}] + @"layouts": @[@{@"variant": @"qwerty", @"title": @"QWERTY", @"profileId": @"id_ID_qwerty", @"layoutJsonId": @"letters_id", @"suggestionEngine": @"latin"}] } ]; return [self parseProfilesFromJSONArray:fallback]; diff --git a/Shared/Resource/kb_input_profiles.json b/Shared/Resource/kb_input_profiles.json index 0bb4aa0..9a2b08a 100644 --- a/Shared/Resource/kb_input_profiles.json +++ b/Shared/Resource/kb_input_profiles.json @@ -13,21 +13,22 @@ "layoutJsonId": "letters", "suggestionEngine": "latin" } - ], - { - "code": "es", - "name": "Español (Latinoamérica)", - "defaultSkinZip": "西班牙初始皮肤.zip", - "layouts": [ - { - "variant": "qwerty", - "title": "QWERTY", - "profileId": "es_419_qwerty", - "layoutJsonId": "letters_es", - "suggestionEngine": "spanish" - } - ] - }, + ] + }, + { + "code": "es", + "name": "Español (Latinoamérica)", + "defaultSkinZip": "西班牙初始皮肤.zip", + "layouts": [ + { + "variant": "qwerty", + "title": "QWERTY", + "profileId": "es_419_qwerty", + "layoutJsonId": "letters_es", + "suggestionEngine": "spanish" + } + ] + }, { "code": "pt", "name": "Português",