| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
| 6 | 6 |
| 7 import android.os.SystemClock; | 7 import android.os.SystemClock; |
| 8 import android.text.Editable; | 8 import android.text.Editable; |
| 9 import android.text.InputType; | 9 import android.text.InputType; |
| 10 import android.text.Selection; | 10 import android.text.Selection; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO; | 94 outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO; |
| 95 } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTel
) { | 95 } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTel
) { |
| 96 // Telephone | 96 // Telephone |
| 97 // Number and telephone do not have both a Tab key and an | 97 // Number and telephone do not have both a Tab key and an |
| 98 // action in default OSK, so set the action to NEXT | 98 // action in default OSK, so set the action to NEXT |
| 99 outAttrs.inputType = InputType.TYPE_CLASS_PHONE; | 99 outAttrs.inputType = InputType.TYPE_CLASS_PHONE; |
| 100 outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; | 100 outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; |
| 101 } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeNum
ber) { | 101 } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeNum
ber) { |
| 102 // Number | 102 // Number |
| 103 outAttrs.inputType = InputType.TYPE_CLASS_NUMBER | 103 outAttrs.inputType = InputType.TYPE_CLASS_NUMBER |
| 104 | InputType.TYPE_NUMBER_VARIATION_NORMAL; | 104 | InputType.TYPE_NUMBER_VARIATION_NORMAL |
| 105 | InputType.TYPE_NUMBER_FLAG_DECIMAL; |
| 105 outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; | 106 outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; |
| 106 } | 107 } |
| 107 outAttrs.initialSelStart = Selection.getSelectionStart(mEditable); | 108 outAttrs.initialSelStart = Selection.getSelectionStart(mEditable); |
| 108 outAttrs.initialSelEnd = Selection.getSelectionEnd(mEditable); | 109 outAttrs.initialSelEnd = Selection.getSelectionEnd(mEditable); |
| 109 mLastUpdateSelectionStart = Selection.getSelectionStart(mEditable); | 110 mLastUpdateSelectionStart = Selection.getSelectionStart(mEditable); |
| 110 mLastUpdateSelectionEnd = Selection.getSelectionEnd(mEditable); | 111 mLastUpdateSelectionEnd = Selection.getSelectionEnd(mEditable); |
| 111 | 112 |
| 112 Selection.setSelection(mEditable, outAttrs.initialSelStart, outAttrs.ini
tialSelEnd); | 113 Selection.setSelection(mEditable, outAttrs.initialSelStart, outAttrs.ini
tialSelEnd); |
| 113 updateSelectionIfRequired(); | 114 updateSelectionIfRequired(); |
| 114 } | 115 } |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 @VisibleForTesting | 467 @VisibleForTesting |
| 467 ImeState getImeStateForTesting() { | 468 ImeState getImeStateForTesting() { |
| 468 String text = mEditable.toString(); | 469 String text = mEditable.toString(); |
| 469 int selectionStart = Selection.getSelectionStart(mEditable); | 470 int selectionStart = Selection.getSelectionStart(mEditable); |
| 470 int selectionEnd = Selection.getSelectionEnd(mEditable); | 471 int selectionEnd = Selection.getSelectionEnd(mEditable); |
| 471 int compositionStart = getComposingSpanStart(mEditable); | 472 int compositionStart = getComposingSpanStart(mEditable); |
| 472 int compositionEnd = getComposingSpanEnd(mEditable); | 473 int compositionEnd = getComposingSpanEnd(mEditable); |
| 473 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); | 474 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); |
| 474 } | 475 } |
| 475 } | 476 } |
| OLD | NEW |