diff options
author | 2011-06-21 18:03:18 +0900 | |
---|---|---|
committer | 2011-06-21 10:42:53 -0700 | |
commit | ec622ced359cfe646efc14b68e25539fa7a438d9 (patch) | |
tree | 6d582ddc027c722ba7dc6276b33bcab94e057c77 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | e5e9bc0e4f43195ef03268565cbd68cdd18e5e2d (diff) | |
download | latinime-ec622ced359cfe646efc14b68e25539fa7a438d9.tar.gz latinime-ec622ced359cfe646efc14b68e25539fa7a438d9.tar.xz latinime-ec622ced359cfe646efc14b68e25539fa7a438d9.zip |
Support Turkish keyboard (DO NOT MERGE)
Basically this change is back port from Master I1ae2c4ff.
Bug: 4435347
Change-Id: Ide1a46bbf5584d8783bb93bbe64328f514c6ab79
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b1689f886..4f3d3ba9f 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -16,13 +16,6 @@ package com.android.inputmethod.latin; -import com.android.inputmethod.latin.LatinIMEUtil.RingCharBuffer; -import com.android.inputmethod.voice.FieldContext; -import com.android.inputmethod.voice.SettingsUtil; -import com.android.inputmethod.voice.VoiceInput; - -import org.xmlpull.v1.XmlPullParserException; - import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -65,6 +58,13 @@ import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.LinearLayout; +import com.android.inputmethod.latin.LatinIMEUtil.RingCharBuffer; +import com.android.inputmethod.voice.FieldContext; +import com.android.inputmethod.voice.SettingsUtil; +import com.android.inputmethod.voice.VoiceInput; + +import org.xmlpull.v1.XmlPullParserException; + import java.io.FileDescriptor; import java.io.IOException; import java.io.PrintWriter; @@ -1413,13 +1413,15 @@ public class LatinIME extends InputMethodService } primaryCode = keyCodes[0]; if (mKeyboardSwitcher.isAlphabetMode() && Character.isLowerCase(primaryCode)) { - int upperCaseCode = Character.toUpperCase(primaryCode); - if (upperCaseCode != primaryCode) { - primaryCode = upperCaseCode; + // In some locales, such as Turkish, Character.toUpperCase() may return a wrong + // character because it doesn't take care of locale. + final String upperCaseString = new String(new int[] {primaryCode}, 0, 1) + .toUpperCase(mLanguageSwitcher.getInputLocale()); + if (upperCaseString.codePointCount(0, upperCaseString.length()) == 1) { + primaryCode = upperCaseString.codePointAt(0); } else { // Some keys, such as [eszett], have upper case as multi-characters. - String upperCase = new String(new int[] {primaryCode}, 0, 1).toUpperCase(); - onText(upperCase); + onText(upperCaseString); return; } } @@ -1983,13 +1985,14 @@ public class LatinIME extends InputMethodService * word. */ private void pickSuggestion(CharSequence suggestion, boolean correcting) { - LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); + final LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); + final Locale inputLocale = mLanguageSwitcher.getInputLocale(); if (mCapsLock) { - suggestion = suggestion.toString().toUpperCase(); + suggestion = suggestion.toString().toUpperCase(inputLocale); } else if (preferCapitalization() || (mKeyboardSwitcher.isAlphabetMode() && inputView.isShifted())) { - suggestion = suggestion.toString().toUpperCase().charAt(0) + suggestion = suggestion.toString().toUpperCase(inputLocale).charAt(0) + suggestion.subSequence(1, suggestion.length()).toString(); } InputConnection ic = getCurrentInputConnection(); @@ -2026,9 +2029,10 @@ public class LatinIME extends InputMethodService // If the first letter of touching is capitalized, make all the suggestions // start with a capital letter. if (Character.isUpperCase(touching.word.charAt(0))) { + final Locale inputLocale = mLanguageSwitcher.getInputLocale(); for (int i = 0; i < suggestions.size(); i++) { String origSugg = (String) suggestions.get(i); - String capsSugg = origSugg.toUpperCase().charAt(0) + String capsSugg = origSugg.toUpperCase(inputLocale).charAt(0) + origSugg.subSequence(1, origSugg.length()).toString(); suggestions.set(i, capsSugg); } |