From cd6ef9a8b117b82623251510fac72ee108ec1a2a Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Sun, 24 Aug 2014 14:37:24 -0700 Subject: Indroduce SuggestedWords#getTypedWordInfoOrNull This is a groundwork for subsequent CLs whith need to do certain things for and only for the typed word. Change-Id: I374b79cbc79470f57f523c996010301ea5701a61 --- .../src/com/android/inputmethod/latin/SuggestedWords.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index d7693af41..38fcb683d 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -19,6 +19,7 @@ package com.android.inputmethod.latin; import android.text.TextUtils; import android.view.inputmethod.CompletionInfo; +import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.define.DebugFlags; import com.android.inputmethod.latin.utils.StringUtils; @@ -420,4 +421,18 @@ public class SuggestedWords { mWillAutoCorrect, mIsObsoleteSuggestions, mIsPrediction, INPUT_STYLE_TAIL_BATCH); } + + /** + * @return the {@link SuggestedWordInfo} which corresponds to the word that is originally + * typed by the user. Otherwise returns {@code null}. Note that gesture input is not + * considered to be a typed word. + */ + @UsedForTesting + public SuggestedWordInfo getTypedWordInfoOrNull() { + if (this == EMPTY) { + return null; + } + final SuggestedWordInfo info = getInfo(SuggestedWords.INDEX_OF_TYPED_WORD); + return (info.getKind() == SuggestedWordInfo.KIND_TYPED) ? info : null; + } } -- cgit v1.2.3-83-g751a