From 0175d7da21f62a97fdae88ca5343c1b5127f8529 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Wed, 2 Jun 2010 20:16:38 +0900 Subject: [PATCH] Add additional punctuations to suggestion strip. Bug: 2729632 Change-Id: I5a3d47fee2a09da06b395529c4eccce6d14ecb9d --- java/res/values/donottranslate.xml | 4 ++-- .../android/inputmethod/latin/LatinIME.java | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index d5017353d..b7bfd9c3a 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -21,9 +21,9 @@ .\u0009\u0020,;:!?\n()[]*&@{}/<>_+=|\u0022 - .,!? + .,!?) - !?,@_ + !?,\u0022\u0027:()-/@_ diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 93c69ee71..50b1d38cd 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -221,6 +221,7 @@ public class LatinIME extends InputMethodService /* package */ String mWordSeparators; private String mSentenceSeparators; + private String mSuggestPuncs; private VoiceInput mVoiceInput; private VoiceResults mVoiceResults = new VoiceResults(); private long mSwipeTriggerTimeMillis; @@ -1116,7 +1117,7 @@ public class LatinIME extends InputMethodService } } if (mKeyboardSwitcher.getInputView().isShifted()) { - // TODO: This doesn't work with ß, need to fix it in the next release. + // TODO: This doesn't work with [beta], need to fix it in the next release. if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT || keyCodes[0] > Character.MAX_CODE_POINT) { return; @@ -1549,7 +1550,8 @@ public class LatinIME extends InputMethodService } // If this is a punctuation, apply it through the normal key press - if (suggestion.length() == 1 && isWordSeparator(suggestion.charAt(0))) { + if (suggestion.length() == 1 && (isWordSeparator(suggestion.charAt(0)) + || isSuggestedPunctuation(suggestion.charAt(0)))) { // Word separators are suggested before the user inputs something. // So, LatinImeLogger logs "" as a user's input. LatinImeLogger.logOnClickSuggestion( @@ -1681,7 +1683,7 @@ public class LatinIME extends InputMethodService return separators.contains(String.valueOf((char)code)); } - public boolean isSentenceSeparator(int code) { + private boolean isSentenceSeparator(int code) { return mSentenceSeparators.contains(String.valueOf((char)code)); } @@ -1952,14 +1954,18 @@ public class LatinIME extends InputMethodService private void initSuggestPuncList() { mSuggestPuncList = new ArrayList(); - String suggestPuncs = mResources.getString(R.string.suggested_punctuations); - if (suggestPuncs != null) { - for (int i = 0; i < suggestPuncs.length(); i++) { - mSuggestPuncList.add(suggestPuncs.subSequence(i, i + 1)); + mSuggestPuncs = mResources.getString(R.string.suggested_punctuations); + if (mSuggestPuncs != null) { + for (int i = 0; i < mSuggestPuncs.length(); i++) { + mSuggestPuncList.add(mSuggestPuncs.subSequence(i, i + 1)); } } } + private boolean isSuggestedPunctuation(int code) { + return mSuggestPuncs.contains(String.valueOf((char)code)); + } + private void showOptionsMenu() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true);