Skip to content

Commit aeabc54

Browse files
committed
bug-fix & new feature
1. 使用ASCII键盘输入英文字符时,直接上屏,跳过复杂的调用,从表面上解决issue osfans#301 知乎输入英语后输入法失去焦点的问题 (从100%复现变为概率性发生) 2. 优化预设皮肤的参数。 3. 在同文风皮肤的默认键盘中增加”更多“按钮,点击打开liquidKeyboard 4. osfans#512 优化背景解析和加载的方法。支持把背景图放置到“background/background_folder”目录。 5. 调整皮肤参数位置。背景图/色从style统一移动到fallback_colors,并且由preset_color_schemes来定义。(为了后续的皮肤优化,代码逻辑简化,不对旧皮肤的相关参数做兼容)包含:root_background candidate_background 废弃layout/background, 改为text_back_color值既可以是色彩、也可以是背景图(window_background) 6. 修复 osfans#515 的bug并调整皮肤中keyboard_padding开头的多个参数名和相关算法,增加左右手键盘switch。在默认皮肤-符号键盘提供了左右手模式的示例(长按,?两个按键)
1 parent 6ec4955 commit aeabc54

14 files changed

+596
-204
lines changed

app/src/main/assets/rime/tongwenfeng.trime.yaml

+120-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ round_corner:
2525
style:
2626
auto_caps: false #自動句首大寫:true|false|ascii
2727
background_dim_amount: 0.5
28+
root_background: keyboard_back_color # 整个键盘区+候选栏的背景图/色
2829
candidate_font: han.ttf #候选字体
2930
candidate_padding: 5 #候选项内边距
3031
candidate_spacing: 0.5 #候选间距
@@ -67,7 +68,7 @@ style:
6768
- {start: "\n", label: "%s.", candidate: "%s", comment: "%s", end: "", sep: "☁️️"}
6869
key_font: symbol.ttf #键盘字体
6970
key_height: *jpgd4 #键高
70-
key_long_text_size: 18 #长标签字号
71+
key_long_text_size: 16 #长标签字号
7172
key_text_size: 24 #键字号
7273
key_width: 10.0 #键宽,占屏幕宽的百分比
7374
keyboards: [.default, letter, default, number, symbols, edit, move, bqrw1, bqrw2, bqrw3, bqrw4, bqrw5, bqrw6, bqqt1, bqqt2, bqqt3, bqqt4, bqqz1, bqqz2, bqqz3, bqqz4, bqqz5, bqqz6, bqpt1, bqpt2, bqhd1, bqhd2, bqhc1, bqhc2, bqhc3, bqlx1, bqlx2, bqlx3, bqlx4, bqlx5, bqlx6, bqkj1, bqkj2, bqkj3, bqkj4, bqkj5, bqfh1, bqfh2, bqfh3, bqfh4, kao_fond, kao_sad, kao_mad, kao_astonished, kao_impotent, kao_happy, numberb] #键盘配置
@@ -103,7 +104,6 @@ fallback_colors:
103104
hilited_candidate_text_color: hilited_text_color
104105
hilited_candidate_back_color: hilited_back_color
105106
hilited_comment_text_color: comment_text_color
106-
text_back_color: back_color
107107
hilited_key_back_color: hilited_candidate_back_color
108108
hilited_key_text_color: hilited_candidate_text_color
109109
hilited_key_symbol_color: hilited_comment_text_color
@@ -115,7 +115,6 @@ fallback_colors:
115115
key_border_color: border_color
116116
key_text_color: candidate_text_color
117117
key_symbol_color: comment_text_color
118-
keyboard_back_color: border_color
119118
label_color: candidate_text_color
120119
off_key_back_color: key_back_color
121120
off_key_text_color: key_text_color
@@ -124,6 +123,12 @@ fallback_colors:
124123
preview_back_color: key_text_color
125124
preview_text_color: key_back_color
126125
shadow_color: border_color
126+
root_background: back_color # 整个键盘区+候选栏的背景图/色
127+
candidate_background: back_color #候选栏的整体背景图/色
128+
keyboard_back_color: border_color #键盘去的背景图/色
129+
liquid_keyboard_background: keyboard_back_color # liquidKeyboard的背景图/色
130+
text_back_color: back_color #编码区背景,即悬浮窗背景
131+
long_text_back_color: key_back_color #长文本按键的背景(剪贴板)
127132

