Bug 945521 - Make sure button text type is consistent with keyboard text type; r=mcomella

This commit is contained in:
Jim Chen 2013-12-20 17:48:59 -05:00
Родитель b5ad221892
Коммит b0775082df
2 изменённых файлов: 23 добавлений и 7 удалений

Просмотреть файл

@ -66,6 +66,7 @@ final public class InputMethods {
@RobocopTarget
public static boolean shouldDisableUrlBarUpdate(Context context) {
String inputMethod = getCurrentInputMethod(context);
// HTC Touch Input does not react well to restarting during input (bug 909940)
return METHOD_HTC_TOUCH_INPUT.equals(inputMethod);
}

Просмотреть файл

@ -47,7 +47,10 @@ public class ToolbarEditText extends CustomEditText
private final Context mContext;
private TextType mTextType;
// Type of the URL bar go/search button
private TextType mToolbarTextType;
// Type of the keyboard go/search button (cannot be EMPTY)
private TextType mKeyboardTextType;
private OnCommitListener mCommitListener;
private OnDismissListener mDismissListener;
@ -66,7 +69,8 @@ public class ToolbarEditText extends CustomEditText
super(context, attrs);
mContext = context;
mTextType = TextType.EMPTY;
mToolbarTextType = TextType.EMPTY;
mKeyboardTextType = TextType.URL;
}
void setOnCommitListener(OnCommitListener listener) {
@ -172,10 +176,13 @@ public class ToolbarEditText extends CustomEditText
}
private void setTextType(TextType textType) {
mTextType = textType;
mToolbarTextType = textType;
if (textType != TextType.EMPTY) {
mKeyboardTextType = textType;
}
if (mTextTypeListener != null) {
mTextTypeListener.onTextTypeChange(this, mTextType);
mTextTypeListener.onTextTypeChange(this, textType);
}
}
@ -186,6 +193,8 @@ public class ToolbarEditText extends CustomEditText
}
if (InputMethods.shouldDisableUrlBarUpdate(mContext)) {
// Set button type to match the previous keyboard type
setTextType(mKeyboardTextType);
return;
}
@ -222,10 +231,16 @@ public class ToolbarEditText extends CustomEditText
restartInput = true;
}
if (restartInput) {
if (!restartInput) {
// If the text content was previously empty, the toolbar text type
// is empty as well. Since the keyboard text type cannot be empty,
// the two text types are now inconsistent. Reset the toolbar text
// type here to the keyboard text type to ensure consistency.
setTextType(mKeyboardTextType);
return;
}
updateKeyboardInputType();
imm.restartInput(ToolbarEditText.this);
}
setTextType(imeAction == EditorInfo.IME_ACTION_GO ?
TextType.URL : TextType.SEARCH_QUERY);