(DO NOT MERGE) Show InputView even when hardware keyboard is connected
Bug: 13988700
Change-Id: I4aeb01bf3571afc97959c213474a6424d7896120
(cherry picked from commit 06514f00f4
)
This commit is contained in:
parent
016d6c424c
commit
8fdff5a111
2 changed files with 41 additions and 1 deletions
|
@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -233,11 +234,21 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMainKeyboardFrame() {
|
private void setMainKeyboardFrame() {
|
||||||
mMainKeyboardFrame.setVisibility(View.VISIBLE);
|
mMainKeyboardFrame.setVisibility(hasHardwareKeyboard() ? View.GONE : View.VISIBLE);
|
||||||
mEmojiPalettesView.setVisibility(View.GONE);
|
mEmojiPalettesView.setVisibility(View.GONE);
|
||||||
mEmojiPalettesView.stopEmojiPalettes();
|
mEmojiPalettesView.stopEmojiPalettes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move this boolean to a member of {@link SettingsValues} and reset it
|
||||||
|
// at {@link LatinIME#onConfigurationChanged(Configuration)}.
|
||||||
|
public boolean hasHardwareKeyboard() {
|
||||||
|
// Copied from {@link InputMethodServce#onEvaluateInputViewShown()}.
|
||||||
|
final Configuration config = mLatinIME.getResources().getConfiguration();
|
||||||
|
final boolean noHardwareKeyboard = config.keyboard == Configuration.KEYBOARD_NOKEYS
|
||||||
|
|| config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES;
|
||||||
|
return !noHardwareKeyboard;
|
||||||
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void setEmojiKeyboard() {
|
public void setEmojiKeyboard() {
|
||||||
|
@ -249,6 +260,14 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mEmojiPalettesView.setVisibility(View.VISIBLE);
|
mEmojiPalettesView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onToggleEmojiKeyboard() {
|
||||||
|
if (isShowingEmojiPalettes()) {
|
||||||
|
setAlphabetKeyboard();
|
||||||
|
} else {
|
||||||
|
setEmojiKeyboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void setSymbolsShiftedKeyboard() {
|
public void setSymbolsShiftedKeyboard() {
|
||||||
|
|
|
@ -145,6 +145,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// If it turns out we need several, it will get grown seamlessly.
|
// If it turns out we need several, it will get grown seamlessly.
|
||||||
final SparseArray<HardwareEventDecoder> mHardwareEventDecoders = new SparseArray<>(1);
|
final SparseArray<HardwareEventDecoder> mHardwareEventDecoders = new SparseArray<>(1);
|
||||||
|
|
||||||
|
// TODO: Move these {@link View}s to {@link KeyboardSwitcher}.
|
||||||
|
private View mInputView;
|
||||||
private View mExtractArea;
|
private View mExtractArea;
|
||||||
private View mKeyPreviewBackingView;
|
private View mKeyPreviewBackingView;
|
||||||
private SuggestionStripView mSuggestionStripView;
|
private SuggestionStripView mSuggestionStripView;
|
||||||
|
@ -709,6 +711,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
@Override
|
@Override
|
||||||
public void setInputView(final View view) {
|
public void setInputView(final View view) {
|
||||||
super.setInputView(view);
|
super.setInputView(view);
|
||||||
|
mInputView = view;
|
||||||
mExtractArea = getWindow().getWindow().getDecorView()
|
mExtractArea = getWindow().getWindow().getDecorView()
|
||||||
.findViewById(android.R.id.extractArea);
|
.findViewById(android.R.id.extractArea);
|
||||||
mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing);
|
mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing);
|
||||||
|
@ -1079,6 +1082,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (visibleKeyboardView == null || !hasSuggestionStripView()) {
|
if (visibleKeyboardView == null || !hasSuggestionStripView()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final boolean hasHardwareKeyboard = mKeyboardSwitcher.hasHardwareKeyboard();
|
||||||
|
if (hasHardwareKeyboard && visibleKeyboardView.getVisibility() == View.GONE) {
|
||||||
|
// If there is a hardware keyboard and a visible software keyboard view has been hidden,
|
||||||
|
// no visual element will be shown on the screen.
|
||||||
|
outInsets.touchableInsets = mInputView.getHeight();
|
||||||
|
outInsets.visibleTopInsets = mInputView.getHeight();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int adjustedBackingHeight = getAdjustedBackingViewHeight();
|
final int adjustedBackingHeight = getAdjustedBackingViewHeight();
|
||||||
final boolean backingGone = (mKeyPreviewBackingView.getVisibility() == View.GONE);
|
final boolean backingGone = (mKeyPreviewBackingView.getVisibility() == View.GONE);
|
||||||
final int backingHeight = backingGone ? 0 : adjustedBackingHeight;
|
final int backingHeight = backingGone ? 0 : adjustedBackingHeight;
|
||||||
|
@ -1110,8 +1121,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
outInsets.visibleTopInsets = visibleTopY;
|
outInsets.visibleTopInsets = visibleTopY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onEvaluateInputViewShown() {
|
||||||
|
// Always show {@link InputView}.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEvaluateFullscreenMode() {
|
public boolean onEvaluateFullscreenMode() {
|
||||||
|
if (mKeyboardSwitcher.hasHardwareKeyboard()) {
|
||||||
|
// If there is a hardware keyboard, disable full screen mode.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Reread resource value here, because this method is called by the framework as needed.
|
// Reread resource value here, because this method is called by the framework as needed.
|
||||||
final boolean isFullscreenModeAllowed = Settings.readUseFullscreenMode(getResources());
|
final boolean isFullscreenModeAllowed = Settings.readUseFullscreenMode(getResources());
|
||||||
if (super.onEvaluateFullscreenMode() && isFullscreenModeAllowed) {
|
if (super.onEvaluateFullscreenMode() && isFullscreenModeAllowed) {
|
||||||
|
|
Loading…
Reference in a new issue