128133
#颜色
129134
colors:
@@ -841,7 +846,115 @@ preset_color_schemes:
841846
off_key_text_color: 0xffd7d7d7
842847
text_color: 0xffcd8c52
843848
#--------配色结束----------------#
844-
849+
850+
liquid_keyboard:
851+
# 目前只能直接写参数,不支持变量或者fallback机制。
852+
# 缺少参数时,自动从style中加载参数。除非需要指定liquid_keyboard使用与主键盘不同的背景色、背景图,否则不应设置被注释掉的参数。
853+
author: "tumuyan"
854+
key_height: 40 #按键高度
855+
key_height_land: 40 #横屏模式按键高度
856+
single_width: 60 #single类型的按键宽度
857+
vertical_gap: 1 #纵向按键间隙
858+
margin_x: 0.5 #左右按键间隙的1/2
859+
keyboards: [emoji, math, ascii, cn, clipboard, history, exit, list , table, symbol, ids , pinyin, jp, unit, exit, grease, rusa, korea, lation, yinbiao, exit] #tab列表
860+
exit:
861+
name: 返回
862+
type: NO_KEY
863+
keys: EXIT
864+
emoji:
865+
type: SINGLE
866+
keys: "🙂😂🤣😆🙃😅🙈🙉🙊☹😑😄🤐😨😱🌚🌝🤔❤💔♡🌹💣👌👍😣😥😮🙄😏😕😯😪😫😴😌🤑😉😋😎😍😘😚😛😜😝😒😓😔😲😷🤒😇🤓🤗🤕🙁😖😞😟😤😢😭😦😧😨😩😬😰😳😵😡😠☝✌🖕👎🙏🤘👏💪💋☘🍀🌸☕🍵🍺🍻🍦🍬🍚🍜🍲🍖🎂💤"
867+
clipboard:
868+
type: CLIPBOARD
869+
name: 剪贴
870+
history:
871+
name: 最近
872+
type: HISTORY
873+
math: #tab名称
874+
type: SINGLE
875+
name: 数学
876+
keys: "≈=≠≌<>≤≥≡()[]{}-+±×*/÷&∥%‰‱°′″∫∮∯∬∭∰∞∑∧∏∈∵∴⊥∝∨∪•√〒∝∽∈∩∧⊙⌒∥∟∣∂∆∞≌∉∪∨⊕⊿⊥∠∫∬∭" #tab中的按键列表
877+
cn:
878+
type: SINGLE
879+
name: 中文
880+
keys: #keys列表可以使用多种格式混合书写。
881+
-
882+
-
883+
-
884+
-
885+
-
886+
-
887+
-
888+
-
889+
-
890+
- ···
891+
- ……
892+
- { click: "——" }
893+
- { click: "——", label: "破折号" }
894+
-
895+
-
896+
-
897+
-
898+
-
899+
-
900+
-
901+
-
902+
-
903+
-
904+
-
905+
-
906+
-
907+
-
908+
-
909+
symbol:
910+
name: 特殊
911+
keys: "△▽○◇□☆▲▼●◆■★▷◁▶◀♻♲†⚝✡⚹✦✸✹�×⌫☑☒✅❎✔✘✓✗☼☽♀☻◐㏂☀☾♂☹◑㏘☜☝☞☚☟☛▪•‥…∷※♩♪♫♬§°♭♯♮‖¶№◎¤۞℗®©卍卐℡™㏇Φ↖↑↗◤㊤◥←↔→㊧㊥㊨↙↓↘◣㊦◢⇄⇅⇆⇤↩⇥❏❐◲〼▢▣⇦⇧⇨⇩⇪↶▸◂▴▾✁↷✍⏍ϟ📝✎✆☱☰☴⚿⛮⚙☲☯☵⛶☩☐☳☷☶💬🗨⟲ღ✈☂🎤🌐🔍"
912+
unit:
913+
name: 单位
914+
type: SINGLE
915+
keys: "℃¥$€฿£㎡m³℉¥£¢₠¹²³⁴⁵ⁿ⁶⁷⁸⁹⁰ˣ⁺⁻⁼⁽⁾½⅓¼⅔¾₁₂₃₄₅ₙ₆₇₈₉₀ₓ₊₋₌₍₎℅"
916+
list:
917+
name: 列表
918+
type: SINGLE
919+
keys: "①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩➊➋➌➍➎➏➐➑➒➓㊀㊁㊂㊃㊄㊅㊆㊇㊈㊉ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ"
920+
pinyin:
921+
name: 拼音
922+
type: SINGLE
923+
keys: "āáǎàōóēéěèǒòīíǐìūúǖǘǚǜǔùêüńňㄚㄛㄜㄧㄨㄩㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙ"
924+
grease:
925+
type: SINGLE
926+
name: 希腊
927+
keys: "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψω"
928+
rusa:
929+
name: 俄语
930+
type: SINGLE
931+
keys: "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя"
932+
lation:
933+
name: 拉丁
934+
type: SINGLE
935+
keys: "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŠŸŒàáâãäåæçèéêëìíîïðñòóõôöøùúûüýþšÿœ"
936+
korea:
937+
type: SINGLE
938+
name: "韩文"
939+
keys: "dㅏㅑㅓㅕㅗㅛㅜㅠㅡㅣㅐㅒㅔㅖㅘㅙㅚㅝㅞㅟㅢㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎㄲㄸㅚㅆㅉ㉠㉡㉢㉣㉤㉥㉦㉧㉨㉩㉪㉫㉬㉭㉮㉯㉰㉱㉲㉳㉴㉵㉶㉷㉸㉹㉺㉻㈀㈁㈂㈃㈄㈅㈆㈇㈈㈉㈊㈋㈌㈍㈎㈏㈐㈑㈒㈓㈔㈕㈖㈗㈘㈙㈚㈛"
940+
yinbiao:
941+
type: SINGLE
942+
name: "音标"
943+
keys: ["a:", "ɔ:", "ɜː", "i:", "u:", "ʌ", "ɒ", "ə", "ɪ", "ʊ", "e", "æ", "eɪ", "aɪ", "ɔɪ", "ɪə", "eə", "ʊə", "əʊ", "aʊ", "p", "t", "k", "f", "θ", "s", "b", "d", "g", "v", "ð", "z", "ʃ", "h", "ts", "tʃ", "j", "tr", "ʒ", "r", "dz", "dʒ", "dr", "w", "m", "n", "ŋ", "l"]
944+
ascii:
945+
type: SINGLE
946+
name: 英文
947+
keys: ",.?!:;/\\|*-+=^$`'\"^~@#%&()[]{}_"
948+
ids:
949+
type: SINGLE
950+
name: IDS
951+
keys: "⿰⿱⿲⿳⿴⿵⿶⿷⿸⿹⿺⿻"
952+
jp:
953+
type: SINGLE
954+
name: 假名
955+
keys: "あいうえおかがきぎくぐけげこごさざしじすずせぜそぞただちぢつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろわをんアィイウェエオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロワヲン"
956+
957+
845958
#键盘布局
846959
preset_keyboards:
847960
default:
@@ -889,7 +1002,7 @@ preset_keyboards:
8891002
- {click: ',', label: ',', long_click: '<>{Left}', key_back_color: bh4, key_text_color: th4}
8901003
- {click: space, long_click: Mode_switch, swipe_left: "Left", swipe_right: "Right", swipe_up: Schema_switchcn, width: 30, key_back_color: bkg, key_text_color: tkg}
8911004
- {click: '.', label: '。', long_click: Keyboard_kao, key_back_color: bh4, key_text_color: th4}
892-
- {click: space_R2, long_click: '?', key_text_size: "18", key_back_color: bh4, key_text_color: th4}
1005+
- {click: space_R2, long_click: liquid_keyboard_switch , key_text_size: "18", key_back_color: bh4, key_text_color: th4}
8931006
- {click: Return, swipe_up: Escape, width: 15, key_back_color: benter, key_text_color: tenter}
8941007

