25
25
import android .view .KeyEvent ;
26
26
import androidx .annotation .NonNull ;
27
27
import com .osfans .trime .setup .Config ;
28
- import com .osfans .trime .util .YamlUtils ;
28
+ import com .osfans .trime .util .ConfigGetter ;
29
29
import java .util .ArrayList ;
30
30
import java .util .List ;
31
31
import java .util .Map ;
@@ -195,33 +195,33 @@ public Keyboard(Context context, String name) {
195
195
== Configuration .ORIENTATION_LANDSCAPE );
196
196
Config config = Config .get (context );
197
197
final Map <String , ?> keyboardConfig = config .getKeyboard (name );
198
- mLabelTransform = YamlUtils . INSTANCE .getString (keyboardConfig , "label_transform" , "none" );
199
- mAsciiMode = YamlUtils . INSTANCE .getInt (keyboardConfig , "ascii_mode" , 1 );
198
+ mLabelTransform = ConfigGetter .getString (keyboardConfig , "label_transform" , "none" );
199
+ mAsciiMode = ConfigGetter .getInt (keyboardConfig , "ascii_mode" , 1 );
200
200
if (mAsciiMode == 0 )
201
- mAsciiKeyboard = YamlUtils . INSTANCE .getString (keyboardConfig , "ascii_keyboard" , "" );
202
- resetAsciiMode = YamlUtils . INSTANCE .getBoolean (keyboardConfig , "reset_ascii_mode" , false );
203
- mLock = YamlUtils . INSTANCE .getBoolean (keyboardConfig , "lock" , false );
204
- int columns = YamlUtils . INSTANCE .getInt (keyboardConfig , "columns" , 30 );
201
+ mAsciiKeyboard = ConfigGetter .getString (keyboardConfig , "ascii_keyboard" , "" );
202
+ resetAsciiMode = ConfigGetter .getBoolean (keyboardConfig , "reset_ascii_mode" , false );
203
+ mLock = ConfigGetter .getBoolean (keyboardConfig , "lock" , false );
204
+ int columns = ConfigGetter .getInt (keyboardConfig , "columns" , 30 );
205
205
int defaultWidth =
206
- (int ) (YamlUtils . INSTANCE .getDouble (keyboardConfig , "width" , 0d ) * mDisplayWidth / 100 );
206
+ (int ) (ConfigGetter .getDouble (keyboardConfig , "width" , 0d ) * mDisplayWidth / 100 );
207
207
if (defaultWidth == 0 ) defaultWidth = mDefaultWidth ;
208
208
209
209
// 按键高度取值顺序: keys > keyboard/height > style/key_height
210
210
// 考虑到key设置height_land需要对皮肤做大量修改,而当部分key设置height而部分没有设时会造成按键高度异常,故取消普通按键的height_land参数
211
- int height = YamlUtils . INSTANCE .getPixel (keyboardConfig , "height" , 0 );
211
+ int height = ConfigGetter .getPixel (keyboardConfig , "height" , 0 );
212
212
int defaultHeight = (height > 0 ) ? height : mDefaultHeight ;
213
213
int rowHeight = defaultHeight ;
214
- autoHeightIndex = YamlUtils . INSTANCE .getInt (keyboardConfig , "auto_height_index" , -1 );
214
+ autoHeightIndex = ConfigGetter .getInt (keyboardConfig , "auto_height_index" , -1 );
215
215
List <Map <String , Object >> lm = (List <Map <String , Object >>) keyboardConfig .get ("keys" );
216
216
217
217
mDefaultHorizontalGap =
218
- YamlUtils . INSTANCE .getPixel (
218
+ ConfigGetter .getPixel (
219
219
keyboardConfig , "horizontal_gap" , config .getFloat ("horizontal_gap" , 3 ));
220
220
mDefaultVerticalGap =
221
- YamlUtils . INSTANCE .getPixel (
221
+ ConfigGetter .getPixel (
222
222
keyboardConfig , "vertical_gap" , config .getFloat ("vertical_gap" , 5 ));
223
223
mRoundCorner =
224
- YamlUtils . INSTANCE .getFloat (
224
+ ConfigGetter .getFloat (
225
225
keyboardConfig , "round_corner" , config .getFloat ("round_corner" , 5 ));
226
226
227
227
Drawable background = config .getDrawable (keyboardConfig , "keyboard_back_color" );
@@ -238,10 +238,10 @@ public Keyboard(Context context, String name) {
238
238
int [] newHeight = new int [0 ];
239
239
240
240
if (keyboardHeight > 0 ) {
241
- int mkeyboardHeight = YamlUtils . INSTANCE .getPixel (keyboardConfig , "keyboard_height" , 0 );
241
+ int mkeyboardHeight = ConfigGetter .getPixel (keyboardConfig , "keyboard_height" , 0 );
242
242
if (land ) {
243
243
int mkeyBoardHeightLand =
244
- YamlUtils . INSTANCE .getPixel (keyboardConfig , "keyboard_height_land" , 0 );
244
+ ConfigGetter .getPixel (keyboardConfig , "keyboard_height_land" , 0 );
245
245
if (mkeyBoardHeightLand > 0 ) mkeyboardHeight = mkeyBoardHeightLand ;
246
246
}
247
247
@@ -251,7 +251,7 @@ public Keyboard(Context context, String name) {
251
251
List <Integer > rawHeight = new ArrayList <>();
252
252
for (Map <String , Object > mk : lm ) {
253
253
int gap = mDefaultHorizontalGap ;
254
- int w = (int ) (YamlUtils . INSTANCE .getDouble (mk , "width" , 0 ) * mDisplayWidth / 100 );
254
+ int w = (int ) (ConfigGetter .getDouble (mk , "width" , 0 ) * mDisplayWidth / 100 );
255
255
if (w == 0 && mk .containsKey ("click" )) w = defaultWidth ;
256
256
w -= gap ;
257
257
if (column >= maxColumns || x + w > mDisplayWidth ) {
@@ -263,7 +263,7 @@ public Keyboard(Context context, String name) {
263
263
rawHeight .add (rowHeight );
264
264
}
265
265
if (column == 0 ) {
266
- int heightK = YamlUtils . INSTANCE .getPixel (mk , "height" , 0 );
266
+ int heightK = ConfigGetter .getPixel (mk , "height" , 0 );
267
267
rowHeight = (heightK > 0 ) ? heightK : defaultHeight ;
268
268
}
269
269
if (!mk .containsKey ("click" )) { // 無按鍵事件
@@ -334,7 +334,7 @@ public Keyboard(Context context, String name) {
334
334
335
335
for (Map <String , Object > mk : lm ) {
336
336
int gap = mDefaultHorizontalGap ;
337
- int w = (int ) (YamlUtils . INSTANCE .getDouble (mk , "width" , 0 ) * mDisplayWidth / 100 );
337
+ int w = (int ) (ConfigGetter .getDouble (mk , "width" , 0 ) * mDisplayWidth / 100 );
338
338
if (w == 0 && mk .containsKey ("click" )) w = defaultWidth ;
339
339
w -= gap ;
340
340
if (column >= maxColumns || x + w > mDisplayWidth ) {
@@ -348,7 +348,7 @@ public Keyboard(Context context, String name) {
348
348
if (keyboardHeight > 0 ) {
349
349
rowHeight = newHeight [row ];
350
350
} else {
351
- int heightK = YamlUtils . INSTANCE .getPixel (mk , "height" , 0 );
351
+ int heightK = ConfigGetter .getPixel (mk , "height" , 0 );
352
352
rowHeight = (heightK > 0 ) ? heightK : defaultHeight ;
353
353
}
354
354
}
@@ -358,47 +358,47 @@ public Keyboard(Context context, String name) {
358
358
}
359
359
360
360
final int defaultKeyTextOffsetX =
361
- YamlUtils . INSTANCE .getPixel (
361
+ ConfigGetter .getPixel (
362
362
keyboardConfig , "key_text_offset_x" , config .getFloat ("key_text_offset_x" ));
363
363
final int defaultKeyTextOffsetY =
364
- YamlUtils . INSTANCE .getPixel (
364
+ ConfigGetter .getPixel (
365
365
keyboardConfig , "key_text_offset_y" , config .getFloat ("key_text_offset_y" ));
366
366
final int defaultKeySymbolOffsetX =
367
- YamlUtils . INSTANCE .getPixel (
367
+ ConfigGetter .getPixel (
368
368
keyboardConfig , "key_symbol_offset_x" , config .getFloat ("key_symbol_offset_x" ));
369
369
final int defaultKeySymbolOffsetY =
370
- YamlUtils . INSTANCE .getPixel (
370
+ ConfigGetter .getPixel (
371
371
keyboardConfig , "key_symbol_offset_y" , config .getFloat ("key_symbol_offset_y" ));
372
372
final int defaultKeyHintOffsetX =
373
- YamlUtils . INSTANCE .getPixel (
373
+ ConfigGetter .getPixel (
374
374
keyboardConfig , "key_hint_offset_x" , config .getFloat ("key_hint_offset_x" ));
375
375
final int defaultKeyHintOffsetY =
376
- YamlUtils . INSTANCE .getPixel (
376
+ ConfigGetter .getPixel (
377
377
keyboardConfig , "key_hint_offset_y" , config .getFloat ("key_hint_offset_y" ));
378
378
final int defaultKeyPressOffsetX =
379
- YamlUtils . INSTANCE .getInt (
379
+ ConfigGetter .getInt (
380
380
keyboardConfig , "key_press_offset_x" , config .getInt ("key_press_offset_x" ));
381
381
final int defaultKeyPressOffsetY =
382
- YamlUtils . INSTANCE .getInt (
382
+ ConfigGetter .getInt (
383
383
keyboardConfig , "key_press_offset_y" , config .getInt ("key_press_offset_y" ));
384
384
385
385
final Key key = new Key (context , this , mk );
386
386
key .setKey_text_offset_x (
387
- YamlUtils . INSTANCE .getPixel (mk , "key_text_offset_x" , defaultKeyTextOffsetX ));
387
+ ConfigGetter .getPixel (mk , "key_text_offset_x" , defaultKeyTextOffsetX ));
388
388
key .setKey_text_offset_y (
389
- YamlUtils . INSTANCE .getPixel (mk , "key_text_offset_y" , defaultKeyTextOffsetY ));
389
+ ConfigGetter .getPixel (mk , "key_text_offset_y" , defaultKeyTextOffsetY ));
390
390
key .setKey_symbol_offset_x (
391
- YamlUtils . INSTANCE .getPixel (mk , "key_symbol_offset_x" , defaultKeySymbolOffsetX ));
391
+ ConfigGetter .getPixel (mk , "key_symbol_offset_x" , defaultKeySymbolOffsetX ));
392
392
key .setKey_symbol_offset_y (
393
- YamlUtils . INSTANCE .getPixel (mk , "key_symbol_offset_y" , defaultKeySymbolOffsetY ));
393
+ ConfigGetter .getPixel (mk , "key_symbol_offset_y" , defaultKeySymbolOffsetY ));
394
394
key .setKey_hint_offset_x (
395
- YamlUtils . INSTANCE .getPixel (mk , "key_hint_offset_x" , defaultKeyHintOffsetX ));
395
+ ConfigGetter .getPixel (mk , "key_hint_offset_x" , defaultKeyHintOffsetX ));
396
396
key .setKey_hint_offset_y (
397
- YamlUtils . INSTANCE .getPixel (mk , "key_hint_offset_y" , defaultKeyHintOffsetY ));
397
+ ConfigGetter .getPixel (mk , "key_hint_offset_y" , defaultKeyHintOffsetY ));
398
398
key .setKey_press_offset_x (
399
- YamlUtils . INSTANCE .getInt (mk , "key_press_offset_x" , defaultKeyPressOffsetX ));
399
+ ConfigGetter .getInt (mk , "key_press_offset_x" , defaultKeyPressOffsetX ));
400
400
key .setKey_press_offset_y (
401
- YamlUtils . INSTANCE .getInt (mk , "key_press_offset_y" , defaultKeyPressOffsetY ));
401
+ ConfigGetter .getInt (mk , "key_press_offset_y" , defaultKeyPressOffsetY ));
402
402
403
403
key .setX (x );
404
404
key .setY (y );
0 commit comments