Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b52d9729 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

NumberPicker does not hide IME when flinged.

Now the IME is hiddedn once the user starts flinging since he is
using another method of updating the current value. This is now
consistent with the case of shown IME and poking the up/down
button.

bug:5174339

Change-Id: Id25934f394314a285b753f0bec7f422034ada90a
parent 6918bca7
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -574,10 +574,7 @@ public class NumberPicker extends LinearLayout {

        OnClickListener onClickListener = new OnClickListener() {
            public void onClick(View v) {
                InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
                if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) {
                    inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
                }
                hideSoftInput();
                mInputText.clearFocus();
                if (v.getId() == R.id.increment) {
                    changeCurrentByOne(true);
@@ -589,6 +586,7 @@ public class NumberPicker extends LinearLayout {

        OnLongClickListener onLongClickListener = new OnLongClickListener() {
            public boolean onLongClick(View v) {
                hideSoftInput();
                mInputText.clearFocus();
                if (v.getId() == R.id.increment) {
                    postChangeCurrentByOneFromLongPress(true);
@@ -769,6 +767,7 @@ public class NumberPicker extends LinearLayout {
                    }
                    mBeginEditOnUpEvent = scrollersFinished;
                    mAdjustScrollerOnUpEvent = true;
                    hideSoftInput();
                    hideInputControls();
                    return true;
                }
@@ -778,6 +777,7 @@ public class NumberPicker extends LinearLayout {
                }
                mAdjustScrollerOnUpEvent = false;
                setSelectorWheelState(SELECTOR_WHEEL_STATE_LARGE);
                hideSoftInput();
                hideInputControls();
                return true;
            case MotionEvent.ACTION_MOVE:
@@ -787,6 +787,7 @@ public class NumberPicker extends LinearLayout {
                    mBeginEditOnUpEvent = false;
                    onScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
                    setSelectorWheelState(SELECTOR_WHEEL_STATE_LARGE);
                    hideSoftInput();
                    hideInputControls();
                    return true;
                }
@@ -1044,6 +1045,16 @@ public class NumberPicker extends LinearLayout {
        invalidate();
    }

    /**
     * Hides the soft input of it is active for the input text.
     */
    private void hideSoftInput() {
        InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
        if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) {
            inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
        }
    }

    /**
     * Computes the max width if no such specified as an attribute.
     */