8951008
letter:
@@ -938,7 +1051,7 @@ preset_keyboards:
9381051
- {click: ',', label: ',', long_click: '<>{Left}', key_back_color: bh4, key_text_color: th4}
9391052
- {label: '______', click: space, long_click: space_R2, swipe_left: "Left", swipe_right: "Right", swipe_up: Keyboard_fbj, width: 30, key_back_color: bkg, key_text_color: tkg}
9401053
- {click: '.', label: '。', long_click: Keyboard_kao, key_back_color: bh4, key_text_color: th4}
941-
- {click: space_R2, long_click: '?', key_text_size: "18", key_back_color: bh4, key_text_color: th4}
1054+
- {click: space_R2, long_click: liquid_keyboard_switch, key_text_size: "18", key_back_color: bh4, key_text_color: th4}
9421055
- {click: Return, swipe_up: Escape, width: 15, key_back_color: benter, key_text_color: tenter}
9431056

9441057
number:
@@ -3797,6 +3910,7 @@ preset_keys:
37973910
Henkan: {toggle: simplification, send: Mode_switch, states: [ 汉字, 汉字 ]}
37983911
Charset_switch: {toggle: extended_charset, send: Mode_switch, states: [ 常用, 增广 ]}
37993912
Punct_switch: {toggle: ascii_punct, send: Mode_switch, states: [ 。,, ., ]}
3913+
liquid_keyboard_switch: { toggle: _liquid_keyboard, send: Mode_switch, states: [ 更多, 普通 ] }
38003914
# trime设置
38013915
IME_switch: {label: 🌐, send: LANGUAGE_SWITCH} #彈出對話框選擇輸入法
38023916
IME_last: {label: 上一输入法, send: LANGUAGE_SWITCH, select: .last} #直接切換到上一輸入法

