Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

samsung soft keyboard loses keystrokes after focus change

My app uses a PIN-based login. I have four EditText views in a row and set a separate instance of the following TextWatcher on each of them:

private class PinDigitWatcher implements TextWatcher {

    private final EditText digit;

    public PinDigitWatcher(EditText digit) {
        this.digit = digit;
    }

    @Override
    public void afterTextChanged(Editable s) {
        if (s.length() <= 0)
            return;
        switch (digit.getId()) {
        case R.id.pin_digit_a:
            mPinDigitB.setFocusableInTouchMode(true);
            mPinDigitB.requestFocus();
            mPinDigitA.setFocusable(false);
            break;
        case R.id.pin_digit_b:
            mPinDigitC.setFocusableInTouchMode(true);
            mPinDigitC.requestFocus();
            mPinDigitB.setFocusable(false);
            break;
        case R.id.pin_digit_c:
            mPinDigitD.setFocusableInTouchMode(true);
            mPinDigitD.requestFocus();
            mPinDigitC.setFocusable(false);
            break;
        case R.id.pin_digit_d:
            mPinDigitD.setFocusable(false);
            onSubmitPin();
            break;
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) { }
}

Each time the user enters text into one of the EditText views the TextWatcher moves focus to the "next" one. If the user enters text on the last one the request is sent to the server.

This work great on all the devices I've tested except for the Samsung S3 and S4. On these devices there's a half-second delay after the focus change when the user taps a key on the soft keyboard. The result is that if the user taps the first EditText to bring up the keyboard then taps a digit four times in quick succession (e.g. if his PIN is "1111") the first digit is registered, focus changes, but the other three digits are dropped.

I went into the "Samsung keyboard settings" and disabled predictive text, auto replacement, auto capitalization, auto spacing and auto punctuate. Didn't seem to make a difference.

Both my S3 and S4 are running Android 4.3 so, unfortunately, I can't tell whether this is a "Samsung issue" or a "Android 4.3 issue". I've verified that it doesn't happen on a Galaxy Nexus running 4.2.2 and a Nexus 4 running 4.4.2.

Any thoughts on a work-around?

EDIT:

I recreated the issue on a Samsung S4 running Android 4.2.2 so it appears to be a Samsung problem and not Android 4.3 specifically. Here is a working project that illustrates the behavior:

https://drive.google.com/file/d/0B6DvDY2BvxUTRUxZNE5DNXJJM2c

Tap on the fist EditText to bring up the soft keyboard then tap any number key four times in quick succession. Only the first tap will be registered. At the conclusion of the four taps the focus will be on the second EditText (from the left).

EDIT:

More info on the two phones that exhibit the problem:

  • S4: Samsung SGH-I337, Android 4.3, Build: JSS15J.I337UCUEMK2, Kernel: 3.4.0-1921628 Nov 16 2013)
  • S3: Samsung SGH-I747, Android 4.3, Build: JSS15J.I747UCUEMJB, Kernel: 3.0.31-2024954 Oct 31 2013)
like image 908
jph Avatar asked Feb 08 '14 14:02

jph


People also ask

Why does my Android keyboard keep disappearing?

Check Your Keyboard Settings Make sure Gboard is set as your default keyboard. If your Android device automatically switched to a different keyboard, that might explain why Gboard disappeared from your keyboard list. By the way, this often happens shortly after you install a new Android version on your device.

Why did my Samsung keyboard disappeared?

It has to do with the touch input on the phone's screen. When a Galaxy device has an edge display, touch input is available along the screen's edges. Because of this, the keyboard may accidentally disappear if you unintentionally touch the edge while typing with the keyboard.

Where did my keyboard go Samsung?

If you don't find the Samsung Keyboard settings via the above steps, go to “Settings -> General Management -> Language and input -> On-screen keyboard -> Samsung Keyboard.” Alternatively, open the Samsung Keyboard while using any app, then tap on the Settings icon on the keyboard to go to its settings.


1 Answers

A quick guess: Try doing your check in the onTextChanged(CharSequence s, int start, int before, int count) method of TextWatcher.

As onTextChanged() is called before afterTextChanged(), it may cause the Samsung devices to recognize the focus switch faster and therefore avoid the delay that causes your trouble.

Also, try playing around with the inputType attribute of your EditText (e.g. set it to number or textNoSuggestions) to further improve speed.

like image 132
saschoar Avatar answered Sep 27 '22 20:09

saschoar