aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Miyakawa <dmiyakawa@google.com>2009-12-28 11:25:10 +0900
committerDaisuke Miyakawa <dmiyakawa@google.com>2009-12-28 11:25:10 +0900
commit2d6595cdc6058d8712a90fc499b7c8b539f81247 (patch)
treedb1bbb7bf4a2bb33a1401f9c528850c35d30d9cc
parent7fccd43e207863966edc47ea9215237bdcfeb723 (diff)
downloadOpenWnn-2d6595cdc6058d8712a90fc499b7c8b539f81247.tar.gz
Update OpenWnn to the latest (v135_091225)
Bug: 2320860, 2346146
-rw-r--r--Android.mk2
-rw-r--r--README.txt2
-rw-r--r--res/drawable-hdpi/immodeic_full_alphabet.pngbin4966 -> 4985 bytes
-rw-r--r--res/drawable-hdpi/immodeic_full_kana.pngbin4901 -> 5024 bytes
-rw-r--r--res/drawable-hdpi/immodeic_full_number.pngbin4670 -> 4596 bytes
-rw-r--r--res/drawable-hdpi/immodeic_half_alphabet.pngbin1091 -> 5317 bytes
-rw-r--r--res/drawable-hdpi/immodeic_half_kana.pngbin5056 -> 5174 bytes
-rw-r--r--res/drawable-hdpi/immodeic_half_number.pngbin5005 -> 5051 bytes
-rw-r--r--res/drawable-hdpi/immodeic_hiragana.pngbin5236 -> 5113 bytes
-rw-r--r--res/values-ja/string.xml6
-rw-r--r--res/values/dimens.xml4
-rw-r--r--res/values/strings.xml6
-rw-r--r--src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java14
-rw-r--r--src/jp/co/omronsoft/openwnn/JAJP/OpenWnnEngineJAJP.java203
-rw-r--r--src/jp/co/omronsoft/openwnn/JAJP/Romkan.java71
-rw-r--r--src/jp/co/omronsoft/openwnn/JAJP/RomkanFullKatakana.java89
-rw-r--r--src/jp/co/omronsoft/openwnn/JAJP/RomkanHalfKatakana.java7
-rw-r--r--src/jp/co/omronsoft/openwnn/OpenWnn.java4
-rw-r--r--src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java146
19 files changed, 311 insertions, 243 deletions
diff --git a/Android.mk b/Android.mk
index a40e5c5..af7bed2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -8,6 +8,8 @@ LOCAL_PACKAGE_NAME := OpenWnn
LOCAL_JNI_SHARED_LIBRARIES := \
libWnnEngDic libWnnJpnDic libwnndict
+LOCAL_AAPT_FLAGS += -c hdpi
+
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/README.txt b/README.txt
index b729380..3b0ac1d 100644
--- a/README.txt
+++ b/README.txt
@@ -1,7 +1,7 @@
-------------------------------------------------------------------------------
OpenWnn Japnese README
- Version 1.3.4
+ Version 1.3.5
(C) Copyright OMRON SOFTWARE Co., Ltd. 2008,2009 All Rights Reserved.
-------------------------------------------------------------------------------
diff --git a/res/drawable-hdpi/immodeic_full_alphabet.png b/res/drawable-hdpi/immodeic_full_alphabet.png
index 3295cd9..5f5137c 100644
--- a/res/drawable-hdpi/immodeic_full_alphabet.png
+++ b/res/drawable-hdpi/immodeic_full_alphabet.png
Binary files differ
diff --git a/res/drawable-hdpi/immodeic_full_kana.png b/res/drawable-hdpi/immodeic_full_kana.png
index 14b2275..870787a 100644
--- a/res/drawable-hdpi/immodeic_full_kana.png
+++ b/res/drawable-hdpi/immodeic_full_kana.png
Binary files differ
diff --git a/res/drawable-hdpi/immodeic_full_number.png b/res/drawable-hdpi/immodeic_full_number.png
index 3192910..fc41837 100644
--- a/res/drawable-hdpi/immodeic_full_number.png
+++ b/res/drawable-hdpi/immodeic_full_number.png
Binary files differ
diff --git a/res/drawable-hdpi/immodeic_half_alphabet.png b/res/drawable-hdpi/immodeic_half_alphabet.png
index 34a13cd..6d14168 100644
--- a/res/drawable-hdpi/immodeic_half_alphabet.png
+++ b/res/drawable-hdpi/immodeic_half_alphabet.png
Binary files differ
diff --git a/res/drawable-hdpi/immodeic_half_kana.png b/res/drawable-hdpi/immodeic_half_kana.png
index d1f4f37..6003174 100644
--- a/res/drawable-hdpi/immodeic_half_kana.png
+++ b/res/drawable-hdpi/immodeic_half_kana.png
Binary files differ
diff --git a/res/drawable-hdpi/immodeic_half_number.png b/res/drawable-hdpi/immodeic_half_number.png
index 8d620e1..fcd2261 100644
--- a/res/drawable-hdpi/immodeic_half_number.png
+++ b/res/drawable-hdpi/immodeic_half_number.png
Binary files differ
diff --git a/res/drawable-hdpi/immodeic_hiragana.png b/res/drawable-hdpi/immodeic_hiragana.png
index 7b79230..2640e3a 100644
--- a/res/drawable-hdpi/immodeic_hiragana.png
+++ b/res/drawable-hdpi/immodeic_hiragana.png
Binary files differ
diff --git a/res/values-ja/string.xml b/res/values-ja/string.xml
index 66ece62..296da5a 100644
--- a/res/values-ja/string.xml
+++ b/res/values-ja/string.xml
@@ -103,13 +103,13 @@
<!-- IME dependency -->
<!-- OpenWnn English -->
- <string name="openwnn_english_copyright">Ver.1.3.4\nオムロン ソフトウェア(株)</string>
+ <string name="openwnn_english_copyright">Ver.1.3.5\nオムロン ソフトウェア(株)</string>
<!-- OpenWnn Japanese -->
- <string name="openwnn_japanese_copyright">Ver.1.3.4\nオムロン ソフトウェア(株)</string>
+ <string name="openwnn_japanese_copyright">Ver.1.3.5\nオムロン ソフトウェア(株)</string>
<!-- OpenWnn Chinese -->
- <string name="openwnn_china_copyright">Ver.1.3.4\nオムロン ソフトウェア(株)</string>
+ <string name="openwnn_china_copyright">Ver.1.3.5\nオムロン ソフトウェア(株)</string>
<!-- Candidate Delete -->
<string name="button_candidate_select">選 択</string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2d87471..d90f9aa 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -18,7 +18,7 @@
<dimen name="key_height">50dip</dimen>
<dimen name="key_height_landscape">34dip</dimen>
<dimen name="candidate_font_size">20sp</dimen>
- <dimen name="candidate_delete_word_size">32dip</dimen>
- <dimen name="candidate_delete_word_size_landscape">28dip</dimen>
+ <dimen name="candidate_delete_word_size">28px</dimen>
+ <dimen name="candidate_delete_word_size_landscape">24px</dimen>
<dimen name="bubble_pointer_offset">22dip</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 49748b4..883a927 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -105,20 +105,20 @@
<!-- IME dependency -->
<!-- OpenWnn English -->
- <string name="openwnn_english_copyright">Ver.1.3.4\nOMRON SOFTWARE Co., Ltd.</string>
+ <string name="openwnn_english_copyright">Ver.1.3.5\nOMRON SOFTWARE Co., Ltd.</string>
<string name="openwnn_english">OpenWnn English</string>
<string name="openwnn_english_system_dictionary">/data/data/jp.co.omronsoft.openwnn/lib/libWnnEngDic.so</string>
<string name="openwnn_english_writable_dictionary">/data/data/jp.co.omronsoft.openwnn/writableEN.dic</string>
<string name="en_word_separators">.,;:!?</string>
<!-- OpenWnn Japanese -->
- <string name="openwnn_japanese_copyright">Ver.1.3.4\nOMRON SOFTWARE Co., Ltd.</string>
+ <string name="openwnn_japanese_copyright">Ver.1.3.5\nOMRON SOFTWARE Co., Ltd.</string>
<string name="openwnn_japanese">Japanese IME</string>
<string name="openwnn_japanese_system_dictionary">/data/data/jp.co.omronsoft.openwnn/lib/libWnnJpnDic.so</string>
<string name="openwnn_japanese_writable_dictionary">/data/data/jp.co.omronsoft.openwnn/writableJAJP.dic</string>
<!-- OpenWnn Chinese -->
- <string name="openwnn_china_copyright">Ver.1.3.4\nOMRON SOFTWARE Co., Ltd.</string>
+ <string name="openwnn_china_copyright">Ver.1.3.5\nOMRON SOFTWARE Co., Ltd.</string>
<string name="openwnn_china">OpenWnn Chinese</string>
<string name="openwnn_china_system_dictionary">/data/data/jp.co.omronsoft.openwnn/lib/libWnnZHCNDic.so</string>
<!-- After Config Change -->
diff --git a/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java b/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java
index b01b629..8079d2f 100644
--- a/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java
+++ b/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java
@@ -440,7 +440,7 @@ public class DefaultSoftKeyboardJAJP extends DefaultSoftKeyboard {
/** @see jp.co.omronsoft.openwnn.DefaultSoftKeyboard#changeKeyboard */
@Override protected boolean changeKeyboard(Keyboard keyboard) {
if (keyboard != null) {
- if (mIsInputTypeNull) {
+ if (mIsInputTypeNull && mChangeModeKey != null) {
mChangeModeKey.popupResId = mPopupResId;
}
@@ -449,7 +449,7 @@ public class DefaultSoftKeyboardJAJP extends DefaultSoftKeyboard {
? KEY_INDEX_CHANGE_MODE_QWERTY : KEY_INDEX_CHANGE_MODE_12KEY;
mChangeModeKey = keys.get(keyIndex);
- if (mIsInputTypeNull) {
+ if (mIsInputTypeNull && mChangeModeKey != null) {
mPopupResId = mChangeModeKey.popupResId;
mChangeModeKey.popupResId = 0;
}
@@ -696,15 +696,19 @@ public class DefaultSoftKeyboardJAJP extends DefaultSoftKeyboard {
if (inputType == EditorInfo.TYPE_NULL) {
if (!mIsInputTypeNull) {
mIsInputTypeNull = true;
- mPopupResId = mChangeModeKey.popupResId;
- mChangeModeKey.popupResId = 0;
+ if (mChangeModeKey != null) {
+ mPopupResId = mChangeModeKey.popupResId;
+ mChangeModeKey.popupResId = 0;
+ }
}
return;
}
if (mIsInputTypeNull) {
mIsInputTypeNull = false;
- mChangeModeKey.popupResId = mPopupResId;
+ if (mChangeModeKey != null) {
+ mChangeModeKey.popupResId = mPopupResId;
+ }
}
}
diff --git a/src/jp/co/omronsoft/openwnn/JAJP/OpenWnnEngineJAJP.java b/src/jp/co/omronsoft/openwnn/JAJP/OpenWnnEngineJAJP.java
index 98b5a40..1181202 100644
--- a/src/jp/co/omronsoft/openwnn/JAJP/OpenWnnEngineJAJP.java
+++ b/src/jp/co/omronsoft/openwnn/JAJP/OpenWnnEngineJAJP.java
@@ -41,33 +41,33 @@ import android.util.Log;
* @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD. All Rights Reserved.
*/
public class OpenWnnEngineJAJP implements WnnEngine {
- /** Current dictionary type */
- private int mDictType = DIC_LANG_INIT;
+ /** Current dictionary type */
+ private int mDictType = DIC_LANG_INIT;
/** Dictionary type (default) */
- public static final int DIC_LANG_INIT = 0;
+ public static final int DIC_LANG_INIT = 0;
/** Dictionary type (Japanese standard) */
- public static final int DIC_LANG_JP = 0;
+ public static final int DIC_LANG_JP = 0;
/** Dictionary type (English standard) */
- public static final int DIC_LANG_EN = 1;
+ public static final int DIC_LANG_EN = 1;
/** Dictionary type (Japanese person's name) */
- public static final int DIC_LANG_JP_PERSON_NAME = 2;
+ public static final int DIC_LANG_JP_PERSON_NAME = 2;
/** Dictionary type (User dictionary) */
- public static final int DIC_USERDIC = 3;
+ public static final int DIC_USERDIC = 3;
/** Dictionary type (Japanese EISU-KANA conversion) */
- public static final int DIC_LANG_JP_EISUKANA = 4;
+ public static final int DIC_LANG_JP_EISUKANA = 4;
/** Dictionary type (e-mail/URI) */
- public static final int DIC_LANG_EN_EMAIL_ADDRESS = 5;
+ public static final int DIC_LANG_EN_EMAIL_ADDRESS = 5;
/** Dictionary type (Japanese postal address) */
- public static final int DIC_LANG_JP_POSTAL_ADDRESS = 6;
+ public static final int DIC_LANG_JP_POSTAL_ADDRESS = 6;
/** Type of the keyboard */
private int mKeyboardType = KEYBOARD_UNDEF;
/** Keyboard type (not defined) */
public static final int KEYBOARD_UNDEF = 0;
/** Keyboard type (12-keys) */
- public static final int KEYBOARD_KEYPAD12 = 1;
+ public static final int KEYBOARD_KEYPAD12 = 1;
/** Keyboard type (Qwerty) */
- public static final int KEYBOARD_QWERTY = 2;
+ public static final int KEYBOARD_QWERTY = 2;
/** Score(frequency value) of word in the learning dictionary */
public static final int FREQ_LEARN = 600;
@@ -80,23 +80,23 @@ public class OpenWnnEngineJAJP implements WnnEngine {
public static final int PREDICT_LIMIT = 100;
/** OpenWnn dictionary */
- private WnnDictionary mDictionaryJP;
+ private WnnDictionary mDictionaryJP;
- /** Word list */
+ /** Word list */
private ArrayList<WnnWord> mConvResult;
/** HashMap for checking duplicate word */
- private HashMap<String, WnnWord> mCandTable;
-
- /** Input string (Hiragana) */
- private String mInputHiragana;
-
- /** Input string (Romaji) */
- private String mInputRomaji;
-
- /** Number of output candidates */
- private int mOutputNum;
-
+ private HashMap<String, WnnWord> mCandTable;
+
+ /** Input string (Hiragana) */
+ private String mInputHiragana;
+
+ /** Input string (Romaji) */
+ private String mInputRomaji;
+
+ /** Number of output candidates */
+ private int mOutputNum;
+
/**
* Where to get the next candidates from.<br>
* (0:prefix search from the dictionary, 1:single clause converter, 2:Kana converter)
@@ -127,17 +127,17 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/**
* Constructor
*
- * @param writableDictionaryName Writable dictionary file name(null if not use)
+ * @param writableDictionaryName Writable dictionary file name(null if not use)
*/
public OpenWnnEngineJAJP(String writableDictionaryName) {
/* load Japanese dictionary library */
mDictionaryJP = new OpenWnnDictionaryImpl(
- "/data/data/jp.co.omronsoft.openwnn/lib/libWnnJpnDic.so",
- writableDictionaryName );
+ "/data/data/jp.co.omronsoft.openwnn/lib/libWnnJpnDic.so",
+ writableDictionaryName );
if (!mDictionaryJP.isActive()) {
- mDictionaryJP = new OpenWnnDictionaryImpl(
- "/system/lib/libWnnJpnDic.so",
- writableDictionaryName );
+ mDictionaryJP = new OpenWnnDictionaryImpl(
+ "/system/lib/libWnnJpnDic.so",
+ writableDictionaryName );
}
/* clear dictionary settings */
@@ -157,7 +157,7 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/**
* Set dictionary for prediction.
*
- * @param strlen Length of input string
+ * @param strlen Length of input string
*/
private void setDictionaryForPrediction(int strlen) {
WnnDictionary dict = mDictionaryJP;
@@ -191,13 +191,13 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/**
* Get a candidate.
*
- * @param index Index of a candidate.
- * @return The candidate; {@code null} if there is no candidate.
+ * @param index Index of a candidate.
+ * @return The candidate; {@code null} if there is no candidate.
*/
private WnnWord getCandidate(int index) {
- WnnWord word;
+ WnnWord word;
- if (mGetCandidateFrom == 0) {
+ if (mGetCandidateFrom == 0) {
if (mDictType == OpenWnnEngineJAJP.DIC_LANG_JP_EISUKANA) {
/* skip to Kana conversion if EISU-KANA conversion mode */
mGetCandidateFrom = 2;
@@ -205,24 +205,24 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/* skip to single clause conversion if single clause conversion mode */
mGetCandidateFrom = 1;
} else {
- if (mConvResult.size() < PREDICT_LIMIT) {
- /* get prefix matching words from the dictionaries */
- while (index >= mConvResult.size()) {
- if ((word = mDictionaryJP.getNextWord()) == null) {
- mGetCandidateFrom = 1;
- break;
- }
- if (!mExactMatchMode || mInputHiragana.equals(word.stroke)) {
- addCandidate(word);
- if (mConvResult.size() >= PREDICT_LIMIT) {
- mGetCandidateFrom = 1;
- break;
- }
- }
- }
- } else {
- mGetCandidateFrom = 1;
- }
+ if (mConvResult.size() < PREDICT_LIMIT) {
+ /* get prefix matching words from the dictionaries */
+ while (index >= mConvResult.size()) {
+ if ((word = mDictionaryJP.getNextWord()) == null) {
+ mGetCandidateFrom = 1;
+ break;
+ }
+ if (!mExactMatchMode || mInputHiragana.equals(word.stroke)) {
+ addCandidate(word);
+ if (mConvResult.size() >= PREDICT_LIMIT) {
+ mGetCandidateFrom = 1;
+ break;
+ }
+ }
+ }
+ } else {
+ mGetCandidateFrom = 1;
+ }
}
}
@@ -240,13 +240,13 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/* get candidates from Kana converter */
if (mGetCandidateFrom == 2) {
- List<WnnWord> addCandidateList
- = mKanaConverter.createPseudoCandidateList(mInputHiragana, mInputRomaji, mKeyboardType);
-
- Iterator<WnnWord> it = addCandidateList.iterator();
- while(it.hasNext()) {
- addCandidate(it.next());
- }
+ List<WnnWord> addCandidateList
+ = mKanaConverter.createPseudoCandidateList(mInputHiragana, mInputRomaji, mKeyboardType);
+
+ Iterator<WnnWord> it = addCandidateList.iterator();
+ while(it.hasNext()) {
+ addCandidate(it.next());
+ }
mGetCandidateFrom = 3;
}
@@ -264,16 +264,16 @@ public class OpenWnnEngineJAJP implements WnnEngine {
* the same one in the buffer and the length of the candidate
* string is not longer than {@code MAX_OUTPUT_LENGTH}.
*
- * @param word A word to be add
- * @return {@code true} if the word added; {@code false} if not.
+ * @param word A word to be add
+ * @return {@code true} if the word added; {@code false} if not.
*/
private boolean addCandidate(WnnWord word) {
if (word.candidate == null || mCandTable.containsKey(word.candidate)
- || word.candidate.length() > MAX_OUTPUT_LENGTH) {
- return false;
- }
+ || word.candidate.length() > MAX_OUTPUT_LENGTH) {
+ return false;
+ }
if (mFilter != null && !mFilter.isAllowed(word)) {
- return false;
+ return false;
}
mCandTable.put(word.candidate, word);
mConvResult.add(word);
@@ -296,20 +296,20 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/**
* Set dictionary type.
*
- * @param type Type of dictionary
- * @return {@code true} if the dictionary is changed; {@code false} if not.
+ * @param type Type of dictionary
+ * @return {@code true} if the dictionary is changed; {@code false} if not.
*/
public boolean setDictionary(int type) {
- mDictType = type;
- return true;
+ mDictType = type;
+ return true;
}
/**
* Set the search key and the search mode from {@link ComposingText}.
*
- * @param text Input text
- * @param maxLen Maximum length to convert
- * @return Length of the search key
+ * @param text Input text
+ * @param maxLen Maximum length to convert
+ * @return Length of the search key
*/
private int setSearchKey(ComposingText text, int maxLen) {
String input = text.toString(ComposingText.LAYER1);
@@ -342,7 +342,7 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/**
* Set keyboard type.
*
- * @param keyboardType Type of keyboard
+ * @param keyboardType Type of keyboard
*/
public void setKeyboardType(int keyboardType) {
mKeyboardType = keyboardType;
@@ -351,11 +351,11 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/**
* Set the candidate filter
*
- * @param filter The candidate filter
+ * @param filter The candidate filter
*/
public void setFilter(CandidateFilter filter) {
- mFilter = filter;
- mClauseConverter.setFilter(filter);
+ mFilter = filter;
+ mClauseConverter.setFilter(filter);
}
/***********************************************************************
@@ -405,11 +405,11 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/** @see jp.co.omronsoft.openwnn.WnnEngine#convert */
public int convert(ComposingText text) {
- clearCandidates();
+ clearCandidates();
- if (text == null) {
- return 0;
- }
+ if (text == null) {
+ return 0;
+ }
mDictionaryJP.setInUseState( true );
@@ -440,26 +440,26 @@ public class OpenWnnEngineJAJP implements WnnEngine {
sentence = new WnnSentence(head, sentence);
}
if (sentence == null) {
- return 0;
- }
-
- StrSegmentClause[] ss = new StrSegmentClause[sentence.elements.size()];
- int pos = 0;
- int idx = 0;
- Iterator<WnnClause> it = sentence.elements.iterator();
- while(it.hasNext()) {
- WnnClause clause = (WnnClause)it.next();
- int len = clause.stroke.length();
- ss[idx] = new StrSegmentClause(clause, pos, pos + len - 1);
- pos += len;
- idx += 1;
- }
- text.setCursor(ComposingText.LAYER2, text.size(ComposingText.LAYER2));
- text.replaceStrSegment(ComposingText.LAYER2, ss,
+ return 0;
+ }
+
+ StrSegmentClause[] ss = new StrSegmentClause[sentence.elements.size()];
+ int pos = 0;
+ int idx = 0;
+ Iterator<WnnClause> it = sentence.elements.iterator();
+ while(it.hasNext()) {
+ WnnClause clause = (WnnClause)it.next();
+ int len = clause.stroke.length();
+ ss[idx] = new StrSegmentClause(clause, pos, pos + len - 1);
+ pos += len;
+ idx += 1;
+ }
+ text.setCursor(ComposingText.LAYER2, text.size(ComposingText.LAYER2));
+ text.replaceStrSegment(ComposingText.LAYER2, ss,
text.getCursor(ComposingText.LAYER2));
mConvertSentence = sentence;
- return 0;
+ return 0;
}
/** @see jp.co.omronsoft.openwnn.WnnEngine#searchWords */
@@ -524,6 +524,9 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/** @see jp.co.omronsoft.openwnn.WnnEngine#addWord */
public int addWord(WnnWord word) {
mDictionaryJP.setInUseState( true );
+ if (word.partOfSpeech.right == 0) {
+ word.partOfSpeech = mDictionaryJP.getPOS(WnnDictionary.POS_TYPE_MEISI);
+ }
mDictionaryJP.addWordToUserDictionary(word);
mDictionaryJP.setInUseState( false );
return 0;
@@ -580,7 +583,7 @@ public class OpenWnnEngineJAJP implements WnnEngine {
/** @see jp.co.omronsoft.openwnn.WnnEngine#initializeDictionary */
public boolean initializeDictionary(int dictionary, int type) {
- return initializeDictionary(dictionary);
+ return initializeDictionary(dictionary);
}
/** @see jp.co.omronsoft.openwnn.WnnEngine#getUserDictionaryWords */
diff --git a/src/jp/co/omronsoft/openwnn/JAJP/Romkan.java b/src/jp/co/omronsoft/openwnn/JAJP/Romkan.java
index 59edf27..797b81e 100644
--- a/src/jp/co/omronsoft/openwnn/JAJP/Romkan.java
+++ b/src/jp/co/omronsoft/openwnn/JAJP/Romkan.java
@@ -119,20 +119,20 @@ public class Romkan implements LetterConverter {
put("vu", "\u30f4"); put("va", "\u30f4\u3041"); put("vi", "\u30f4\u3043");
put("vyi", "\u30f4\u3043"); put("ve", "\u30f4\u3047"); put("vye", "\u30f4\u3047");
put("vo", "\u30f4\u3049"); put("vya", "\u30f4\u3083"); put("vyu", "\u30f4\u3085");
- put("vyo", "\u30f4\u3087");
- put("bb", "\u3063b"); put("cc", "\u3063c"); put("dd", "\u3063d");
- put("ff", "\u3063f"); put("gg", "\u3063g"); put("hh", "\u3063h");
- put("jj", "\u3063j"); put("kk", "\u3063k"); put("ll", "\u3063l");
- put("mm", "\u3063m"); put("pp", "\u3063p"); put("qq", "\u3063q");
- put("rr", "\u3063r"); put("ss", "\u3063s"); put("tt", "\u3063t");
- put("vv", "\u3063v"); put("ww", "\u3063w"); put("xx", "\u3063x");
- put("yy", "\u3063y"); put("zz", "\u3063z"); put("nb", "\u3093b");
- put("nc", "\u3093c"); put("nd", "\u3093d"); put("nf", "\u3093f");
- put("ng", "\u3093g"); put("nh", "\u3093h"); put("nj", "\u3093j");
- put("nk", "\u3093k"); put("nm", "\u3093m"); put("np", "\u3093p");
- put("nq", "\u3093q"); put("nr", "\u3093r"); put("ns", "\u3093s");
- put("nt", "\u3093t"); put("nv", "\u3093v"); put("nw", "\u3093w");
- put("nx", "\u3093x"); put("nz", "\u3093z"); put("nl", "\u3093l");
+ put("vyo", "\u30f4\u3087");
+ put("bb", "\u3063b"); put("cc", "\u3063c"); put("dd", "\u3063d");
+ put("ff", "\u3063f"); put("gg", "\u3063g"); put("hh", "\u3063h");
+ put("jj", "\u3063j"); put("kk", "\u3063k"); put("ll", "\u3063l");
+ put("mm", "\u3063m"); put("pp", "\u3063p"); put("qq", "\u3063q");
+ put("rr", "\u3063r"); put("ss", "\u3063s"); put("tt", "\u3063t");
+ put("vv", "\u3063v"); put("ww", "\u3063w"); put("xx", "\u3063x");
+ put("yy", "\u3063y"); put("zz", "\u3063z"); put("nb", "\u3093b");
+ put("nc", "\u3093c"); put("nd", "\u3093d"); put("nf", "\u3093f");
+ put("ng", "\u3093g"); put("nh", "\u3093h"); put("nj", "\u3093j");
+ put("nk", "\u3093k"); put("nm", "\u3093m"); put("np", "\u3093p");
+ put("nq", "\u3093q"); put("nr", "\u3093r"); put("ns", "\u3093s");
+ put("nt", "\u3093t"); put("nv", "\u3093v"); put("nw", "\u3093w");
+ put("nx", "\u3093x"); put("nz", "\u3093z"); put("nl", "\u3093l");
put("-", "\u30fc"); put(".", "\u3002"); put(",", "\u3001"); put("?", "\uff1f"); put("/", "\u30fb");
put("@", "\uff20"); put("#", "\uff03"); put("%", "\uff05"); put("&", "\uff06"); put("*", "\uff0a");
put("+", "\uff0b"); put("=", "\uff1d"); put("(", "\uff08"); put(")", "\uff09");
@@ -144,6 +144,17 @@ public class Romkan implements LetterConverter {
put("6", "\uff16"); put("7", "\uff17"); put("8", "\uff18"); put("9", "\uff19"); put("0", "\uff10");
}};
+ /** Max length of the target text */
+ private static final int MAX_LENGTH = 4;
+
+
+ /**
+ * Default constructor
+ */
+ public Romkan() {
+ super();
+ }
+
/***********************************************************************
* LetterConverter's interface
***********************************************************************/
@@ -155,21 +166,17 @@ public class Romkan implements LetterConverter {
return false;
}
- StrSegment[] str = new StrSegment[3];
- int start = 2;
- str[2] = text.getStrSegment(1, cursor - 1);
- if (cursor >= 2) {
- str[1] = text.getStrSegment(1, cursor - 2);
- start = 1;
- if (cursor >= 3) {
- str[0] = text.getStrSegment(1, cursor - 3);
- start = 0;
- }
+ StrSegment[] str = new StrSegment[MAX_LENGTH];
+ int start = MAX_LENGTH;
+ int checkLength = Math.min(cursor, MAX_LENGTH);
+ for (int i = 1; i <= checkLength; i++) {
+ str[MAX_LENGTH - i] = text.getStrSegment(1, cursor - i);
+ start--;
}
StringBuffer key = new StringBuffer();
- while (start < 3) {
- for (int i = start; i < 3; i++) {
+ while (start < MAX_LENGTH) {
+ for (int i = start; i < MAX_LENGTH; i++) {
key.append(str[i].string);
}
boolean upper = Character.isUpperCase(key.charAt(key.length() - 1));
@@ -181,13 +188,15 @@ public class Romkan implements LetterConverter {
StrSegment[] out;
if (match.length() == 1) {
out = new StrSegment[1];
- out[0] = new StrSegment(match, str[start].from, str[2].to);
- text.replaceStrSegment(1, out, 3 - start);
+ out[0] = new StrSegment(match, str[start].from, str[MAX_LENGTH - 1].to);
+ text.replaceStrSegment(ComposingText.LAYER1, out, MAX_LENGTH - start);
} else {
out = new StrSegment[2];
- out[0] = new StrSegment(match.substring(0, match.length() - 1), str[start].from, str[2].to - 1);
- out[1] = new StrSegment(match.substring(match.length() - 1), str[2].to, str[2].to);
- text.replaceStrSegment(1, out, 3 - start);
+ out[0] = new StrSegment(match.substring(0, match.length() - 1),
+ str[start].from, str[MAX_LENGTH - 1].to - 1);
+ out[1] = new StrSegment(match.substring(match.length() - 1),
+ str[MAX_LENGTH - 1].to, str[MAX_LENGTH - 1].to);
+ text.replaceStrSegment(1, out, MAX_LENGTH - start);
}
return true;
}
diff --git a/src/jp/co/omronsoft/openwnn/JAJP/RomkanFullKatakana.java b/src/jp/co/omronsoft/openwnn/JAJP/RomkanFullKatakana.java
index d42a3c3..37fd6ed 100644
--- a/src/jp/co/omronsoft/openwnn/JAJP/RomkanFullKatakana.java
+++ b/src/jp/co/omronsoft/openwnn/JAJP/RomkanFullKatakana.java
@@ -21,8 +21,6 @@ import jp.co.omronsoft.openwnn.ComposingText;
import jp.co.omronsoft.openwnn.StrSegment;
import java.util.HashMap;
import android.content.SharedPreferences;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
/**
* The Romaji to full-width Katakana converter class for Japanese IME.
@@ -42,6 +40,7 @@ public class RomkanFullKatakana implements LetterConverter {
put("le", "\u30a7"); put("lye", "\u30a7"); put("xe", "\u30a7");
put("xye", "\u30a7"); put("e", "\u30a8"); put("lo", "\u30a9");
put("xo", "\u30a9"); put("o", "\u30aa"); put("ca", "\u30ab");
+ put("lka", "\u30f5"); put("xka", "\u30f5");
put("ka", "\u30ab"); put("ga", "\u30ac"); put("ki", "\u30ad");
put("kyi", "\u30ad\u30a3"); put("kye", "\u30ad\u30a7"); put("kya", "\u30ad\u30e3");
put("kyu", "\u30ad\u30e5"); put("kyo", "\u30ad\u30e7"); put("gi", "\u30ae");
@@ -54,7 +53,8 @@ public class RomkanFullKatakana implements LetterConverter {
put("qo", "\u30af\u30a9"); put("qwo", "\u30af\u30a9"); put("qya", "\u30af\u30e3");
put("qyu", "\u30af\u30e5"); put("qyo", "\u30af\u30e7"); put("gu", "\u30b0");
put("gwa", "\u30b0\u30a1"); put("gwi", "\u30b0\u30a3"); put("gwu", "\u30b0\u30a5");
- put("gwe", "\u30b0\u30a7"); put("gwo", "\u30b0\u30a9"); put("ke", "\u30b1");
+ put("gwe", "\u30b0\u30a7"); put("gwo", "\u30b0\u30a9");
+ put("lke", "\u30f6"); put("xke", "\u30f6"); put("ke", "\u30b1");
put("ge", "\u30b2"); put("co", "\u30b3"); put("ko", "\u30b3");
put("go", "\u30b4"); put("sa", "\u30b5"); put("za", "\u30b6");
put("ci", "\u30b7"); put("shi", "\u30b7"); put("si", "\u30b7");
@@ -123,23 +123,34 @@ public class RomkanFullKatakana implements LetterConverter {
put("vu", "\u30f4"); put("va", "\u30f4\u30a1"); put("vi", "\u30f4\u30a3");
put("vyi", "\u30f4\u30a3"); put("ve", "\u30f4\u30a7"); put("vye", "\u30f4\u30a7");
put("vo", "\u30f4\u30a9"); put("vya", "\u30f4\u30e3"); put("vyu", "\u30f4\u30e5");
- put("vyo", "\u30f4\u30e7");
- put("bb", "\u30c3b"); put("cc", "\u30c3c"); put("dd", "\u30c3d");
- put("ff", "\u30c3f"); put("gg", "\u30c3g"); put("hh", "\u30c3h");
- put("jj", "\u30c3j"); put("kk", "\u30c3k"); put("ll", "\u30c3l");
- put("mm", "\u30c3m"); put("pp", "\u30c3p"); put("qq", "\u30c3q");
- put("rr", "\u30c3r"); put("ss", "\u30c3s"); put("tt", "\u30c3t");
- put("vv", "\u30c3v"); put("ww", "\u30c3w"); put("xx", "\u30c3x");
- put("yy", "\u30c3y"); put("zz", "\u30c3z"); put("nb", "\u30f3b");
- put("nc", "\u30f3c"); put("nd", "\u30f3d"); put("nf", "\u30f3f");
- put("ng", "\u30f3g"); put("nh", "\u30f3h"); put("nj", "\u30f3j");
- put("nk", "\u30f3k"); put("nm", "\u30f3m"); put("np", "\u30f3p");
- put("nq", "\u30f3q"); put("nr", "\u30f3r"); put("ns", "\u30f3s");
- put("nt", "\u30f3t"); put("nv", "\u30f3v"); put("nw", "\u30f3w");
- put("nx", "\u30f3x"); put("nz", "\u30f3z"); put("nl", "\u30f3l");
+ put("vyo", "\u30f4\u30e7");
+ put("bb", "\u30c3b"); put("cc", "\u30c3c"); put("dd", "\u30c3d");
+ put("ff", "\u30c3f"); put("gg", "\u30c3g"); put("hh", "\u30c3h");
+ put("jj", "\u30c3j"); put("kk", "\u30c3k"); put("ll", "\u30c3l");
+ put("mm", "\u30c3m"); put("pp", "\u30c3p"); put("qq", "\u30c3q");
+ put("rr", "\u30c3r"); put("ss", "\u30c3s"); put("tt", "\u30c3t");
+ put("vv", "\u30c3v"); put("ww", "\u30c3w"); put("xx", "\u30c3x");
+ put("yy", "\u30c3y"); put("zz", "\u30c3z"); put("nb", "\u30f3b");
+ put("nc", "\u30f3c"); put("nd", "\u30f3d"); put("nf", "\u30f3f");
+ put("ng", "\u30f3g"); put("nh", "\u30f3h"); put("nj", "\u30f3j");
+ put("nk", "\u30f3k"); put("nm", "\u30f3m"); put("np", "\u30f3p");
+ put("nq", "\u30f3q"); put("nr", "\u30f3r"); put("ns", "\u30f3s");
+ put("nt", "\u30f3t"); put("nv", "\u30f3v"); put("nw", "\u30f3w");
+ put("nx", "\u30f3x"); put("nz", "\u30f3z"); put("nl", "\u30f3l");
put("-", "\u30fc"); put(".", "\u3002"); put(",", "\u3001"); put("?", "\uff1f"); put("/", "\u30fb");
}};
+ /** Max length of the target text */
+ private static final int MAX_LENGTH = 4;
+
+
+ /**
+ * Default constructor
+ */
+ public RomkanFullKatakana() {
+ super();
+ }
+
/** @see LetterConverter#convert */
public boolean convert(ComposingText text) {
return convert(text, mRomkanTable);
@@ -148,9 +159,9 @@ public class RomkanFullKatakana implements LetterConverter {
/**
* convert Romaji to Full Katakana
*
- * @param text The input/output text
- * @param table HashMap for Romaji-to-Kana conversion
- * @return {@code true} if conversion is compleated; {@code false} if not
+ * @param text The input/output text
+ * @param table HashMap for Romaji-to-Kana conversion
+ * @return {@code true} if conversion is compleated; {@code false} if not
*/
public static boolean convert(ComposingText text, HashMap<String, String> table) {
int cursor = text.getCursor(1);
@@ -159,21 +170,17 @@ public class RomkanFullKatakana implements LetterConverter {
return false;
}
- StrSegment[] str = new StrSegment[3];
- int start = 2;
- str[2] = text.getStrSegment(ComposingText.LAYER1, cursor - 1);
- if (cursor >= 2) {
- str[1] = text.getStrSegment(ComposingText.LAYER1, cursor - 2);
- start = 1;
- if (cursor >= 3) {
- str[0] = text.getStrSegment(ComposingText.LAYER1, cursor - 3);
- start = 0;
- }
+ StrSegment[] str = new StrSegment[MAX_LENGTH];
+ int start = MAX_LENGTH;
+ int checkLength = Math.min(cursor, MAX_LENGTH);
+ for (int i = 1; i <= checkLength; i++) {
+ str[MAX_LENGTH - i] = text.getStrSegment(1, cursor - i);
+ start--;
}
StringBuffer key = new StringBuffer();
- while (start < 3) {
- for (int i = start; i < 3; i++) {
+ while (start < MAX_LENGTH) {
+ for (int i = start; i < MAX_LENGTH; i++) {
key.append(str[i].string);
}
boolean upper = Character.isUpperCase(key.charAt(key.length() - 1));
@@ -185,19 +192,15 @@ public class RomkanFullKatakana implements LetterConverter {
StrSegment[] out;
if (match.length() == 1) {
out = new StrSegment[1];
- out[0] = new StrSegment(match, str[start].from, str[2].to);
- text.replaceStrSegment(ComposingText.LAYER1, out, 3 - start);
+ out[0] = new StrSegment(match, str[start].from, str[MAX_LENGTH - 1].to);
+ text.replaceStrSegment(ComposingText.LAYER1, out, MAX_LENGTH - start);
} else {
out = new StrSegment[2];
- out[0] = new StrSegment(match.substring(0, match.length() - 1), str[start].from, str[2].to - 1);
- out[1] = new StrSegment(match.substring(match.length() - 1), str[2].to, str[2].to);
- text.replaceStrSegment(ComposingText.LAYER1, out, 3 - start);
- }
- String regex = ".*[a-zA-Z]$";
- Pattern p = Pattern.compile(regex);
- Matcher m = p.matcher(text.toString(ComposingText.LAYER1));
- if (m.matches()) {
- text.moveCursor(ComposingText.LAYER1, -1);
+ out[0] = new StrSegment(match.substring(0, match.length() - 1),
+ str[start].from, str[MAX_LENGTH - 1].to - 1);
+ out[1] = new StrSegment(match.substring(match.length() - 1),
+ str[MAX_LENGTH - 1].to, str[MAX_LENGTH - 1].to);
+ text.replaceStrSegment(1, out, MAX_LENGTH - start);
}
return true;
}
diff --git a/src/jp/co/omronsoft/openwnn/JAJP/RomkanHalfKatakana.java b/src/jp/co/omronsoft/openwnn/JAJP/RomkanHalfKatakana.java
index 732f4b5..b119fe8 100644
--- a/src/jp/co/omronsoft/openwnn/JAJP/RomkanHalfKatakana.java
+++ b/src/jp/co/omronsoft/openwnn/JAJP/RomkanHalfKatakana.java
@@ -136,6 +136,13 @@ public class RomkanHalfKatakana implements LetterConverter {
put("-", "\uff70"); put(".", "\uff61"); put(",", "\uff64"); put("/", "\uff65");
}};
+ /**
+ * Default constructor
+ */
+ public RomkanHalfKatakana() {
+ super();
+ }
+
/** @see LetterConverter#convert */
public boolean convert(ComposingText text) {
return RomkanFullKatakana.convert(text, mRomkanTable);
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnn.java b/src/jp/co/omronsoft/openwnn/OpenWnn.java
index a68ef74..fdc643b 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnn.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnn.java
@@ -21,6 +21,7 @@ import android.view.WindowManager;
import android.content.Context;
import android.view.View;
import android.view.KeyEvent;
+import android.view.MotionEvent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@@ -30,7 +31,6 @@ import android.view.inputmethod.*;
import android.content.res.Configuration;
import android.graphics.*;
import android.graphics.drawable.*;
-import android.view.MotionEvent;
/**
* The OpenWnn IME's base class.
@@ -140,7 +140,7 @@ public class OpenWnn extends InputMethodService {
@Override public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting);
mInputConnection = getCurrentInputConnection();
- if (mComposingText != null) {
+ if (!restarting && mComposingText != null) {
mComposingText.clear();
}
}
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java b/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java
index b93c837..47df1ca 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java
@@ -284,7 +284,7 @@ public class OpenWnnJAJP extends OpenWnn {
/** Symbol lists to display when the symbol key is pressed */
private static final String[] SYMBOL_LISTS = {
- SymbolList.SYMBOL_JAPANESE_FACE, SymbolList.SYMBOL_JAPANESE, SymbolList.SYMBOL_ENGLISH
+ SymbolList.SYMBOL_JAPANESE_FACE, SymbolList.SYMBOL_JAPANESE, SymbolList.SYMBOL_ENGLISH
};
/** Current symbol list */
@@ -392,6 +392,9 @@ public class OpenWnnJAJP extends OpenWnn {
/** Whether there is a continued predicted candidate */
private boolean mHasContinuedPrediction = false;
+ /** Whether text selection has started */
+ private boolean mHasStartedTextSelection = true;
+
/** {@code Handler} for drawing candidates/displaying tutorial */
Handler mHandler = new Handler() {
@Override
@@ -481,30 +484,32 @@ public class OpenWnnJAJP extends OpenWnn {
/** @see jp.co.omronsoft.openwnn.OpenWnn#onStartInputView */
@Override public void onStartInputView(EditorInfo attribute, boolean restarting) {
- EngineState state = new EngineState();
- state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
- updateEngineState(state);
-
- mPrevCommitCount = 0;
- clearCommitInfo();
-
- ((DefaultSoftKeyboard) mInputViewManager).resetCurrentKeyboard();
+ if (restarting) {
+ super.onStartInputView(attribute, restarting);
+ } else {
+ EngineState state = new EngineState();
+ state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
+ updateEngineState(state);
- super.onStartInputView(attribute, restarting);
+ mPrevCommitCount = 0;
+ clearCommitInfo();
+
+ ((DefaultSoftKeyboard) mInputViewManager).resetCurrentKeyboard();
+
+ super.onStartInputView(attribute, restarting);
+
+ mCandidatesViewManager.clearCandidates();
+ mStatus = STATUS_INIT;
+ mExactMatchMode = false;
- /* initialize views */
- mCandidatesViewManager.clearCandidates();
- /* initialize status */
- mStatus = STATUS_INIT;
- mExactMatchMode = false;
+ /* hardware keyboard support */
+ mHardShift = 0;
+ mHardAlt = 0;
+ updateMetaKeyStateDisplay();
+ }
/* load preferences */
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
- /* hardware keyboard support */
- mHardShift = 0;
- mHardAlt = 0;
- updateMetaKeyStateDisplay();
-
/* initialize the engine's state */
fitInputType(pref, attribute);
@@ -535,8 +540,12 @@ public class OpenWnnJAJP extends OpenWnn {
mComposingStartCursor = (candidatesStart < 0) ? newSelEnd : candidatesStart;
+ boolean prevSelection = mHasStartedTextSelection;
if (newSelStart != newSelEnd) {
clearCommitInfo();
+ mHasStartedTextSelection = true;
+ } else {
+ mHasStartedTextSelection = false;
}
if (mHasContinuedPrediction) {
@@ -567,7 +576,9 @@ public class OpenWnnJAJP extends OpenWnn {
mInputConnection.finishComposingText();
}
}
- initializeScreen();
+ if ((prevSelection != mHasStartedTextSelection) || !mHasStartedTextSelection) {
+ initializeScreen();
+ }
}
}
}
@@ -689,10 +700,23 @@ public class OpenWnnJAJP extends OpenWnn {
}
if (mDirectInputMode) {
- if (ev.code == OpenWnnEvent.INPUT_SOFT_KEY && mInputConnection != null) {
- mInputConnection.sendKeyEvent(keyEvent);
- mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP,
- keyEvent.getKeyCode()));
+ if (mInputConnection != null) {
+ switch (ev.code) {
+ case OpenWnnEvent.INPUT_SOFT_KEY:
+ if (keyCode == KeyEvent.KEYCODE_ENTER) {
+ sendKeyChar('\n');
+ } else {
+ mInputConnection.sendKeyEvent(keyEvent);
+ mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP,
+ keyEvent.getKeyCode()));
+ }
+ break;
+ case OpenWnnEvent.INPUT_CHAR:
+ sendKeyChar(ev.chars[0]);
+ break;
+ default:
+ break;
+ }
}
/* return if InputConnection is not active */
@@ -760,7 +784,7 @@ public class OpenWnnJAJP extends OpenWnn {
case OpenWnnEvent.TOGGLE_REVERSE_CHAR:
if (((mStatus & ~STATUS_CANDIDATE_FULL) == STATUS_INPUT)
- && !(mEngineState.isConvertState())) {
+ && !(mEngineState.isConvertState()) && (ev.toggleTable != null)) {
int cursor = mComposingText.getCursor(ComposingText.LAYER1);
if (cursor > 0) {
@@ -833,13 +857,13 @@ public class OpenWnnJAJP extends OpenWnn {
case OpenWnnEvent.INPUT_SOFT_KEY:
ret = processKeyEvent(keyEvent);
if (!ret) {
- int code = keyEvent.getKeyCode();
- if (code == KeyEvent.KEYCODE_ENTER) {
+ int code = keyEvent.getKeyCode();
+ if (code == KeyEvent.KEYCODE_ENTER) {
sendKeyChar('\n');
- } else {
+ } else {
mInputConnection.sendKeyEvent(keyEvent);
mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, code));
- }
+ }
ret = true;
}
break;
@@ -920,7 +944,7 @@ public class OpenWnnJAJP extends OpenWnn {
if (ev.isPrintingKey()) {
/* do nothing if the character is not able to display or the character is dead key */
if ((mHardShift > 0 && mHardAlt > 0) ||
- (ev.isAltPressed() == true && ev.isShiftPressed() == true)) {
+ (ev.isAltPressed() && ev.isShiftPressed())) {
int charCode = ev.getUnicodeChar(MetaKeyKeyListener.META_SHIFT_ON | MetaKeyKeyListener.META_ALT_ON);
if (charCode == 0 || (charCode & KeyCharacterMap.COMBINING_ACCENT) != 0 || charCode == PRIVATE_AREA_CODE) {
if(mHardShift == 1){
@@ -1027,7 +1051,8 @@ public class OpenWnnJAJP extends OpenWnn {
mComposingText.toString(ComposingText.LAYER1).length());
mExactMatchMode = false;
} else {
- if (mComposingText.size(ComposingText.LAYER1) == 1) {
+ if ((mComposingText.size(ComposingText.LAYER1) == 1)
+ && mComposingText.getCursor(ComposingText.LAYER1) != 0) {
initializeScreen();
return true;
} else {
@@ -1100,6 +1125,8 @@ public class OpenWnnJAJP extends OpenWnn {
return true;
case KeyEvent.KEYCODE_CALL:
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ case KeyEvent.KEYCODE_VOLUME_UP:
return false;
default:
@@ -1133,14 +1160,6 @@ public class OpenWnnJAJP extends OpenWnn {
}
} else {
switch (key) {
- case KeyEvent.KEYCODE_DPAD_CENTER:
- case KeyEvent.KEYCODE_ENTER:
- if (mEnableAutoHideKeyboard) {
- mInputViewManager.closing();
- requestHideSelf(0);
- return true;
- }
- break;
case KeyEvent.KEYCODE_BACK:
/*
* If 'BACK' key is pressed when the SW-keyboard is shown
@@ -1254,7 +1273,11 @@ public class OpenWnnJAJP extends OpenWnn {
}
if (completed) {
- commitText(false);
+ if (!mEngineState.isEnglish()) {
+ commitTextWithoutLastAlphabet();
+ } else {
+ commitText(false);
+ }
} else {
updateViewStatus(ComposingText.LAYER1, false, true);
}
@@ -1367,6 +1390,8 @@ public class OpenWnnJAJP extends OpenWnn {
break;
case KeyEvent.KEYCODE_CALL:
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ case KeyEvent.KEYCODE_VOLUME_UP:
return false;
case KeyEvent.KEYCODE_DPAD_CENTER:
@@ -1478,7 +1503,9 @@ public class OpenWnnJAJP extends OpenWnn {
displayCursor = (cursor == 0) ? 0 : 1;
}
/* update the composing text on the EditView */
- mInputConnection.setComposingText(mDisplayText, displayCursor);
+ if ((mDisplayText.length() != 0) || !mHasStartedTextSelection) {
+ mInputConnection.setComposingText(mDisplayText, displayCursor);
+ }
}
}
@@ -1572,6 +1599,22 @@ public class OpenWnnJAJP extends OpenWnn {
}
/**
+ * Commit the composing text except the alphabet character at the tail.
+ */
+ private void commitTextWithoutLastAlphabet() {
+ int layer = mTargetLayer;
+ String tmp = mComposingText.getStrSegment(layer, -1).string;
+
+ if (isAlphabetLast(tmp)) {
+ mComposingText.moveCursor(ComposingText.LAYER1, -1);
+ commitText(false);
+ mComposingText.moveCursor(ComposingText.LAYER1, 1);
+ } else {
+ commitText(false);
+ }
+ }
+
+ /**
* Commit all uncommitted words.
*/
private void commitAllText() {
@@ -1637,16 +1680,16 @@ public class OpenWnnJAJP extends OpenWnn {
layer = 1; /* for connected prediction */
}
- boolean commited = autoCommitEnglish();
+ boolean committed = autoCommitEnglish();
mEnableAutoDeleteSpace = true;
if (layer == ComposingText.LAYER2) {
EngineState state = new EngineState();
state.convertType = EngineState.CONVERT_TYPE_RENBUN;
updateEngineState(state);
- updateViewStatus(layer, !commited, false);
+ updateViewStatus(layer, !committed, false);
} else {
- updateViewStatusForPrediction(!commited, false);
+ updateViewStatusForPrediction(!committed, false);
}
if (mComposingText.size(ComposingText.LAYER0) == 0) {
@@ -1960,10 +2003,7 @@ public class OpenWnnJAJP extends OpenWnn {
String str = table[0];
/* shift on */
- if (mAutoCaps
- && isEnglishPrediction()
- && (getShiftKeyState(getCurrentInputEditorInfo()) == 1)) {
-
+ if (mAutoCaps && (getShiftKeyState(getCurrentInputEditorInfo()) == 1)) {
char top = table[0].charAt(0);
if (Character.isLowerCase(top)) {
str = Character.toString(Character.toUpperCase(top));
@@ -1996,7 +2036,7 @@ public class OpenWnnJAJP extends OpenWnn {
} else {
boolean completed = mPreConverter.convert(text);
if (completed) {
- commitText(false);
+ commitTextWithoutLastAlphabet();
} else {
mStatus = STATUS_INPUT;
updateViewStatusForPrediction(true, true);
@@ -2508,9 +2548,9 @@ public class OpenWnnJAJP extends OpenWnn {
DefaultSoftKeyboardJAJP inputManager = ((DefaultSoftKeyboardJAJP) mInputViewManager);
View v = inputManager.getKeyboardView();
v.setOnTouchListener(new View.OnTouchListener() {
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }});
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }});
mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_START_TUTORIAL), 500);
}