Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java

Issue 11418295: Use WebCore:DateTimeChooser for date/time form types instead of considering them text fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
index 2160d13f618c3e9c603fb0cfd373d66558d37974..0e8dd820772bbf4660465b21ff4d728ef82da401 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
@@ -160,14 +160,16 @@ class ImeAdapter {
mHandler = new Handler();
mInputDialogContainer = new InputDialogContainer(context,
new InputDialogContainer.InputActionDelegate() {
+
@Override
- public void clearFocus() {
- nativeClearFocus(mNativeImeAdapterAndroid);
+ public void replaceDateTime(String text) {
+ mViewEmbedder.onSetFieldValue();
+ nativeReplaceDateTime(mNativeImeAdapterAndroid, text);
}
+
@Override
- public void replaceText(String text) {
- nativeReplaceText(mNativeImeAdapterAndroid, text);
- mViewEmbedder.onSetFieldValue();
+ public void cancelDateTimeDialog() {
+ nativeCancelDialog(mNativeImeAdapterAndroid);
}
});
}
@@ -494,6 +496,7 @@ class ImeAdapter {
static public class AdapterInputConnection extends BaseInputConnection {
private View mInternalView;
private ImeAdapter mImeAdapter;
+ private Editable mEditable;
private boolean mSingleLine;
private int numBatchEdits;
private boolean shouldUpdateImeSelection;
@@ -522,13 +525,16 @@ class ImeAdapter {
public void setEditableText(String text, int selectionStart, int selectionEnd,
int compositionStart, int compositionEnd) {
- Editable editable = getEditable();
- int prevSelectionStart = Selection.getSelectionStart(editable);
- int prevSelectionEnd = Selection.getSelectionEnd(editable);
- int prevEditableLength = editable.length();
- int prevCompositionStart = getComposingSpanStart(editable);
- int prevCompositionEnd = getComposingSpanEnd(editable);
- String prevText = editable.toString();
+ if (mEditable == null) {
+ mEditable = Editable.Factory.getInstance().newEditable("");
+ }
+
+ int prevSelectionStart = Selection.getSelectionStart(mEditable);
+ int prevSelectionEnd = Selection.getSelectionEnd(mEditable);
+ int prevEditableLength = mEditable.length();
+ int prevCompositionStart = getComposingSpanStart(mEditable);
+ int prevCompositionEnd = getComposingSpanEnd(mEditable);
+ String prevText = mEditable.toString();
selectionStart = Math.min(selectionStart, text.length());
selectionEnd = Math.min(selectionEnd, text.length());
@@ -553,9 +559,9 @@ class ImeAdapter {
}
if (!textUnchanged) {
- editable.replace(0, editable.length(), text);
+ mEditable.replace(0, mEditable.length(), text);
}
- Selection.setSelection(editable, selectionStart, selectionEnd);
+ Selection.setSelection(mEditable, selectionStart, selectionEnd);
super.setComposingRegion(compositionStart, compositionEnd);
if (textUnchanged || prevText.equals("")) {
@@ -568,6 +574,15 @@ class ImeAdapter {
}
@Override
+ public Editable getEditable() {
+ if (mEditable == null) {
+ mEditable = Editable.Factory.getInstance().newEditable("");
+ Selection.setSelection(mEditable, 0);
+ }
+ return mEditable;
+ }
+
+ @Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
super.setComposingText(text, newCursorPosition);
shouldUpdateImeSelection = true;
@@ -621,14 +636,13 @@ class ImeAdapter {
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
ExtractedText et = new ExtractedText();
- Editable editable = getEditable();
- if (editable == null) {
+ if (mEditable == null) {
et.text = "";
} else {
- et.text = editable.toString();
- et.partialEndOffset = editable.length();
- et.selectionStart = Selection.getSelectionStart(editable);
- et.selectionEnd = Selection.getSelectionEnd(editable);
+ et.text = mEditable.toString();
+ et.partialEndOffset = mEditable.length();
+ et.selectionStart = Selection.getSelectionStart(mEditable);
+ et.selectionEnd = Selection.getSelectionEnd(mEditable);
}
et.flags = mSingleLine ? ExtractedText.FLAG_SINGLE_LINE : 0;
return et;
@@ -678,9 +692,8 @@ class ImeAdapter {
@Override
public boolean finishComposingText() {
- Editable editable = getEditable();
- if (editable == null
- || (getComposingSpanStart(editable) == getComposingSpanEnd(editable))) {
+ if (mEditable == null
+ || (getComposingSpanStart(mEditable) == getComposingSpanEnd(mEditable))) {
return true;
}
super.finishComposingText();
@@ -722,13 +735,12 @@ class ImeAdapter {
}
private void updateImeSelection() {
- Editable editable = getEditable();
- if (editable != null) {
+ if (mEditable != null) {
getInputMethodManager().updateSelection(mInternalView,
- Selection.getSelectionStart(editable),
- Selection.getSelectionEnd(editable),
- getComposingSpanStart(editable),
- getComposingSpanEnd(editable));
+ Selection.getSelectionStart(mEditable),
+ Selection.getSelectionEnd(mEditable),
+ getComposingSpanStart(mEditable),
+ getComposingSpanEnd(mEditable));
}
}
@@ -814,9 +826,9 @@ class ImeAdapter {
private native void nativeAttachImeAdapter(int nativeImeAdapterAndroid);
- private native void nativeReplaceText(int nativeImeAdapterAndroid, String text);
+ private native void nativeReplaceDateTime(int nativeImeAdapterAndroid, String text);
- private native void nativeClearFocus(int nativeImeAdapterAndroid);
+ private native void nativeCancelDialog(int nativeImeAdapterAndroid);
private native void nativeSetEditableSelectionOffsets(int nativeImeAdapterAndroid,
int start, int end);

Powered by Google App Engine
This is Rietveld 408576698