38
38
import android .view .LayoutInflater ;
39
39
import android .view .MotionEvent ;
40
40
import android .view .View ;
41
- import android .view .ViewConfiguration ;
42
41
import android .view .ViewGroup ;
43
42
import android .view .inputmethod .EditorInfo ;
44
43
import android .widget .PopupWindow ;
@@ -202,17 +201,12 @@ public interface OnKeyboardActionListener {
202
201
private int mComboCount = 0 ;
203
202
private boolean mComboMode = false ;
204
203
205
- private static int REPEAT_INTERVAL = 50 ; // ~20 keys per second
206
- private static int REPEAT_START_DELAY = 400 ;
207
- private static int LONG_PRESS_TIMEOUT = ViewConfiguration .getLongPressTimeout ();
208
-
209
204
private static final int MAX_NEARBY_KEYS = 12 ;
210
205
private final int [] mDistances = new int [MAX_NEARBY_KEYS ];
211
206
212
207
// For multi-tap
213
208
private int mLastSentIndex ;
214
209
private long mLastTapTime ;
215
- private static int MULTI_TAP_INTERVAL = 800 ; // milliseconds
216
210
private final StringBuilder mPreviewLabel = new StringBuilder (1 );
217
211
218
212
/** Whether the keyboard bitmap needs to be redrawn before it's blitted. * */
@@ -298,8 +292,8 @@ public void setEnterLabel(int action, CharSequence actionLabel) {
298
292
}
299
293
300
294
@ NonNull
301
- private AppPrefs getPrefs () {
302
- return AppPrefs .Companion . defaultInstance ();
295
+ private static AppPrefs getPrefs () {
296
+ return AppPrefs .defaultInstance ();
303
297
}
304
298
305
299
private final MyHandler mHandler = new MyHandler (this );
@@ -324,7 +318,7 @@ public void handleMessage(Message msg) {
324
318
case MSG_REPEAT :
325
319
if (mKeyboardView .repeatKey ()) {
326
320
Message repeat = Message .obtain (this , MSG_REPEAT );
327
- sendMessageDelayed (repeat , REPEAT_INTERVAL );
321
+ sendMessageDelayed (repeat , getPrefs (). getKeyboard (). getRepeatInterval () );
328
322
}
329
323
break ;
330
324
case MSG_LONGPRESS :
@@ -403,11 +397,6 @@ public void reset() {
403
397
mPaintSymbol .setTextSize (mSymbolSize );
404
398
mPreviewText .setTypeface (config .getFont ("preview_font" ));
405
399
406
- REPEAT_INTERVAL = config .getRepeatInterval ();
407
- REPEAT_START_DELAY = config .getLongTimeout () + 1 ;
408
- LONG_PRESS_TIMEOUT = config .getLongTimeout ();
409
- MULTI_TAP_INTERVAL = config .getLongTimeout ();
410
-
411
400
mEnterLabels = config .getmEnterLabels ();
412
401
enterLabelMode = config .getInt ("enter_label_mode" );
413
402
invalidateAllKeys ();
@@ -1576,7 +1565,8 @@ else if (action == MotionEvent.ACTION_UP)
1576
1565
if (mCurrentKey >= 0 && mKeys [mCurrentKey ].getClick ().isRepeatable ()) {
1577
1566
mRepeatKeyIndex = mCurrentKey ;
1578
1567
final Message msg = mHandler .obtainMessage (MSG_REPEAT );
1579
- mHandler .sendMessageDelayed (msg , REPEAT_START_DELAY );
1568
+ final int repeatStartDelay = getPrefs ().getKeyboard ().getLongPressTimeout () + 1 ;
1569
+ mHandler .sendMessageDelayed (msg , repeatStartDelay );
1580
1570
// Delivering the key could have caused an abort
1581
1571
if (mAbortKey ) {
1582
1572
mRepeatKeyIndex = NOT_A_KEY ;
@@ -1585,7 +1575,7 @@ else if (action == MotionEvent.ACTION_UP)
1585
1575
}
1586
1576
if (mCurrentKey != NOT_A_KEY ) {
1587
1577
final Message msg = mHandler .obtainMessage (MSG_LONGPRESS , me );
1588
- mHandler .sendMessageDelayed (msg , LONG_PRESS_TIMEOUT );
1578
+ mHandler .sendMessageDelayed (msg , getPrefs (). getKeyboard (). getLongPressTimeout () );
1589
1579
}
1590
1580
showPreview (keyIndex , 0 );
1591
1581
break ;
@@ -1617,7 +1607,7 @@ else if (action == MotionEvent.ACTION_UP)
1617
1607
// Start new long press if key has changed
1618
1608
if (keyIndex != NOT_A_KEY ) {
1619
1609
final Message msg = mHandler .obtainMessage (MSG_LONGPRESS , me );
1620
- mHandler .sendMessageDelayed (msg , LONG_PRESS_TIMEOUT );
1610
+ mHandler .sendMessageDelayed (msg , getPrefs (). getKeyboard (). getLongPressTimeout () );
1621
1611
}
1622
1612
}
1623
1613
showPreview (mCurrentKey );
@@ -1768,7 +1758,8 @@ private void resetMultiTap() {
1768
1758
private void checkMultiTap (long eventTime , int keyIndex ) {
1769
1759
if (keyIndex == NOT_A_KEY ) return ;
1770
1760
// final Key key = mKeys[keyIndex];
1771
- if (eventTime > mLastTapTime + MULTI_TAP_INTERVAL || keyIndex != mLastSentIndex ) {
1761
+ final int multiTabInterval = getPrefs ().getKeyboard ().getLongPressTimeout ();
1762
+ if (eventTime > mLastTapTime + multiTabInterval || keyIndex != mLastSentIndex ) {
1772
1763
resetMultiTap ();
1773
1764
}
1774
1765
}
0 commit comments