28
28
import com .osfans .trime .data .Config ;
29
29
import com .osfans .trime .ime .enums .KeyEventType ;
30
30
import com .osfans .trime .util .ConfigGetter ;
31
+ import java .text .MessageFormat ;
32
+ import java .util .Arrays ;
31
33
import java .util .Locale ;
32
34
import java .util .Map ;
33
35
import timber .log .Timber ;
@@ -48,13 +50,14 @@ public class Key {
48
50
public static final int [] KEY_STATE_PRESSED = {android .R .attr .state_pressed };
49
51
public static final int [][] KEY_STATES =
50
52
new int [][] {
51
- KEY_STATE_PRESSED_ON , // 0
52
- KEY_STATE_PRESSED_OFF , // 1
53
- KEY_STATE_NORMAL_ON , // 2
54
- KEY_STATE_NORMAL_OFF , // 3
55
- KEY_STATE_PRESSED , // 4
56
- KEY_STATE_NORMAL // 5
53
+ KEY_STATE_PRESSED_ON , // 0 "hilited_on_key_back_color" 锁定时按下的背景
54
+ KEY_STATE_PRESSED_OFF , // 1 "hilited_off_key_back_color" 功能键按下的背景
55
+ KEY_STATE_NORMAL_ON , // 2 "on_key_back_color" 锁定时背景
56
+ KEY_STATE_NORMAL_OFF , // 3 "off_key_back_color" 功能键背景
57
+ KEY_STATE_PRESSED , // 4 "hilited_key_back_color" 按键按下的背景
58
+ KEY_STATE_NORMAL // 5 "key_back_color" 按键背景
57
59
};
60
+
58
61
public static Map <String , Map <String , String >> presetKeys ;
59
62
private static final int EVENT_NUM = KeyEventType .values ().length ;
60
63
public Event [] events = new Event [EVENT_NUM ];
@@ -321,9 +324,7 @@ public int getKey_offset_y() {
321
324
}
322
325
323
326
private boolean isNormal (int [] drawableState ) {
324
- return (drawableState == KEY_STATE_NORMAL
325
- || drawableState == KEY_STATE_NORMAL_ON
326
- || drawableState == KEY_STATE_NORMAL_OFF );
327
+ return (drawableState == KEY_STATE_NORMAL || drawableState == KEY_STATE_NORMAL_OFF );
327
328
}
328
329
329
330
public Drawable getBackColorForState (int [] drawableState ) {
@@ -428,8 +429,6 @@ public void printModifierKeyState() {
428
429
public int [] getCurrentDrawableState () {
429
430
int [] states = KEY_STATE_NORMAL ;
430
431
boolean isShifted = isTrimeModifierKey () && mKeyboard .hasModifier (getModifierKeyOnMask ());
431
- // only for modiferKey debug
432
- if (isTrimeModifierKey ()) mKeyboard .printModifierKeyState ("getCurrentDrawableState" );
433
432
434
433
if (isShifted || on ) {
435
434
if (pressed ) {
@@ -450,6 +449,18 @@ public int[] getCurrentDrawableState() {
450
449
}
451
450
}
452
451
}
452
+
453
+ // only for modiferKey debug
454
+ if (isTrimeModifierKey ())
455
+ mKeyboard .printModifierKeyState (
456
+ MessageFormat .format (
457
+ "getCurrentDrawableState() Key={0} states={1} on={2} isShifted={3} pressed={4} sticky={5}" ,
458
+ getLabel (),
459
+ Arrays .asList (KEY_STATES ).indexOf (states ),
460
+ on ,
461
+ isShifted ,
462
+ pressed ,
463
+ getClick ().isSticky ()));
453
464
return states ;
454
465
}
455
466
0 commit comments