diff --git a/Mymr/src/main/java/com/google/languageresources/mymr/CandidateView.java b/Mymr/src/main/java/com/google/languageresources/mymr/CandidateView.java index 33ee467..aee5559 100644 --- a/Mymr/src/main/java/com/google/languageresources/mymr/CandidateView.java +++ b/Mymr/src/main/java/com/google/languageresources/mymr/CandidateView.java @@ -39,17 +39,17 @@ public class CandidateView extends View { private int mTouchX = OUT_OF_BOUNDS; private Drawable mSelectionHighlight; private boolean mTypedWordValid; - + private Rect mBgPadding; private static final int MAX_SUGGESTIONS = 32; private static final int SCROLL_PIXELS = 20; - + private int[] mWordWidth = new int[MAX_SUGGESTIONS]; private int[] mWordX = new int[MAX_SUGGESTIONS]; private static final int X_GAP = 10; - + private static final List EMPTY_LIST = new ArrayList(); private int mColorNormal; @@ -59,9 +59,9 @@ public class CandidateView extends View { private Paint mPaint; private boolean mScrolled; private int mTargetScrollX; - + private int mTotalWidth; - + private GestureDetector mGestureDetector; /** @@ -71,55 +71,61 @@ public class CandidateView extends View { */ public CandidateView(Context context) { super(context); - mSelectionHighlight = context.getResources().getDrawable( - android.R.drawable.list_selector_background); - mSelectionHighlight.setState(new int[] { - android.R.attr.state_enabled, - android.R.attr.state_focused, - android.R.attr.state_window_focused, - android.R.attr.state_pressed - }); + mSelectionHighlight = + context.getResources().getDrawable(android.R.drawable.list_selector_background); + mSelectionHighlight.setState( + new int[] { + android.R.attr.state_enabled, + android.R.attr.state_focused, + android.R.attr.state_window_focused, + android.R.attr.state_pressed + }); Resources r = context.getResources(); - + setBackgroundColor(r.getColor(R.color.candidate_background)); - + mColorNormal = r.getColor(R.color.candidate_normal); mColorRecommended = r.getColor(R.color.candidate_recommended); mColorOther = r.getColor(R.color.candidate_other); mVerticalPadding = r.getDimensionPixelSize(R.dimen.candidate_vertical_padding); - + mPaint = new Paint(); mPaint.setColor(mColorNormal); mPaint.setAntiAlias(true); mPaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_height)); mPaint.setStrokeWidth(0); - - mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { - @Override - public boolean onScroll(MotionEvent e1, MotionEvent e2, - float distanceX, float distanceY) { - mScrolled = true; - int sx = getScrollX(); - sx += distanceX; - if (sx < 0) { - sx = 0; - } - if (sx + getWidth() > mTotalWidth) { - sx -= distanceX; - } - mTargetScrollX = sx; - scrollTo(sx, getScrollY()); - invalidate(); - return true; - } - }); + + mGestureDetector = + new GestureDetector( + new GestureDetector.SimpleOnGestureListener() { + @Override + public boolean onScroll( + MotionEvent e1, + MotionEvent e2, + float distanceX, + float distanceY) { + mScrolled = true; + int sx = getScrollX(); + sx += distanceX; + if (sx < 0) { + sx = 0; + } + if (sx + getWidth() > mTotalWidth) { + sx -= distanceX; + } + mTargetScrollX = sx; + scrollTo(sx, getScrollY()); + invalidate(); + return true; + } + }); setHorizontalFadingEdgeEnabled(true); setWillNotDraw(false); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); } - + /** * A connection back to the service to communicate with the text field * @param listener @@ -127,7 +133,7 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, public void setService(SoftKeyboard listener) { mService = listener; } - + @Override public int computeHorizontalScrollRange() { return mTotalWidth; @@ -136,17 +142,16 @@ public int computeHorizontalScrollRange() { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int measuredWidth = resolveSize(50, widthMeasureSpec); - + // Get the desired height of the icon menu view (last row of items does // not have a divider below) Rect padding = new Rect(); mSelectionHighlight.getPadding(padding); - final int desiredHeight = ((int)mPaint.getTextSize()) + mVerticalPadding - + padding.top + padding.bottom; - + final int desiredHeight = + ((int) mPaint.getTextSize()) + mVerticalPadding + padding.top + padding.bottom; + // Maximum possible width and desired height - setMeasuredDimension(measuredWidth, - resolveSize(desiredHeight, heightMeasureSpec)); + setMeasuredDimension(measuredWidth, resolveSize(desiredHeight, heightMeasureSpec)); } /** @@ -160,7 +165,7 @@ protected void onDraw(Canvas canvas) { } mTotalWidth = 0; if (mSuggestions == null) return; - + if (mBgPadding == null) { mBgPadding = new Rect(0, 0, 0, 0); if (getBackground() != null) { @@ -168,7 +173,7 @@ protected void onDraw(Canvas canvas) { } } int x = 0; - final int count = mSuggestions.size(); + final int count = mSuggestions.size(); final int height = getHeight(); final Rect bgPadding = mBgPadding; final Paint paint = mPaint; @@ -204,9 +209,13 @@ protected void onDraw(Canvas canvas) { paint.setColor(mColorOther); } canvas.drawText(suggestion, x + X_GAP, y, paint); - paint.setColor(mColorOther); - canvas.drawLine(x + wordWidth + 0.5f, bgPadding.top, - x + wordWidth + 0.5f, height + 1, paint); + paint.setColor(mColorOther); + canvas.drawLine( + x + wordWidth + 0.5f, + bgPadding.top, + x + wordWidth + 0.5f, + height + 1, + paint); paint.setFakeBoldText(false); } x += wordWidth; @@ -216,7 +225,7 @@ protected void onDraw(Canvas canvas) { scrollToTarget(); } } - + private void scrollToTarget() { int sx = getScrollX(); if (mTargetScrollX > sx) { @@ -235,9 +244,9 @@ private void scrollToTarget() { scrollTo(sx, getScrollY()); invalidate(); } - - public void setSuggestions(List suggestions, boolean completions, - boolean typedWordValid) { + + public void setSuggestions( + List suggestions, boolean completions, boolean typedWordValid) { clear(); if (suggestions != null) { mSuggestions = new ArrayList(suggestions); @@ -257,7 +266,7 @@ public void clear() { mSelectedIndex = -1; invalidate(); } - + @Override public boolean onTouchEvent(MotionEvent me) { @@ -271,36 +280,36 @@ public boolean onTouchEvent(MotionEvent me) { mTouchX = x; switch (action) { - case MotionEvent.ACTION_DOWN: - mScrolled = false; - invalidate(); - break; - case MotionEvent.ACTION_MOVE: - if (y <= 0) { - // Fling up!? - if (mSelectedIndex >= 0) { - mService.pickSuggestionManually(mSelectedIndex); - mSelectedIndex = -1; + case MotionEvent.ACTION_DOWN: + mScrolled = false; + invalidate(); + break; + case MotionEvent.ACTION_MOVE: + if (y <= 0) { + // Fling up!? + if (mSelectedIndex >= 0) { + mService.pickSuggestionManually(mSelectedIndex); + mSelectedIndex = -1; + } } - } - invalidate(); - break; - case MotionEvent.ACTION_UP: - if (!mScrolled) { - if (mSelectedIndex >= 0) { - mService.pickSuggestionManually(mSelectedIndex); + invalidate(); + break; + case MotionEvent.ACTION_UP: + if (!mScrolled) { + if (mSelectedIndex >= 0) { + mService.pickSuggestionManually(mSelectedIndex); + } } - } - mSelectedIndex = -1; - removeHighlight(); - requestLayout(); - break; + mSelectedIndex = -1; + removeHighlight(); + requestLayout(); + break; } return true; } - + /** - * For flick through from keyboard, call this method with the x coordinate of the flick + * For flick through from keyboard, call this method with the x coordinate of the flick * gesture. * @param x */ diff --git a/Mymr/src/main/java/com/google/languageresources/mymr/SoftKeyboard.java b/Mymr/src/main/java/com/google/languageresources/mymr/SoftKeyboard.java index cdebde5..aa26f63 100644 --- a/Mymr/src/main/java/com/google/languageresources/mymr/SoftKeyboard.java +++ b/Mymr/src/main/java/com/google/languageresources/mymr/SoftKeyboard.java @@ -43,15 +43,15 @@ * a basic example for how you would get started writing an input method, to * be fleshed out as appropriate. */ -public class SoftKeyboard extends InputMethodService +public class SoftKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener { static final boolean DEBUG = false; - + /** * This boolean indicates the optional example code for performing * processing of hard keys in addition to regular text generation * from on-screen interaction. It would be used for input methods that - * perform language translations (such as converting text entered on + * perform language translations (such as converting text entered on * a QWERTY keyboard to Chinese), but may not be used for input methods * that are primarily intended to be used for on-screen text entry. */ @@ -62,7 +62,7 @@ public class SoftKeyboard extends InputMethodService private LatinKeyboardView mInputView; private CandidateView mCandidateView; private CompletionInfo[] mCompletions; - + private StringBuilder mComposing = new StringBuilder(); private boolean mPredictionOn; private boolean mCompletionOn; @@ -70,30 +70,32 @@ public class SoftKeyboard extends InputMethodService private boolean mCapsLock; private long mLastShiftTime; private long mMetaState; - + private LatinKeyboard mSymbolsKeyboard; private LatinKeyboard mSymbolsShiftedKeyboard; private LatinKeyboard mQwertyKeyboard; - + private LatinKeyboard mCurKeyboard; - + private String mWordSeparators; - + /** * Main initialization of the input method component. Be sure to call * to super class. */ - @Override public void onCreate() { + @Override + public void onCreate() { super.onCreate(); - mInputMethodManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); + mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); mWordSeparators = getResources().getString(R.string.word_separators); } - + /** * This is the point where you can do all of your UI initialization. It * is called after creation and any configuration change. */ - @Override public void onInitializeInterface() { + @Override + public void onInitializeInterface() { if (mQwertyKeyboard != null) { // Configuration changes can happen after the keyboard gets recreated, // so we need to be able to re-build the keyboards if the available @@ -106,16 +108,16 @@ public class SoftKeyboard extends InputMethodService mSymbolsKeyboard = new LatinKeyboard(this, R.xml.symbols); mSymbolsShiftedKeyboard = new LatinKeyboard(this, R.xml.symbols_shift); } - + /** * Called by the framework when your view for creating input needs to * be generated. This will be called the first time your input method * is displayed, and every time it needs to be re-created such as due to * a configuration change. */ - @Override public View onCreateInputView() { - mInputView = (LatinKeyboardView) getLayoutInflater().inflate( - R.layout.input, null); + @Override + public View onCreateInputView() { + mInputView = (LatinKeyboardView) getLayoutInflater().inflate(R.layout.input, null); mInputView.setOnKeyboardActionListener(this); setLatinKeyboard(mQwertyKeyboard); return mInputView; @@ -132,7 +134,8 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) { * Called by the framework when your view for showing candidates needs to * be generated, like {@link #onCreateInputView}. */ - @Override public View onCreateCandidatesView() { + @Override + public View onCreateCandidatesView() { mCandidateView = new CandidateView(this); mCandidateView.setService(this); return mCandidateView; @@ -144,23 +147,24 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) { * bound to the client, and are now receiving all of the detailed information * about the target of our edits. */ - @Override public void onStartInput(EditorInfo attribute, boolean restarting) { + @Override + public void onStartInput(EditorInfo attribute, boolean restarting) { super.onStartInput(attribute, restarting); - + // Reset our state. We want to do this even if restarting, because // the underlying state of the text editor could have changed in any way. mComposing.setLength(0); updateCandidates(); - + if (!restarting) { // Clear shift states. mMetaState = 0; } - + mPredictionOn = false; mCompletionOn = false; mCompletions = null; - + // We are now going to initialize our state based on the type of // text being edited. switch (attribute.inputType & InputType.TYPE_MASK_CLASS) { @@ -170,13 +174,13 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) { // no extra features. mCurKeyboard = mSymbolsKeyboard; break; - + case InputType.TYPE_CLASS_PHONE: // Phones will also default to the symbols keyboard, though // often you will want to have a dedicated phone keyboard. mCurKeyboard = mSymbolsKeyboard; break; - + case InputType.TYPE_CLASS_TEXT: // This is general text editing. We will default to the // normal alphabetic keyboard, and assume that we should @@ -184,17 +188,17 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) { // user types). mCurKeyboard = mQwertyKeyboard; mPredictionOn = true; - + // We now look for a few special variations of text that will // modify our behavior. int variation = attribute.inputType & InputType.TYPE_MASK_VARIATION; - if (variation == InputType.TYPE_TEXT_VARIATION_PASSWORD || - variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { + if (variation == InputType.TYPE_TEXT_VARIATION_PASSWORD + || variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { // Do not display predictions / what the user is typing // when they are entering a password. mPredictionOn = false; } - + if (variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS || variation == InputType.TYPE_TEXT_VARIATION_URI || variation == InputType.TYPE_TEXT_VARIATION_FILTER) { @@ -202,7 +206,7 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) { // or URIs. mPredictionOn = false; } - + if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) { // If this is an auto-complete text view, then our predictions // will not be shown and instead we will allow the editor @@ -212,20 +216,20 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) { mPredictionOn = false; mCompletionOn = isFullscreenMode(); } - + // We also want to look at the current state of the editor // to decide whether our alphabetic keyboard should start out // shifted. updateShiftKeyState(attribute); break; - + default: // For all unknown input types, default to the alphabetic // keyboard with no special features. mCurKeyboard = mQwertyKeyboard; updateShiftKeyState(attribute); } - + // Update the label on the enter key, depending on what the application // says it will do. mCurKeyboard.setImeOptions(getResources(), attribute.imeOptions); @@ -235,26 +239,28 @@ private void setLatinKeyboard(LatinKeyboard nextKeyboard) { * This is called when the user is done editing a field. We can use * this to reset our state. */ - @Override public void onFinishInput() { + @Override + public void onFinishInput() { super.onFinishInput(); - + // Clear current composing text and candidates. mComposing.setLength(0); updateCandidates(); - + // We only hide the candidates window when finishing input on // a particular editor, to avoid popping the underlying application // up and down if the user is entering text into the bottom of // its window. setCandidatesViewShown(false); - + mCurKeyboard = mQwertyKeyboard; if (mInputView != null) { mInputView.closing(); } } - - @Override public void onStartInputView(EditorInfo attribute, boolean restarting) { + + @Override + public void onStartInputView(EditorInfo attribute, boolean restarting) { super.onStartInputView(attribute, restarting); // Apply the selected keyboard to the input view. setLatinKeyboard(mCurKeyboard); @@ -271,16 +277,21 @@ public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { /** * Deal with the editor reporting movement of its cursor. */ - @Override public void onUpdateSelection(int oldSelStart, int oldSelEnd, - int newSelStart, int newSelEnd, - int candidatesStart, int candidatesEnd) { - super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd, - candidatesStart, candidatesEnd); - + @Override + public void onUpdateSelection( + int oldSelStart, + int oldSelEnd, + int newSelStart, + int newSelEnd, + int candidatesStart, + int candidatesEnd) { + super.onUpdateSelection( + oldSelStart, oldSelEnd, newSelStart, newSelEnd, candidatesStart, candidatesEnd); + // If the current selection in the text view changes, we should // clear whatever candidate text we have. - if (mComposing.length() > 0 && (newSelStart != candidatesEnd - || newSelEnd != candidatesEnd)) { + if (mComposing.length() > 0 + && (newSelStart != candidatesEnd || newSelEnd != candidatesEnd)) { mComposing.setLength(0); updateCandidates(); InputConnection ic = getCurrentInputConnection(); @@ -296,14 +307,15 @@ public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { * to show the completions ourself, since the editor can not be seen * in that situation. */ - @Override public void onDisplayCompletions(CompletionInfo[] completions) { + @Override + public void onDisplayCompletions(CompletionInfo[] completions) { if (mCompletionOn) { mCompletions = completions; if (completions == null) { setSuggestions(null, false, false); return; } - + List stringList = new ArrayList(); for (int i = 0; i < completions.length; i++) { CompletionInfo ci = completions[i]; @@ -312,50 +324,50 @@ public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { setSuggestions(stringList, true, true); } } - + /** * This translates incoming hard key events in to edit operations on an * InputConnection. It is only needed when using the * PROCESS_HARD_KEYS option. */ private boolean translateKeyDown(int keyCode, KeyEvent event) { - mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, - keyCode, event); + mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event); int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState)); mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState); InputConnection ic = getCurrentInputConnection(); if (c == 0 || ic == null) { return false; } - + boolean dead = false; if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) { dead = true; c = c & KeyCharacterMap.COMBINING_ACCENT_MASK; } - + if (mComposing.length() > 0) { - char accent = mComposing.charAt(mComposing.length() -1 ); + char accent = mComposing.charAt(mComposing.length() - 1); int composed = KeyEvent.getDeadChar(accent, c); if (composed != 0) { c = composed; - mComposing.setLength(mComposing.length()-1); + mComposing.setLength(mComposing.length() - 1); } } - + onKey(c, null); - + return true; } - + /** * Use this to monitor key events being delivered to the application. * We get first crack at them, and can either resume them or let them * continue to the app. */ - @Override public boolean onKeyDown(int keyCode, KeyEvent event) { + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: // The InputMethodService already takes care of the back @@ -368,7 +380,7 @@ private boolean translateKeyDown(int keyCode, KeyEvent event) { } } break; - + case KeyEvent.KEYCODE_DEL: // Special handling of the delete key: if we currently are // composing text for the user, we want to modify that instead @@ -378,18 +390,18 @@ private boolean translateKeyDown(int keyCode, KeyEvent event) { return true; } break; - + case KeyEvent.KEYCODE_ENTER: // Let the underlying text editor always handle these. return false; - + default: // For all other keys, if we want to do transformations on // text being entered with a hard keyboard, we need to process // it and do the appropriate action. if (PROCESS_HARD_KEYS) { if (keyCode == KeyEvent.KEYCODE_SPACE - && (event.getMetaState()&KeyEvent.META_ALT_ON) != 0) { + && (event.getMetaState() & KeyEvent.META_ALT_ON) != 0) { // A silly example: in our input method, Alt+Space // is a shortcut for 'android' in lower case. InputConnection ic = getCurrentInputConnection(); @@ -413,7 +425,7 @@ private boolean translateKeyDown(int keyCode, KeyEvent event) { } } } - + return super.onKeyDown(keyCode, event); } @@ -422,17 +434,17 @@ private boolean translateKeyDown(int keyCode, KeyEvent event) { * We get first crack at them, and can either resume them or let them * continue to the app. */ - @Override public boolean onKeyUp(int keyCode, KeyEvent event) { + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { // If we want to do transformations on text being entered with a hard // keyboard, we need to process the up events to update the meta key // state we are tracking. if (PROCESS_HARD_KEYS) { if (mPredictionOn) { - mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState, - keyCode, event); + mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState, keyCode, event); } } - + return super.onKeyUp(keyCode, event); } @@ -452,8 +464,7 @@ private void commitTyped(InputConnection inputConnection) { * editor state. */ private void updateShiftKeyState(EditorInfo attr) { - if (attr != null - && mInputView != null && mQwertyKeyboard == mInputView.getKeyboard()) { + if (attr != null && mInputView != null && mQwertyKeyboard == mInputView.getKeyboard()) { int caps = 0; EditorInfo ei = getCurrentInputEditorInfo(); if (ei != null && ei.inputType != InputType.TYPE_NULL) { @@ -462,7 +473,7 @@ private void updateShiftKeyState(EditorInfo attr) { mInputView.setShifted(mCapsLock || caps != 0); } } - + /** * Helper to determine if a given character code is alphabetic. */ @@ -473,17 +484,15 @@ private boolean isAlphabet(int code) { return false; } } - + /** * Helper to send a key down / key up pair to the current editor. */ private void keyDownUp(int keyEventCode) { - getCurrentInputConnection().sendKeyEvent( - new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode)); - getCurrentInputConnection().sendKeyEvent( - new KeyEvent(KeyEvent.ACTION_UP, keyEventCode)); + getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode)); + getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEventCode)); } - + /** * Helper to send a character to the editor as raw key events. */ @@ -524,8 +533,7 @@ public void onKey(int primaryCode, int[] keyCodes) { return; } else if (primaryCode == LatinKeyboardView.KEYCODE_OPTIONS) { // Show a menu or somethin' - } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE - && mInputView != null) { + } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE && mInputView != null) { Keyboard current = mInputView.getKeyboard(); if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) { setLatinKeyboard(mQwertyKeyboard); @@ -566,9 +574,9 @@ private void updateCandidates() { } } } - - public void setSuggestions(List suggestions, boolean completions, - boolean typedWordValid) { + + public void setSuggestions( + List suggestions, boolean completions, boolean typedWordValid) { if (suggestions != null && suggestions.size() > 0) { setCandidatesViewShown(true); } else if (isExtractViewShown()) { @@ -578,7 +586,7 @@ public void setSuggestions(List suggestions, boolean completions, mCandidateView.setSuggestions(suggestions, completions, typedWordValid); } } - + private void handleBackspace() { final int length = mComposing.length(); if (length > 1) { @@ -599,7 +607,7 @@ private void handleShift() { if (mInputView == null) { return; } - + Keyboard currentKeyboard = mInputView.getKeyboard(); if (mQwertyKeyboard == currentKeyboard) { // Alphabet keyboard @@ -615,7 +623,7 @@ private void handleShift() { mSymbolsKeyboard.setShifted(false); } } - + private void handleCharacter(int primaryCode, int[] keyCodes) { if (isInputViewShown()) { if (mInputView.isShifted()) { @@ -628,8 +636,7 @@ private void handleCharacter(int primaryCode, int[] keyCodes) { updateShiftKeyState(getCurrentInputEditorInfo()); updateCandidates(); } else { - getCurrentInputConnection().commitText( - String.valueOf((char) primaryCode), 1); + getCurrentInputConnection().commitText(String.valueOf((char) primaryCode), 1); } } @@ -664,23 +671,22 @@ private void checkToggleCapsLock() { mLastShiftTime = now; } } - + private String getWordSeparators() { return mWordSeparators; } - + public boolean isWordSeparator(int code) { String separators = getWordSeparators(); - return separators.contains(String.valueOf((char)code)); + return separators.contains(String.valueOf((char) code)); } public void pickDefaultCandidate() { pickSuggestionManually(0); } - + public void pickSuggestionManually(int index) { - if (mCompletionOn && mCompletions != null && index >= 0 - && index < mCompletions.length) { + if (mCompletionOn && mCompletions != null && index >= 0 && index < mCompletions.length) { CompletionInfo ci = mCompletions[index]; getCurrentInputConnection().commitCompletion(ci); if (mCandidateView != null) { @@ -694,13 +700,13 @@ public void pickSuggestionManually(int index) { commitTyped(getCurrentInputConnection()); } } - + public void swipeRight() { if (mCompletionOn) { pickDefaultCandidate(); } } - + public void swipeLeft() { handleBackspace(); } @@ -709,12 +715,9 @@ public void swipeDown() { handleClose(); } - public void swipeUp() { - } - - public void onPress(int primaryCode) { - } - - public void onRelease(int primaryCode) { - } + public void swipeUp() {} + + public void onPress(int primaryCode) {} + + public void onRelease(int primaryCode) {} }