(DO NOT MERGE) Update fullscreen mode also at onStartInputView

This is a cherry-pick cheof I190a71f7 from Master.

Bug: 5315001
Change-Id: I76c756eeecf21eec4c88dd4558d5c50f10ff3d3c
main
Tadashi G. Takaoka 2011-09-20 14:57:31 +09:00
parent 43d8dee6ac
commit 6d8d25ee5a
2 changed files with 17 additions and 28 deletions

View File

@ -26,16 +26,12 @@ public class EditorInfoCompatUtils {
EditorInfo.class, "IME_FLAG_NAVIGATE_NEXT"); EditorInfo.class, "IME_FLAG_NAVIGATE_NEXT");
private static final Field FIELD_IME_FLAG_NAVIGATE_PREVIOUS = CompatUtils.getField( private static final Field FIELD_IME_FLAG_NAVIGATE_PREVIOUS = CompatUtils.getField(
EditorInfo.class, "IME_FLAG_NAVIGATE_PREVIOUS"); EditorInfo.class, "IME_FLAG_NAVIGATE_PREVIOUS");
private static final Field FIELD_IME_FLAG_NO_FULLSCREEN = CompatUtils.getField(
EditorInfo.class, "IME_FLAG_NO_FULLSCREEN");
private static final Field FIELD_IME_ACTION_PREVIOUS = CompatUtils.getField( private static final Field FIELD_IME_ACTION_PREVIOUS = CompatUtils.getField(
EditorInfo.class, "IME_ACTION_PREVIOUS"); EditorInfo.class, "IME_ACTION_PREVIOUS");
private static final Integer OBJ_IME_FLAG_NAVIGATE_NEXT = (Integer) CompatUtils private static final Integer OBJ_IME_FLAG_NAVIGATE_NEXT = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_NEXT); .getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_NEXT);
private static final Integer OBJ_IME_FLAG_NAVIGATE_PREVIOUS = (Integer) CompatUtils private static final Integer OBJ_IME_FLAG_NAVIGATE_PREVIOUS = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_PREVIOUS); .getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_PREVIOUS);
private static final Integer OBJ_IME_FLAG_NO_FULLSCREEN = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_IME_FLAG_NO_FULLSCREEN);
private static final Integer OBJ_IME_ACTION_PREVIOUS = (Integer) CompatUtils private static final Integer OBJ_IME_ACTION_PREVIOUS = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_IME_ACTION_PREVIOUS); .getFieldValue(null, null, FIELD_IME_ACTION_PREVIOUS);
@ -51,12 +47,6 @@ public class EditorInfoCompatUtils {
return (imeOptions & OBJ_IME_FLAG_NAVIGATE_PREVIOUS) != 0; return (imeOptions & OBJ_IME_FLAG_NAVIGATE_PREVIOUS) != 0;
} }
public static boolean hasFlagNoFullscreen(int imeOptions) {
if (FIELD_IME_FLAG_NO_FULLSCREEN == null)
return false;
return (imeOptions & OBJ_IME_FLAG_NO_FULLSCREEN) != 0;
}
public static void performEditorActionNext(InputConnection ic) { public static void performEditorActionNext(InputConnection ic) {
ic.performEditorAction(EditorInfo.IME_ACTION_NEXT); ic.performEditorAction(EditorInfo.IME_ACTION_NEXT);
} }

View File

