3838import android .view .LayoutInflater ;
3939import android .view .MotionEvent ;
4040import android .view .View ;
41- import android .view .ViewConfiguration ;
4241import android .view .ViewGroup ;
4342import android .view .inputmethod .EditorInfo ;
4443import android .widget .PopupWindow ;
@@ -202,17 +201,12 @@ public interface OnKeyboardActionListener {
202201 private int mComboCount = 0 ;
203202 private boolean mComboMode = false ;
204203
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-
209204 private static final int MAX_NEARBY_KEYS = 12 ;
210205 private final int [] mDistances = new int [MAX_NEARBY_KEYS ];
211206
212207 // For multi-tap
213208 private int mLastSentIndex ;
214209 private long mLastTapTime ;
215- private static int MULTI_TAP_INTERVAL = 800 ; // milliseconds
216210 private final StringBuilder mPreviewLabel = new StringBuilder (1 );
217211
218212 /** Whether the keyboard bitmap needs to be redrawn before it's blitted. * */
@@ -298,8 +292,8 @@ public void setEnterLabel(int action, CharSequence actionLabel) {
298292 }
299293
300294 @ NonNull
301- private AppPrefs getPrefs () {
302- return AppPrefs .Companion . defaultInstance ();
295+ private static AppPrefs getPrefs () {
296+ return AppPrefs .defaultInstance ();
303297 }
304298
305299 private final MyHandler mHandler = new MyHandler (this );
@@ -324,7 +318,7 @@ public void handleMessage(Message msg) {
324318 case MSG_REPEAT :
325319 if (mKeyboardView .repeatKey ()) {
326320 Message repeat = Message .obtain (this , MSG_REPEAT );
327- sendMessageDelayed (repeat , REPEAT_INTERVAL );
321+ sendMessageDelayed (repeat , getPrefs (). getKeyboard (). getRepeatInterval () );
328322 }
329323 break ;
330324 case MSG_LONGPRESS :
@@ -403,11 +397,6 @@ public void reset() {
403397 mPaintSymbol .setTextSize (mSymbolSize );
404398 mPreviewText .setTypeface (config .getFont ("preview_font" ));
405399
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-
411400 mEnterLabels = config .getmEnterLabels ();
412401 enterLabelMode = config .getInt ("enter_label_mode" );
413402 invalidateAllKeys ();
@@ -1576,7 +1565,8 @@ else if (action == MotionEvent.ACTION_UP)
15761565 if (mCurrentKey >= 0 && mKeys [mCurrentKey ].getClick ().isRepeatable ()) {
15771566 mRepeatKeyIndex = mCurrentKey ;
15781567 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 );
15801570 // Delivering the key could have caused an abort
15811571 if (mAbortKey ) {
15821572 mRepeatKeyIndex = NOT_A_KEY ;
@@ -1585,7 +1575,7 @@ else if (action == MotionEvent.ACTION_UP)
15851575 }
15861576 if (mCurrentKey != NOT_A_KEY ) {
15871577 final Message msg = mHandler .obtainMessage (MSG_LONGPRESS , me );
1588- mHandler .sendMessageDelayed (msg , LONG_PRESS_TIMEOUT );
1578+ mHandler .sendMessageDelayed (msg , getPrefs (). getKeyboard (). getLongPressTimeout () );
15891579 }
15901580 showPreview (keyIndex , 0 );
15911581 break ;
@@ -1617,7 +1607,7 @@ else if (action == MotionEvent.ACTION_UP)
16171607 // Start new long press if key has changed
16181608 if (keyIndex != NOT_A_KEY ) {
16191609 final Message msg = mHandler .obtainMessage (MSG_LONGPRESS , me );
1620- mHandler .sendMessageDelayed (msg , LONG_PRESS_TIMEOUT );
1610+ mHandler .sendMessageDelayed (msg , getPrefs (). getKeyboard (). getLongPressTimeout () );
16211611 }
16221612 }
16231613 showPreview (mCurrentKey );
@@ -1768,7 +1758,8 @@ private void resetMultiTap() {
17681758 private void checkMultiTap (long eventTime , int keyIndex ) {
17691759 if (keyIndex == NOT_A_KEY ) return ;
17701760 // 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 ) {
17721763 resetMultiTap ();
17731764 }
17741765 }
0 commit comments