app/src/main/assets/rime/trime.yaml

+23-12
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ author: osfans #作者資訊
88
style:
99
auto_caps: false #自動句首大寫:true|false|ascii
1010
background_dim_amount: 0.5
11-
#root_background: #ddeeeeee # 整个键盘区+候选栏的背景图/色
12-
#candidate_background: #eeeeeeee #候选栏的背景图/色
1311
candidate_font: han.ttf #候選字型
1412
candidate_padding: 5 #候選項內邊距
1513
candidate_spacing: 0.5 #候選間距
@@ -25,8 +23,11 @@ style:
2523
horizontal: true #水平模式
2624
horizontal_gap: 1 #鍵水平間距
2725
keyboard_padding: 0 #竖屏模式下,屏幕左右两侧与键盘的距离(曲面屏减少误触)
28-
keyboard_padding_landscape: 40 #横屏模式下,屏幕左右两侧与键盘的距离(避免横屏UI变形)
29-
keyboard_padding_portrait: 20 #竖屏模式下,屏幕下边缘与键盘的距离(避免误触发全面屏手势)
26+
keyboard_padding_left: 0 #竖屏屏模式下,左手键盘布局,屏幕左侧与键盘的距离
27+
keyboard_padding_right: 40 #竖屏屏模式下,左手键盘布局,屏幕右侧与键盘的距离
28+
keyboard_padding_bottom: 0 #竖屏模式下,屏幕下边缘与键盘的距离(避免误触发全面屏手势)
29+
keyboard_padding_land: 40 #横屏模式下,屏幕左右两侧与键盘的距离(避免横屏按键过度拉伸变形)
30+
keyboard_padding_land_bottom: 0 #横屏模式下,屏幕下侧与键盘的距离
3031
layout: #懸浮窗口設置
3132
position: fixed #位置:left|right|left_up|right_up|fixed|bottom_left|bottom_right|top_left|top_right(left、right需要>=Android5.0)
3233
min_length: 5 #最小詞長
@@ -50,7 +51,6 @@ style:
5051
round_corner: 8 #窗口圓角
5152
alpha: 0xdd #透明度(0-255)
5253
elevation: 5 #陰影(>=Android5.0)
53-
background: background.png #顏色或者backgrounds目錄下的圖片文件名
5454
movable: once #是否可移動窗口,或僅移動一次 true|false|once
5555
window: #懸浮窗口組件
5656
- {start: "", move: 'ㄓ ', end: ""}
@@ -84,6 +84,8 @@ style:
8484
vertical_correction: -10
8585
vertical_gap: 1 #鍵盤行距
8686
long_text_font: comment.ttf #剪贴板等可能包含大段文本使用的字体
87+
#background_folder: #背景图保存在background目录下的哪个子目录
88+
key_long_text_border: 1
8789