@ -158,7 +158,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private View mKeyPreviewBackingView; private View mKeyPreviewBackingView;
private View mSuggestionsContainer; private View mSuggestionsContainer;
private int mSuggestionsStripHeight;
private SuggestionsView mSuggestionsView; private SuggestionsView mSuggestionsView;
private Suggest mSuggest; private Suggest mSuggest;
private CompletionInfo[] mApplicationSpecifiedCompletions; private CompletionInfo[] mApplicationSpecifiedCompletions;
@ -612,7 +611,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view); mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view);
if (mSuggestionsView != null) if (mSuggestionsView != null)
mSuggestionsView.setListener(this, view); mSuggestionsView.setListener(this, view);
mSuggestionsStripHeight = (int)mResources.getDimension(R.dimen.suggestions_strip_height);
} }
@Override @Override
@ -681,6 +679,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (mSuggestionsView != null) if (mSuggestionsView != null)
mSuggestionsView.clear(); mSuggestionsView.clear();
// The EditorInfo might have a flag that affects fullscreen mode.
updateFullscreenMode();
setSuggestionStripShownInternal( setSuggestionStripShownInternal(
isSuggestionsStripVisible(), /* needsInputViewShown */ false); isSuggestionsStripVisible(), /* needsInputViewShown */ false);
// Delay updating suggestions because keyboard input view may not be shown at this point. // Delay updating suggestions because keyboard input view may not be shown at this point.
@ -945,14 +945,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final boolean shouldShowSuggestions = shown final boolean shouldShowSuggestions = shown
&& (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true); && (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true);
if (isFullscreenMode()) { if (isFullscreenMode()) {
// No need to have extra space to show the key preview.
mKeyPreviewBackingView.setVisibility(View.GONE);
mSuggestionsContainer.setVisibility( mSuggestionsContainer.setVisibility(
shouldShowSuggestions ? View.VISIBLE : View.GONE); shouldShowSuggestions ? View.VISIBLE : View.GONE);
} else { } else {
// We must control the visibility of the suggestion strip in order to avoid clipped
// key previews, even when we don't show the suggestion strip.
mKeyPreviewBackingView.setVisibility(View.VISIBLE);
mSuggestionsContainer.setVisibility( mSuggestionsContainer.setVisibility(
shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE); shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE);
} }
@ -971,12 +966,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return; return;
final int backingHeight = (mKeyPreviewBackingView.getVisibility() == View.GONE) ? 0 final int backingHeight = (mKeyPreviewBackingView.getVisibility() == View.GONE) ? 0
: mKeyPreviewBackingView.getHeight(); : mKeyPreviewBackingView.getHeight();
final int extraHeight = mSuggestionsContainer.getHeight() + backingHeight; final int suggestionsHeight = (mSuggestionsContainer.getVisibility() == View.GONE) ? 0
: mSuggestionsContainer.getHeight();
final int extraHeight = backingHeight + suggestionsHeight;
int touchY = extraHeight; int touchY = extraHeight;
// Need to set touchable region only if input view is being shown // Need to set touchable region only if input view is being shown
if (mKeyboardSwitcher.isInputViewShown()) { if (mKeyboardSwitcher.isInputViewShown()) {
if (mSuggestionsContainer.getVisibility() == View.VISIBLE) { if (mSuggestionsContainer.getVisibility() == View.VISIBLE) {
touchY -= mSuggestionsStripHeight; touchY -= suggestionsHeight;
} }
final int touchWidth = inputView.getWidth(); final int touchWidth = inputView.getWidth();
final int touchHeight = inputView.getHeight() + extraHeight final int touchHeight = inputView.getHeight() + extraHeight
@ -994,16 +991,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override @Override
public boolean onEvaluateFullscreenMode() { public boolean onEvaluateFullscreenMode() {
final EditorInfo ei = getCurrentInputEditorInfo(); return super.onEvaluateFullscreenMode()
if (ei != null) { && mResources.getBoolean(R.bool.config_use_fullscreen_mode);
final int imeOptions = ei.imeOptions;
if (EditorInfoCompatUtils.hasFlagNoFullscreen(imeOptions))
return false;
if ((imeOptions & EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0)
return false;
} }
return mResources.getBoolean(R.bool.config_use_fullscreen_mode); @Override
public void updateFullscreenMode() {
super.updateFullscreenMode();
if (mKeyPreviewBackingView == null) return;
// In fullscreen mode, no need to have extra space to show the key preview.
// If not, we should have extra space above the keyboard to show the key preview.
mKeyPreviewBackingView.setVisibility(isFullscreenMode() ? View.GONE : View.VISIBLE);
} }
@Override @Override