Merge "Refresh editor info when the text field attributes changes." into jb-mr1-dev
This commit is contained in:
commit
91c64902b0
3 changed files with 17 additions and 5 deletions
|
@ -29,10 +29,12 @@ public class InputAttributes {
|
||||||
final public boolean mInputTypeNoAutoCorrect;
|
final public boolean mInputTypeNoAutoCorrect;
|
||||||
final public boolean mIsSettingsSuggestionStripOn;
|
final public boolean mIsSettingsSuggestionStripOn;
|
||||||
final public boolean mApplicationSpecifiedCompletionOn;
|
final public boolean mApplicationSpecifiedCompletionOn;
|
||||||
|
final private int mInputType;
|
||||||
|
|
||||||
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) {
|
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) {
|
||||||
final int inputType = null != editorInfo ? editorInfo.inputType : 0;
|
final int inputType = null != editorInfo ? editorInfo.inputType : 0;
|
||||||
final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
|
final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
|
||||||
|
mInputType = inputType;
|
||||||
if (inputClass != InputType.TYPE_CLASS_TEXT) {
|
if (inputClass != InputType.TYPE_CLASS_TEXT) {
|
||||||
// If we are not looking at a TYPE_CLASS_TEXT field, the following strange
|
// If we are not looking at a TYPE_CLASS_TEXT field, the following strange
|
||||||
// cases may arise, so we do a couple sanity checks for them. If it's a
|
// cases may arise, so we do a couple sanity checks for them. If it's a
|
||||||
|
@ -93,6 +95,10 @@ public class InputAttributes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSameInputType(final EditorInfo editorInfo) {
|
||||||
|
return editorInfo.inputType == mInputType;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private void dumpFlags(final int inputType) {
|
private void dumpFlags(final int inputType) {
|
||||||
Log.i(TAG, "Input class:");
|
Log.i(TAG, "Input class:");
|
||||||
|
|
|
@ -670,7 +670,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
accessUtils.onStartInputViewInternal(mainKeyboardView, editorInfo, restarting);
|
accessUtils.onStartInputViewInternal(mainKeyboardView, editorInfo, restarting);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!restarting) {
|
final boolean selectionChanged = mLastSelectionStart != editorInfo.initialSelStart
|
||||||
|
|| mLastSelectionEnd != editorInfo.initialSelEnd;
|
||||||
|
final boolean inputTypeChanged = !mCurrentSettings.isSameInputType(editorInfo);
|
||||||
|
final boolean isDifferentTextField = !restarting || inputTypeChanged;
|
||||||
|
if (isDifferentTextField) {
|
||||||
mSubtypeSwitcher.updateParametersOnStartInputView();
|
mSubtypeSwitcher.updateParametersOnStartInputView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,9 +683,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
updateFullscreenMode();
|
updateFullscreenMode();
|
||||||
mApplicationSpecifiedCompletions = null;
|
mApplicationSpecifiedCompletions = null;
|
||||||
|
|
||||||
final boolean selectionChanged = mLastSelectionStart != editorInfo.initialSelStart
|
if (isDifferentTextField || selectionChanged) {
|
||||||
|| mLastSelectionEnd != editorInfo.initialSelEnd;
|
|
||||||
if (!restarting || selectionChanged) {
|
|
||||||
// If the selection changed, we reset the input state. Essentially, we come here with
|
// If the selection changed, we reset the input state. Essentially, we come here with
|
||||||
// restarting == true when the app called setText() or similar. We should reset the
|
// restarting == true when the app called setText() or similar. We should reset the
|
||||||
// state if the app set the text to something else, but keep it if it set a suggestion
|
// state if the app set the text to something else, but keep it if it set a suggestion
|
||||||
|
@ -696,7 +698,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!restarting) {
|
if (isDifferentTextField) {
|
||||||
mainKeyboardView.closing();
|
mainKeyboardView.closing();
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,10 @@ public class SettingsValues {
|
||||||
prefs.edit().putString(Settings.PREF_LAST_USER_DICTIONARY_WRITE_TIME, newStr).apply();
|
prefs.edit().putString(Settings.PREF_LAST_USER_DICTIONARY_WRITE_TIME, newStr).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSameInputType(final EditorInfo editorInfo) {
|
||||||
|
return mInputAttributes.isSameInputType(editorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
// For debug.
|
// For debug.
|
||||||
public String getInputAttributesDebugString() {
|
public String getInputAttributesDebugString() {
|
||||||
return mInputAttributes.toString();
|
return mInputAttributes.toString();
|
||||||
|
|
Loading…
Reference in a new issue