8890
fallback_colors:
8991
candidate_text_color: text_color
@@ -96,7 +98,6 @@ fallback_colors:
9698
hilited_candidate_back_color: hilited_back_color
9799
hilited_label_color: hilited_candidate_text_color # 高亮候选序号 颜色
98100
hilited_comment_text_color: comment_text_color
99-
text_back_color: back_color
100101
hilited_key_back_color: hilited_candidate_back_color
101102
hilited_key_text_color: hilited_candidate_text_color
102103
hilited_key_symbol_color: hilited_comment_text_color
@@ -108,7 +109,6 @@ fallback_colors:
108109
key_border_color: border_color
109110
key_text_color: candidate_text_color
110111
key_symbol_color: comment_text_color
111-
keyboard_back_color: border_color
112112
label_color: candidate_text_color
113113
off_key_back_color: key_back_color
114114
off_key_text_color: key_text_color
@@ -117,6 +117,12 @@ fallback_colors:
117117
preview_back_color: key_back_color
118118
preview_text_color: key_text_color
119119
shadow_color: border_color
120+
root_background: back_color # 整个键盘区+候选栏的背景图/色
121+
candidate_background: back_color #候选栏的整体背景图/色
122+
keyboard_back_color: border_color #键盘去的背景图/色
123+
liquid_keyboard_background: keyboard_back_color # liquidKeyboard的背景图/色
124+
text_back_color: back_color #编码区背景,即悬浮窗背景
125+
long_text_back_color: key_back_color #长文本按键的背景(剪贴板)
120126

121127
preset_color_schemes:
122128
default:
@@ -665,12 +671,14 @@ preset_color_schemes:
665671
text_color: 0x7f7f7f
666672

667673
liquid_keyboard:
674+
# 目前只能直接写参数,不支持变量或者fallback机制。
675+
# 缺少参数时,自动从style中加载参数。除非需要指定liquid_keyboard使用与主键盘不同的背景色、背景图,否则不应设置被注释掉的参数。
668676
author: "tumuyan"
669677
key_height: 40 #按键高度
670678
key_height_land: 40 #横屏模式按键高度
671679
single_width: 60 #single类型的按键宽度
672-
vertical_gap: 5 #纵向按键间隙
673-
margin_x: 1 #左右按键间隙的1/2
680+
vertical_gap: 1 #纵向按键间隙
681+
margin_x: 0.5 #左右按键间隙的1/2
674682
keyboards: [emoji, math, ascii, cn, clipboard, history, exit, list , table, symbol, ids , pinyin, jp, unit, exit, grease, rusa, korea, lation, yinbiao, exit] #tab列表
675683
exit:
676684
name: 返回
@@ -922,7 +930,10 @@ preset_keys:
922930
Keyboard_default: {label: 返回, send: Eisu_toggle, select: .default}
923931
Keyboard_switch: {label: 鍵盤, send: Eisu_toggle, select: .next}
924932
Schema_switch: {label: 下一方案, send: Control+Shift+1}
925-
liquid_keyboard_switch: { toggle: _liquid_keyboard, send: Mode_switch, states: [ 更多, "" ] }
933+
liquid_keyboard_switch: { toggle: _liquid_keyboard, send: Mode_switch, states: [ 更多, 普通 ] }
934+
one_hand_switch_1: {toggle: _one_hand_mode_1, send: Mode_switch, states: [ 左手, 普通 ]}
935+
one_hand_switch_2: {toggle: _one_hand_mode_2, send: Mode_switch, states: [ 右手, 普通 ]}
936+
one_hand_switch_3: {toggle: _one_hand_mode_3, send: Mode_switch, states: [ 左手, 右手 ]}
926937
Color_switch: {label: 配色, send: PROG_RED}
927938
Help: {label: 說明, send: Help}
928939
Info: {label: 關於, send: INFO}
@@ -1298,8 +1309,8 @@ preset_keyboards:
12981309
- {click: '〉', long_click: '》', ascii: '>'}
12991310
- {click: '“', ascii: '"', long_click: '‘'}
13001311
- {click: '”', ascii: "'", long_click: '’'}
1301-
- {click: ',', ascii: ','}
1302-
- {click: '?', ascii: '?'}
1312+
- {click: ',', ascii: ',', long_click: one_hand_switch_1}
1313+
- {click: '?', ascii: '?', long_click: one_hand_switch_3}
13031314
- {click: BackSpace, long_click: Escape}
13041315
- {click: Keyboard_default, long_click: Menu, width: 15}
13051316
- {click: Keyboard_number, long_click: Color_switch}

