aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-06-09 14:22:37 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-06-09 14:22:37 +0900
commitc97810693dfe83bf37c09f73c8d4b40f2ba8dddb (patch)
tree2ed8aa72fcf516343fe11d45218f57c544bc8f80 /java/src
parent3d3e6f5faa8792033b40681eb6b6191e6e735bb7 (diff)
downloadlatinime-c97810693dfe83bf37c09f73c8d4b40f2ba8dddb.tar.gz
latinime-c97810693dfe83bf37c09f73c8d4b40f2ba8dddb.tar.xz
latinime-c97810693dfe83bf37c09f73c8d4b40f2ba8dddb.zip
Introduce CandidateView.Listener
Bug: 4175031 Change-Id: Ie84d1c86ff099350b786c71e7081d9ea9ee0d81f
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java17
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java7
2 files changed, 16 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index fe3c72f4c..5fe404367 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -49,6 +49,11 @@ import java.util.List;
public class CandidateView extends LinearLayout implements OnClickListener, OnLongClickListener {
+ public interface Listener {
+ public boolean addWordToDictionary(String word);
+ public void pickSuggestionManually(int index, CharSequence word);
+ }
+
private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD);
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
private static final int MAX_SUGGESTIONS = 16;
@@ -66,7 +71,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private final PopupWindow mPreviewPopup;
private final TextView mPreviewText;
- private LatinIME mService;
+ private Listener mListener;
private SuggestedWords mSuggestions = SuggestedWords.EMPTY;
private boolean mShowingAutoCorrectionInverted;
private boolean mShowingAddToDictionary;
@@ -159,11 +164,11 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
/**
- * A connection back to the service to communicate with the text field
+ * A connection back to the input method.
* @param listener
*/
- public void setService(LatinIME listener) {
- mService = listener;
+ public void setListener(Listener listener) {
+ mListener = listener;
}
public void setSuggestions(SuggestedWords suggestions) {
@@ -327,7 +332,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
private void addToDictionary(CharSequence word) {
- if (mService.addWordToDictionary(word.toString())) {
+ if (mListener.addWordToDictionary(word.toString())) {
showPreview(0, getContext().getString(R.string.added_word, word));
}
}
@@ -349,7 +354,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
if (mShowingAddToDictionary && index == 0) {
addToDictionary(word);
} else {
- mService.pickSuggestionManually(index, word);
+ mListener.pickSuggestionManually(index, word);
}
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index a4a04ffb1..a71935012 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -77,7 +77,8 @@ import java.util.Locale;
/**
* Input method implementation for Qwerty'ish keyboard.
*/
-public class LatinIME extends InputMethodServiceCompatWrapper implements KeyboardActionListener {
+public class LatinIME extends InputMethodServiceCompatWrapper implements KeyboardActionListener,
+ CandidateView.Listener {
private static final String TAG = LatinIME.class.getSimpleName();
private static final boolean PERF_DEBUG = false;
private static final boolean TRACE = false;
@@ -491,7 +492,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
super.setInputView(view);
mCandidateViewContainer = view.findViewById(R.id.candidates_container);
mCandidateView = (CandidateView) view.findViewById(R.id.candidates);
- mCandidateView.setService(this);
+ mCandidateView.setListener(this);
mCandidateStripHeight = (int)mResources.getDimension(R.dimen.candidate_strip_height);
}
@@ -1000,6 +1001,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
}
+ @Override
public boolean addWordToDictionary(String word) {
mUserDictionary.addWord(word, 128);
// Suggestion strip should be updated after the operation of adding word to the
@@ -1524,6 +1526,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return false;
}
+ @Override
public void pickSuggestionManually(int index, CharSequence suggestion) {
SuggestedWords suggestions = mCandidateView.getSuggestions();
mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,