diff options
Diffstat (limited to 'java/src')
7 files changed, 72 insertions, 76 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java index 6a900b45f..e15310721 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java @@ -178,42 +178,43 @@ public final class KeyboardLayoutSet { private Keyboard getKeyboard(final ElementParams elementParams, final KeyboardId id) { final SoftReference<Keyboard> ref = sKeyboardCache.get(id); - Keyboard keyboard = (ref == null) ? null : ref.get(); - if (keyboard == null) { - final KeyboardBuilder<KeyboardParams> builder = - new KeyboardBuilder<KeyboardParams>(mContext, new KeyboardParams()); - if (id.isAlphabetKeyboard()) { - builder.setAutoGenerate(sKeysCache); - } - final int keyboardXmlId = elementParams.mKeyboardXmlId; - builder.load(keyboardXmlId, id); - if (mParams.mDisableTouchPositionCorrectionDataForTest) { - builder.disableTouchPositionCorrectionDataForTest(); + final Keyboard cachedKeyboard = (ref == null) ? null : ref.get(); + if (cachedKeyboard != null) { + if (DEBUG_CACHE) { + Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": HIT id=" + id); } - builder.setProximityCharsCorrectionEnabled( - elementParams.mProximityCharsCorrectionEnabled); - keyboard = builder.build(); - sKeyboardCache.put(id, new SoftReference<Keyboard>(keyboard)); - if ((id.mElementId == KeyboardId.ELEMENT_ALPHABET - || id.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) - && !mParams.mIsSpellChecker) { - // We only forcibly cache the primary, "ALPHABET", layouts. - for (int i = sForcibleKeyboardCache.length - 1; i >= 1; --i) { - sForcibleKeyboardCache[i] = sForcibleKeyboardCache[i - 1]; - } - sForcibleKeyboardCache[0] = keyboard; - if (DEBUG_CACHE) { - Log.d(TAG, "forcing caching of keyboard with id=" + id); - } + return cachedKeyboard; + } + + final KeyboardBuilder<KeyboardParams> builder = + new KeyboardBuilder<KeyboardParams>(mContext, new KeyboardParams()); + if (id.isAlphabetKeyboard()) { + builder.setAutoGenerate(sKeysCache); + } + final int keyboardXmlId = elementParams.mKeyboardXmlId; + builder.load(keyboardXmlId, id); + if (mParams.mDisableTouchPositionCorrectionDataForTest) { + builder.disableTouchPositionCorrectionDataForTest(); + } + builder.setProximityCharsCorrectionEnabled(elementParams.mProximityCharsCorrectionEnabled); + final Keyboard keyboard = builder.build(); + sKeyboardCache.put(id, new SoftReference<Keyboard>(keyboard)); + if ((id.mElementId == KeyboardId.ELEMENT_ALPHABET + || id.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) + && !mParams.mIsSpellChecker) { + // We only forcibly cache the primary, "ALPHABET", layouts. + for (int i = sForcibleKeyboardCache.length - 1; i >= 1; --i) { + sForcibleKeyboardCache[i] = sForcibleKeyboardCache[i - 1]; } + sForcibleKeyboardCache[0] = keyboard; if (DEBUG_CACHE) { - Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": " - + ((ref == null) ? "LOAD" : "GCed") + " id=" + id); + Log.d(TAG, "forcing caching of keyboard with id=" + id); } - } else if (DEBUG_CACHE) { - Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": HIT id=" + id); } - + if (DEBUG_CACHE) { + Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": " + + ((ref == null) ? "LOAD" : "GCed") + " id=" + id); + } return keyboard; } @@ -293,7 +294,7 @@ public final class KeyboardLayoutSet { } public Builder setIsSpellChecker(final boolean isSpellChecker) { - mParams.mIsSpellChecker = true; + mParams.mIsSpellChecker = isSpellChecker; return this; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java index d65aae2dc..dc815e57d 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java @@ -53,7 +53,7 @@ public final class KeyboardCodesSet { "key_action_previous", "key_shift_enter", "key_language_switch", - "key_research", + "key_emoji", "key_unspecified", "key_left_parenthesis", "key_right_parenthesis", @@ -90,7 +90,7 @@ public final class KeyboardCodesSet { Constants.CODE_ACTION_PREVIOUS, Constants.CODE_SHIFT_ENTER, Constants.CODE_LANGUAGE_SWITCH, - Constants.CODE_RESEARCH, + Constants.CODE_EMOJI, Constants.CODE_UNSPECIFIED, CODE_LEFT_PARENTHESIS, CODE_RIGHT_PARENTHESIS, diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index 4e3f7618b..336db186e 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -56,6 +56,7 @@ public final class KeyboardIconsSet { "language_switch_key", R.styleable.Keyboard_iconLanguageSwitchKey, "zwnj_key", R.styleable.Keyboard_iconZwnjKey, "zwj_key", R.styleable.Keyboard_iconZwjKey, + "emoji_key", R.styleable.Keyboard_iconEmojiKey, }; private static int NUM_ICONS = NAMES_AND_ATTR_IDS.length / 2; diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java index 6d67bdb04..8aec03f71 100644 --- a/java/src/com/android/inputmethod/latin/Constants.java +++ b/java/src/com/android/inputmethod/latin/Constants.java @@ -187,7 +187,7 @@ public final class Constants { public static final int CODE_ACTION_NEXT = -8; public static final int CODE_ACTION_PREVIOUS = -9; public static final int CODE_LANGUAGE_SWITCH = -10; - public static final int CODE_RESEARCH = -11; + public static final int CODE_EMOJI = -11; public static final int CODE_SHIFT_ENTER = -12; // Code value representing the code is not specified. public static final int CODE_UNSPECIFIED = -13; @@ -208,10 +208,11 @@ public final class Constants { case CODE_ACTION_NEXT: return "actionNext"; case CODE_ACTION_PREVIOUS: return "actionPrevious"; case CODE_LANGUAGE_SWITCH: return "languageSwitch"; + case CODE_EMOJI: return "emoji"; + case CODE_SHIFT_ENTER: return "shiftEnter"; case CODE_UNSPECIFIED: return "unspec"; case CODE_TAB: return "tab"; case CODE_ENTER: return "enter"; - case CODE_RESEARCH: return "research"; default: if (code < CODE_SPACE) return String.format("'\\u%02x'", code); if (code < 0x100) return String.format("'%c'", code); diff --git a/java/src/com/android/inputmethod/latin/InputView.java b/java/src/com/android/inputmethod/latin/InputView.java index 5359c8185..81ccf83d8 100644 --- a/java/src/com/android/inputmethod/latin/InputView.java +++ b/java/src/com/android/inputmethod/latin/InputView.java @@ -24,7 +24,7 @@ import android.view.View; import android.widget.LinearLayout; public final class InputView extends LinearLayout { - private View mSuggestionStripContainer; + private View mSuggestionStripView; private View mKeyboardView; private int mKeyboardTopPadding; @@ -33,33 +33,29 @@ public final class InputView extends LinearLayout { private final Rect mEventForwardingRect = new Rect(); private final Rect mEventReceivingRect = new Rect(); - public InputView(Context context, AttributeSet attrs) { + public InputView(final Context context, final AttributeSet attrs) { super(context, attrs, 0); } - public void setKeyboardGeometry(int keyboardTopPadding) { + public void setKeyboardGeometry(final int keyboardTopPadding) { mKeyboardTopPadding = keyboardTopPadding; } @Override protected void onFinishInflate() { - mSuggestionStripContainer = findViewById(R.id.suggestions_container); + mSuggestionStripView = findViewById(R.id.suggestion_strip_view); mKeyboardView = findViewById(R.id.keyboard_view); } @Override - public boolean dispatchTouchEvent(MotionEvent me) { - if (mSuggestionStripContainer.getVisibility() == VISIBLE - && mKeyboardView.getVisibility() == VISIBLE - && forwardTouchEvent(me)) { - return true; + public boolean dispatchTouchEvent(final MotionEvent me) { + if (mSuggestionStripView.getVisibility() != VISIBLE + || mKeyboardView.getVisibility() != VISIBLE) { + return super.dispatchTouchEvent(me); } - return super.dispatchTouchEvent(me); - } - // The touch events that hit the top padding of keyboard should be forwarded to - // {@link SuggestionStripView}. - private boolean forwardTouchEvent(MotionEvent me) { + // The touch events that hit the top padding of keyboard should be forwarded to + // {@link SuggestionStripView}. final Rect rect = mInputViewRect; this.getGlobalVisibleRect(rect); final int x = (int)me.getX() + rect.left; @@ -68,7 +64,7 @@ public final class InputView extends LinearLayout { final Rect forwardingRect = mEventForwardingRect; mKeyboardView.getGlobalVisibleRect(forwardingRect); if (!mIsForwardingEvent && !forwardingRect.contains(x, y)) { - return false; + return super.dispatchTouchEvent(me); } final int forwardingLimitY = forwardingRect.top + mKeyboardTopPadding; @@ -93,11 +89,11 @@ public final class InputView extends LinearLayout { } if (!sendToTarget) { - return false; + return super.dispatchTouchEvent(me); } final Rect receivingRect = mEventReceivingRect; - mSuggestionStripContainer.getGlobalVisibleRect(receivingRect); + mSuggestionStripView.getGlobalVisibleRect(receivingRect); final int translatedX = x - receivingRect.left; final int translatedY; if (y < forwardingLimitY) { @@ -107,7 +103,7 @@ public final class InputView extends LinearLayout { translatedY = y - receivingRect.top; } me.setLocation(translatedX, translatedY); - mSuggestionStripContainer.dispatchTouchEvent(me); + mSuggestionStripView.dispatchTouchEvent(me); return true; } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 719c7c81f..d970bca5e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -152,7 +152,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private View mExtractArea; private View mKeyPreviewBackingView; - private View mSuggestionsContainer; private SuggestionStripView mSuggestionStripView; // Never null private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY; @@ -667,7 +666,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mExtractArea = getWindow().getWindow().getDecorView() .findViewById(android.R.id.extractArea); mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing); - mSuggestionsContainer = view.findViewById(R.id.suggestions_container); mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view); if (mSuggestionStripView != null) mSuggestionStripView.setListener(this, view); @@ -1111,17 +1109,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void setSuggestionStripShownInternal(final boolean shown, final boolean needsInputViewShown) { // TODO: Modify this if we support suggestions with hard keyboard - if (onEvaluateInputViewShown() && mSuggestionsContainer != null) { + if (onEvaluateInputViewShown() && mSuggestionStripView != null) { final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); final boolean inputViewShown = (mainKeyboardView != null) ? mainKeyboardView.isShown() : false; final boolean shouldShowSuggestions = shown && (needsInputViewShown ? inputViewShown : true); if (isFullscreenMode()) { - mSuggestionsContainer.setVisibility( + mSuggestionStripView.setVisibility( shouldShowSuggestions ? View.VISIBLE : View.GONE); } else { - mSuggestionsContainer.setVisibility( + mSuggestionStripView.setVisibility( shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE); } } @@ -1142,7 +1140,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return 0; } final int keyboardHeight = mainKeyboardView.getHeight(); - final int suggestionsHeight = mSuggestionsContainer.getHeight(); + final int suggestionsHeight = mSuggestionStripView.getHeight(); final int displayHeight = getResources().getDisplayMetrics().heightPixels; final Rect rect = new Rect(); mKeyPreviewBackingView.getWindowVisibleDisplayFrame(rect); @@ -1160,7 +1158,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onComputeInsets(final InputMethodService.Insets outInsets) { super.onComputeInsets(outInsets); final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); - if (mainKeyboardView == null || mSuggestionsContainer == null) { + if (mainKeyboardView == null || mSuggestionStripView == null) { return; } final int adjustedBackingHeight = getAdjustedBackingViewHeight(); @@ -1170,13 +1168,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // be considered. // See {@link android.inputmethodservice.InputMethodService#onComputeInsets}. final int extractHeight = isFullscreenMode() ? mExtractArea.getHeight() : 0; - final int suggestionsHeight = (mSuggestionsContainer.getVisibility() == View.GONE) ? 0 - : mSuggestionsContainer.getHeight(); + final int suggestionsHeight = (mSuggestionStripView.getVisibility() == View.GONE) ? 0 + : mSuggestionStripView.getHeight(); final int extraHeight = extractHeight + backingHeight + suggestionsHeight; int visibleTopY = extraHeight; // Need to set touchable region only if input view is being shown if (mainKeyboardView.isShown()) { - if (mSuggestionsContainer.getVisibility() == View.VISIBLE) { + if (mSuggestionStripView.getVisibility() == View.VISIBLE) { visibleTopY -= suggestionsHeight; } final int touchY = mainKeyboardView.isShowingMoreKeysPanel() ? 0 : visibleTopY; @@ -1512,10 +1510,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen case Constants.CODE_LANGUAGE_SWITCH: handleLanguageSwitchKey(); break; - case Constants.CODE_RESEARCH: - if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { - ResearchLogger.getInstance().onResearchKeySelected(this); - } + case Constants.CODE_EMOJI: + // TODO: Implement emoji keyboard switch. break; case Constants.CODE_ENTER: final EditorInfo editorInfo = getCurrentInputEditorInfo(); @@ -1608,6 +1604,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen resetComposingState(true /* alsoResetLastComposedWord */); } mHandler.postUpdateSuggestionStrip(); + if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS + && ResearchLogger.RESEARCH_KEY_OUTPUT_TEXT.equals(rawText)) { + ResearchLogger.getInstance().onResearchKeySelected(this); + return; + } final String text = specificTldProcessingOnTextInput(rawText); if (SPACE_STATE_PHANTOM == mSpaceState) { promotePhantomSpace(); @@ -1639,7 +1640,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } final int wordComposerSize = mWordComposer.size(); // Since isComposingWord() is true, the size is at least 1. - final int lastChar = mWordComposer.getCodeBeforeCursor(); if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) { // If we are in the middle of a recorrection, we need to commit the recorrection // first so that we can insert the batch input at the current cursor position. diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 25187ced1..0bd493970 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -132,6 +132,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang // FEEDBACK_WORD_BUFFER_SIZE should add 1 because it must also hold the feedback LogUnit itself. public static final int FEEDBACK_WORD_BUFFER_SIZE = (Integer.MAX_VALUE - 1) + 1; + // The special output text to invoke a research feedback dialog. + public static final String RESEARCH_KEY_OUTPUT_TEXT = ".research."; + // constants related to specific log points private static final String WHITESPACE_SEPARATORS = " \t\n\r"; private static final int MAX_INPUTVIEW_LENGTH_TO_CAPTURE = 8192; // must be >=1 @@ -402,6 +405,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } public void onResearchKeySelected(final LatinIME latinIME) { + mCurrentLogUnit.removeResearchButtonInvocation(); if (mInFeedbackDialog) { Toast.makeText(latinIME, R.string.research_please_exit_feedback_form, Toast.LENGTH_LONG).show(); @@ -1506,16 +1510,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang Constants.printableCode(scrubDigitFromCodePoint(code)), outputText == null ? null : scrubDigitsFromString(outputText.toString()), x, y, ignoreModifierKey, altersCode, key.isEnabled()); - if (code == Constants.CODE_RESEARCH) { - researchLogger.suppressResearchKeyMotionData(); - } } } - private void suppressResearchKeyMotionData() { - mCurrentLogUnit.removeResearchButtonInvocation(); - } - /** * Log a call to PointerTracker.callListenerCallListenerOnRelease(). * |