app/src/main/java/com/osfans/trime/Rime.java

-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ public static void onMessage(String message_type, String message_value) {
523523
initSchema();
524524
if (trime != null) {
525525
trime.initKeyboard();
526-
trime.updateComposing();
527526
}
528527
break;
529528
case "option":

app/src/main/java/com/osfans/trime/ime/SymbolKeyboard/ClipboardAdapter.java

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.annotation.SuppressLint;
44
import android.content.Context;
55
import android.graphics.Typeface;
6+
import android.graphics.drawable.Drawable;
67
import android.view.LayoutInflater;
78
import android.view.MotionEvent;
89
import android.view.View;
@@ -24,6 +25,7 @@ public class ClipboardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
2425
private Integer textColor;
2526
private float textSize;
2627
private Typeface textFont;
28+
private Drawable background;
2729

2830
public ClipboardAdapter(Context context, List<SimpleKeyBean> itemlist) {
2931
myContext = context;
@@ -47,6 +49,10 @@ public void configStyle(int keyMarginX, int keyMarginTop) {
4749
textSize = config.getFloat("key_long_text_size");
4850
if (textSize <= 0) textSize = config.getFloat("label_text_size");
4951

52+
background =
53+
config.getDrawable(
54+
"long_text_back_color", "key_border", "key_long_text_border", "round_corner", null);
55+
5056
textFont = config.getFont("long_text_font");
5157
}
5258

@@ -102,6 +108,8 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int in
102108

103109
}
104110

111+
if (background != null) itemViewHold.listItemLayout.setBackground(background);
112+
105113
// 如果设置了回调,则设置点击事件
106114
if (mOnItemClickLitener != null) {
107115
itemViewHold.listItemLayout.setOnClickListener(

app/src/main/java/com/osfans/trime/ime/SymbolKeyboard/LiquidKeyboard.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.osfans.trime.ime.SymbolKeyboard;
22

33
import android.content.Context;
4+
import android.graphics.drawable.Drawable;
45
import android.view.inputmethod.InputConnection;
56
import android.widget.LinearLayout;
67
import androidx.recyclerview.widget.RecyclerView;
@@ -103,7 +104,9 @@ public void calcPadding(int width) {
103104

104105
// 初次显示布局,需要刷新背景
105106
parentView = (LinearLayout) keyboardView.getParent();
106-
parentView.setBackground(config.getLiquidDrawable("keyboard_back_color", context));
107+
Drawable keyboardBackground =
108+
config.getDrawable("liquid_keyboard_background", null, null, null, null);
109+
if (keyboardBackground != null) parentView.setBackground(keyboardBackground);
107110

108111
keyHeight = config.getLiquidPixel("key_height_land");
109112
if (!isLand || keyHeight <= 0) keyHeight = config.getLiquidPixel("key_height");
@@ -123,18 +126,16 @@ public void calcPadding(int width) {
123126
private void calcPadding(SymbolKeyboardType type) {
124127

125128
Config config = Config.get(context);
126-
int padding = config.getPixel("keyboard_padding");
129+
int[] padding = config.getKeyboardPadding();
127130

128131
if (type == SymbolKeyboardType.SINGLE) {
129-
padding =
132+
padding[0] =
130133
(parentView.getWidth() > 0 ? parentView.getWidth() : parent_width)
131134
% (single_width + margin_x * 2)
132135
/ 2;
136+
padding[1] = padding[0];
133137
}
134-
135-
Timber.d("set_keyboard_padding=%s / %s", padding, parentView.getWidth());
136-
if (padding > 0) parentView.setPadding(padding, 0, padding, 0);
137-
138+
parentView.setPadding(padding[0], 0, padding[1], padding[2]);
138139
historyBeans = SimpleKeyDao.getSymbolKeyHistory(historySavePath);
139140
}
140141

0 commit comments

Comments
 (0)