diff --git a/README.txt b/README.txt
index 4975e42..f629b4e 100644
--- a/README.txt
+++ b/README.txt
@@ -1,7 +1,7 @@
 -------------------------------------------------------------------------------
                             OpenWnn for Android README
 
-                                   Version 1.20
+                             Version 1.21-RC-20090403
                   
      (C) Copyright OMRON SOFTWARE Co., Ltd. 2008,2009 All Rights Reserved.
 -------------------------------------------------------------------------------
diff --git a/libs/Android.mk b/libs/Android.mk
index 72383a0..21ff42f 100644
--- a/libs/Android.mk
+++ b/libs/Android.mk
@@ -1,4 +1,3 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := eng 
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/res/values-ja/string.xml b/res/values-ja/string.xml
index 419b207..2f75fe5 100644
--- a/res/values-ja/string.xml
+++ b/res/values-ja/string.xml
@@ -99,13 +99,13 @@
 
   <!-- IME dependency -->
     <!-- OpenWnn English -->
-    <string name="openwnn_english_copyright">Ver.1.20\nオムロン ソフトウェア(株)</string>
+    <string name="openwnn_english_copyright">Ver.1.21-RC-20090403\nオムロン ソフトウェア(株)</string>
 
     <!-- OpenWnn Japanese -->
-    <string name="openwnn_japanese_copyright">Ver.1.20\nオムロン ソフトウェア(株)</string>
+    <string name="openwnn_japanese_copyright">Ver.1.21-RC-20090403\nオムロン ソフトウェア(株)</string>
 
     <!-- OpenWnn Chinese -->
-    <string name="openwnn_china_copyright">Ver.1.20\nオムロン ソフトウェア(株)</string>
+    <string name="openwnn_china_copyright">Ver.1.21-RC-20090403\nオムロン ソフトウェア(株)</string>
 
   <!-- Candidate Delete -->
       <string name="button_candidate_select">選　択</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index baf5d19..993dad8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -115,20 +115,20 @@
 
   <!-- IME dependency -->
     <!-- OpenWnn English -->
-    <string name="openwnn_english_copyright">Ver.1.20\nOMRON SOFTWARE Co., Ltd.</string>
+    <string name="openwnn_english_copyright">Ver.1.21-RC-20090403\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.20\nOMRON SOFTWARE Co., Ltd.</string>
+    <string name="openwnn_japanese_copyright">Ver.1.21-RC-20090403\nOMRON SOFTWARE Co., Ltd.</string>
     <string name="openwnn_japanese">OpenWnn Japanese</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.20\nOMRON SOFTWARE Co., Ltd.</string>
+    <string name="openwnn_china_copyright">Ver.1.21-RC-20090403\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/CandidateFilter.java b/src/jp/co/omronsoft/openwnn/CandidateFilter.java
index a3bac7c..f3dd55a 100644
--- a/src/jp/co/omronsoft/openwnn/CandidateFilter.java
+++ b/src/jp/co/omronsoft/openwnn/CandidateFilter.java
@@ -28,43 +28,43 @@
  */
 public class CandidateFilter {
     /** Filtering pattern (No filter) */
-	public static final int FILTER_NONE = 0x0;
+    public static final int FILTER_NONE = 0x0;
     /** Filtering pattern (Emoji filter) */
-	public static final int FILTER_EMOJI = 0x1;
+    public static final int FILTER_EMOJI = 0x1;
 
     /** Regular expression pattern for emoji */
     private static final Pattern PATTERN_EMOJI = Pattern.compile("[\uDBB8\uDBB9\uDBBA\uDBBB]");
 
     /** Current filter type */
-	private int mFilter = 0;
+    private int mFilter = 0;
 
-	/**
-	 * Set specified filter type.
-	 * 
-	 * @param filter	The filter type
-	 * @see jp.co.omronsoft.openwnn.CandidateFilter#FILTER_NONE
-	 * @see jp.co.omronsoft.openwnn.CandidateFilter#FILTER_EMOJI
-	 */
-	public void setFilter(int filter) {
-		mFilter = filter;
-	}
-	
-	/**
-	 * Checking whether a specified word is filtered.
-	 * 
-	 * @param word		A word
-	 * @return			{@code true} if the word is allowed; {@code false} if the word is denied.
-	 */
-	public boolean isAllowed(WnnWord word) {
-		if (mFilter == 0) {
-			return true;
-		}
-		if ((mFilter & FILTER_EMOJI) != 0) {
-			Matcher m = PATTERN_EMOJI.matcher(word.candidate);
-			if (m.matches()) {
-				return false;
-			}
-		}		
-		return true;
-	}
+    /**
+     * Set specified filter type.
+     * 
+     * @param filter    The filter type
+     * @see jp.co.omronsoft.openwnn.CandidateFilter#FILTER_NONE
+     * @see jp.co.omronsoft.openwnn.CandidateFilter#FILTER_EMOJI
+     */
+    public void setFilter(int filter) {
+        mFilter = filter;
+    }
+    
+    /**
+     * Checking whether a specified word is filtered.
+     * 
+     * @param word      A word
+     * @return          {@code true} if the word is allowed; {@code false} if the word is denied.
+     */
+    public boolean isAllowed(WnnWord word) {
+        if (mFilter == 0) {
+            return true;
+        }
+        if ((mFilter & FILTER_EMOJI) != 0) {
+            Matcher m = PATTERN_EMOJI.matcher(word.candidate);
+            if (m.matches()) {
+                return false;
+            }
+        }       
+        return true;
+    }
 }
diff --git a/src/jp/co/omronsoft/openwnn/ComposingText.java b/src/jp/co/omronsoft/openwnn/ComposingText.java
index dbf26f5..328efb5 100644
--- a/src/jp/co/omronsoft/openwnn/ComposingText.java
+++ b/src/jp/co/omronsoft/openwnn/ComposingText.java
@@ -93,10 +93,10 @@
     /**
      * Get a {@link StrSegment} at the position specified.
      *
-     * @param layer		Layer
-     * @param pos 		Position (<0 : the tail segment)
+     * @param layer     Layer
+     * @param pos       Position (<0 : the tail segment)
      *
-     * @return			The segment; {@code null} if error occurs.
+     * @return          The segment; {@code null} if error occurs.
      */
     public StrSegment getStrSegment(int layer, int pos) {
         try {
@@ -116,10 +116,10 @@
     /**
      * Convert the range of segments to a string.
      *
-     * @param layer		Layer
-     * @param from		Convert range from
-     * @param to		Convert range to
-     * @return			The string converted; {@code null} if error occurs.
+     * @param layer     Layer
+     * @param from      Convert range from
+     * @param to        Convert range to
+     * @return          The string converted; {@code null} if error occurs.
      */
     public String toString(int layer, int from, int to) {
         try {
@@ -139,8 +139,8 @@
     /**
      * Convert segments of the layer to a string.
      *
-     * @param layer		Layer
-     * @return			The string converted; {@code null} if error occurs.
+     * @param layer     Layer
+     * @return          The string converted; {@code null} if error occurs.
      */
     public String toString(int layer) {
         return this.toString(layer, 0, mStringLayer[layer].size() - 1);
@@ -149,10 +149,10 @@
     /**
      * Update the upper layer's data.
      *
-     * @param layer			The base layer
-     * @param mod_from		Modified from
-     * @param mod_len		Length after modified (# of StrSegments from {@code mod_from})
-     * @param org_len		Length before modified (# of StrSegments from {@code mod_from})
+     * @param layer         The base layer
+     * @param mod_from      Modified from
+     * @param mod_len       Length after modified (# of StrSegments from {@code mod_from})
+     * @param org_len       Length before modified (# of StrSegments from {@code mod_from})
      */
     private void modifyUpper(int layer, int mod_from, int mod_len, int org_len) {
         if (layer >= MAX_LAYER - 1) {
@@ -272,9 +272,9 @@
     /**
      * Insert a {@link StrSegment} at the cursor position(without merging to the previous segment).
      * <p>
-     * @param layer1		Layer to insert
-     * @param layer2		Never merge to the previous segment from {@code layer1} to {@code layer2}.
-     * @param str   		String
+     * @param layer1        Layer to insert
+     * @param layer2        Never merge to the previous segment from {@code layer1} to {@code layer2}.
+     * @param str           String
      **/
     public void insertStrSegment(int layer1, int layer2, StrSegment str) {
         mStringLayer[layer1].add(mCursor[layer1], str);
@@ -300,10 +300,10 @@
     /**
      * Replace segments at the range specified.
      *
-     * @param layer		Layer
-     * @param str		String segment array to replace
-     * @param from		Replace from
-     * @param to		Replace to
+     * @param layer     Layer
+     * @param str       String segment array to replace
+     * @param from      Replace from
+     * @param to        Replace to
      **/
     protected void replaceStrSegment0(int layer, StrSegment[] str, int from, int to) {
         ArrayList<StrSegment> strLayer = mStringLayer[layer];
@@ -327,9 +327,9 @@
     /**
      * Replace segments at the range specified.
      *
-     * @param layer		Layer
-     * @param str		String segment array to replace
-     * @param num		Size of string segment array
+     * @param layer     Layer
+     * @param str       String segment array to replace
+     * @param num       Size of string segment array
      **/
     public void replaceStrSegment(int layer, StrSegment[] str, int num) {
         int cursor = mCursor[layer];
@@ -340,8 +340,8 @@
     /**
      * Replace the segment at the cursor.
      *
-     * @param layer 	Layer
-     * @param str   	String segment to replace
+     * @param layer     Layer
+     * @param str       String segment to replace
      **/
     public void replaceStrSegment(int layer, StrSegment[] str) {
         int cursor = mCursor[layer];
@@ -427,10 +427,10 @@
     /**
      * Delete segments (internal method).
      * 
-     * @param layer		Layer
-     * @param from		Delete from
-     * @param to		Delete to
-	 * @param diff		Differential
+     * @param layer     Layer
+     * @param from      Delete from
+     * @param to        Delete to
+     * @param diff      Differential
      **/
     private void deleteStrSegment0(int layer, int from, int to, int diff) {
         ArrayList<StrSegment> strLayer = mStringLayer[layer];
@@ -449,9 +449,9 @@
     /**
      * Delete a segment at the cursor.
      * 
-     * @param layer     	Layer
-     * @param rightside		{@code true} if direction is rightward at the cursor, {@code false} if direction is leftward at the cursor
-     * @return				The number of string segments in the specified layer
+     * @param layer         Layer
+     * @param rightside     {@code true} if direction is rightward at the cursor, {@code false} if direction is leftward at the cursor
+     * @return              The number of string segments in the specified layer
      **/
     public int delete(int layer, boolean rightside) {
         int cursor = mCursor[layer];
@@ -470,8 +470,8 @@
     /**
      * Get the string layer.
      *
-     * @param layer		Layer
-     * @return			{@link ArrayList} of {@link StrSegment}; {@code null} if error.
+     * @param layer     Layer
+     * @return          {@link ArrayList} of {@link StrSegment}; {@code null} if error.
      **/
     public ArrayList<StrSegment> getStringLayer(int layer) {
         try {
@@ -484,9 +484,9 @@
     /**
      * Get upper the segment which includes the position.
      * 
-     * @param layer		Layer	
-     * @param pos		Position		
-     * @return 		Index of upper segment
+     * @param layer     Layer   
+     * @param pos       Position        
+     * @return      Index of upper segment
      */
     private int included(int layer, int pos) {
         if (pos == 0) {
@@ -507,9 +507,9 @@
     /**
      * Set the cursor.
      * 
-     * @param layer		Layer
-     * @param pos   	Position of cursor
-     * @return 		New position of cursor
+     * @param layer     Layer
+     * @param pos       Position of cursor
+     * @return      New position of cursor
      */
     public int setCursor(int layer, int pos) {
         if (pos > mStringLayer[layer].size()) {
@@ -537,9 +537,9 @@
     /**
      * Move the cursor.
      *
-     * @param layer		Layer
-     * @param diff		Relative position from current cursor position
-     * @return 		New position of cursor
+     * @param layer     Layer
+     * @param diff      Relative position from current cursor position
+     * @return      New position of cursor
      **/
     public int moveCursor(int layer, int diff) {
         int c = mCursor[layer] + diff;
@@ -550,8 +550,8 @@
     /**
      * Get the cursor position.
      *
-     * @param layer		Layer
-     * @return cursor	Current position of cursor
+     * @param layer     Layer
+     * @return cursor   Current position of cursor
      **/
     public int getCursor(int layer) {
         return mCursor[layer];
@@ -560,8 +560,8 @@
     /**
      * Get the number of segments.
      *
-     * @param layer		Layer
-     * @return			Number of segments
+     * @param layer     Layer
+     * @return          Number of segments
      **/
     public int size(int layer) {
         return mStringLayer[layer].size();
diff --git a/src/jp/co/omronsoft/openwnn/DefaultSoftKeyboard.java b/src/jp/co/omronsoft/openwnn/DefaultSoftKeyboard.java
index 4da207c..9b72074 100644
--- a/src/jp/co/omronsoft/openwnn/DefaultSoftKeyboard.java
+++ b/src/jp/co/omronsoft/openwnn/DefaultSoftKeyboard.java
@@ -38,207 +38,209 @@
  * @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD.  All Rights Reserved.
  */
 public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKeyboardActionListener {
-	/*
-	 *----------------------------------------------------------------------
-	 * key codes for a software keyboard
-	 *----------------------------------------------------------------------
-	 */
+    /*
+     *----------------------------------------------------------------------
+     * key codes for a software keyboard
+     *----------------------------------------------------------------------
+     */
     /** Change the keyboard language */
-	public static final int KEYCODE_CHANGE_LANG = -500;
+    public static final int KEYCODE_CHANGE_LANG = -500;
 
-	/* for Japanese 12-key keyboard */
-	/** Japanese 12-key keyboard [1] */
-	public static final int KEYCODE_JP12_1 = -201;
-	/** Japanese 12-key keyboard [2] */
-	public static final int KEYCODE_JP12_2 = -202;
-	/** Japanese 12-key keyboard [3] */
-	public static final int KEYCODE_JP12_3 = -203;
-	/** Japanese 12-key keyboard [4] */
-	public static final int KEYCODE_JP12_4 = -204;
-	/** Japanese 12-key keyboard [5] */
-	public static final int KEYCODE_JP12_5 = -205;
-	/** Japanese 12-key keyboard [6] */
-	public static final int KEYCODE_JP12_6 = -206;
-	/** Japanese 12-key keyboard [7] */
-	public static final int KEYCODE_JP12_7 = -207;
-	/** Japanese 12-key keyboard [8] */
-	public static final int KEYCODE_JP12_8 = -208;
-	/** Japanese 12-key keyboard [9] */
-	public static final int KEYCODE_JP12_9 = -209;
-	/** Japanese 12-key keyboard [0] */
-	public static final int KEYCODE_JP12_0 = -210;
-	/** Japanese 12-key keyboard [#] */
-	public static final int KEYCODE_JP12_SHARP = -211;
-	/** Japanese 12-key keyboard [*] */
-	public static final int KEYCODE_JP12_ASTER = -213;
-	/** Japanese 12-key keyboard [DEL] */
-	public static final int KEYCODE_JP12_BACKSPACE = -214;
-	/** Japanese 12-key keyboard [SPACE] */
-	public static final int KEYCODE_JP12_SPACE = -215;
-	/** Japanese 12-key keyboard [ENTER] */
-	public static final int KEYCODE_JP12_ENTER = -216;
-	/** Japanese 12-key keyboard [RIGHT ARROW] */
-	public static final int KEYCODE_JP12_RIGHT = -217;
-	/** Japanese 12-key keyboard [LEFT ARROW] */
-	public static final int KEYCODE_JP12_LEFT = -218;
-	/** Japanese 12-key keyboard [REVERSE TOGGLE] */
-	public static final int KEYCODE_JP12_REVERSE = -219;
-	/** Japanese 12-key keyboard [CLOSE] */
-	public static final int KEYCODE_JP12_CLOSE   = -220;
-	/** Japanese 12-key keyboard [KEYBOARD TYPE CHANGE] */
-	public static final int KEYCODE_JP12_KBD   = -221;
-	/** Japanese 12-key keyboard [EMOJI] */
-	public static final int KEYCODE_JP12_EMOJI      = -222;
-	/** Japanese 12-key keyboard [FULL-WIDTH HIRAGANA MODE] */
-	public static final int KEYCODE_JP12_ZEN_HIRA   = -223;
-	/** Japanese 12-key keyboard [FULL-WIDTH NUMBER MODE] */
-	public static final int KEYCODE_JP12_ZEN_NUM    = -224;
-	/** Japanese 12-key keyboard [FULL-WIDTH ALPHABET MODE] */
-	public static final int KEYCODE_JP12_ZEN_ALPHA  = -225;
-	/** Japanese 12-key keyboard [FULL-WIDTH KATAKANA MODE] */
-	public static final int KEYCODE_JP12_ZEN_KATA   = -226;
-	/** Japanese 12-key keyboard [HALF-WIDTH KATAKANA MODE] */
-	public static final int KEYCODE_JP12_HAN_KATA   = -227;
-	/** Japanese 12-key keyboard [HALF-WIDTH NUMBER MODE] */
-	public static final int KEYCODE_JP12_HAN_NUM    = -228;
-	/** Japanese 12-key keyboard [HALF-WIDTH ALPHABET MODE] */
-	public static final int KEYCODE_JP12_HAN_ALPHA  = -229;
-	/** Japanese 12-key keyboard [MODE TOOGLE CHANGE] */
-	public static final int KEYCODE_JP12_TOGGLE_MODE = -230;
-	
-	/* for Qwerty keyboard */
-	/** Qwerty keyboard [DEL] */
-	public static final int KEYCODE_QWERTY_BACKSPACE = -100;
-	/** Qwerty keyboard [ENTER] */
-	public static final int KEYCODE_QWERTY_ENTER = -101;
-	/** Qwerty keyboard [SHIFT] */
-	public static final int KEYCODE_QWERTY_SHIFT = Keyboard.KEYCODE_SHIFT;
-	/** Qwerty keyboard [ALT] */
-	public static final int KEYCODE_QWERTY_ALT   = -103;
-	/** Qwerty keyboard [KEYBOARD TYPE CHANGE] */
-	public static final int KEYCODE_QWERTY_KBD   = -104;
-	/** Qwerty keyboard [CLOSE] */
-	public static final int KEYCODE_QWERTY_CLOSE = -105;
-	/** Japanese Qwerty keyboard [EMOJI] */
-	public static final int KEYCODE_QWERTY_EMOJI = -106;
-	/** Japanese Qwerty keyboard [FULL-WIDTH HIRAGANA MODE] */
-	public static final int KEYCODE_QWERTY_ZEN_HIRA   = -107;
-	/** Japanese Qwerty keyboard [FULL-WIDTH NUMBER MODE] */
-	public static final int KEYCODE_QWERTY_ZEN_NUM    = -108;
-	/** Japanese Qwerty keyboard [FULL-WIDTH ALPHABET MODE] */
-	public static final int KEYCODE_QWERTY_ZEN_ALPHA  = -109;
-	/** Japanese Qwerty keyboard [FULL-WIDTH KATAKANA MODE] */
-	public static final int KEYCODE_QWERTY_ZEN_KATA   = -110;
-	/** Japanese Qwerty keyboard [HALF-WIDTH KATAKANA MODE] */
-	public static final int KEYCODE_QWERTY_HAN_KATA   = -111;
-	/** Qwerty keyboard [NUMBER MODE] */
-	public static final int KEYCODE_QWERTY_HAN_NUM    = -112;
-	/** Qwerty keyboard [ALPHABET MODE] */
-	public static final int KEYCODE_QWERTY_HAN_ALPHA  = -113;
-	/** Qwerty keyboard [MODE TOOGLE CHANGE] */
-	public static final int KEYCODE_QWERTY_TOGGLE_MODE = -114;
-	/** Qwerty keyboard [PINYIN MODE] */
-	public static final int KEYCODE_QWERTY_PINYIN  = -115;
-	
-	/** OpenWnn instance which hold this software keyboard*/
-	protected OpenWnn      mWnn;
-	
-	/** Current keyboard view */
-	protected KeyboardView mKeyboardView;
-	
-	/** View objects (main side) */
-	protected ViewGroup mMainView;
-	/** View objects (sub side) */
-	protected ViewGroup mSubView;
-	
-	/** Current keyboard definition */
-	protected Keyboard mCurrentKeyboard;
-	
+    /* for Japanese 12-key keyboard */
+    /** Japanese 12-key keyboard [1] */
+    public static final int KEYCODE_JP12_1 = -201;
+    /** Japanese 12-key keyboard [2] */
+    public static final int KEYCODE_JP12_2 = -202;
+    /** Japanese 12-key keyboard [3] */
+    public static final int KEYCODE_JP12_3 = -203;
+    /** Japanese 12-key keyboard [4] */
+    public static final int KEYCODE_JP12_4 = -204;
+    /** Japanese 12-key keyboard [5] */
+    public static final int KEYCODE_JP12_5 = -205;
+    /** Japanese 12-key keyboard [6] */
+    public static final int KEYCODE_JP12_6 = -206;
+    /** Japanese 12-key keyboard [7] */
+    public static final int KEYCODE_JP12_7 = -207;
+    /** Japanese 12-key keyboard [8] */
+    public static final int KEYCODE_JP12_8 = -208;
+    /** Japanese 12-key keyboard [9] */
+    public static final int KEYCODE_JP12_9 = -209;
+    /** Japanese 12-key keyboard [0] */
+    public static final int KEYCODE_JP12_0 = -210;
+    /** Japanese 12-key keyboard [#] */
+    public static final int KEYCODE_JP12_SHARP = -211;
+    /** Japanese 12-key keyboard [*] */
+    public static final int KEYCODE_JP12_ASTER = -213;
+    /** Japanese 12-key keyboard [DEL] */
+    public static final int KEYCODE_JP12_BACKSPACE = -214;
+    /** Japanese 12-key keyboard [SPACE] */
+    public static final int KEYCODE_JP12_SPACE = -215;
+    /** Japanese 12-key keyboard [ENTER] */
+    public static final int KEYCODE_JP12_ENTER = -216;
+    /** Japanese 12-key keyboard [RIGHT ARROW] */
+    public static final int KEYCODE_JP12_RIGHT = -217;
+    /** Japanese 12-key keyboard [LEFT ARROW] */
+    public static final int KEYCODE_JP12_LEFT = -218;
+    /** Japanese 12-key keyboard [REVERSE TOGGLE] */
+    public static final int KEYCODE_JP12_REVERSE = -219;
+    /** Japanese 12-key keyboard [CLOSE] */
+    public static final int KEYCODE_JP12_CLOSE   = -220;
+    /** Japanese 12-key keyboard [KEYBOARD TYPE CHANGE] */
+    public static final int KEYCODE_JP12_KBD   = -221;
+    /** Japanese 12-key keyboard [EMOJI] */
+    public static final int KEYCODE_JP12_EMOJI      = -222;
+    /** Japanese 12-key keyboard [FULL-WIDTH HIRAGANA MODE] */
+    public static final int KEYCODE_JP12_ZEN_HIRA   = -223;
+    /** Japanese 12-key keyboard [FULL-WIDTH NUMBER MODE] */
+    public static final int KEYCODE_JP12_ZEN_NUM    = -224;
+    /** Japanese 12-key keyboard [FULL-WIDTH ALPHABET MODE] */
+    public static final int KEYCODE_JP12_ZEN_ALPHA  = -225;
+    /** Japanese 12-key keyboard [FULL-WIDTH KATAKANA MODE] */
+    public static final int KEYCODE_JP12_ZEN_KATA   = -226;
+    /** Japanese 12-key keyboard [HALF-WIDTH KATAKANA MODE] */
+    public static final int KEYCODE_JP12_HAN_KATA   = -227;
+    /** Japanese 12-key keyboard [HALF-WIDTH NUMBER MODE] */
+    public static final int KEYCODE_JP12_HAN_NUM    = -228;
+    /** Japanese 12-key keyboard [HALF-WIDTH ALPHABET MODE] */
+    public static final int KEYCODE_JP12_HAN_ALPHA  = -229;
+    /** Japanese 12-key keyboard [MODE TOOGLE CHANGE] */
+    public static final int KEYCODE_JP12_TOGGLE_MODE = -230;
+    
+    /* for Qwerty keyboard */
+    /** Qwerty keyboard [DEL] */
+    public static final int KEYCODE_QWERTY_BACKSPACE = -100;
+    /** Qwerty keyboard [ENTER] */
+    public static final int KEYCODE_QWERTY_ENTER = -101;
+    /** Qwerty keyboard [SHIFT] */
+    public static final int KEYCODE_QWERTY_SHIFT = Keyboard.KEYCODE_SHIFT;
+    /** Qwerty keyboard [ALT] */
+    public static final int KEYCODE_QWERTY_ALT   = -103;
+    /** Qwerty keyboard [KEYBOARD TYPE CHANGE] */
+    public static final int KEYCODE_QWERTY_KBD   = -104;
+    /** Qwerty keyboard [CLOSE] */
+    public static final int KEYCODE_QWERTY_CLOSE = -105;
+    /** Japanese Qwerty keyboard [EMOJI] */
+    public static final int KEYCODE_QWERTY_EMOJI = -106;
+    /** Japanese Qwerty keyboard [FULL-WIDTH HIRAGANA MODE] */
+    public static final int KEYCODE_QWERTY_ZEN_HIRA   = -107;
+    /** Japanese Qwerty keyboard [FULL-WIDTH NUMBER MODE] */
+    public static final int KEYCODE_QWERTY_ZEN_NUM    = -108;
+    /** Japanese Qwerty keyboard [FULL-WIDTH ALPHABET MODE] */
+    public static final int KEYCODE_QWERTY_ZEN_ALPHA  = -109;
+    /** Japanese Qwerty keyboard [FULL-WIDTH KATAKANA MODE] */
+    public static final int KEYCODE_QWERTY_ZEN_KATA   = -110;
+    /** Japanese Qwerty keyboard [HALF-WIDTH KATAKANA MODE] */
+    public static final int KEYCODE_QWERTY_HAN_KATA   = -111;
+    /** Qwerty keyboard [NUMBER MODE] */
+    public static final int KEYCODE_QWERTY_HAN_NUM    = -112;
+    /** Qwerty keyboard [ALPHABET MODE] */
+    public static final int KEYCODE_QWERTY_HAN_ALPHA  = -113;
+    /** Qwerty keyboard [MODE TOOGLE CHANGE] */
+    public static final int KEYCODE_QWERTY_TOGGLE_MODE = -114;
+    /** Qwerty keyboard [PINYIN MODE] */
+    public static final int KEYCODE_QWERTY_PINYIN  = -115;
+    
+    /** OpenWnn instance which hold this software keyboard*/
+    protected OpenWnn      mWnn;
+    
+    /** Current keyboard view */
+    protected KeyboardView mKeyboardView;
+    
+    /** View objects (main side) */
+    protected ViewGroup mMainView;
+    /** View objects (sub side) */
+    protected ViewGroup mSubView;
+    
+    /** Current keyboard definition */
+    protected Keyboard mCurrentKeyboard;
+    
     /** Caps lock state */
-	protected boolean mCapsLock;
-	
-	/**
-	 * Keyboard surfaces 
-	 * <br>
-	 * Keyboard[language][portrait/landscape][keyboard type][shift off/on][key-mode]
-	 */
-	protected Keyboard[][][][][][] mKeyboard;
+    protected boolean mCapsLock;
+    
+    /** Input restraint */
+    protected boolean mDisableKeyInput = true;
+    /**
+     * Keyboard surfaces 
+     * <br>
+     * Keyboard[language][portrait/landscape][keyboard type][shift off/on][key-mode]
+     */
+    protected Keyboard[][][][][][] mKeyboard;
 
-	/* languages */
-	/** Current language */
-	protected int mCurrentLanguage;
-	/** Language (English) */
-	public static final int LANG_EN  = 0;
-	/** Language (Japanese) */
-	public static final int LANG_JA  = 1;
-	/** Language (Chinese) */
-	public static final int LANG_CN  = 2;
+    /* languages */
+    /** Current language */
+    protected int mCurrentLanguage;
+    /** Language (English) */
+    public static final int LANG_EN  = 0;
+    /** Language (Japanese) */
+    public static final int LANG_JA  = 1;
+    /** Language (Chinese) */
+    public static final int LANG_CN  = 2;
 
-	/* portrait/landscape */
-	/** State of the display */
-	protected int mDisplayMode = 0;
-	/** Display mode (Portrait) */
-	public static final int PORTRAIT  = 0;
-	/** Display mode (Landscape) */
-	public static final int LANDSCAPE = 1;
+    /* portrait/landscape */
+    /** State of the display */
+    protected int mDisplayMode = 0;
+    /** Display mode (Portrait) */
+    public static final int PORTRAIT  = 0;
+    /** Display mode (Landscape) */
+    public static final int LANDSCAPE = 1;
 
-	/* keyboard type */
-	/** Current keyboard type */
-	protected int mCurrentKeyboardType;
-	/** Keyboard (QWERTY keyboard) */
-	public static final int KEYBOARD_QWERTY  = 0;
-	/** Keyboard (12-keys keyboard) */
-	public static final int KEYBOARD_12KEY   = 1;
-	/** State of the shift key */
-	protected int mShiftOn = 0;
-	/** Shift key off */
-	public static final int KEYBOARD_SHIFT_OFF = 0;
-	/** Shift key on */
-	public static final int KEYBOARD_SHIFT_ON  = 1;
+    /* keyboard type */
+    /** Current keyboard type */
+    protected int mCurrentKeyboardType;
+    /** Keyboard (QWERTY keyboard) */
+    public static final int KEYBOARD_QWERTY  = 0;
+    /** Keyboard (12-keys keyboard) */
+    public static final int KEYBOARD_12KEY   = 1;
+    /** State of the shift key */
+    protected int mShiftOn = 0;
+    /** Shift key off */
+    public static final int KEYBOARD_SHIFT_OFF = 0;
+    /** Shift key on */
+    public static final int KEYBOARD_SHIFT_ON  = 1;
 
-	/* key-modes */
-	/** Current key-mode */
-	protected int mCurrentKeyMode;
+    /* key-modes */
+    /** Current key-mode */
+    protected int mCurrentKeyMode;
 
-	/* key-modes for English */
+    /* key-modes for English */
     /** English key-mode (alphabet) */
-	public static final int KEYMODE_EN_ALPHABET = 0;
+    public static final int KEYMODE_EN_ALPHABET = 0;
     /** English key-mode (number) */
-	public static final int KEYMODE_EN_NUMBER   = 1;
+    public static final int KEYMODE_EN_NUMBER   = 1;
     /** English key-mode (phone number) */
-	public static final int KEYMODE_EN_PHONE    = 2;
+    public static final int KEYMODE_EN_PHONE    = 2;
 
-	/* key-modes for Japanese */
+    /* key-modes for Japanese */
     /** Japanese key-mode (Full-width Hiragana) */
-	public static final int KEYMODE_JA_FULL_HIRAGANA = 0;
+    public static final int KEYMODE_JA_FULL_HIRAGANA = 0;
     /** Japanese key-mode (Full-width alphabet) */
-	public static final int KEYMODE_JA_FULL_ALPHABET = 1;
+    public static final int KEYMODE_JA_FULL_ALPHABET = 1;
     /** Japanese key-mode (Full-width number) */
-	public static final int KEYMODE_JA_FULL_NUMBER   = 2;
+    public static final int KEYMODE_JA_FULL_NUMBER   = 2;
     /** Japanese key-mode (Full-width Katakana) */
-	public static final int KEYMODE_JA_FULL_KATAKANA = 3;
+    public static final int KEYMODE_JA_FULL_KATAKANA = 3;
     /** Japanese key-mode (Half-width alphabet) */
-	public static final int KEYMODE_JA_HALF_ALPHABET = 4;
+    public static final int KEYMODE_JA_HALF_ALPHABET = 4;
     /** Japanese key-mode (Half-width number) */
-	public static final int KEYMODE_JA_HALF_NUMBER   = 5;
+    public static final int KEYMODE_JA_HALF_NUMBER   = 5;
     /** Japanese key-mode (Half-width Katakana) */
-	public static final int KEYMODE_JA_HALF_KATAKANA = 6;
+    public static final int KEYMODE_JA_HALF_KATAKANA = 6;
     /** Japanese key-mode (Half-width phone number) */
-	public static final int KEYMODE_JA_HALF_PHONE    = 7;
+    public static final int KEYMODE_JA_HALF_PHONE    = 7;
 
-	/* key-modes for Chinese */
+    /* key-modes for Chinese */
     /** Chinese key-mode (pinyin) */
-	public static final int KEYMODE_CN_PINYIN   = 0;
+    public static final int KEYMODE_CN_PINYIN   = 0;
     /** Chinese key-mode (Full-width number) */
-	public static final int KEYMODE_CN_FULL_NUMBER   = 1;
+    public static final int KEYMODE_CN_FULL_NUMBER   = 1;
     /** Chinese key-mode (alphabet) */
-	public static final int KEYMODE_CN_ALPHABET = 2;
+    public static final int KEYMODE_CN_ALPHABET = 2;
     /** Chinese key-mode (phone) */
-	public static final int KEYMODE_CN_PHONE    = 3;
+    public static final int KEYMODE_CN_PHONE    = 3;
     /** Chinese key-mode (Half-width number) */
-	public static final int KEYMODE_CN_HALF_NUMBER   = 4;
-	
-	/* key-modes for HARD */
+    public static final int KEYMODE_CN_HALF_NUMBER   = 4;
+    
+    /* key-modes for HARD */
     /** HARD key-mode (SHIFT_OFF_ALT_OFF) */
     public static final int HARD_KEYMODE_SHIFT_OFF_ALT_OFF     = 2;
     /** HARD key-mode (SHIFT_ON_ALT_OFF) */
@@ -247,7 +249,7 @@
     public static final int HARD_KEYMODE_SHIFT_OFF_ALT_ON      = 4;
     /** HARD key-mode (SHIFT_ON_ALT_ON) */
     public static final int HARD_KEYMODE_SHIFT_ON_ALT_ON       = 5;
-	/** HARD key-mode (SHIFT_LOCK_ALT_OFF) */
+    /** HARD key-mode (SHIFT_LOCK_ALT_OFF) */
     public static final int HARD_KEYMODE_SHIFT_LOCK_ALT_OFF    = 6;
     /** HARD key-mode (SHIFT_LOCK_ALT_ON) */
     public static final int HARD_KEYMODE_SHIFT_LOCK_ALT_ON     = 7;
@@ -261,26 +263,26 @@
     /** Whether the H/W keyboard is hidden. */
     protected boolean mHardKeyboardHidden = true;
 
-	/**
-	 * Status of the composing text
-	 * <br>
-	 * {@code true} if there is no composing text.
-	 */
-	protected boolean mNoInput = true;
-	
-	/** Vibratior for key click vibration */
-	protected Vibrator mVibrator = null;
-	
-	/** MediaPlayer for key click sound */
-	protected MediaPlayer mSound = null;
-	
-	/** Key toggle cycle table currently using */
-	protected String[] mCurrentCycleTable;
+    /**
+     * Status of the composing text
+     * <br>
+     * {@code true} if there is no composing text.
+     */
+    protected boolean mNoInput = true;
+    
+    /** Vibratior for key click vibration */
+    protected Vibrator mVibrator = null;
+    
+    /** MediaPlayer for key click sound */
+    protected MediaPlayer mSound = null;
+    
+    /** Key toggle cycle table currently using */
+    protected String[] mCurrentCycleTable;
 
-	/**
+    /**
      * Constructor
      */
-	public DefaultSoftKeyboard() { }
+    public DefaultSoftKeyboard() { }
 
     /**
      * Create keyboard views
@@ -298,8 +300,8 @@
     /**
      * Get the keyboard changed the specified shift state.
      *
-     * @param shift		Shift state
-     * @return			Keyboard view
+     * @param shift     Shift state
+     * @return          Keyboard view
      */
     protected Keyboard getShiftChangeKeyboard(int shift) {
         try {
@@ -317,8 +319,8 @@
     /**
      * Get the keyboard changed the specified input mode.
      *
-     * @param mode		Input mode
-     * @return			Keyboard view
+     * @param mode      Input mode
+     * @return          Keyboard view
      */
     protected Keyboard getModeChangeKeyboard(int mode) {
         try {
@@ -336,8 +338,8 @@
     /**
      * Get the keyboard changed the specified keyboard type
      *
-     * @param type		Keyboard type
-     * @return			Keyboard view
+     * @param type      Keyboard type
+     * @return          Keyboard view
      */
     protected Keyboard getTypeChangeKeyboard(int type) {
         try {
@@ -355,8 +357,8 @@
     /**
      * Get the keyboard when some characters are input or no character is input.
      *
-     * @param inputed	{@code true} if some characters are inputed; {@code false} if no character is inputed.
-     * @return			Keyboard view
+     * @param inputed   {@code true} if some characters are inputed; {@code false} if no character is inputed.
+     * @return          Keyboard view
      */
     protected Keyboard getKeyboardInputed(boolean inputed) {
         try {
@@ -527,11 +529,10 @@
         SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(parent);
         String skin = pref.getString("keyboard_skin",
                                      mWnn.getResources().getString(R.string.keyboard_skin_id_default));
-        Log.d("OpenWnn", "keyboard_skin="+skin);
         int id = parent.getResources().getIdentifier(skin, "layout", "jp.co.omronsoft.openwnn");
 
         mKeyboardView = (KeyboardView) mWnn.getLayoutInflater().inflate(id, null);
-		mKeyboardView.setOnKeyboardActionListener(this);
+        mKeyboardView.setOnKeyboardActionListener(this);
         mCurrentKeyboard = null;
 
         mMainView = (ViewGroup) parent.getLayoutInflater().inflate(R.layout.keyboard_default_main, null);
@@ -690,6 +691,7 @@
         if (mKeyboardView != null) {
             mKeyboardView.closing();
         }
+        mDisableKeyInput = true;
     }
 
     /***********************************************************************
@@ -755,6 +757,3 @@
     }
 
 }
-
-
-
diff --git a/src/jp/co/omronsoft/openwnn/InputViewManager.java b/src/jp/co/omronsoft/openwnn/InputViewManager.java
index 25bcdf4..f6e15ec 100644
--- a/src/jp/co/omronsoft/openwnn/InputViewManager.java
+++ b/src/jp/co/omronsoft/openwnn/InputViewManager.java
@@ -29,18 +29,18 @@
     /**
      * Initialize the input view.
      *
-     * @param parent   	The OpenWnn object
-     * @param width   	The width of the display
-     * @param height  	The height of the display
+     * @param parent    The OpenWnn object
+     * @param width     The width of the display
+     * @param height    The height of the display
      *
-     * @return 		The input view created in the initialize process; {@code null} if cannot create a input view.
+     * @return      The input view created in the initialize process; {@code null} if cannot create a input view.
      */
     public View initView(OpenWnn parent, int width, int height);
 
     /**
      * Get the input view being used currently.
      *
-     * @return 	The input view; {@code null} if no input view is used currently.
+     * @return  The input view; {@code null} if no input view is used currently.
      */
     public View getCurrentView();
 
diff --git a/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java b/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java
index 0181960..6941fda 100644
--- a/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java
+++ b/src/jp/co/omronsoft/openwnn/JAJP/DefaultSoftKeyboardJAJP.java
@@ -459,6 +459,10 @@
     /** @see jp.co.omronsoft.openwnn.DefaultSoftKeyboard#onKey */
     @Override public void onKey(int primaryCode, int[] keyCodes) {
 
+        if (mDisableKeyInput) {
+            return;
+        }
+
         switch (primaryCode) {
         case KEYCODE_JP12_TOGGLE_MODE:
         case KEYCODE_QWERTY_TOGGLE_MODE:
@@ -667,6 +671,8 @@
         mEnableAutoCaps = pref.getBoolean("auto_caps", true);
         mFixedKeyMode = INVALID_KEYMODE;
         mPreferenceKeyMode = INVALID_KEYMODE;
+        mNoInput = true;
+        mDisableKeyInput = false;
 
         switch (inputType & EditorInfo.TYPE_MASK_CLASS) {
 
@@ -711,7 +717,9 @@
     /** @see jp.co.omronsoft.openwnn.DefaultSoftKeyboard#onUpdateState */
     @Override public void onUpdateState(OpenWnn parent) {
         super.onUpdateState(parent);
-        setShiftByEditorInfo();
+        if (!mCapsLock) {
+            setShiftByEditorInfo();
+        }
     }
 
     /**
diff --git a/src/jp/co/omronsoft/openwnn/LetterConverter.java b/src/jp/co/omronsoft/openwnn/LetterConverter.java
index 7d8aff2..adb6226 100644
--- a/src/jp/co/omronsoft/openwnn/LetterConverter.java
+++ b/src/jp/co/omronsoft/openwnn/LetterConverter.java
@@ -35,8 +35,8 @@
      * Romaji-to-Kana conversion in Japanese <it>(ex: "w"+"a" to "&#x308F;")</it>, 
      * Hangul conversion in Korean.
      *
-     * @param text  	The text data includes input sequence(layer #0) and output area(layer #1)
-     * @return 		{@code true} if conversion is completed; {@code false} if not.
+     * @param text      The text data includes input sequence(layer #0) and output area(layer #1)
+     * @return      {@code true} if conversion is completed; {@code false} if not.
      */
     public boolean convert(ComposingText text);
 
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnn.java b/src/jp/co/omronsoft/openwnn/OpenWnn.java
index 01341ac..41795f6 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnn.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnn.java
@@ -199,7 +199,7 @@
      * Process an event.
      *
      * @param  ev  An event
-     * @return 	{@code true} if the event is processed in this method; {@code false} if not.
+     * @return  {@code true} if the event is processed in this method; {@code false} if not.
      */
     public boolean onEvent(OpenWnnEvent ev) {
         return false;
@@ -211,7 +211,7 @@
      * @param prevChar     The character input previous
      * @param toggleTable  Toggle table
      * @param reverse      {@code false} if toggle direction is forward, {@code true} if toggle direction is backward
-     * @return 			A character ({@code null} if no character is found)
+     * @return          A character ({@code null} if no character is found)
      */
     protected String searchToggleCharacter(String prevChar, String[] toggleTable, boolean reverse) {
         for (int i = 0; i < toggleTable.length; i++) {
@@ -236,6 +236,3 @@
         return null;
     }
 }
-
-
-
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImpl.java b/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImpl.java
index 3659fa3..6c8a464 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImpl.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImpl.java
@@ -30,26 +30,26 @@
  * @author Copyright (C) 2008, 2009 OMRON SOFTWARE CO., LTD.  All Rights Reserved.
  */
 public class OpenWnnDictionaryImpl implements WnnDictionary {
-	/*
-	 * DEFINITION FOR JNI
-	 */
-	static {
-		/* Load the dictionary search library */ 
-		System.loadLibrary( "wnndict" );
-	}
+    /*
+     * DEFINITION FOR JNI
+     */
+    static {
+        /* Load the dictionary search library */ 
+        System.loadLibrary( "wnndict" );
+    }
 
-	/*
-	 * DEFINITION OF CONSTANTS
-	 */
-	/** The maximum length of stroke */
+    /*
+     * DEFINITION OF CONSTANTS
+     */
+    /** The maximum length of stroke */
     public static final int MAX_STROKE_LENGTH       = 50;
-	/** The maximum length of candidate */
+    /** The maximum length of candidate */
     public static final int MAX_CANDIDATE_LENGTH    = 50;
-	/** The table name of writable dictionary on the database */
-	protected static final String TABLE_NAME_DIC    = "dic";
-	/** The type name of user word */
+    /** The table name of writable dictionary on the database */
+    protected static final String TABLE_NAME_DIC    = "dic";
+    /** The type name of user word */
     protected static final int TYPE_NAME_USER   = 0;
-	/** The type name of learn word */
+    /** The type name of learn word */
     protected static final int TYPE_NAME_LEARN  = 1;
 
     /** The column name of database */
@@ -105,10 +105,10 @@
 
     /*
      * Constants to define the upper limit of query.
-	 *
-	 * That is used to fix the size of query expression.
-	 * If the number of approximate patterns for a character is exceeded MAX_PATTERN_OF_APPROX,
-	 * increase that constant to the maximum number of patterns.
+     *
+     * That is used to fix the size of query expression.
+     * If the number of approximate patterns for a character is exceeded MAX_PATTERN_OF_APPROX,
+     * increase that constant to the maximum number of patterns.
      */
     /** Constants to define the upper limit of approximate patterns */
     protected final static int MAX_PATTERN_OF_APPROX    = 6;
@@ -117,23 +117,23 @@
     /**
      * Constants to define the turn around time of query.
      * <br>
-	 * It can be set between 1 to {@code MAX_LENGTH_OF_QUERY}. If the length of query
-	 * string is shorter than {@code FAST_QUERY_LENGTH}, the simple search logic is applied.
-	 * Therefore, the turn around time for short query string is fast so that it is short.
-	 * However, the difference of turn around time at the border length grows big.
-	 * the value should be fixed carefully.
+     * It can be set between 1 to {@code MAX_LENGTH_OF_QUERY}. If the length of query
+     * string is shorter than {@code FAST_QUERY_LENGTH}, the simple search logic is applied.
+     * Therefore, the turn around time for short query string is fast so that it is short.
+     * However, the difference of turn around time at the border length grows big.
+     * the value should be fixed carefully.
      */
     protected final static int FAST_QUERY_LENGTH        = 20;
 
-	/*
-	 * DEFINITION OF PRIVATE FIELD
-	 */
-	/** Internal work area for the dictionary search library */
-	protected long mWnnWork = 0;
+    /*
+     * DEFINITION OF PRIVATE FIELD
+     */
+    /** Internal work area for the dictionary search library */
+    protected long mWnnWork = 0;
 
-	/** The file path of the writable dictionary */
+    /** The file path of the writable dictionary */
     protected String mDicFilePath = "";
-	/** The writable dictionary object */
+    /** The writable dictionary object */
     protected SQLiteDatabase mDbDic = null;
     /** The search cursor of the writable dictionary */
     protected SQLiteCursor mDbCursor = null;
@@ -177,31 +177,31 @@
     /** The Frequency offset of learn dictionary */
     protected int mFrequencyOffsetOfLearnDictionary = -1;
 
-	/*
-	 * DEFINITION OF METHODS
-	 */
-	/**
-	 * The constructor of this class without writable dictionary.
+    /*
+     * DEFINITION OF METHODS
+     */
+    /**
+     * The constructor of this class without writable dictionary.
      *
-	 * Create a internal work area for the search engine. It is allocated for each object.
-	 *
-	 * @param dicLibPath	The dictionary library file path
-	 */
-	public OpenWnnDictionaryImpl( String dicLibPath ) {
+     * Create a internal work area for the search engine. It is allocated for each object.
+     *
+     * @param dicLibPath    The dictionary library file path
+     */
+    public OpenWnnDictionaryImpl( String dicLibPath ) {
         this( dicLibPath, null );
-	}
+    }
 
-	/**
-	 * The constructor of this class with writable dictionary.
+    /**
+     * The constructor of this class with writable dictionary.
      *
-	 * Create a internal work area and the writable dictionary for the search engine. It is allocated for each object.
-	 *
-	 * @param dicLibPath	The dictionary library file path
-     * @param dicFilePath	The path name of writable dictionary
-	 */
-	public OpenWnnDictionaryImpl( String dicLibPath, String dicFilePath ) {
+     * Create a internal work area and the writable dictionary for the search engine. It is allocated for each object.
+     *
+     * @param dicLibPath    The dictionary library file path
+     * @param dicFilePath   The path name of writable dictionary
+     */
+    public OpenWnnDictionaryImpl( String dicLibPath, String dicFilePath ) {
         /* Create the internal work area */
-		this.mWnnWork = OpenWnnDictionaryImplJni.createWnnWork( dicLibPath );
+        this.mWnnWork = OpenWnnDictionaryImplJni.createWnnWork( dicLibPath );
 
         if( this.mWnnWork != 0 && dicFilePath != null ) {
             /* Create query base strings */
@@ -264,33 +264,33 @@
 
 
             try {
-            	/* Create the database object */
+                /* Create the database object */
                 mDicFilePath = dicFilePath;
                 setInUseState( true );
 
-            	/* Create the table if not exist */
-            	createDictionaryTable( TABLE_NAME_DIC );
+                /* Create the table if not exist */
+                createDictionaryTable( TABLE_NAME_DIC );
             } catch( SQLException e ) {
             }
         }
-	}
+    }
 
-	/**
-	 * The finalizer of this class.
-	 * Destroy the internal work area for the search engine.
-	 */
-	protected void finalize( ) {
-		/* Free the internal work area */
-		if( this.mWnnWork != 0 ) {
-			OpenWnnDictionaryImplJni.freeWnnWork( this.mWnnWork );
-			this.mWnnWork = 0;
+    /**
+     * The finalizer of this class.
+     * Destroy the internal work area for the search engine.
+     */
+    protected void finalize( ) {
+        /* Free the internal work area */
+        if( this.mWnnWork != 0 ) {
+            OpenWnnDictionaryImplJni.freeWnnWork( this.mWnnWork );
+            this.mWnnWork = 0;
 
             freeDatabase();
-		}
-	}
+        }
+    }
 
-	/**
-	 * Create the table of writable dictionary.
+    /**
+     * Create the table of writable dictionary.
      *
      * @param tableName     The name of table
      */
@@ -312,103 +312,103 @@
         }
     }
 
-	/**
+    /**
      * Free the {@link SQLiteDatabase} of writable dictionary.
      */
     protected void freeDatabase( ) {
-		freeCursor();
+        freeCursor();
 
-		if( mDbDic != null ) {
+        if( mDbDic != null ) {
             /* The SQLiteDataBase object must close() before releasing. */
             mDbDic.close();
             mDbDic = null;
         }
     }
-	/**
+    /**
      * Free the {@link SQLiteCursor} of writable dictionary.
      */
     protected void freeCursor( ) {
-    	if( mDbCursor != null) {
+        if( mDbCursor != null) {
             /* The SQLiteCursor object must close() before releasing. */
-    		mDbCursor.close();
-    		mDbCursor = null;
+            mDbCursor.close();
+            mDbCursor = null;
 
             mTypeOfQuery = -1;
-    	}
+        }
     }
 
-	
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#setInUseState
-	 */
-	public boolean isActive() {
-		return (this.mWnnWork != 0);
-	}
-	
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#setInUseState
-	 */
+    
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#setInUseState
+     */
+    public boolean isActive() {
+        return (this.mWnnWork != 0);
+    }
+    
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#setInUseState
+     */
     public void setInUseState( boolean flag ) {
         if( flag ) {
             if( mDbDic == null ) {
-            	mDbDic = SQLiteDatabase.openOrCreateDatabase( mDicFilePath, null );
+                mDbDic = SQLiteDatabase.openOrCreateDatabase( mDicFilePath, null );
             }
         } else {
             freeDatabase();
         }
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#clearDictionary
-	 */
-	public int clearDictionary( ) {
-		if( this.mWnnWork != 0 ) {
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#clearDictionary
+     */
+    public int clearDictionary( ) {
+        if( this.mWnnWork != 0 ) {
             mFrequencyOffsetOfUserDictionary  = -1;
             mFrequencyOffsetOfLearnDictionary = -1;
 
-			return OpenWnnDictionaryImplJni.clearDictionaryParameters( this.mWnnWork );
-		} else {
-			return -1;
-		}
-	}
+            return OpenWnnDictionaryImplJni.clearDictionaryParameters( this.mWnnWork );
+        } else {
+            return -1;
+        }
+    }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#setDictionary
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#setDictionary
+     */
     public int setDictionary(int index, int base, int high ) {
-		if( this.mWnnWork != 0 ) {
-			switch( index ) {
-			case WnnDictionary.INDEX_USER_DICTIONARY:
+        if( this.mWnnWork != 0 ) {
+            switch( index ) {
+            case WnnDictionary.INDEX_USER_DICTIONARY:
                 if( base < 0 || high < 0 || base > high
                     /* || base < OFFSET_FREQUENCY_OF_USER_DICTIONARY || high >= OFFSET_FREQUENCY_OF_LEARN_DICTIONARY */ ) {
                     mFrequencyOffsetOfUserDictionary = -1;
                 } else {
                     mFrequencyOffsetOfUserDictionary = high;
                 }
-				return 0;
-			case WnnDictionary.INDEX_LEARN_DICTIONARY:
+                return 0;
+            case WnnDictionary.INDEX_LEARN_DICTIONARY:
                 if( base < 0 || high < 0 || base > high
                     /* || base < OFFSET_FREQUENCY_OF_LEARN_DICTIONARY */ ) {
                     mFrequencyOffsetOfLearnDictionary = -1;
                 } else {
                     mFrequencyOffsetOfLearnDictionary = high;
                 }
-				return 0;
-			default:
+                return 0;
+            default:
                 return OpenWnnDictionaryImplJni.setDictionaryParameter( this.mWnnWork, index, base, high );
-			}
-		} else {
-			return -1;
-		}
-	}
+            }
+        } else {
+            return -1;
+        }
+    }
 
     /**
      * Query to the database
      *
-     * @param keyString		The key string
+     * @param keyString     The key string
      * @param wnnWord      The previous word for link search
      * @param operation    The search operation
-     * @param order			The type of sort order
+     * @param order         The type of sort order
      */
     protected void createQuery( String keyString, WnnWord wnnWord, int operation, int order) {
         int newTypeOfQuery, maxBindsOfQuery;
@@ -422,45 +422,45 @@
         switch( operation ) {
         case WnnDictionary.SEARCH_EXACT:
             querySqlOrderByFreq = mExactQuerySqlOrderByFreq; 
-            querySqlOrderByKey	= mExactQuerySqlOrderByKey;
+            querySqlOrderByKey  = mExactQuerySqlOrderByKey;
             newTypeOfQuery      = 0;
-            queryArgs			= mExactQueryArgs;
+            queryArgs           = mExactQueryArgs;
 
             queryArgs[ 0 ]      = keyString;
             break;
 
         case WnnDictionary.SEARCH_PREFIX:
         case WnnDictionary.SEARCH_LINK:
-        	/* Select the suitable parameters for the query */
-        	if( keyString.length() <= FAST_QUERY_LENGTH ) {
+            /* Select the suitable parameters for the query */
+            if( keyString.length() <= FAST_QUERY_LENGTH ) {
                 if( wnnWord != null ) {
-            		querySqlOrderByFreq = mFastLinkQuerySqlOrderByFreq; 
-            		querySqlOrderByKey	= mFastLinkQuerySqlOrderByKey;
-            		newTypeOfQuery      = 1;
+                    querySqlOrderByFreq = mFastLinkQuerySqlOrderByFreq; 
+                    querySqlOrderByKey  = mFastLinkQuerySqlOrderByKey;
+                    newTypeOfQuery      = 1;
                 } else {
-            		querySqlOrderByFreq = mFastPrefixQuerySqlOrderByFreq; 
-            		querySqlOrderByKey	= mFastPrefixQuerySqlOrderByKey;
-            		newTypeOfQuery      = 2;
+                    querySqlOrderByFreq = mFastPrefixQuerySqlOrderByFreq; 
+                    querySqlOrderByKey  = mFastPrefixQuerySqlOrderByKey;
+                    newTypeOfQuery      = 2;
                 }
-        		maxBindsOfQuery		= FAST_QUERY_LENGTH;
-        		queryArgs			= mFastQueryArgs;
-        	} else {
+                maxBindsOfQuery     = FAST_QUERY_LENGTH;
+                queryArgs           = mFastQueryArgs;
+            } else {
                 if( wnnWord != null ) {
-            		querySqlOrderByFreq = mFullLinkQuerySqlOrderByFreq; 
-            		querySqlOrderByKey	= mFullLinkQuerySqlOrderByKey;
-            		newTypeOfQuery      = 3;
+                    querySqlOrderByFreq = mFullLinkQuerySqlOrderByFreq; 
+                    querySqlOrderByKey  = mFullLinkQuerySqlOrderByKey;
+                    newTypeOfQuery      = 3;
                 } else {
-            		querySqlOrderByFreq = mFullPrefixQuerySqlOrderByFreq; 
-            		querySqlOrderByKey	= mFullPrefixQuerySqlOrderByKey;
-            		newTypeOfQuery      = 4;
+                    querySqlOrderByFreq = mFullPrefixQuerySqlOrderByFreq; 
+                    querySqlOrderByKey  = mFullPrefixQuerySqlOrderByKey;
+                    newTypeOfQuery      = 4;
                 }
-        		maxBindsOfQuery		= MAX_LENGTH_OF_QUERY;
-        		queryArgs			= mFullQueryArgs;
-        	}
+                maxBindsOfQuery     = MAX_LENGTH_OF_QUERY;
+                queryArgs           = mFullQueryArgs;
+            }
 
             if( wnnWord != null ) {
                 /* If link search is enabled, insert information of the previous word */
-            	String[] queryArgsTemp = OpenWnnDictionaryImplJni.createBindArray( this.mWnnWork, keyString, maxBindsOfQuery, MAX_PATTERN_OF_APPROX );
+                String[] queryArgsTemp = OpenWnnDictionaryImplJni.createBindArray( this.mWnnWork, keyString, maxBindsOfQuery, MAX_PATTERN_OF_APPROX );
 
                 queryArgs = new String[ queryArgsTemp.length + 2 ];
                 for( int i = 0 ; i < queryArgsTemp.length ; i++ ) {
@@ -470,110 +470,110 @@
                 queryArgs[ 0 ] = wnnWord.stroke;
                 queryArgs[ 1 ] = wnnWord.candidate;
             } else {
-            	queryArgs = OpenWnnDictionaryImplJni.createBindArray( this.mWnnWork, keyString, maxBindsOfQuery, MAX_PATTERN_OF_APPROX );
+                queryArgs = OpenWnnDictionaryImplJni.createBindArray( this.mWnnWork, keyString, maxBindsOfQuery, MAX_PATTERN_OF_APPROX );
             }
             break;
 
         default:
-    		mCountCursor = 0;
+            mCountCursor = 0;
             freeCursor( );
             return;
         }
 
-    	/* Create the cursor and set arguments */
-		mCountCursor = 0;
+        /* Create the cursor and set arguments */
+        mCountCursor = 0;
 
-		if( mDbCursor == null || mTypeOfQuery != newTypeOfQuery ) {
-   			/* If the cursor is not exist or the type of query is changed, compile the query string and query words */
+        if( mDbCursor == null || mTypeOfQuery != newTypeOfQuery ) {
+            /* If the cursor is not exist or the type of query is changed, compile the query string and query words */
             freeCursor( );
 
             try {
-            	switch( order ) {
-            	case WnnDictionary.ORDER_BY_FREQUENCY:
-            		mDbCursor = ( SQLiteCursor )mDbDic.rawQuery( querySqlOrderByFreq, queryArgs );
-        			break;
-            	case WnnDictionary.ORDER_BY_KEY:
-            		mDbCursor = ( SQLiteCursor )mDbDic.rawQuery( querySqlOrderByKey, queryArgs );
-        			break;
-            	default:
-            		return;
-            	}
-        	} catch( SQLException e ) {
-        		return;
-        	}
+                switch( order ) {
+                case WnnDictionary.ORDER_BY_FREQUENCY:
+                    mDbCursor = ( SQLiteCursor )mDbDic.rawQuery( querySqlOrderByFreq, queryArgs );
+                    break;
+                case WnnDictionary.ORDER_BY_KEY:
+                    mDbCursor = ( SQLiteCursor )mDbDic.rawQuery( querySqlOrderByKey, queryArgs );
+                    break;
+                default:
+                    return;
+                }
+            } catch( SQLException e ) {
+                return;
+            }
 
-    		mTypeOfQuery = newTypeOfQuery;
-    	} else {
-    		/* If the cursor is exist, bind new arguments and re-query words (DO NOT recompile the query string) */
+            mTypeOfQuery = newTypeOfQuery;
+        } else {
+            /* If the cursor is exist, bind new arguments and re-query words (DO NOT recompile the query string) */
             try {
-        		mDbCursor.setSelectionArguments( queryArgs );
-        		mDbCursor.requery( );
-        	} catch( SQLException e ) {
-        		return;
-        	}
-    	}
-
-		if( mDbCursor != null ) {
-            /* If querying is succeed, count the number of words */
-			mCountCursor = mDbCursor.getCount();
-            if( mCountCursor == 0 ) {
-                /* If no word is retrieved, deactivate the cursor for reduce the resource */
-        		mDbCursor.deactivate( );
+                mDbCursor.setSelectionArguments( queryArgs );
+                mDbCursor.requery( );
+            } catch( SQLException e ) {
+                return;
             }
         }
 
-		return;
+        if( mDbCursor != null ) {
+            /* If querying is succeed, count the number of words */
+            mCountCursor = mDbCursor.getCount();
+            if( mCountCursor == 0 ) {
+                /* If no word is retrieved, deactivate the cursor for reduce the resource */
+                mDbCursor.deactivate( );
+            }
+        }
+
+        return;
     }
 
     /**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#searchWord
-	 */
-	public int searchWord( int operation, int order, String keyString ) {
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#searchWord
+     */
+    public int searchWord( int operation, int order, String keyString ) {
         /* Unset the previous word information */
         OpenWnnDictionaryImplJni.clearResult( this.mWnnWork );
 
         /* Search to user/learn dictionary */
         if( mDbDic != null && ( mFrequencyOffsetOfUserDictionary  >= 0 ||
                                 mFrequencyOffsetOfLearnDictionary >= 0 ) ) {
-			try {
-    			if( keyString.length() > 0 ) {
-    				createQuery( keyString, null, operation, order );
-    				if( mDbCursor != null ) {
-        				mDbCursor.moveToFirst();
-    				}
-   				} else {
+            try {
+                if( keyString.length() > 0 ) {
+                    createQuery( keyString, null, operation, order );
+                    if( mDbCursor != null ) {
+                        mDbCursor.moveToFirst();
+                    }
+                } else {
                     /* If the key string is "", no word is retrieved */
                     if( mDbCursor != null ) {
                         mDbCursor.deactivate();
                     }
                     mCountCursor = 0;
-   				}
-			} catch( SQLException e ) {
+                }
+            } catch( SQLException e ) {
                 if( mDbCursor != null ) {
                     mDbCursor.deactivate();
                 }
                 mCountCursor = 0;
-	        }
+            }
         } else {
             mCountCursor = 0;
         }
 
         /* Search to fixed dictionary */
-		if( this.mWnnWork != 0 ) {
-			int ret = OpenWnnDictionaryImplJni.searchWord( this.mWnnWork, operation, order, keyString );
-			if (mCountCursor > 0) {
-				ret = 1;
-			}
-			return ret;
-		} else {
-			return -1;
-		}
-	}
+        if( this.mWnnWork != 0 ) {
+            int ret = OpenWnnDictionaryImplJni.searchWord( this.mWnnWork, operation, order, keyString );
+            if (mCountCursor > 0) {
+                ret = 1;
+            }
+            return ret;
+        } else {
+            return -1;
+        }
+    }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#searchWord
-	 */
-	public int searchWord( int operation, int order, String keyString, WnnWord wnnWord ) {
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#searchWord
+     */
+    public int searchWord( int operation, int order, String keyString, WnnWord wnnWord ) {
         if( wnnWord == null || wnnWord.partOfSpeech == null ) {
             return -1;
         }
@@ -581,17 +581,17 @@
         /* Search to user/learn dictionary with link information */
         if( mDbDic != null && ( mFrequencyOffsetOfUserDictionary  >= 0 ||
                                 mFrequencyOffsetOfLearnDictionary >= 0 ) ) {
-			try {
-				createQuery( keyString, wnnWord, operation, order );
-				if( mDbCursor != null ) {
-    				mDbCursor.moveToFirst();
-				}
-			} catch( SQLException e ) {
+            try {
+                createQuery( keyString, wnnWord, operation, order );
+                if( mDbCursor != null ) {
+                    mDbCursor.moveToFirst();
+                }
+            } catch( SQLException e ) {
                 if( mDbCursor != null ) {
                     mDbCursor.deactivate();
                 }
                 mCountCursor = 0;
-	        }
+            }
         } else {
             mCountCursor = 0;
         }
@@ -604,33 +604,33 @@
         OpenWnnDictionaryImplJni.setRightPartOfSpeech( this.mWnnWork, wnnWord.partOfSpeech.right );
         OpenWnnDictionaryImplJni.selectWord( this.mWnnWork );
 
-		if( this.mWnnWork != 0 ) {
-			int ret = OpenWnnDictionaryImplJni.searchWord( this.mWnnWork, operation, order, keyString );
-			if (mCountCursor > 0) {
-				ret = 1;
-			}
-			return ret;
-		} else {
-			return -1;
-		}
-	}
+        if( this.mWnnWork != 0 ) {
+            int ret = OpenWnnDictionaryImplJni.searchWord( this.mWnnWork, operation, order, keyString );
+            if (mCountCursor > 0) {
+                ret = 1;
+            }
+            return ret;
+        } else {
+            return -1;
+        }
+    }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#getNextWord
-	 */
-	public WnnWord getNextWord( ) {
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#getNextWord
+     */
+    public WnnWord getNextWord( ) {
         return getNextWord( 0 );
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#getNextWord
-	 */
-	public WnnWord getNextWord( int length ) {
-		if( this.mWnnWork != 0 ) {
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#getNextWord
+     */
+    public WnnWord getNextWord( int length ) {
+        if( this.mWnnWork != 0 ) {
             if( mDbDic != null && mDbCursor != null && mCountCursor > 0 ) {
                 /* If the user/learn dictionary is queried, get the result from the user/learn dictionary */
-				WnnWord result = new WnnWord( );
-            	try {
+                WnnWord result = new WnnWord( );
+                try {
                     /* Skip results if that is not contained the type of search or length of stroke is not equal specified length */
                     while( mCountCursor > 0 &&
                            ( ( mFrequencyOffsetOfUserDictionary < 0  && mDbCursor.getInt( 4 ) == TYPE_NAME_USER      ) ||
@@ -642,8 +642,8 @@
 
                     if( mCountCursor > 0 ) {
                         /* Get the information of word */
-        				result.stroke		        = mDbCursor.getString( 0 );
-        				result.candidate	        = mDbCursor.getString( 1 );
+                        result.stroke               = mDbCursor.getString( 0 );
+                        result.candidate            = mDbCursor.getString( 1 );
                         result.partOfSpeech.left    = mDbCursor.getInt( 2 );
                         result.partOfSpeech.right   = mDbCursor.getInt( 3 );
 
@@ -663,46 +663,46 @@
                     } else {
                         /* if no result is found, terminate the searching of user/learn dictionary */
                         mDbCursor.deactivate();
-                		result = null;
+                        result = null;
                     }
-            	} catch( SQLException e ) {
+                } catch( SQLException e ) {
                     mDbCursor.deactivate();
                     mCountCursor = 0;
-            		result = null;
-            	}
+                    result = null;
+                }
             }
 
             /* Get the result from fixed dictionary */
-			int res = OpenWnnDictionaryImplJni.getNextWord( this.mWnnWork, length );
-			if( res > 0 ) {
-				WnnWord result = new WnnWord( );
+            int res = OpenWnnDictionaryImplJni.getNextWord( this.mWnnWork, length );
+            if( res > 0 ) {
+                WnnWord result = new WnnWord( );
                 if( result != null ) {
-    				result.stroke		        = OpenWnnDictionaryImplJni.getStroke( this.mWnnWork );
-    				result.candidate	        = OpenWnnDictionaryImplJni.getCandidate( this.mWnnWork );
-    				result.frequency	        = OpenWnnDictionaryImplJni.getFrequency( this.mWnnWork );
+                    result.stroke               = OpenWnnDictionaryImplJni.getStroke( this.mWnnWork );
+                    result.candidate            = OpenWnnDictionaryImplJni.getCandidate( this.mWnnWork );
+                    result.frequency            = OpenWnnDictionaryImplJni.getFrequency( this.mWnnWork );
                     result.partOfSpeech.left    = OpenWnnDictionaryImplJni.getLeftPartOfSpeech( this.mWnnWork );
                     result.partOfSpeech.right   = OpenWnnDictionaryImplJni.getRightPartOfSpeech( this.mWnnWork );
                 }
-				return result;
-			} else if ( res == 0 ) {
-				/* No result is found. */
-				return null;
-			} else {
-				/* An error occur (It is regarded as "No result is found".) */
-				return null;
-			}
-		} else {
-			return null;
-		}
-	}
+                return result;
+            } else if ( res == 0 ) {
+                /* No result is found. */
+                return null;
+            } else {
+                /* An error occur (It is regarded as "No result is found".) */
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#getUserDictionaryWords
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#getUserDictionaryWords
+     */
     public WnnWord[] getUserDictionaryWords( ) {
-		if( this.mWnnWork != 0 && mDbDic != null ) {
+        if( this.mWnnWork != 0 && mDbDic != null ) {
             int numOfWords, i;
-    		SQLiteCursor cursor = null;
+            SQLiteCursor cursor = null;
 
             try {
                 /* Count all words in the user dictionary */
@@ -720,16 +720,16 @@
                     cursor.moveToFirst();
                     for( i = 0 ; i < numOfWords ; i++ ) {
                         words[ i ] = new WnnWord();
-        				words[ i ].stroke       = cursor.getString( 0 );
-        				words[ i ].candidate    = cursor.getString( 1 );
+                        words[ i ].stroke       = cursor.getString( 0 );
+                        words[ i ].candidate    = cursor.getString( 1 );
                         cursor.moveToNext();
                     }
 
                     return words;
                 }
             } catch( SQLException e ) {
-            	/* An error occurs */
-            	return null;
+                /* An error occurs */
+                return null;
             } finally {
                 if( cursor != null ) {
                     cursor.close( );
@@ -739,67 +739,67 @@
         return null;
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#clearApproxPattern
-	 */
-	public void clearApproxPattern( ) {
-		if( this.mWnnWork != 0 ) {
-			OpenWnnDictionaryImplJni.clearApproxPatterns( this.mWnnWork );
-		}
-	}
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#clearApproxPattern
+     */
+    public void clearApproxPattern( ) {
+        if( this.mWnnWork != 0 ) {
+            OpenWnnDictionaryImplJni.clearApproxPatterns( this.mWnnWork );
+        }
+    }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#setApproxPattern
-	 */
-	public int setApproxPattern( String src, String dst ) {
-		if( this.mWnnWork != 0 ) {
-			return OpenWnnDictionaryImplJni.setApproxPattern( this.mWnnWork, src, dst );
-		} else {
-			return -1;
-		}
-	}
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#setApproxPattern
+     */
+    public int setApproxPattern( String src, String dst ) {
+        if( this.mWnnWork != 0 ) {
+            return OpenWnnDictionaryImplJni.setApproxPattern( this.mWnnWork, src, dst );
+        } else {
+            return -1;
+        }
+    }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#setApproxPattern
-	 */
-	public int setApproxPattern( int approxPattern ) {
-		if( this.mWnnWork != 0 ) {
-			return OpenWnnDictionaryImplJni.setApproxPattern( this.mWnnWork, approxPattern );
-		} else {
-			return -1;
-		}
-	}
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#setApproxPattern
+     */
+    public int setApproxPattern( int approxPattern ) {
+        if( this.mWnnWork != 0 ) {
+            return OpenWnnDictionaryImplJni.setApproxPattern( this.mWnnWork, approxPattern );
+        } else {
+            return -1;
+        }
+    }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#getConnectMatrix
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#getConnectMatrix
+     */
     public byte[][] getConnectMatrix( ) {
         byte[][]    result;
         int         lcount, i;
 
         if (this.mWnnWork != 0) {
-        	/* 1-origin */
-        	lcount = OpenWnnDictionaryImplJni.getNumberOfLeftPOS( this.mWnnWork );
-        	result = new byte[ lcount + 1 ][ ];
+            /* 1-origin */
+            lcount = OpenWnnDictionaryImplJni.getNumberOfLeftPOS( this.mWnnWork );
+            result = new byte[ lcount + 1 ][ ];
 
-        	if( result != null ) {
-        		for( i = 0 ; i < lcount + 1 ; i++ ) {
-        			result[ i ] = OpenWnnDictionaryImplJni.getConnectArray( this.mWnnWork, i );
+            if( result != null ) {
+                for( i = 0 ; i < lcount + 1 ; i++ ) {
+                    result[ i ] = OpenWnnDictionaryImplJni.getConnectArray( this.mWnnWork, i );
 
-        			if( result[ i ] == null ) {
-        				return null;
-        			}
-        		}
-        	}
+                    if( result[ i ] == null ) {
+                        return null;
+                    }
+                }
+            }
         } else {
-        	result = new byte[1][1];
+            result = new byte[1][1];
         }
         return result;
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#getPOS
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#getPOS
+     */
     public WnnPOS getPOS( int type ) {
         WnnPOS result = new WnnPOS( );
 
@@ -814,38 +814,38 @@
         return result;
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#clearUserDictionary
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#clearUserDictionary
+     */
     public int clearUserDictionary() {
         if( mDbDic != null ) {
-        	mDbDic.execSQL( String.format( "delete from %s where %s=%d", TABLE_NAME_DIC, COLUMN_NAME_TYPE, TYPE_NAME_USER ) );
+            mDbDic.execSQL( String.format( "delete from %s where %s=%d", TABLE_NAME_DIC, COLUMN_NAME_TYPE, TYPE_NAME_USER ) );
         }
 
         /* If no writable dictionary exists, no error occurs. */
         return 0;
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#clearLearnDictionary
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#clearLearnDictionary
+     */
     public int clearLearnDictionary() {
         if( mDbDic != null ) {
-        	mDbDic.execSQL( String.format( "delete from %s where %s=%d", TABLE_NAME_DIC, COLUMN_NAME_TYPE, TYPE_NAME_LEARN ) );
+            mDbDic.execSQL( String.format( "delete from %s where %s=%d", TABLE_NAME_DIC, COLUMN_NAME_TYPE, TYPE_NAME_LEARN ) );
         }
         
         /* If no writable dictionary exists, no error occurs. */
         return 0;
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#addWordToUserDictionary
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#addWordToUserDictionary
+     */
     public int addWordToUserDictionary( WnnWord[] word ) {
-		int result = 0;
+        int result = 0;
 
-		if( mDbDic != null ) {
-    		SQLiteCursor cursor;
+        if( mDbDic != null ) {
+            SQLiteCursor cursor;
 
             /* Count all words in the user dictionary */
             cursor = ( SQLiteCursor )mDbDic.query(
@@ -855,18 +855,18 @@
                 null, null, null, null);
 
             int count = cursor.getCount();
-           	cursor.close();
+            cursor.close();
 
             if( count + word.length > MAX_WORDS_IN_USER_DICTIONARY ) {
                 /* If user dictionary is full, an error occurs. */
                 return -1;
             } else {
-            	mDbDic.beginTransaction();
+                mDbDic.beginTransaction();
                 try {
                     StringBuilder strokeSQL    = new StringBuilder();
                     StringBuilder candidateSQL = new StringBuilder();
 
-                	for( int index = 0 ; index < word.length ; index++ ) {
+                    for( int index = 0 ; index < word.length ; index++ ) {
                         if( word[index].stroke.length()    > 0 && word[index].stroke.length()    <= MAX_STROKE_LENGTH &&
                             word[index].candidate.length() > 0 && word[index].candidate.length() <= MAX_CANDIDATE_LENGTH ) {
                             strokeSQL.setLength( 0 );
@@ -874,7 +874,7 @@
                             DatabaseUtils.appendEscapedSQLString( strokeSQL, word[index].stroke );
                             DatabaseUtils.appendEscapedSQLString( candidateSQL, word[index].candidate );
 
-    	                	cursor = ( SQLiteCursor )mDbDic.query(
+                            cursor = ( SQLiteCursor )mDbDic.query(
                                 TABLE_NAME_DIC,
                                 new String[] { COLUMN_NAME_ID },
                                 String.format( "%s=%d and %s=%s and %s=%s",
@@ -882,31 +882,31 @@
                                                COLUMN_NAME_STROKE, strokeSQL.toString(),
                                                COLUMN_NAME_CANDIDATE, candidateSQL.toString() ),
                                 null, null, null, null );
-    		
-    		                if( cursor.getCount() > 0 ) {
-    		                	/* if the specified word is exist, an error reported and skipped that word. */
-    		                	result = -2;
-    		                } else {
-    			            	ContentValues content = new ContentValues();
-    			
-    			                content.clear();
-    			                content.put( COLUMN_NAME_TYPE,      TYPE_NAME_USER );
-    			                content.put( COLUMN_NAME_STROKE,    word[index].stroke );
-    			                content.put( COLUMN_NAME_CANDIDATE, word[index].candidate );
-    			                content.put( COLUMN_NAME_POS_LEFT,  word[index].partOfSpeech.left );
-    			                content.put( COLUMN_NAME_POS_RIGHT, word[index].partOfSpeech.right );
-    		
-    		                    mDbDic.insert( TABLE_NAME_DIC, null, content );
-    		                }
+            
+                            if( cursor.getCount() > 0 ) {
+                                /* if the specified word is exist, an error reported and skipped that word. */
+                                result = -2;
+                            } else {
+                                ContentValues content = new ContentValues();
+                
+                                content.clear();
+                                content.put( COLUMN_NAME_TYPE,      TYPE_NAME_USER );
+                                content.put( COLUMN_NAME_STROKE,    word[index].stroke );
+                                content.put( COLUMN_NAME_CANDIDATE, word[index].candidate );
+                                content.put( COLUMN_NAME_POS_LEFT,  word[index].partOfSpeech.left );
+                                content.put( COLUMN_NAME_POS_RIGHT, word[index].partOfSpeech.right );
+            
+                                mDbDic.insert( TABLE_NAME_DIC, null, content );
+                            }
 
                             cursor.close( );
                             cursor = null;
                         }
-                	}
+                    }
                     mDbDic.setTransactionSuccessful();
                 } catch( SQLException e ) {
-                	/* An error occurs */
-                	return -1;
+                    /* An error occurs */
+                    return -1;
                 } finally {
                     mDbDic.endTransaction();
                     if( cursor != null ) {
@@ -920,28 +920,28 @@
         return result;
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#addWordToUserDictionary
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#addWordToUserDictionary
+     */
     public int addWordToUserDictionary( WnnWord word ) {
-    	WnnWord[] words = new WnnWord[1];
-    	words[0] = word;
+        WnnWord[] words = new WnnWord[1];
+        words[0] = word;
    
-    	return addWordToUserDictionary( words );
+        return addWordToUserDictionary( words );
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#removeWordFromUserDictionary
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#removeWordFromUserDictionary
+     */
     public int removeWordFromUserDictionary( WnnWord[] word ) {
-    	if( mDbDic != null ) {
-        	/* Remove the specified word */
-        	mDbDic.beginTransaction();
+        if( mDbDic != null ) {
+            /* Remove the specified word */
+            mDbDic.beginTransaction();
             try {
                 StringBuilder strokeSQL    = new StringBuilder();
                 StringBuilder candidateSQL = new StringBuilder();
 
-            	for( int index = 0 ; index < word.length ; index++ ) {
+                for( int index = 0 ; index < word.length ; index++ ) {
                     if( word[index].stroke.length()    > 0 && word[index].stroke.length()    <= MAX_STROKE_LENGTH &&
                         word[index].candidate.length() > 0 && word[index].candidate.length() <= MAX_CANDIDATE_LENGTH ) {
                         strokeSQL.setLength( 0 );
@@ -949,18 +949,18 @@
                         DatabaseUtils.appendEscapedSQLString( strokeSQL, word[index].stroke );
                         DatabaseUtils.appendEscapedSQLString( candidateSQL, word[index].candidate );
 
-    	            	mDbDic.delete( TABLE_NAME_DIC,
+                        mDbDic.delete( TABLE_NAME_DIC,
                             String.format( "%s=%d and %s=%s and %s=%s",
                                            COLUMN_NAME_TYPE, TYPE_NAME_USER,
                                            COLUMN_NAME_STROKE, strokeSQL,
                                            COLUMN_NAME_CANDIDATE, candidateSQL ),
                             null );
                     }
-            	}
-            	mDbDic.setTransactionSuccessful();
+                }
+                mDbDic.setTransactionSuccessful();
             } catch( SQLException e ) {
-            	/* An error occurs */
-            	return -1;
+                /* An error occurs */
+                return -1;
             } finally {
                 mDbDic.endTransaction();
             }
@@ -970,9 +970,9 @@
         return 0;
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#removeWordFromUserDictionary
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#removeWordFromUserDictionary
+     */
     public int removeWordFromUserDictionary( WnnWord word ) {
         WnnWord[] words = new WnnWord[1];
         words[0] = word;
@@ -980,9 +980,9 @@
         return removeWordFromUserDictionary( words );
     }
 
-	/**
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#learnWord
-	 */
+    /**
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#learnWord
+     */
     public int learnWord( WnnWord word ) {
         return learnWord( word, null );
     }
@@ -990,9 +990,9 @@
     /**
      * Learn the word with connection.
      * 
-     * @param word           	The word to learn
-     * @param previousWord   	The word which is selected previously.
-     * @return					0 if success; minus value if fail.
+     * @param word              The word to learn
+     * @param previousWord      The word which is selected previously.
+     * @return                  0 if success; minus value if fail.
      */
     public int learnWord( WnnWord word, WnnWord previousWord ) {
         if( mDbDic != null ) {
@@ -1016,7 +1016,7 @@
                 DatabaseUtils.appendEscapedSQLString( strokeSQL, word.stroke );
                 DatabaseUtils.appendEscapedSQLString( candidateSQL, word.candidate );
 
-            	SQLiteCursor cursor;
+                SQLiteCursor cursor;
 
                 /* If the words which have same stroke and same candidate is already learned, move to the tail */
                 cursor = ( SQLiteCursor )mDbDic.query(
@@ -1047,7 +1047,7 @@
 
                     boolean isExistConnectLearnData = false;
 
-                	mDbDic.beginTransaction();
+                    mDbDic.beginTransaction();
                     try {
                         do {
                             /* Record the ID that is removed later */
@@ -1092,7 +1092,7 @@
                         return -1;
                     } finally {
                         mDbDic.endTransaction();
-                    	cursor.close();
+                        cursor.close();
                     }
                 } else {
                     cursor.close();
@@ -1129,7 +1129,7 @@
                         return -1;
                     } finally {
                         mDbDic.endTransaction();
-                    	cursor.close();
+                        cursor.close();
                     }
                 } else {
                     cursor.close();
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImplJni.java b/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImplJni.java
index b813724..34d533f 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImplJni.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnnDictionaryImplJni.java
@@ -22,398 +22,398 @@
  * @author Copyright (C) 2008, 2009 OMRON SOFTWARE CO., LTD.  All Rights Reserved.
  */
 public class OpenWnnDictionaryImplJni {
-	/*
-	 * DEFINITION OF CONSTANTS
-	 */
-	/**
-	 * Constant about the approximate pattern (for JNI native library)
+    /*
+     * DEFINITION OF CONSTANTS
+     */
+    /**
+     * Constant about the approximate pattern (for JNI native library)
      *
-   	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOUPPER
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOUPPER
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#setApproxPattern
-	 */
-	public static final int APPROX_PATTERN_EN_TOUPPER               = WnnDictionary.APPROX_PATTERN_EN_TOUPPER;
-	/**
-	 * Constant about the approximate pattern (for JNI native library)
+     */
+    public static final int APPROX_PATTERN_EN_TOUPPER               = WnnDictionary.APPROX_PATTERN_EN_TOUPPER;
+    /**
+     * Constant about the approximate pattern (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOLOWER
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOLOWER
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#setApproxPattern
-	 */
-	public static final int APPROX_PATTERN_EN_TOLOWER               = WnnDictionary.APPROX_PATTERN_EN_TOLOWER;
-	/**
-	 * Constant about the approximate pattern (for JNI native library)
+     */
+    public static final int APPROX_PATTERN_EN_TOLOWER               = WnnDictionary.APPROX_PATTERN_EN_TOLOWER;
+    /**
+     * Constant about the approximate pattern (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#setApproxPattern
-	 */
-	public static final int APPROX_PATTERN_EN_QWERTY_NEAR           = WnnDictionary.APPROX_PATTERN_EN_QWERTY_NEAR;
-	/**
-	 * Constant about the approximate pattern (for JNI native library)
+     */
+    public static final int APPROX_PATTERN_EN_QWERTY_NEAR           = WnnDictionary.APPROX_PATTERN_EN_QWERTY_NEAR;
+    /**
+     * Constant about the approximate pattern (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR_UPPER
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR_UPPER
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#setApproxPattern
-	 */
-	public static final int APPROX_PATTERN_EN_QWERTY_NEAR_UPPER     = WnnDictionary.APPROX_PATTERN_EN_QWERTY_NEAR_UPPER;
-	/**
-	 * Constant about the approximate pattern (for JNI native library)
+     */
+    public static final int APPROX_PATTERN_EN_QWERTY_NEAR_UPPER     = WnnDictionary.APPROX_PATTERN_EN_QWERTY_NEAR_UPPER;
+    /**
+     * Constant about the approximate pattern (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_JAJP_12KEY_NORMAL
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_JAJP_12KEY_NORMAL
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#setApproxPattern
-	 */
-	public static final int APPROX_PATTERN_JAJP_12KEY_NORMAL        = WnnDictionary.APPROX_PATTERN_JAJP_12KEY_NORMAL;
+     */
+    public static final int APPROX_PATTERN_JAJP_12KEY_NORMAL        = WnnDictionary.APPROX_PATTERN_JAJP_12KEY_NORMAL;
 
-	/**
-	 * Constant about the search operation (for JNI native library)
+    /**
+     * Constant about the search operation (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_EXACT
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_EXACT
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#searchWord
-	 */
-	public static final int SEARCH_EXACT                           = WnnDictionary.SEARCH_EXACT;
-	/**
-	 * Constant about the search operation (for JNI native library)
+     */
+    public static final int SEARCH_EXACT                           = WnnDictionary.SEARCH_EXACT;
+    /**
+     * Constant about the search operation (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_PREFIX
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_PREFIX
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#searchWord
-	 */
-	public static final int SEARCH_PREFIX                          = WnnDictionary.SEARCH_PREFIX;
-	/**
-	 * Constant about the search operation (for JNI native library)
+     */
+    public static final int SEARCH_PREFIX                          = WnnDictionary.SEARCH_PREFIX;
+    /**
+     * Constant about the search operation (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_LINK
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_LINK
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#searchWord
-	 */
-	public static final int SEARCH_LINK                            = WnnDictionary.SEARCH_LINK;
+     */
+    public static final int SEARCH_LINK                            = WnnDictionary.SEARCH_LINK;
 
-	/**
-	 * Constant about the sort order (for JNI native library)
+    /**
+     * Constant about the sort order (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_FREQUENCY
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_FREQUENCY
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#searchWord
-	 */
-	public static final int ORDER_BY_FREQUENCY                     = WnnDictionary.ORDER_BY_FREQUENCY;
-	/**
-	 * Constant about the sort order (for JNI native library)
+     */
+    public static final int ORDER_BY_FREQUENCY                     = WnnDictionary.ORDER_BY_FREQUENCY;
+    /**
+     * Constant about the sort order (for JNI native library)
      *
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_KEY
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_KEY
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#searchWord
-	 */
-	public static final int ORDER_BY_KEY                           = WnnDictionary.ORDER_BY_KEY;
+     */
+    public static final int ORDER_BY_KEY                           = WnnDictionary.ORDER_BY_KEY;
 
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V1
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V1
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_V1                             = WnnDictionary.POS_TYPE_V1;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V2
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V2
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_V2                             = WnnDictionary.POS_TYPE_V2;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V3
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V3
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_V3                             = WnnDictionary.POS_TYPE_V3;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_BUNTOU
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_BUNTOU
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_BUNTOU                         = WnnDictionary.POS_TYPE_BUNTOU;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_TANKANJI
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_TANKANJI
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_TANKANJI                       = WnnDictionary.POS_TYPE_TANKANJI;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_SUUJI
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_SUUJI
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_SUUJI                          = WnnDictionary.POS_TYPE_SUUJI;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_MEISI
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_MEISI
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_MEISI                          = WnnDictionary.POS_TYPE_MEISI;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_JINMEI
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_JINMEI
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_JINMEI                         = WnnDictionary.POS_TYPE_JINMEI;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_CHIMEI
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_CHIMEI
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_CHIMEI                         = WnnDictionary.POS_TYPE_CHIMEI;
-	/**
-	 * Type of a part of speech (for JNI native library)
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_KIGOU
+    /**
+     * Type of a part of speech (for JNI native library)
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_KIGOU
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getLeftPartOfSpeechSpecifiedType
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getRightPartOfSpeechSpecifiedType
-	 */
+     */
     public static final int POS_TYPE_KIGOU                          = WnnDictionary.POS_TYPE_KIGOU;
 
     /*
      * METHODS
      */
-	/**
-	 * Create a internal work area. 
+    /**
+     * Create a internal work area. 
      * A internal work area is allocated dynamically, and the specified dictionary library is loaded.
      *
-	 * @param dicLibPath    The path of the dictionary library file
-	 * @return              The internal work area or null
-	 */
-	public static final native long createWnnWork( String dicLibPath );
+     * @param dicLibPath    The path of the dictionary library file
+     * @return              The internal work area or null
+     */
+    public static final native long createWnnWork( String dicLibPath );
 
-	/**
-	 * Free the internal work area.
+    /**
+     * Free the internal work area.
      * The specified work area and the loaded dictionary library is free.
      *
-	 * @param work      The internal work area
-	 * @return          0 if processing is successful; <0 if an error occur
-	 */
-	public static final native int freeWnnWork( long work );
+     * @param work      The internal work area
+     * @return          0 if processing is successful; <0 if an error occur
+     */
+    public static final native int freeWnnWork( long work );
 
-	/**
-	 * Clear all dictionary information.
+    /**
+     * Clear all dictionary information.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#clearDictionary
-	 * @param work      The internal work area
-	 * @return          0 if processing is successful; <0 if an error occur
-	 */
-	public static final native int clearDictionaryParameters( long work );
+     * @param work      The internal work area
+     * @return          0 if processing is successful; <0 if an error occur
+     */
+    public static final native int clearDictionaryParameters( long work );
 
-	/**
-	 * Set a dictionary information.
+    /**
+     * Set a dictionary information.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#setDictionary
-	 * @param work      The internal work area
-	 * @param index     The index of dictionary
-	 * @param base      The base frequency or -1
-	 * @param high      The maximum frequency or -1
-	 * @return			 0 if processing is successful; <0 otherwise
-	 */
-	public static final native int setDictionaryParameter( long work, int index, int base, int high );
+     * @param work      The internal work area
+     * @param index     The index of dictionary
+     * @param base      The base frequency or -1
+     * @param high      The maximum frequency or -1
+     * @return           0 if processing is successful; <0 otherwise
+     */
+    public static final native int setDictionaryParameter( long work, int index, int base, int high );
 
-	/**
-	 * Search a word from dictionaries.
+    /**
+     * Search a word from dictionaries.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#searchWord
-	 * @param work          The internal work area
-	 * @param operation     The search operation (see "Constant about the search operation")
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_EXACT
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_PREFIX
-	 * @param order         The sort order (see "Constant about the sort order")
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_FREQUENCY
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_KEY
-	 * @param keyString     The key string
-	 * @return              0 if no result is found; 1 if a result is found; <0 if an error occur
-	 *
-	 */
-	public static final native int searchWord(long work, int operation, int order, String keyString );
+     * @param work          The internal work area
+     * @param operation     The search operation (see "Constant about the search operation")
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_EXACT
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_PREFIX
+     * @param order         The sort order (see "Constant about the sort order")
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_FREQUENCY
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_KEY
+     * @param keyString     The key string
+     * @return              0 if no result is found; 1 if a result is found; <0 if an error occur
+     *
+     */
+    public static final native int searchWord(long work, int operation, int order, String keyString );
 
-	/**
-	 * Retrieve a word information.
+    /**
+     * Retrieve a word information.
      * A word information is stored to the internal work area. To retrieve a detail information,
      * use {@code getStroke()}, {@code getCandidate()}, {@code getFreqeuency(),} or other {@code get...()} method.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#getNextWord
-	 * @param work      The internal work area
+     * @param work      The internal work area
      * @param length    >0 if only the result of specified length is retrieved; 0 if no condition exist
-	 * @return          0 if no result is retrieved; >0 if a result is retrieved; <0 if an error occur
-	 */
-	public static final native int getNextWord( long work, int length );
+     * @return          0 if no result is retrieved; >0 if a result is retrieved; <0 if an error occur
+     */
+    public static final native int getNextWord( long work, int length );
 
-	/**
-	 * Retrieve the key string from the current word information.
+    /**
+     * Retrieve the key string from the current word information.
      *
-	 * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getNextWord
-	 * @param work      The internal work area
-	 * @return          The Key string
-	 */
-	public static final native String getStroke( long work );
+     * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getNextWord
+     * @param work      The internal work area
+     * @return          The Key string
+     */
+    public static final native String getStroke( long work );
 
-	/**
-	 * Retrieve the candidate string from the current word information.
+    /**
+     * Retrieve the candidate string from the current word information.
      *
-	 * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getNextWord
-	 * @param work      The internal work area
-	 * @return          The candidate string
-	 */
-	public static final native String getCandidate( long work );
+     * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getNextWord
+     * @param work      The internal work area
+     * @return          The candidate string
+     */
+    public static final native String getCandidate( long work );
 
-	/**
-	 * Retrieve the frequency from the current word information.
+    /**
+     * Retrieve the frequency from the current word information.
      *
-	 * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getNextWord
-	 * @param work      The internal work area
-	 * @return          The frequency
-	 */
-	public static final native int getFrequency( long work );
+     * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#getNextWord
+     * @param work      The internal work area
+     * @return          The frequency
+     */
+    public static final native int getFrequency( long work );
 
-	/**
-	 * Retrieve the part of speech at left side from the current word information.
+    /**
+     * Retrieve the part of speech at left side from the current word information.
      *
-	 * @param work      The internal work area
-	 * @return          The part of speech
-	 */
-	public static final native int getLeftPartOfSpeech( long work );
+     * @param work      The internal work area
+     * @return          The part of speech
+     */
+    public static final native int getLeftPartOfSpeech( long work );
 
-	/**
-	 * Retrieve the part of speech at right side from the current word information.
+    /**
+     * Retrieve the part of speech at right side from the current word information.
      *
-	 * @param work      The internal work area
-	 * @return          The part of speech
-	 */
-	public static final native int getRightPartOfSpeech( long work );
+     * @param work      The internal work area
+     * @return          The part of speech
+     */
+    public static final native int getRightPartOfSpeech( long work );
 
-	/**
-	 * Clear approximate patterns.
+    /**
+     * Clear approximate patterns.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#clearApproxPattern
-	 * @param work      The internal work area.
-	 */
-	public static final native void clearApproxPatterns( long work );
+     * @param work      The internal work area.
+     */
+    public static final native void clearApproxPatterns( long work );
 
-	/**
-	 * Set a approximate pattern.
+    /**
+     * Set a approximate pattern.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#setApproxPattern
-	 * @param work      The internal work area
-	 * @param src       The string (before)
-	 * @param dst       The string (after)
-	 * @return          0 if processing is successful; <0 if an error occur
-	 */
-	public static final native int setApproxPattern( long work, String src, String dst );
+     * @param work      The internal work area
+     * @param src       The string (before)
+     * @param dst       The string (after)
+     * @return          0 if processing is successful; <0 if an error occur
+     */
+    public static final native int setApproxPattern( long work, String src, String dst );
 
-	/**
-	 * Set a predefined approximate pattern.
+    /**
+     * Set a predefined approximate pattern.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#setApproxPattern
-	 * @param work              The internal work area
-	 * @param approxPattern     The index of predefined approximate pattern (See "Constant about the approximate pattern")
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOUPPER
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOLOWER
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR
-	 * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR_UPPER
-	 * @return                  0 if processing is successful; <0 if an error occur
-	 */
-	public static final native int setApproxPattern( long work, int approxPattern );
+     * @param work              The internal work area
+     * @param approxPattern     The index of predefined approximate pattern (See "Constant about the approximate pattern")
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOUPPER
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOLOWER
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR
+     * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR_UPPER
+     * @return                  0 if processing is successful; <0 if an error occur
+     */
+    public static final native int setApproxPattern( long work, int approxPattern );
 
-	/**
-	 * Get the specified approximate pattern.
-	 * @param work		The internal work area
-	 * @param src		The string (before)
-	 * @return			The string array (after)
-	 */
-	public static final native String[] getApproxPattern( long work, String src );
-	
-	/**
-	 * Clear the current word information.
+    /**
+     * Get the specified approximate pattern.
+     * @param work      The internal work area
+     * @param src       The string (before)
+     * @return          The string array (after)
+     */
+    public static final native String[] getApproxPattern( long work, String src );
+    
+    /**
+     * Clear the current word information.
      *
-	 * @param work      The internal work area
-	 */
+     * @param work      The internal work area
+     */
     public static final native void clearResult( long work );
 
-	/**
-	 * Set the part of speech at left side to the current word information.
+    /**
+     * Set the part of speech at left side to the current word information.
      *
-	 * @param work          The internal work area
+     * @param work          The internal work area
      * @param partOfSpeech  The part of speech
-	 * @return              0 if processing is successful; <0 if an error occur
+     * @return              0 if processing is successful; <0 if an error occur
      *
-	 */
+     */
     public static final native int setLeftPartOfSpeech( long work, int partOfSpeech );
-	/**
-	 * Set the part of speech at right side to the current word information.
+    /**
+     * Set the part of speech at right side to the current word information.
      *
-	 * @param work          The internal work area
+     * @param work          The internal work area
      * @param partOfSpeech  The part of speech
-	 * @return              0 if processing is successful; <0 if an error occur
+     * @return              0 if processing is successful; <0 if an error occur
      *
-	 */
+     */
     public static final native int setRightPartOfSpeech( long work, int partOfSpeech );
 
-	/**
-	 * Set the key string to the current word information.
+    /**
+     * Set the key string to the current word information.
      *
-	 * @param work          The internal work area
+     * @param work          The internal work area
      * @param stroke        The key string
-	 * @return              0 if processing is successful; <0 if an error occur
+     * @return              0 if processing is successful; <0 if an error occur
      *
-	 */
+     */
     public static final native int setStroke( long work, String stroke );
-	/**
-	 * Set the candidate string to the current word information.
+    /**
+     * Set the candidate string to the current word information.
      *
-	 * @param work          The internal work area
+     * @param work          The internal work area
      * @param candidate     The candidate string
-	 * @return              0 if processing is successful; <0 if an error occur
+     * @return              0 if processing is successful; <0 if an error occur
      *
-	 */
+     */
     public static final native int setCandidate( long work, String candidate );
 
-	/**
-	 * Set the previous word information from the current word information.
+    /**
+     * Set the previous word information from the current word information.
      *
-	 * @param work          The internal work area
-	 * @return              0 if processing is successful; <0 if an error occur
-	 */
-	public static final native int selectWord( long work );
+     * @param work          The internal work area
+     * @return              0 if processing is successful; <0 if an error occur
+     */
+    public static final native int selectWord( long work );
 
-	/**
-	 * Retrieve the connect array
+    /**
+     * Retrieve the connect array
      *
-	 * @param work                  The internal work area
+     * @param work                  The internal work area
      * @param leftPartOfSpeech      The part of speech at left side
-	 * @return                      The connect array
-	 */
+     * @return                      The connect array
+     */
     public static final native byte[] getConnectArray( long work, int leftPartOfSpeech );
 
-	/**
-	 * Retrieve the number of the part of speeches at left side.
+    /**
+     * Retrieve the number of the part of speeches at left side.
      *
-	 * @return              The number
-	 */
+     * @return              The number
+     */
     public static final native int getNumberOfLeftPOS( long work );
-	/**
-	 * Retrieve the number of the part of speeches at right side.
+    /**
+     * Retrieve the number of the part of speeches at right side.
      *
-	 * @return              The number
-	 */
+     * @return              The number
+     */
     public static final native int getNumberOfRightPOS( long work );
 
-	/**
-	 * Retrieve the specified part of speech at left side.
+    /**
+     * Retrieve the specified part of speech at left side.
      *
-	 * @param work          The internal work area
+     * @param work          The internal work area
      * @param type          The type of a part of speech
-	 * @return              0 if type is not found; <0 if an error occur; >0 The part of speech
-	 */
+     * @return              0 if type is not found; <0 if an error occur; >0 The part of speech
+     */
     public static final native int getLeftPartOfSpeechSpecifiedType( long work, int type );
 
-	/**
-	 * Retrieve the specified part of speech at right side.
+    /**
+     * Retrieve the specified part of speech at right side.
      *
-	 * @param work          The internal work area
+     * @param work          The internal work area
      * @param type          The type of a part of speech
-	 * @return              0 if type is not found; <0 if an error occur; >0 The part of speech
+     * @return              0 if type is not found; <0 if an error occur; >0 The part of speech
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#POS_TYPE_V1
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#POS_TYPE_V2
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#POS_TYPE_V3
@@ -424,26 +424,26 @@
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#POS_TYPE_JINMEI
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#POS_TYPE_CHIMEI
      * @see jp.co.omronsoft.openwnn.OpenWnnDictionaryImplJni#POS_TYPE_KIGOU
-	 */
+     */
     public static final native int getRightPartOfSpeechSpecifiedType( long work, int type );
 
     /**
      * Create the string array that is used by operation of query
-     * 	
-     * @param work					The internal work area
-     * @param keyString				The key string
-     * @param maxBindsOfQuery		The maximum number of binds of query
-     * @param maxPatternOfApprox	The maximum number of approximate patterns per character
+     *  
+     * @param work                  The internal work area
+     * @param keyString             The key string
+     * @param maxBindsOfQuery       The maximum number of binds of query
+     * @param maxPatternOfApprox    The maximum number of approximate patterns per character
      * @return                     The string array for binding
      */
     public static final native String[] createBindArray( long work, String keyString, int maxBindsOfQuery, int maxPatternOfApprox );
 
     /**
      * Create the string which used query parameter
-     * 	
-     * @param work					The internal work area
-     * @param maxBindsOfQuery		The maximum number of binds of query
-     * @param maxPatternOfApprox	The maximum number of approximate patterns per character
+     *  
+     * @param work                  The internal work area
+     * @param maxBindsOfQuery       The maximum number of binds of query
+     * @param maxPatternOfApprox    The maximum number of approximate patterns per character
      * @param keyColumnName        The name of the key column
      * @return                     The string for querying
      */
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnnEN.java b/src/jp/co/omronsoft/openwnn/OpenWnnEN.java
index 0b25b29..ab0754d 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnnEN.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnnEN.java
@@ -42,96 +42,96 @@
  * @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD.  All Rights Reserved.
  */
 public class OpenWnnEN extends OpenWnn {
-	/** A space character */
-	private static final char[] SPACE = {' '};
-	
-	/** Character style of underline */
-	private static final CharacterStyle SPAN_UNDERLINE   = new UnderlineSpan();
+    /** A space character */
+    private static final char[] SPACE = {' '};
+    
+    /** Character style of underline */
+    private static final CharacterStyle SPAN_UNDERLINE   = new UnderlineSpan();
     /** Highlight color style for the selected string  */
     private static final CharacterStyle SPAN_EXACT_BGCOLOR_HL     = new BackgroundColorSpan(0xFF66CDAA);
     /** Highlight color style for the composing text */
     private static final CharacterStyle SPAN_REMAIN_BGCOLOR_HL    = new BackgroundColorSpan(0xFFF0FFFF);
 
-	/** A private area code(ALT+SHIFT+X) to be ignore (G1 specific). */
-	private static final int PRIVATE_AREA_CODE = 61184;
-	/** Never move cursor in to the composing text (adapting to IMF's specification change) */
+    /** A private area code(ALT+SHIFT+X) to be ignore (G1 specific). */
+    private static final int PRIVATE_AREA_CODE = 61184;
+    /** Never move cursor in to the composing text (adapting to IMF's specification change) */
     private static final boolean FIX_CURSOR_TEXT_END = true;
 
-	/** Whether using Emoji or not */
+    /** Whether using Emoji or not */
     private static final boolean ENABLE_EMOJI_LIMITATION = true;
-	
-	/** Spannable string for the composing text */
-	protected SpannableStringBuilder mDisplayText;
+    
+    /** Spannable string for the composing text */
+    protected SpannableStringBuilder mDisplayText;
 
-	/** Handler for drawing the candidates view */
-	private Handler mDelayUpdateHandler;
-	/** Characters treated as a separator */
-	private String mWordSeparators;
-	/** Previous event's code */
-	private int mPreviousEventCode;
+    /** Handler for drawing the candidates view */
+    private Handler mDelayUpdateHandler;
+    /** Characters treated as a separator */
+    private String mWordSeparators;
+    /** Previous event's code */
+    private int mPreviousEventCode;
 
-	/** Array of words from the user dictionary */
-	private WnnWord[] mUserDictionaryWords = null;
+    /** Array of words from the user dictionary */
+    private WnnWord[] mUserDictionaryWords = null;
 
-	/** The converter for English prediction/spell correction */
-	private OpenWnnEngineEN mConverterEN;
-	/** The symbol list generator */
-	private SymbolList mSymbolList;
-	/** Whether it is displaying symbol list */
-	private boolean mSymbolMode;
-	/** Whether prediction is enabled */
-	private boolean mOptPrediction;
-	/** Whether spell correction is enabled */
-	private boolean mOptSpellCorrection;
-	/** Whether learning is enabled */
-	private boolean mOptLearning;
-	
-	/** SHIFT key state */
-	private int mHardShift;
+    /** The converter for English prediction/spell correction */
+    private OpenWnnEngineEN mConverterEN;
+    /** The symbol list generator */
+    private SymbolList mSymbolList;
+    /** Whether it is displaying symbol list */
+    private boolean mSymbolMode;
+    /** Whether prediction is enabled */
+    private boolean mOptPrediction;
+    /** Whether spell correction is enabled */
+    private boolean mOptSpellCorrection;
+    /** Whether learning is enabled */
+    private boolean mOptLearning;
+    
+    /** SHIFT key state */
+    private int mHardShift;
     /** SHIFT key state (pressing) */
-	private boolean mShiftPressing;
-	/** ALT key state */
-	private int mHardAlt;
+    private boolean mShiftPressing;
+    /** ALT key state */
+    private int mHardAlt;
     /** ALT key state (pressing) */
-	private boolean mAltPressing;
+    private boolean mAltPressing;
 
-	/** Instance of this service */
-	private static OpenWnnEN mSelf = null;
+    /** Instance of this service */
+    private static OpenWnnEN mSelf = null;
 
-	/** Shift lock toggle definition */
-	private static final int[] mShiftKeyToggle = {0, MetaKeyKeyListener.META_SHIFT_ON, MetaKeyKeyListener.META_CAP_LOCKED};
-	/** Alt lock toggle definition */
-	private static final int[] mAltKeyToggle = {0, MetaKeyKeyListener.META_ALT_ON, MetaKeyKeyListener.META_ALT_LOCKED};
-	/** Auto caps mode */
-	private boolean mAutoCaps = false;
-	
-	private CandidateFilter mFilter;
+    /** Shift lock toggle definition */
+    private static final int[] mShiftKeyToggle = {0, MetaKeyKeyListener.META_SHIFT_ON, MetaKeyKeyListener.META_CAP_LOCKED};
+    /** Alt lock toggle definition */
+    private static final int[] mAltKeyToggle = {0, MetaKeyKeyListener.META_ALT_ON, MetaKeyKeyListener.META_ALT_LOCKED};
+    /** Auto caps mode */
+    private boolean mAutoCaps = false;
+    
+    private CandidateFilter mFilter;
 
     /**
      * Constructor
      */
-	public OpenWnnEN() {
-		super();
+    public OpenWnnEN() {
+        super();
         mSelf = this;
 
-		/* used by OpenWnn */
-		mComposingText = new ComposingText();
-		mCandidatesViewManager = new TextCandidatesViewManager(-1);
-		mInputViewManager = new DefaultSoftKeyboardEN();
-		mConverterEN = new OpenWnnEngineEN("/data/data/jp.co.omronsoft.openwnn/writableEN.dic");
-		mConverter = mConverterEN;
-		mFilter = new CandidateFilter();
-		mSymbolList = null;
+        /* used by OpenWnn */
+        mComposingText = new ComposingText();
+        mCandidatesViewManager = new TextCandidatesViewManager(-1);
+        mInputViewManager = new DefaultSoftKeyboardEN();
+        mConverterEN = new OpenWnnEngineEN("/data/data/jp.co.omronsoft.openwnn/writableEN.dic");
+        mConverter = mConverterEN;
+        mFilter = new CandidateFilter();
+        mSymbolList = null;
 
-		/* etc */
-		mDisplayText = new SpannableStringBuilder();
-		mAutoHideMode = false;
-		mDelayUpdateHandler = new Handler();
-		mSymbolMode = false;
-		mOptPrediction = true;
-		mOptSpellCorrection = true;
-		mOptLearning = true;
-	}
+        /* etc */
+        mDisplayText = new SpannableStringBuilder();
+        mAutoHideMode = false;
+        mDelayUpdateHandler = new Handler();
+        mSymbolMode = false;
+        mOptPrediction = true;
+        mOptSpellCorrection = true;
+        mOptLearning = true;
+    }
 
     /**
      * Constructor
@@ -142,51 +142,51 @@
         this();
         attachBaseContext(context);
     }
-	/**
-	 * Get the instance of this service.
-	 * <br>
-	 * Before using this method, the constructor of this service must be invoked.
-	 * 
-	 * @return		The instance of this object
-	 */
-	public static OpenWnnEN getInstance() {
-		return mSelf;
-	}
+    /**
+     * Get the instance of this service.
+     * <br>
+     * Before using this method, the constructor of this service must be invoked.
+     * 
+     * @return      The instance of this object
+     */
+    public static OpenWnnEN getInstance() {
+        return mSelf;
+    }
 
-	/**
-	 * Insert a character into the composing text.
-	 *
-	 * @param chars		A array of character
-	 */
-	private void insertCharToComposingText(char[] chars) {
-		StrSegment seg = new StrSegment(chars);
+    /**
+     * Insert a character into the composing text.
+     *
+     * @param chars     A array of character
+     */
+    private void insertCharToComposingText(char[] chars) {
+        StrSegment seg = new StrSegment(chars);
 
-		if (chars[0] == SPACE[0] || chars[0] == '\u0009') {
-			/* if the character is a space, commit the composing text */
-			commitText(1);
-			commitText(seg.string);
-			mComposingText.clear();
-		} else if (mWordSeparators.contains(seg.string)) {
-			/* if the character is a separator, remove an auto-inserted space and commit the composing text. */
-			if (mPreviousEventCode == OpenWnnEvent.SELECT_CANDIDATE) {
-				mInputConnection.deleteSurroundingText(1, 0);
-			}
-			commitText(1);
-			commitText(seg.string);
-			mComposingText.clear();
-		} else {
-			mComposingText.insertStrSegment(0, 1, seg);
-			updateComposingText(1);
-		}
-	}
+        if (chars[0] == SPACE[0] || chars[0] == '\u0009') {
+            /* if the character is a space, commit the composing text */
+            commitText(1);
+            commitText(seg.string);
+            mComposingText.clear();
+        } else if (mWordSeparators.contains(seg.string)) {
+            /* if the character is a separator, remove an auto-inserted space and commit the composing text. */
+            if (mPreviousEventCode == OpenWnnEvent.SELECT_CANDIDATE) {
+                mInputConnection.deleteSurroundingText(1, 0);
+            }
+            commitText(1);
+            commitText(seg.string);
+            mComposingText.clear();
+        } else {
+            mComposingText.insertStrSegment(0, 1, seg);
+            updateComposingText(1);
+        }
+    }
 
-	/**
-	 * Insert a character into the composing text.
-	 *
-	 * @param charCode		A character code
-     * @return				{@code true} if success; {@code false} if an error occurs.
-	 */
-	private boolean insertCharToComposingText(int charCode) {
+    /**
+     * Insert a character into the composing text.
+     *
+     * @param charCode      A character code
+     * @return              {@code true} if success; {@code false} if an error occurs.
+     */
+    private boolean insertCharToComposingText(int charCode) {
         if (charCode == 0) {
             return false;
         }
@@ -194,198 +194,185 @@
         return true;
     }
 
-	/**
-	 * Get the shift key state from the editor.
-	 *
-	 * @param editor	Editor
-	 *
-	 * @return			State ID of the shift key (0:off, 1:on)
-	 */
-	protected int getShiftKeyState(EditorInfo editor) {
-		return (getCurrentInputConnection().getCursorCapsMode(editor.inputType) == 0) ? 0 : 1;
-	}
+    /**
+     * Get the shift key state from the editor.
+     *
+     * @param editor    Editor
+     *
+     * @return          State ID of the shift key (0:off, 1:on)
+     */
+    protected int getShiftKeyState(EditorInfo editor) {
+        return (getCurrentInputConnection().getCursorCapsMode(editor.inputType) == 0) ? 0 : 1;
+    }
 
     /**
      * Set the mode of the symbol list.
      * 
-     * @param mode 		{@code SymbolList.SYMBOL_ENGLISH} or {@code null}.
+     * @param mode      {@code SymbolList.SYMBOL_ENGLISH} or {@code null}.
      */
-	private void setSymbolMode(String mode) {
-		if (mode != null) {
-			mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
-			mSymbolMode = true;
-			mSymbolList.setDictionary(mode);
-			mConverter = mSymbolList;
-		} else {
-			if (!mSymbolMode) {
-				return;
-			}
-			mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
-			mSymbolMode = false;
-			mConverter = mConverterEN;
-		}
-	}
+    private void setSymbolMode(String mode) {
+        if (mode != null) {
+            mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
+            mSymbolMode = true;
+            mSymbolList.setDictionary(mode);
+            mConverter = mSymbolList;
+        } else {
+            if (!mSymbolMode) {
+                return;
+            }
+            mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
+            mSymbolMode = false;
+            mConverter = mConverterEN;
+        }
+    }
 
-	/***********************************************************************
-	 * InputMethodServer
-	 ***********************************************************************/
+    /***********************************************************************
+     * InputMethodServer
+     ***********************************************************************/
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onCreate */
-	@Override public void onCreate() {
-		super.onCreate();
-		mWordSeparators = getResources().getString(R.string.en_word_separators);
+    @Override public void onCreate() {
+        super.onCreate();
+        mWordSeparators = getResources().getString(R.string.en_word_separators);
 
-		if (mSymbolList == null) {
-			mSymbolList = new SymbolList(this, SymbolList.LANG_EN);
-		}
-	}
-	
+        if (mSymbolList == null) {
+            mSymbolList = new SymbolList(this, SymbolList.LANG_EN);
+        }
+    }
+    
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onCreateInputView */
     @Override public View onCreateInputView() {
-    	int hiddenState = getResources().getConfiguration().hardKeyboardHidden;
-    	boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
-    	((DefaultSoftKeyboardEN) mInputViewManager).setHardKeyboardHidden(hidden);
-    	((TextCandidatesViewManager)
-    			mCandidatesViewManager).setHardKeyboardHidden(hidden);
+        int hiddenState = getResources().getConfiguration().hardKeyboardHidden;
+        boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
+        ((DefaultSoftKeyboardEN) mInputViewManager).setHardKeyboardHidden(hidden);
+        ((TextCandidatesViewManager)
+                mCandidatesViewManager).setHardKeyboardHidden(hidden);
 
         return super.onCreateInputView();
     }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onStartInputView */
-	@Override public void onStartInputView(EditorInfo attribute, boolean restarting) {
-		super.onStartInputView(attribute, restarting);
+    @Override public void onStartInputView(EditorInfo attribute, boolean restarting) {
+        super.onStartInputView(attribute, restarting);
 
-		/* initialize views */
-		mCandidatesViewManager.clearCandidates();
+        /* initialize views */
+        mCandidatesViewManager.clearCandidates();
+        mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_CLOSE);
 
-		mHardShift = 0;
-		mHardAlt   = 0;
+        mHardShift = 0;
+        mHardAlt   = 0;
         updateMetaKeyStateDisplay();
 
         /* load preferences */
-		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
+        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
 
-		/* auto caps mode */
-		mAutoCaps = pref.getBoolean("auto_caps", true);
+        /* auto caps mode */
+        mAutoCaps = pref.getBoolean("auto_caps", true);
 
-		/* set TextCandidatesViewManager's option */
-		((TextCandidatesViewManager)mCandidatesViewManager).setAutoHide(false);
-
+        /* set TextCandidatesViewManager's option */
+        ((TextCandidatesViewManager)mCandidatesViewManager).setAutoHide(true);
         
-		/* display status icon */
- 		showStatusIcon(R.drawable.immodeic_half_alphabet);
+        /* display status icon */
+        showStatusIcon(R.drawable.immodeic_half_alphabet);
 
-		/* set prediction & spell correction mode */
-		mOptPrediction      = pref.getBoolean("opt_en_prediction", true);
-		mOptSpellCorrection = pref.getBoolean("opt_en_spell_correction", true);
-		mOptLearning        = pref.getBoolean("opt_en_enable_learning", true);
+        /* set prediction & spell correction mode */
+        mOptPrediction      = pref.getBoolean("opt_en_prediction", true);
+        mOptSpellCorrection = pref.getBoolean("opt_en_spell_correction", true);
+        mOptLearning        = pref.getBoolean("opt_en_enable_learning", true);
 
-		/* prediction on/off */
+        /* prediction on/off */
         switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) {
         case EditorInfo.TYPE_CLASS_NUMBER:
         case EditorInfo.TYPE_CLASS_DATETIME:
         case EditorInfo.TYPE_CLASS_PHONE:
             mOptPrediction = false;
-    		mOptLearning = false;
+            mOptLearning = false;
             break;
 
         case EditorInfo.TYPE_CLASS_TEXT:
-        	switch (attribute.inputType & EditorInfo.TYPE_MASK_VARIATION) {
-        	case EditorInfo.TYPE_TEXT_VARIATION_PASSWORD:
+            switch (attribute.inputType & EditorInfo.TYPE_MASK_VARIATION) {
+            case EditorInfo.TYPE_TEXT_VARIATION_PASSWORD:
             case EditorInfo.TYPE_TEXT_VARIATION_PHONETIC:
-            	mOptLearning = false;
-        		mOptPrediction = false;
-        		break;
-        	default:
-        		break;
-        	}
+                mOptLearning = false;
+                mOptPrediction = false;
+                break;
+            default:
+                break;
+            }
         }
 
         /* set engine's mode */
         if (mOptSpellCorrection) {
-        	mConverterEN.setDictionary(OpenWnnEngineEN.DICT_FOR_CORRECT_MISTYPE);
+            mConverterEN.setDictionary(OpenWnnEngineEN.DICT_FOR_CORRECT_MISTYPE);
         } else {
-        	mConverterEN.setDictionary(OpenWnnEngineEN.DICT_DEFAULT);
+            mConverterEN.setDictionary(OpenWnnEngineEN.DICT_DEFAULT);
         }
         /* emoji */
         if (ENABLE_EMOJI_LIMITATION) {
             Bundle bundle = attribute.extras;
             if (bundle != null && bundle.getBoolean("allowEmoji")) {
-            	mConverterEN.setFilter(null);
+                mConverterEN.setFilter(null);
             } else {
-            	mFilter.setFilter(CandidateFilter.FILTER_EMOJI);
-            	mConverterEN.setFilter(mFilter);
+                mFilter.setFilter(CandidateFilter.FILTER_EMOJI);
+                mConverterEN.setFilter(mFilter);
             }
         } else {
-        	mConverterEN.setFilter(null);
+            mConverterEN.setFilter(null);
         }
 
         /* doesn't learn any word if it is not prediction mode */
         if (!mOptPrediction) {
-        	mOptLearning = false;
+            mOptLearning = false;
         }
 
         if (mComposingText != null) {
-        	mComposingText.clear();
+            mComposingText.clear();
         }
         /* initialize the engine's state */
         fitInputType(pref, attribute);
-	}
+    }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onComputeInsets */
-	@Override public void onComputeInsets(InputMethodService.Insets outInsets) {
-		if (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL) {
-			outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_FRAME;
-		} else {
-			super.onComputeInsets(outInsets);
-		}
-	}
-
-    /** @see jp.co.omronsoft.openwnn.OpenWnn#isFullscreenMode */
-	@Override public boolean isFullscreenMode() {
-		boolean ret;
-		if (mInputViewManager == null) {
-			ret = (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL);
-		} else {
-			ret = false;
-		}
-		return ret;
-	}
+    @Override public void onComputeInsets(InputMethodService.Insets outInsets) {
+        /* use default value. means;
+         * outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_VISIBLE;
+         */
+    }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onUpdateSelection */
-	@Override public void onUpdateSelection(int oldSelStart, int oldSelEnd,
-			int newSelStart, int newSelEnd, int candidatesStart,
-			int candidatesEnd) {
-		if (mComposingText.size(1) != 0) {
-			updateComposingText(1);
-		}
-	}
+    @Override public void onUpdateSelection(int oldSelStart, int oldSelEnd,
+            int newSelStart, int newSelEnd, int candidatesStart,
+            int candidatesEnd) {
+        if (mComposingText.size(1) != 0) {
+            updateComposingText(1);
+        }
+    }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onConfigurationChanged */
-	@Override public void onConfigurationChanged(Configuration newConfig) {
-		try {
-			super.onConfigurationChanged(newConfig);
-			if (mInputConnection != null) {
-				updateComposingText(1);
-			}
-		} catch (Exception ex) {
-		}
-	}
+    @Override public void onConfigurationChanged(Configuration newConfig) {
+        try {
+            super.onConfigurationChanged(newConfig);
+            if (mInputConnection != null) {
+                updateComposingText(1);
+            }
+        } catch (Exception ex) {
+        }
+    }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onEvaluateFullscreenMode */
-	@Override public boolean onEvaluateFullscreenMode() {
-		return false;
-	}
+    @Override public boolean onEvaluateFullscreenMode() {
+        return false;
+    }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onEvaluateInputViewShown */
-	@Override public boolean onEvaluateInputViewShown() {
-		return true;
-	}
+    @Override public boolean onEvaluateInputViewShown() {
+        return true;
+    }
 
-	/***********************************************************************
-	 * OpenWnn
-	 ***********************************************************************/
+    /***********************************************************************
+     * OpenWnn
+     ***********************************************************************/
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onEvent */
-	@Override synchronized public boolean onEvent(OpenWnnEvent ev) {
+    @Override synchronized public boolean onEvent(OpenWnnEvent ev) {
         /* handling events which are valid when InputConnection is not active. */
         switch (ev.code) {
         
@@ -403,33 +390,33 @@
             mUserDictionaryWords = mConverterEN.getUserDictionaryWords( );
             return true;
 
-		case OpenWnnEvent.GET_WORD:
-			if( mUserDictionaryWords != null ) {
-				ev.word = mUserDictionaryWords[ 0 ];
-				for( int i = 0 ; i < mUserDictionaryWords.length-1 ; i++ ) {
-					mUserDictionaryWords[ i ] = mUserDictionaryWords[ i + 1 ];
-				}
-				mUserDictionaryWords[ mUserDictionaryWords.length-1 ] = null;
-				if( mUserDictionaryWords[ 0 ] == null ) {
-					mUserDictionaryWords = null;
-				}
-				return true;
-			}
+        case OpenWnnEvent.GET_WORD:
+            if( mUserDictionaryWords != null ) {
+                ev.word = mUserDictionaryWords[ 0 ];
+                for( int i = 0 ; i < mUserDictionaryWords.length-1 ; i++ ) {
+                    mUserDictionaryWords[ i ] = mUserDictionaryWords[ i + 1 ];
+                }
+                mUserDictionaryWords[ mUserDictionaryWords.length-1 ] = null;
+                if( mUserDictionaryWords[ 0 ] == null ) {
+                    mUserDictionaryWords = null;
+                }
+                return true;
+            }
             break;
 
-		case OpenWnnEvent.ADD_WORD:
-			mConverterEN.addWord(ev.word);
-			return true;
+        case OpenWnnEvent.ADD_WORD:
+            mConverterEN.addWord(ev.word);
+            return true;
 
-		case OpenWnnEvent.DELETE_WORD:
-			mConverterEN.deleteWord(ev.word);
-			return true;
+        case OpenWnnEvent.DELETE_WORD:
+            mConverterEN.deleteWord(ev.word);
+            return true;
 
-		case OpenWnnEvent.CHANGE_MODE:
+        case OpenWnnEvent.CHANGE_MODE:
             return false;
             
         case OpenWnnEvent.CHANGE_INPUT_VIEW:
-        	setInputView(onCreateInputView());
+            setInputView(onCreateInputView());
             return true;
 
         case OpenWnnEvent.CANDIDATE_VIEW_TOUCH:
@@ -439,84 +426,85 @@
 
         default:
             break;
-		}
+        }
 
-		dismissPopupKeyboard();
+        dismissPopupKeyboard();
         KeyEvent keyEvent = ev.keyEvent;
         int keyCode = 0;
         if (keyEvent != null) {
             keyCode = keyEvent.getKeyCode();
         }
-		if (mDirectInputMode) {
+        if (mDirectInputMode) {
             if (ev.code == OpenWnnEvent.INPUT_SOFT_KEY && mInputConnection != null) {
                 mInputConnection.sendKeyEvent(keyEvent);
-				mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP,
+                mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP,
                                                            keyEvent.getKeyCode()));
             }
-			return false;
-		}
+            return false;
+        }
 
-		if (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL) {
-			mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_FULL);
-			return true;
-		}
+        if (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL) {
+            mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_FULL);
+            return true;
+        }
 
-		boolean ret = false;
-		switch (ev.code) {
-		case OpenWnnEvent.INPUT_CHAR:
-			EditorInfo edit = getCurrentInputEditorInfo();
-			if( edit.inputType == EditorInfo.TYPE_CLASS_PHONE){
-				commitText(new String(ev.chars));			
-			}else{
-				setSymbolMode(null);
-				insertCharToComposingText(ev.chars);
-				ret = true;
-				mPreviousEventCode = ev.code;
-			}
-			break;
-
-		case OpenWnnEvent.INPUT_KEY:
-			keyCode = ev.keyEvent.getKeyCode();
-			/* update shift/alt state */
-			switch (keyCode) {
-			case KeyEvent.KEYCODE_ALT_LEFT:
-			case KeyEvent.KEYCODE_ALT_RIGHT:
-				if (ev.keyEvent.getRepeatCount() == 0) {
-					if (++mHardAlt > 2) { mHardAlt = 0; }
-				}
-                mAltPressing   = true;
-				updateMetaKeyStateDisplay();
-				return true;
-
-			case KeyEvent.KEYCODE_SHIFT_LEFT:
-			case KeyEvent.KEYCODE_SHIFT_RIGHT:
-				if (ev.keyEvent.getRepeatCount() == 0) {
-					if (++mHardShift > 2) { mHardShift = 0; }
-				}
-                mShiftPressing = true;
-				updateMetaKeyStateDisplay();
-				return true;
-			}
-			setSymbolMode(null);
-			updateComposingText(1);
-			/* handle other key event */
-			ret = processKeyEvent(ev.keyEvent);
-			mPreviousEventCode = ev.code;
-			break;
-
-		case OpenWnnEvent.INPUT_SOFT_KEY:
-			setSymbolMode(null);
-			updateComposingText(1);
-			ret = processKeyEvent(ev.keyEvent);
-			if (!ret) {
-				mInputConnection.sendKeyEvent(ev.keyEvent);
-				mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, ev.keyEvent.getKeyCode()));
+        boolean ret = false;
+        switch (ev.code) {
+        case OpenWnnEvent.INPUT_CHAR:
+             ((TextCandidatesViewManager)mCandidatesViewManager).setAutoHide(false);
+            EditorInfo edit = getCurrentInputEditorInfo();
+            if( edit.inputType == EditorInfo.TYPE_CLASS_PHONE){
+                commitText(new String(ev.chars));           
+            }else{
+                setSymbolMode(null);
+                insertCharToComposingText(ev.chars);
                 ret = true;
-			}
-			mPreviousEventCode = ev.code;
-			break;
+                mPreviousEventCode = ev.code;
+            }
+            break;
 
-		case OpenWnnEvent.SELECT_CANDIDATE:
+        case OpenWnnEvent.INPUT_KEY:
+            keyCode = ev.keyEvent.getKeyCode();
+            /* update shift/alt state */
+            switch (keyCode) {
+            case KeyEvent.KEYCODE_ALT_LEFT:
+            case KeyEvent.KEYCODE_ALT_RIGHT:
+                if (ev.keyEvent.getRepeatCount() == 0) {
+                    if (++mHardAlt > 2) { mHardAlt = 0; }
+                }
+                mAltPressing   = true;
+                updateMetaKeyStateDisplay();
+                return true;
+
+            case KeyEvent.KEYCODE_SHIFT_LEFT:
+            case KeyEvent.KEYCODE_SHIFT_RIGHT:
+                if (ev.keyEvent.getRepeatCount() == 0) {
+                    if (++mHardShift > 2) { mHardShift = 0; }
+                }
+                mShiftPressing = true;
+                updateMetaKeyStateDisplay();
+                return true;
+            }
+            setSymbolMode(null);
+            updateComposingText(1);
+            /* handle other key event */
+            ret = processKeyEvent(ev.keyEvent);
+            mPreviousEventCode = ev.code;
+            break;
+
+        case OpenWnnEvent.INPUT_SOFT_KEY:
+            setSymbolMode(null);
+            updateComposingText(1);
+            ret = processKeyEvent(ev.keyEvent);
+            if (!ret) {
+                mInputConnection.sendKeyEvent(ev.keyEvent);
+                mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, ev.keyEvent.getKeyCode()));
+                ret = true;
+            }
+            mPreviousEventCode = ev.code;
+            break;
+
+        case OpenWnnEvent.SELECT_CANDIDATE:
             if (mSymbolMode) {
                 commitText(ev.word, false);
             } else {
@@ -531,79 +519,81 @@
             updateComposingText(1);
             break;
 
-		case OpenWnnEvent.LIST_SYMBOLS:
-			commitText(1);
-			mComposingText.clear();
-			setSymbolMode(SymbolList.SYMBOL_ENGLISH);
-			updateComposingText(1);
-			break;
+        case OpenWnnEvent.LIST_SYMBOLS:
+            commitText(1);
+            mComposingText.clear();
+            setSymbolMode(SymbolList.SYMBOL_ENGLISH);
+            updateComposingText(1);
+            break;
 
-		default:
-			break;
-		}
+        default:
+            break;
+        }
 
-		if (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL) {
-			mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_NORMAL);
-		}
+        if (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL) {
+            mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_NORMAL);
+        }
 
-		return ret;
-	}
+        return ret;
+    }
 
-	/***********************************************************************
-	 * OpenWnnEN
-	 ***********************************************************************/
-	/**
-	 * Handling KeyEvent
-	 * <br>
-	 * This method is called from {@link #onEvent()}.
-	 *
-	 * @param ev   A key event
-	 * @return		{@code true} if the event is processed in this method; {@code false} if the event is not processed in this method
-	 */
-	private boolean processKeyEvent(KeyEvent ev) {
+    /***********************************************************************
+     * OpenWnnEN
+     ***********************************************************************/
+    /**
+     * Handling KeyEvent
+     * <br>
+     * This method is called from {@link #onEvent()}.
+     *
+     * @param ev   A key event
+     * @return      {@code true} if the event is processed in this method; {@code false} if the event is not processed in this method
+     */
+    private boolean processKeyEvent(KeyEvent ev) {
 
-		int key = ev.getKeyCode();
-		EditorInfo edit = getCurrentInputEditorInfo();
-		/* keys which produce a glyph */
-		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() && 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) {
+        int key = ev.getKeyCode();
+        EditorInfo edit = getCurrentInputEditorInfo();
+        /* keys which produce a glyph */
+        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() && 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){
                         mShiftPressing = false;
                     }
                     if(mHardAlt == 1){
                         mAltPressing   = false;
                     }
-	            	if(!ev.isAltPressed()){
-	            		if (mHardAlt == 1) {
-	            			mHardAlt = 0;
-	            		}
-	            	}
-	            	if(!ev.isShiftPressed()){
-	            		if (mHardShift == 1) {
-	            			mHardShift = 0;
-	            		}
-	            	}
-	            	if(!ev.isShiftPressed() && !ev.isAltPressed()){
-	                    updateMetaKeyStateDisplay();
-	            	}
-					return true;
-				}
-			}
+                    if(!ev.isAltPressed()){
+                        if (mHardAlt == 1) {
+                            mHardAlt = 0;
+                        }
+                    }
+                    if(!ev.isShiftPressed()){
+                        if (mHardShift == 1) {
+                            mHardShift = 0;
+                        }
+                    }
+                    if(!ev.isShiftPressed() && !ev.isAltPressed()){
+                        updateMetaKeyStateDisplay();
+                    }
+                    return true;
+                }
+            }
+            
+            ((TextCandidatesViewManager)mCandidatesViewManager).setAutoHide(false);
 
             /* get the key character */
-			if (mHardShift== 0  && mHardAlt == 0) {
+            if (mHardShift== 0  && mHardAlt == 0) {
                 /* no meta key is locked */
-				int shift = (mAutoCaps) ? getShiftKeyState(edit) : 0;
-				if (shift != mHardShift && (key >= KeyEvent.KEYCODE_A && key <= KeyEvent.KEYCODE_Z)) {
+                int shift = (mAutoCaps) ? getShiftKeyState(edit) : 0;
+                if (shift != mHardShift && (key >= KeyEvent.KEYCODE_A && key <= KeyEvent.KEYCODE_Z)) {
                     /* handling auto caps for a alphabet character */
                     insertCharToComposingText(ev.getUnicodeChar(MetaKeyKeyListener.META_SHIFT_ON));
                 } else {
                     insertCharToComposingText(ev.getUnicodeChar());
                 }
-			} else {
+            } else {
                 insertCharToComposingText(ev.getUnicodeChar(mShiftKeyToggle[mHardShift]
                                                             | mAltKeyToggle[mHardAlt]));
                 if(mHardShift == 1){
@@ -613,234 +603,234 @@
                     mAltPressing   = false;
                 }
                 /* back to 0 (off) if 1 (on/not locked) */
-            	if(!ev.isAltPressed()){
-            		if (mHardAlt == 1) {
-            			mHardAlt = 0;
-            		}
-            	}
-            	if(!ev.isShiftPressed()){
-            		if (mHardShift == 1) {
-            			mHardShift = 0;
-            		}
-            	}
-            	if(!ev.isShiftPressed() && !ev.isAltPressed()){
+                if(!ev.isAltPressed()){
+                    if (mHardAlt == 1) {
+                        mHardAlt = 0;
+                    }
+                }
+                if(!ev.isShiftPressed()){
+                    if (mHardShift == 1) {
+                        mHardShift = 0;
+                    }
+                }
+                if(!ev.isShiftPressed() && !ev.isAltPressed()){
                     updateMetaKeyStateDisplay();
-            	}
-			}
+                }
+            }
 
             if (edit.inputType == EditorInfo.TYPE_CLASS_PHONE) {
-				commitText(1);
-				mComposingText.clear();
-				return true;
-			}
-			return true;
+                commitText(1);
+                mComposingText.clear();
+                return true;
+            }
+            return true;
 
-		} else if (key == KeyEvent.KEYCODE_SPACE) {
-			if (ev.isAltPressed()) {
+        } else if (key == KeyEvent.KEYCODE_SPACE) {
+            if (ev.isAltPressed()) {
                 /* display the symbol list (G1 specific. same as KEYCODE_SYM) */
-				commitText(1);
-				mComposingText.clear();
-				setSymbolMode(SymbolList.SYMBOL_ENGLISH);
-				updateComposingText(1);		
-				mHardAlt = 0;
+                commitText(1);
+                mComposingText.clear();
+                setSymbolMode(SymbolList.SYMBOL_ENGLISH);
+                updateComposingText(1);     
+                mHardAlt = 0;
                 updateMetaKeyStateDisplay();
-			} else {
-				insertCharToComposingText(SPACE);	
-			}
-			return true;
+            } else {
+                insertCharToComposingText(SPACE);   
+            }
+            return true;
         } else if (key == KeyEvent.KEYCODE_SYM) {
             /* display the symbol list */
             commitText(1);
             mComposingText.clear();
             setSymbolMode(SymbolList.SYMBOL_ENGLISH);
-            updateComposingText(1);		
+            updateComposingText(1);     
             mHardAlt = 0;
             updateMetaKeyStateDisplay();
-		} 
+        } 
 
 
-		/* Functional key */
-		if (mComposingText.size(1) > 0) {
-			switch (key) {
-			case KeyEvent.KEYCODE_DEL:
-				mComposingText.delete(1, false);
-				updateComposingText(1);
-				return true;
+        /* Functional key */
+        if (mComposingText.size(1) > 0) {
+            switch (key) {
+            case KeyEvent.KEYCODE_DEL:
+                mComposingText.delete(1, false);
+                updateComposingText(1);
+                return true;
 
-			case KeyEvent.KEYCODE_BACK:
-				if (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL) {
-					mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_NORMAL);
-				} else {
-					mComposingText.clear();
-					updateComposingText(1);
-				}
-				return true;
+            case KeyEvent.KEYCODE_BACK:
+                if (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL) {
+                    mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_NORMAL);
+                } else {
+                    mComposingText.clear();
+                    updateComposingText(1);
+                }
+                return true;
 
-			case KeyEvent.KEYCODE_DPAD_LEFT:
-				mComposingText.moveCursor(1, -1);
-				updateComposingText(1);
-				return true;
+            case KeyEvent.KEYCODE_DPAD_LEFT:
+                mComposingText.moveCursor(1, -1);
+                updateComposingText(1);
+                return true;
 
-			case KeyEvent.KEYCODE_DPAD_RIGHT:
-				mComposingText.moveCursor(1, 1);
-				updateComposingText(1);
-				return true;
+            case KeyEvent.KEYCODE_DPAD_RIGHT:
+                mComposingText.moveCursor(1, 1);
+                updateComposingText(1);
+                return true;
 
-			case KeyEvent.KEYCODE_ENTER:
-			case KeyEvent.KEYCODE_DPAD_CENTER:
-				commitText(1);
-				mComposingText.clear();
-				return true;
+            case KeyEvent.KEYCODE_ENTER:
+            case KeyEvent.KEYCODE_DPAD_CENTER:
+                commitText(1);
+                mComposingText.clear();
+                return true;
 
-			default:
-				break;
-			}
-		}
-
-		return false;
-	}
-
-	/**
-	 * Runnable for a thread getting and displaying candidates.
-	 */
-	private final Runnable updatePredictionRunnable = new Runnable() {
-		public void run() {
-			int candidates = 0;
-			if (mConverter != null) {
-				/* normal prediction */
-				candidates = mConverter.predict(mComposingText, 0, -1);
-			}
-			/* update the candidates view */
-			if (candidates > 0) {
-				mCandidatesViewManager.displayCandidates(mConverter);
-			} else {
-				mCandidatesViewManager.clearCandidates();
-			}
-		}
-	};
-
-	/**
-	 * Update the composing text.
-	 *
-	 * @param layer  {@link mComposingText}'s layer to display
-	 */
-	private void updateComposingText(int layer) {
-		/* update the candidates view */
-		if (!mOptPrediction) {
-			commitText(1);
-			mComposingText.clear();
-            if (mSymbolMode) {
-				mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
-				mDelayUpdateHandler.postDelayed(updatePredictionRunnable, 0);         
+            default:
+                break;
             }
-		} else {
-			if (mComposingText.size(1) != 0) {
-				mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
-				mDelayUpdateHandler.postDelayed(updatePredictionRunnable, 250);
-			} else {
-				mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
-				mDelayUpdateHandler.postDelayed(updatePredictionRunnable, 0);         
-			}
+        }
 
-			/* notice to the input view */
-			this.mInputViewManager.onUpdateState(this);
+        return false;
+    }
 
-			/* set the candidates view to the normal size */
-			if (mCandidatesViewManager.getViewType() != CandidatesViewManager.VIEW_TYPE_NORMAL) {
-				mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_NORMAL);
-			}
-			/* set the text for displaying as the composing text */
-			SpannableStringBuilder disp = mDisplayText;
-			disp.clear();
-			disp.insert(0, mComposingText.toString(layer));
+    /**
+     * Runnable for a thread getting and displaying candidates.
+     */
+    private final Runnable updatePredictionRunnable = new Runnable() {
+        public void run() {
+            int candidates = 0;
+            if (mConverter != null) {
+                /* normal prediction */
+                candidates = mConverter.predict(mComposingText, 0, -1);
+            }
+            /* update the candidates view */
+            if (candidates > 0) {
+                mCandidatesViewManager.displayCandidates(mConverter);
+            } else {
+                mCandidatesViewManager.clearCandidates();
+            }
+        }
+    };
 
-			/* add decoration to the text */
-			int cursor = mComposingText.getCursor(layer);
-			if (disp.length() != 0) {
-				if (cursor > 0 && cursor < disp.length()) {
-					disp.setSpan(SPAN_EXACT_BGCOLOR_HL, 0, cursor,
-							Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-				}
-				if (cursor < disp.length()) {
+    /**
+     * Update the composing text.
+     *
+     * @param layer  {@link mComposingText}'s layer to display
+     */
+    private void updateComposingText(int layer) {
+        /* update the candidates view */
+        if (!mOptPrediction) {
+            commitText(1);
+            mComposingText.clear();
+            if (mSymbolMode) {
+                mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
+                mDelayUpdateHandler.postDelayed(updatePredictionRunnable, 0);         
+            }
+        } else {
+            if (mComposingText.size(1) != 0) {
+                mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
+                mDelayUpdateHandler.postDelayed(updatePredictionRunnable, 250);
+            } else {
+                mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
+                mDelayUpdateHandler.postDelayed(updatePredictionRunnable, 0);         
+            }
+
+            /* notice to the input view */
+            this.mInputViewManager.onUpdateState(this);
+
+            /* set the candidates view to the normal size */
+            if (mCandidatesViewManager.getViewType() != CandidatesViewManager.VIEW_TYPE_NORMAL) {
+                mCandidatesViewManager.setViewType(CandidatesViewManager.VIEW_TYPE_NORMAL);
+            }
+            /* set the text for displaying as the composing text */
+            SpannableStringBuilder disp = mDisplayText;
+            disp.clear();
+            disp.insert(0, mComposingText.toString(layer));
+
+            /* add decoration to the text */
+            int cursor = mComposingText.getCursor(layer);
+            if (disp.length() != 0) {
+                if (cursor > 0 && cursor < disp.length()) {
+                    disp.setSpan(SPAN_EXACT_BGCOLOR_HL, 0, cursor,
+                            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+                }
+                if (cursor < disp.length()) {
                     mDisplayText.setSpan(SPAN_REMAIN_BGCOLOR_HL, cursor, disp.length(),
                             Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-				}
-				
-				disp.setSpan(SPAN_UNDERLINE, 0, disp.length(),
-						Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-			}
-			
+                }
+                
+                disp.setSpan(SPAN_UNDERLINE, 0, disp.length(),
+                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+            }
+            
             int displayCursor = cursor;
             if (FIX_CURSOR_TEXT_END) {
                 displayCursor = (cursor == 0) ?  0 : 1;
             } 
-			/* update the composing text on the EditView */
-			mInputConnection.setComposingText(disp, displayCursor);
-		}
-	}
+            /* update the composing text on the EditView */
+            mInputConnection.setComposingText(disp, displayCursor);
+        }
+    }
 
-	/**
-	 * Commit the composing text.
-	 *
-	 * @param layer  {@link mComposingText}'s layer to commit.
-	 */
-	private void commitText(int layer) {
-		String tmp = mComposingText.toString(layer);
+    /**
+     * Commit the composing text.
+     *
+     * @param layer  {@link mComposingText}'s layer to commit.
+     */
+    private void commitText(int layer) {
+        String tmp = mComposingText.toString(layer);
 
-		if (mOptLearning && mConverter != null && tmp.length() > 0) {
-			WnnWord word = new WnnWord(tmp, tmp);
-			mConverter.learn(word);
-		}
+        if (mOptLearning && mConverter != null && tmp.length() > 0) {
+            WnnWord word = new WnnWord(tmp, tmp);
+            mConverter.learn(word);
+        }
 
         mInputConnection.commitText(tmp, (FIX_CURSOR_TEXT_END ? 1 : tmp.length()));
-		mCandidatesViewManager.clearCandidates();
-	}
+        mCandidatesViewManager.clearCandidates();
+    }
 
-	/**
-	 * Commit a word
-	 *
-	 * @param word 		 	A word to commit
-	 * @param withSpace		Append a space after the word if {@code true}.
-	 */
-	private void commitText(WnnWord word, boolean withSpace) {
+    /**
+     * Commit a word
+     *
+     * @param word          A word to commit
+     * @param withSpace     Append a space after the word if {@code true}.
+     */
+    private void commitText(WnnWord word, boolean withSpace) {
 
-		if (mOptLearning && mConverter != null) {
-			mConverter.learn(word);
-		}
+        if (mOptLearning && mConverter != null) {
+            mConverter.learn(word);
+        }
 
         mInputConnection.commitText(word.candidate, (FIX_CURSOR_TEXT_END ? 1 : word.candidate.length()));
 
-		if (withSpace) {
-			commitText(" ");
-		}		
-	}
+        if (withSpace) {
+            commitText(" ");
+        }       
+    }
 
-	/**
-	 * Commit a string
+    /**
+     * Commit a string
      * <br>
      * The string is not registered into the learning dictionary.
-	 *
-	 * @param str  A string to commit
-	 */
-	private void commitText(String str) {
+     *
+     * @param str  A string to commit
+     */
+    private void commitText(String str) {
         mInputConnection.commitText(str, (FIX_CURSOR_TEXT_END ? 1 : str.length()));
-		mCandidatesViewManager.clearCandidates();
-	}
+        mCandidatesViewManager.clearCandidates();
+    }
 
-	/**
-	 * Dismiss the pop-up keyboard
-	 */
-	protected void dismissPopupKeyboard() {
-		DefaultSoftKeyboardEN kbd = (DefaultSoftKeyboardEN)mInputViewManager;
-		if (kbd != null) {
-			kbd.dismissPopupKeyboard();
-		}
-	}
+    /**
+     * Dismiss the pop-up keyboard
+     */
+    protected void dismissPopupKeyboard() {
+        DefaultSoftKeyboardEN kbd = (DefaultSoftKeyboardEN)mInputViewManager;
+        if (kbd != null) {
+            kbd.dismissPopupKeyboard();
+        }
+    }
 
-	/**
-	 * Display current meta-key state.
-	 */
-	private void updateMetaKeyStateDisplay() {
+    /**
+     * Display current meta-key state.
+     */
+    private void updateMetaKeyStateDisplay() {
         int mode = 0;
         if(mHardShift == 0 && mHardAlt == 0){
             mode = DefaultSoftKeyboard.HARD_KEYMODE_SHIFT_OFF_ALT_OFF;
@@ -865,15 +855,15 @@
         }
 
         ((DefaultSoftKeyboard) mInputViewManager).updateIndicator(mode);
-	}
+    }
 
-	/**
-	 * Handling KeyEvent(KEYUP)
-	 * <br>
-	 * This method is called from {@link #onEvent()}.
-	 *
-	 * @param ev   An up key event
-	 */
+    /**
+     * Handling KeyEvent(KEYUP)
+     * <br>
+     * This method is called from {@link #onEvent()}.
+     *
+     * @param ev   An up key event
+     */
     private void onKeyUpEvent(KeyEvent ev) {
         int key = ev.getKeyCode();
         if(!mShiftPressing){
@@ -895,7 +885,7 @@
      * Fits an editor info.
      * 
      * @param preferences  The preference data.
-     * @param info  		The editor info.
+     * @param info          The editor info.
      */
     private void fitInputType(SharedPreferences preference, EditorInfo info) {
         if (info.inputType == EditorInfo.TYPE_NULL) {
@@ -904,11 +894,3 @@
         }
     }
 }
-
-
-
-
-
-
-
-
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java b/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java
index 72c8306..6db1817 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnnJAJP.java
@@ -337,6 +337,18 @@
     /** Regular expression pattern for English separators */
     private  Pattern mEnglishAutoCommitDelimiter = null;
 
+    /** Lenght of committed text */
+    private int mCommitLength = 0;
+
+    /** Last cursor position */
+    private int mLastSelectionEnd = 0;
+
+    /** Cursor position before committing text */
+    private int mCommitStartCursor = 0;
+
+    /** Previous committed text */
+    private StringBuffer mPrevCommitText = null;
+
     /** List of words in the user dictionary */
     private WnnWord[] mUserDictionaryWords = null;
 
@@ -344,13 +356,13 @@
     private int mHardShift;
 
     /** SHIFT key state (pressing) */
-	private boolean mShiftPressing;
+    private boolean mShiftPressing;
 
     /** Alt lock status of the Hardware keyboard */
     private int mHardAlt;
 
     /** ALT key state (pressing) */
-	private boolean mAltPressing;
+    private boolean mAltPressing;
 
     /** Shift lock toggle definition */
     private static final int[] mShiftKeyToggle = {0, MetaKeyKeyListener.META_SHIFT_ON, MetaKeyKeyListener.META_CAP_LOCKED};
@@ -384,6 +396,7 @@
         mAutoHideMode = false;
 
         mDelayUpdateHandler = new Handler();
+        mPrevCommitText = new StringBuffer();
     }
 
     /**
@@ -409,11 +422,11 @@
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onCreateInputView */
     @Override public View onCreateInputView() {
-    	int hiddenState = getResources().getConfiguration().hardKeyboardHidden;
-    	boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
-    	((DefaultSoftKeyboardJAJP) mInputViewManager).setHardKeyboardHidden(hidden);
-    	((TextCandidatesViewManager)
-    			mCandidatesViewManager).setHardKeyboardHidden(hidden);
+        int hiddenState = getResources().getConfiguration().hardKeyboardHidden;
+        boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
+        ((DefaultSoftKeyboardJAJP) mInputViewManager).setHardKeyboardHidden(hidden);
+        ((TextCandidatesViewManager)
+         mCandidatesViewManager).setHardKeyboardHidden(hidden);
 
         return super.onCreateInputView();
     }
@@ -425,6 +438,8 @@
         state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
         updateEngineState(state);
 
+        clearCommitInfo();
+
         if (mDirectInputMode) {
             DefaultSoftKeyboardJAJP inputManager = ((DefaultSoftKeyboardJAJP)mInputViewManager);
             inputManager.setDefaultKeyboard();
@@ -450,40 +465,50 @@
         fitInputType(pref, attribute);
 
         ((TextCandidatesViewManager)mCandidatesViewManager).setAutoHide(true);
+
+        if (isEnableL2Converter()) {
+            mEnableAutoDeleteSpace = false;
+            mConverter.breakSequence();
+        }
     }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#hideWindow */
     @Override public void hideWindow() {
         mComposingText.clear();
         mInputViewManager.onUpdateState(this);
+        clearCommitInfo();
         mInputViewManager.closing();
         super.hideWindow();
     }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onComputeInsets */
     @Override public void onComputeInsets(InputMethodService.Insets outInsets) {
-        if (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL) {
-            outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_FRAME;
-        } else {
-            super.onComputeInsets(outInsets);
-        }
-    }
-
-    /** @see jp.co.omronsoft.openwnn.OpenWnn#isFullscreenMode */
-    @Override public boolean isFullscreenMode() {
-        boolean ret;
-        if (mInputViewManager == null) {
-            ret = (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL);
-        } else {
-            ret = false;
-        }
-        return ret;
+        /* use default value. means;
+         * outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_VISIBLE;
+         */
     }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onUpdateSelection */
     @Override public void onUpdateSelection(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd) {
+
+        mLastSelectionEnd = newSelEnd;
+
         if (mComposingText.size(ComposingText.LAYER1) != 0) {
             updateViewStatus(mTargetLayer, false, true);
+        } else {
+            int commitEnd = mCommitStartCursor + mCommitLength;
+            if ((mCommitLength != 0)
+                && (commitEnd != newSelEnd)
+                && ((newSelEnd < oldSelEnd) || (commitEnd < newSelEnd))) {
+
+                if (isEnableL2Converter()) {
+                    mEnableAutoDeleteSpace = false;
+                    mConverter.breakSequence();
+                }
+
+                clearCommitInfo();
+                initializeScreen();
+            }
         }
     }
 
@@ -508,8 +533,8 @@
                 int hiddenState = newConfig.hardKeyboardHidden;
                 boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
                 ((DefaultSoftKeyboardJAJP) mInputViewManager).setHardKeyboardHidden(hidden);
-                    ((TextCandidatesViewManager)
-                     mCandidatesViewManager).setHardKeyboardHidden(hidden);
+                ((TextCandidatesViewManager)
+                 mCandidatesViewManager).setHardKeyboardHidden(hidden);
             }
         } catch (Exception ex) {
             /* do nothing if an error occurs. */
@@ -565,7 +590,7 @@
         case OpenWnnEvent.CHANGE_MODE:
             changeEngineMode(ev.mode);
             if (!(ev.mode == ENGINE_MODE_SYMBOL || ev.mode == ENGINE_MODE_EISU_KANA)) {
-            	initializeScreen();
+                initializeScreen();
             }
             
             if (ev.mode != ENGINE_MODE_SYMBOL) {
@@ -587,12 +612,12 @@
             return true;
 
         case OpenWnnEvent.CHANGE_INPUT_VIEW:
-        	setInputView(onCreateInputView());
+            setInputView(onCreateInputView());
             return true;
 
         case OpenWnnEvent.CANDIDATE_VIEW_TOUCH:
             boolean ret;
-                ret = ((TextCandidatesViewManager)mCandidatesViewManager).onTouchSync();
+            ret = ((TextCandidatesViewManager)mCandidatesViewManager).onTouchSync();
             return ret;
 
         default:
@@ -616,27 +641,31 @@
             return false;
         }
         
-        /* notice a break the sequence of input to the converter */
-        View candidateView = mCandidatesViewManager.getCurrentView();
-        if ((candidateView != null) && !candidateView.isShown()
-            && (mComposingText.size(0) == 0)) {
-            if (isEnableL2Converter()) {
-                disableAutoDeleteSpace(ev);
-                mConverter.breakSequence();
-            }
-        }
+        if (!((ev.code == OpenWnnEvent.COMMIT_COMPOSING_TEXT)
+              || ((keyEvent != null)
+                  && ((keyCode == KeyEvent.KEYCODE_SHIFT_LEFT)
+                      || (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)
+                      || (keyCode == KeyEvent.KEYCODE_ALT_LEFT)
+                      || (keyCode == KeyEvent.KEYCODE_ALT_RIGHT)
+                      || (keyEvent.isAltPressed() && (keyCode == KeyEvent.KEYCODE_SPACE)))))) {
 
+            clearCommitInfo();
+        }       
+                
         /* change back the dictionary if necessary */
         if (!((ev.code == OpenWnnEvent.SELECT_CANDIDATE)
-        		|| (ev.code == OpenWnnEvent.LIST_CANDIDATES_NORMAL)
-        		|| (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL)
-        		|| ((keyEvent != null)
-        				&& ((keyCode == KeyEvent.KEYCODE_ALT_LEFT)
-        						||(keyCode == KeyEvent.KEYCODE_ALT_RIGHT)
-        						||(keyEvent.isAltPressed() && (keyCode == KeyEvent.KEYCODE_SPACE)))))) {
-        	state = new EngineState();
-        	state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
-        	updateEngineState(state);
+              || (ev.code == OpenWnnEvent.LIST_CANDIDATES_NORMAL)
+              || (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL)
+              || ((keyEvent != null)
+                  && ((keyCode == KeyEvent.KEYCODE_SHIFT_LEFT)
+                      ||(keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)
+                      ||(keyCode == KeyEvent.KEYCODE_ALT_LEFT)
+                      ||(keyCode == KeyEvent.KEYCODE_ALT_RIGHT)
+                      ||(keyEvent.isAltPressed() && (keyCode == KeyEvent.KEYCODE_SPACE)))))) {
+
+            state = new EngineState();
+            state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
+            updateEngineState(state);
         }
 
         if (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL) {
@@ -737,16 +766,28 @@
             ret = processKeyEvent(keyEvent);
             if (!ret) {
                 mInputConnection.sendKeyEvent(keyEvent);
-				mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent.getKeyCode()));
+                mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent.getKeyCode()));
                 ret = true;
             }
             break;
 
         case OpenWnnEvent.SELECT_CANDIDATE:
+            boolean hasSetInfo = false;
+            if (isEnableL2Converter()) {
+                setCommitInfo(ev.word.candidate.length());
+                hasSetInfo = true;
+            }
             if (isEnglishPrediction()) {
                 mComposingText.clear();
             }
             mStatus = commitText(ev.word);
+            if (hasSetInfo) {
+                checkCommitInfo();
+            }
+
+            if (mEngineState.isSymbolList()) {
+                mEnableAutoDeleteSpace = false;
+            }
             break;
 
         case OpenWnnEvent.CONVERT:           
@@ -786,8 +827,8 @@
     /**
      * Create a {@link StrSegment} from a character code.
      * <br>
-     * @param charCode		 A character code
-     * @return 			{@link StrSegment} created; {@code null} if an error occurs.
+     * @param charCode           A character code
+     * @return                  {@link StrSegment} created; {@code null} if an error occurs.
      */
     private StrSegment createStrSegment(int charCode) {
         if (charCode == 0) {
@@ -799,8 +840,8 @@
     /**
      * Key event handler.
      *
-     * @param ev  	A key event
-     * @return 	{@code true} if the event is handled in this method.
+     * @param ev        A key event
+     * @return  {@code true} if the event is handled in this method.
      */
     private boolean processKeyEvent(KeyEvent ev) {
         int key = ev.getKeyCode();
@@ -872,7 +913,7 @@
                 }
                 if (!ev.isShiftPressed() && !ev.isShiftPressed()) {
                     updateMetaKeyStateDisplay();
-            	}
+                }
             }
             
             if (str == null) {
@@ -885,11 +926,11 @@
                 return true;
             } else {
                 mEnableAutoInsertSpace = false;
-            	commitText(true);
+                commitText(true);
                 mEnableAutoInsertSpace = true;
-            	commitText(str.string);
+                commitText(str.string);
                 initializeScreen();
-            	return true;
+                return true;
             }
 
         } else if (key == KeyEvent.KEYCODE_SPACE) {
@@ -947,7 +988,7 @@
                 return true;
 
             case KeyEvent.KEYCODE_DPAD_LEFT:
-            	if (!isEnableL2Converter()) {
+                if (!isEnableL2Converter()) {
                     commitText(false);
                     return false;
                 } else {
@@ -956,7 +997,7 @@
                 }
 
             case KeyEvent.KEYCODE_DPAD_RIGHT:
-            	if (!isEnableL2Converter()) {
+                if (!isEnableL2Converter()) {
                     commitText(false);
                     return false;
                 } else {
@@ -966,7 +1007,24 @@
 
             case KeyEvent.KEYCODE_DPAD_CENTER:
             case KeyEvent.KEYCODE_ENTER:
+                boolean hasSetInfo = false;
+            	if (isEnableL2Converter()) {
+                    if (isEnglishPrediction()) {
+                        setCommitInfo(mComposingText.toString(mTargetLayer).length());
+                    } else {
+                        int layer = mTargetLayer;
+                        int cursor = mComposingText.getCursor(layer);
+                        if (0 < cursor) {
+                            String tmp = mComposingText.toString(layer, 0, cursor - 1);
+                            setCommitInfo(tmp.length());
+                        }
+                    }
+                    hasSetInfo = true;
+                }
                 mStatus = commitText(true);
+            	if (hasSetInfo) {
+                    checkCommitInfo();
+                }
                 return true;
 
             case KeyEvent.KEYCODE_CALL:
@@ -1029,10 +1087,10 @@
             updateMetaKeyStateDisplay();
             if (mEngineState.isEnglish()) {
                 ((DefaultSoftKeyboardJAJP) mInputViewManager).changeKeyMode(DefaultSoftKeyboard.KEYMODE_JA_FULL_HIRAGANA);
-            mConverter = mConverterJAJP;
+                mConverter = mConverterJAJP;
             } else {
                 ((DefaultSoftKeyboardJAJP) mInputViewManager).changeKeyMode(DefaultSoftKeyboard.KEYMODE_JA_HALF_ALPHABET);
-            mConverter = mConverterEN;
+                mConverter = mConverterEN;
             }
             mCandidatesViewManager.clearCandidates();
 
@@ -1050,9 +1108,12 @@
                 commitText(" ");
                 mCandidatesViewManager.clearCandidates();
             } else {
+                setCommitInfo(mComposingText.toString(mTargetLayer).length());
                 commitText(true);
                 commitSpaceJustOne();
+                checkCommitInfo();
             }
+            mEnableAutoDeleteSpace = false;
 
         } else {
             /* start consecutive clause conversion if Japanese mode */
@@ -1114,7 +1175,7 @@
             public void run() {
                 int candidates = 0;
                 int cursor = mComposingText.getCursor(ComposingText.LAYER1);
-            if (isEnableL2Converter() || mEngineState.isSymbolList()) {
+                if (isEnableL2Converter() || mEngineState.isSymbolList()) {
                     if (mExactMatchMode) {
                         /* exact matching */
                         candidates = mConverter.predict(mComposingText, 0, cursor);
@@ -1181,7 +1242,7 @@
             }
         } else {
             if (mComposingText.getCursor(ComposingText.LAYER1)
-                    < mComposingText.size(ComposingText.LAYER1)) {
+                < mComposingText.size(ComposingText.LAYER1)) {
                 mComposingText.moveCursor(ComposingText.LAYER1, 1);
             }
         }
@@ -1196,8 +1257,8 @@
      * Handle a key event which is not right or left key when the
      * composing text is empty and some candidates are shown.
      *
-     * @param ev  	A key event
-     * @return		{@code true} if this consumes the event; {@code false} if not.
+     * @param ev        A key event
+     * @return          {@code true} if this consumes the event; {@code false} if not.
      */
     boolean processKeyEventNoInputCandidateShown(KeyEvent ev) {
         boolean ret = true;
@@ -1218,7 +1279,7 @@
             
         case KeyEvent.KEYCODE_DPAD_CENTER:
         case KeyEvent.KEYCODE_BACK:
-        	ret = true;
+            ret = true;
             break;
         
         default:
@@ -1249,7 +1310,7 @@
     /**
      * Update views and the display of the composing text.
      *
-     * @param layer  			 Display layer of the composing text
+     * @param layer                      Display layer of the composing text
      * @param updateCandidates  {@code true} to update the candidates view
      * @param updateEmptyText   {@code false} to update the composing text if it is not empty; {@code true} to update always.
      */
@@ -1360,7 +1421,7 @@
      * Commit the displaying composing text.
      *
      * @param learn  {@code true} to register the committed string to the learning dictionary.
-     * @return 		IME's status after commit
+     * @return          IME's status after commit
      */
     private int commitText(boolean learn) {
         if (isEnglishPrediction()) {
@@ -1398,6 +1459,11 @@
      * Commit all uncommitted words.
      */
     private void commitAllText() {
+        boolean hasSetInfo = false;
+        if (isEnableL2Converter()) {
+            setCommitInfo(mComposingText.toString(mTargetLayer).length());
+            hasSetInfo = true;
+        }
         if (mEngineState.isConvertState()) {
             commitConvertingText();
         } else {
@@ -1405,13 +1471,16 @@
                                      mComposingText.size(ComposingText.LAYER1));
             mStatus = commitText(true);
         }
+        if (hasSetInfo) {
+            checkCommitInfo();
+        }
     }
 
     /**
      * Commit a word.
      *
-     * @param word		A word to commit
-     * @return			IME's status after commit
+     * @param word              A word to commit
+     * @return                  IME's status after commit
      */
     private int commitText(WnnWord word) {
         if (mConverter != null) {
@@ -1427,6 +1496,8 @@
      */
     private void commitText(String str) {
         mInputConnection.commitText(str, (FIX_CURSOR_TEXT_END ? 1 : str.length()));
+        mPrevCommitText.append(str);
+        mCommitLength += str.length();
         mEnableAutoDeleteSpace = true;
         updateViewStatusForPrediction(false, false);
     }
@@ -1435,12 +1506,14 @@
      * Commit a string through {@link InputConnection}.
      *
      * @param string  A string to commit
-     * @return			IME's status after commit
+     * @return                  IME's status after commit
      */
     private int commitTextThroughInputConnection(String string) {
         int layer = mTargetLayer;
 
         mInputConnection.commitText(string, (FIX_CURSOR_TEXT_END ? 1 : string.length()));
+        mPrevCommitText.append(string);
+        
         int cursor = mComposingText.getCursor(layer);
         if (cursor > 0) {
             mComposingText.deleteStrSegment(layer, 0, mComposingText.getCursor(layer) - 1);
@@ -1475,7 +1548,7 @@
     /**
      * Returns whether it is English prediction mode or not.
      *
-     * @return 	{@code true} if it is English prediction mode; otherwise, {@code false}.
+     * @return  {@code true} if it is English prediction mode; otherwise, {@code false}.
      */
     private boolean isEnglishPrediction() {
         return (mEngineState.isEnglish() && isEnableL2Converter());
@@ -1495,11 +1568,13 @@
         case ENGINE_MODE_OPT_TYPE_QWERTY:
             state.keyboard = EngineState.KEYBOARD_QWERTY;
             updateEngineState(state);
+            clearCommitInfo();
             return;
 
         case ENGINE_MODE_OPT_TYPE_12KEY:
             state.keyboard = EngineState.KEYBOARD_12KEY;
             updateEngineState(state);
+            clearCommitInfo();
             return;
 
         case ENGINE_MODE_EISU_KANA:
@@ -1514,7 +1589,6 @@
 
         case ENGINE_MODE_SYMBOL:
             if (mEnableSymbolList && !mDirectInputMode) {
-                initializeScreen();
                 state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_SYMBOL;
                 updateEngineState(state);
                 updateViewStatusForPrediction(true, true);
@@ -1525,8 +1599,6 @@
             break;
         }
 
-        initializeScreen();
-
         state = new EngineState();
         state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
         updateEngineState(state);
@@ -1732,7 +1804,7 @@
             break;
         }
  
-        switch (target) {
+        switch (mode) {
         case OpenWnnEngineJAJP.DIC_LANG_JP:
         case OpenWnnEngineJAJP.DIC_LANG_EN:
             mPrevDictionarySet = mode;
@@ -1838,12 +1910,15 @@
                 commitText(new String(chars));
             } else {
                 if (isEnglishPrediction()) {
+                    setCommitInfo(mComposingText.toString(mTargetLayer).length());
                     commitText(true);
                     commitSpaceJustOne();
+                    checkCommitInfo();
                 } else {
                     startConvert(EngineState.CONVERT_TYPE_RENBUN);
                 }
             }
+            mEnableAutoDeleteSpace = false;
         } else {
             commitConvertingText();
 
@@ -1879,7 +1954,7 @@
     /**
      * Start consecutive clause conversion or EISU-KANA conversion mode.
      *
-     * @param convertType 		The conversion type({@code EngineState.CONVERT_TYPE_*})
+     * @param convertType               The conversion type({@code EngineState.CONVERT_TYPE_*})
      */
     private void startConvert(int convertType) {
         if (!isEnableL2Converter()) {
@@ -1938,7 +2013,9 @@
             if (m.matches()) {
                 if ((seq.charAt(0) == ' ') && mEnableAutoDeleteSpace) {
                     mInputConnection.deleteSurroundingText(2, 0);
-                    mInputConnection.commitText(seq.subSequence(1, 2), 1);
+                    CharSequence str = seq.subSequence(1, 2);
+                    mInputConnection.commitText(str, 1);
+                    mPrevCommitText.append(str);
                 }
 
                 mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
@@ -1967,8 +2044,8 @@
     /**
      * Get the shift key state from the editor.
      *
-     * @param editor	The editor
-     * @return 		State ID of the shift key (0:off, 1:on)
+     * @param editor    The editor
+     * @return          State ID of the shift key (0:off, 1:on)
      */
     protected int getShiftKeyState(EditorInfo editor) {
         return (getCurrentInputConnection().getCursorCapsMode(editor.inputType) == 0) ? 0 : 1;
@@ -2037,7 +2114,7 @@
      * Fits an editor info.
      * 
      * @param preferences  The preference data.
-     * @param info  		The editor info.
+     * @param info              The editor info.
      */
     private void fitInputType(SharedPreferences preference, EditorInfo info) {
         if (info.inputType == EditorInfo.TYPE_NULL) {
@@ -2108,12 +2185,12 @@
             mEnableEmoji = true;
         }
         if (mEnableEmoji) {
-        	mConverterEN.setFilter(null);
-        	mConverterJAJP.setFilter(null);
+            mConverterEN.setFilter(null);
+            mConverterJAJP.setFilter(null);
         } else {
-        	mFilter.setFilter(CandidateFilter.FILTER_EMOJI);
-        	mConverterEN.setFilter(mFilter);
-        	mConverterJAJP.setFilter(mFilter);
+            mFilter.setFilter(CandidateFilter.FILTER_EMOJI);
+            mConverterEN.setFilter(mFilter);
+            mConverterJAJP.setFilter(mFilter);
         }
 
         EngineState state = new EngineState();
@@ -2177,52 +2254,14 @@
     /**
      * Whether the tail of the string is alphabet or not.
      *
-     * @param  str  	The string
-     * @return 		{@code true} if the tail is alphabet; {@code false} if otherwise.
+     * @param  str      The string
+     * @return          {@code true} if the tail is alphabet; {@code false} if otherwise.
      */
     private boolean isAlphabetLast(String str) {
         Matcher m = ENGLISH_CHARACTER.matcher(str);
         return m.matches();
     }
 
-    /**
-     * Disable auto-delete-space.
-     * 
-     * @param ev  An event
-     */
-    private void disableAutoDeleteSpace(OpenWnnEvent ev) {
-        if (mEnableAutoDeleteSpace) {
-            if (!isEnglishPrediction()) {
-                mEnableAutoDeleteSpace = false;
-                return;
-            }
-
-            String input = null;
-            if (ev.code == OpenWnnEvent.TOGGLE_CHAR) {
-                input = ev.toggleTable[0];
-            }
-            
-            try {
-                if ((ev.code == OpenWnnEvent.INPUT_KEY) || (ev.code == OpenWnnEvent.INPUT_SOFT_KEY)) {
-                    input = new String(Character.toChars(ev.keyEvent.getUnicodeChar(0)));
-                } else if (ev.code == OpenWnnEvent.INPUT_CHAR) {
-                	input = new String(ev.chars);
-                }
-            } catch (Exception e) {
-                input = null;
-            }
-            
-            if (input != null) {
-                Matcher m = mEnglishAutoCommitDelimiter.matcher(input);
-                if (!m.matches()) {
-                    mEnableAutoDeleteSpace = false;
-                }
-            } else {
-                mEnableAutoDeleteSpace = false;
-            }
-        }
-    }
-
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onFinishInput */
     @Override public void onFinishInput() {
         if (mInputConnection != null) {
@@ -2248,13 +2287,13 @@
         return true;
     }
 
-	/**
-	 * Handling KeyEvent(KEYUP)
-	 * <br>
-	 * This method is called from {@link #onEvent()}.
-	 *
-	 * @param ev   An up key event
-	 */
+    /**
+     * Handling KeyEvent(KEYUP)
+     * <br>
+     * This method is called from {@link #onEvent()}.
+     *
+     * @param ev   An up key event
+     */
     private void onKeyUpEvent(KeyEvent ev) {
         int key = ev.getKeyCode();
         if(!mShiftPressing){
@@ -2273,6 +2312,42 @@
         }
     }
 
+    /**
+     * Remember the commit test's info.
+     * @param length  length of commit text
+     */
+    private void setCommitInfo(int length) {
+        if (length == 0) {
+            return;
+        }
+        mCommitLength = length;
+        mCommitStartCursor = mLastSelectionEnd - mComposingText.size(mTargetLayer);
+        mPrevCommitText.delete(0, mPrevCommitText.length());
+    }
+    
+    /**
+     * Clear the commit text's info.
+     */
+    private void clearCommitInfo() {
+        mCommitLength = 0;
+        mCommitStartCursor = 0;
+    }
+
+    /**
+     * Verify the commit text.
+     */
+    private void checkCommitInfo() {
+        if (mCommitLength == 0) {
+            return;
+        }
+
+        int composingLength = mComposingText.toString(mTargetLayer).length();
+        CharSequence seq = mInputConnection.getTextBeforeCursor(mCommitLength + composingLength, 0);
+        seq = seq.subSequence(0, seq.length() - composingLength);
+        if (!seq.equals(mPrevCommitText.toString())) {
+            clearCommitInfo();
+    	}
+    }
 }
 
 
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnnZHCN.java b/src/jp/co/omronsoft/openwnn/OpenWnnZHCN.java
index 7295a87..043730c 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnnZHCN.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnnZHCN.java
@@ -252,7 +252,7 @@
     /** pre-converter (for symbols) */
     private LetterConverterZH mPreConverterSymbols;
     
-   /** Conversion Engine's state */
+    /** Conversion Engine's state */
     private EngineState mEngineState = new EngineState();
 
     /** Whether learning function is active of not. */
@@ -297,6 +297,18 @@
     /** Regular expression pattern for English separators */
     private  Pattern mEnglishAutoCommitDelimiter = null;
 
+    /** Lenght of committed text */
+    private int mCommitLength = 0;
+
+    /** Last cursor position */
+    private int mLastSelectionEnd = 0;
+
+    /** Cursor position before committing text */
+    private int mCommitStartCursor = 0;
+
+    /** Previous committed text */
+    private StringBuffer mPrevCommitText = null;
+
     /** List of words in the user dictionary */
     private WnnWord[] mUserDictionaryWords = null;
 
@@ -304,13 +316,13 @@
     private int mHardShift;
 
     /** SHIFT key state (pressing) */
-	private boolean mShiftPressing;
+    private boolean mShiftPressing;
 
     /** Alt lock status of the Hardware keyboard */
     private int mHardAlt;
 
     /** ALT key state (pressing) */
-	private boolean mAltPressing;
+    private boolean mAltPressing;
     
     /** Shift lock toggle definition */
     private static final int[] mShiftKeyToggle = {0, MetaKeyKeyListener.META_SHIFT_ON, MetaKeyKeyListener.META_CAP_LOCKED};
@@ -335,8 +347,8 @@
         mInputViewManager  = new DefaultSoftKeyboardZH();
 
         mConverter = mConverterZHCN = new OpenWnnEngineZHCN(
-        		"libWnnZHCNDic.so",
-                "/data/data/jp.co.omronsoft.openwnn/writableZHCN.dic");
+                                                            "libWnnZHCNDic.so",
+                                                            "/data/data/jp.co.omronsoft.openwnn/writableZHCN.dic");
 
         mConverterEN = new OpenWnnEngineEN("/data/data/jp.co.omronsoft.openwnn/writableEN.dic");
         mPreConverter = mPreConverterSymbols = new LetterConverterZH();
@@ -346,6 +358,7 @@
         mAutoHideMode = false;
 
         mDelayUpdateHandler = new Handler();
+        mPrevCommitText = new StringBuffer();
     }
 
     /**
@@ -371,11 +384,11 @@
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onCreateInputView */
     @Override public View onCreateInputView() {
-    	int hiddenState = getResources().getConfiguration().hardKeyboardHidden;
-    	boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
-    	((DefaultSoftKeyboardZH) mInputViewManager).setHardKeyboardHidden(hidden);
-    	((TextCandidatesViewManager)
-    			mCandidatesViewManager).setHardKeyboardHidden(hidden);
+        int hiddenState = getResources().getConfiguration().hardKeyboardHidden;
+        boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
+        ((DefaultSoftKeyboardZH) mInputViewManager).setHardKeyboardHidden(hidden);
+        ((TextCandidatesViewManager)
+         mCandidatesViewManager).setHardKeyboardHidden(hidden);
 
         return super.onCreateInputView();
     }
@@ -387,6 +400,8 @@
         state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
         updateEngineState(state);
 
+        clearCommitInfo();
+
         if (mDirectInputMode) {
             DefaultSoftKeyboardZH inputManager = ((DefaultSoftKeyboardZH)mInputViewManager);
             inputManager.setDefaultKeyboard();
@@ -412,40 +427,50 @@
         fitInputType(pref, attribute);
 
         ((TextCandidatesViewManager)mCandidatesViewManager).setAutoHide(true);
+
+        if (isEnableL2Converter()) {
+            mEnableAutoDeleteSpace = false;
+            mConverter.breakSequence();
+        }
     }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#hideWindow */
     @Override public void hideWindow() {
         mComposingText.clear();
         mInputViewManager.onUpdateState(this);
+        clearCommitInfo();
         mInputViewManager.closing();
         super.hideWindow();
     }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onComputeInsets */
     @Override public void onComputeInsets(InputMethodService.Insets outInsets) {
-        if (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL) {
-            outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_FRAME;
-        } else {
-            super.onComputeInsets(outInsets);
-        }
-    }
-
-    /** @see jp.co.omronsoft.openwnn.OpenWnn#isFullscreenMode */
-    @Override public boolean isFullscreenMode() {
-        boolean ret;
-        if (mInputViewManager == null) {
-            ret = (mCandidatesViewManager.getViewType() == CandidatesViewManager.VIEW_TYPE_FULL);
-        } else {
-            ret = false;
-        }
-        return ret;
+        /* use default value. means;
+         * outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_VISIBLE;
+         */
     }
 
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onUpdateSelection */
     @Override public void onUpdateSelection(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd) {
+
+        mLastSelectionEnd = newSelEnd;
+
         if (mComposingText.size(ComposingText.LAYER1) != 0) {
             updateViewStatus(mTargetLayer, false, true);
+        } else {
+            int commitEnd = mCommitStartCursor + mCommitLength;
+            if ((mCommitLength != 0)
+                && (commitEnd != newSelEnd)
+                && ((newSelEnd < oldSelEnd) || (commitEnd < newSelEnd))) {
+
+                if (isEnableL2Converter()) {
+                    mEnableAutoDeleteSpace = false;
+                    mConverter.breakSequence();
+                }
+
+                clearCommitInfo();
+                initializeScreen();
+            }
         }
     }
 
@@ -470,8 +495,8 @@
                 int hiddenState = newConfig.hardKeyboardHidden;
                 boolean hidden = (hiddenState == Configuration.HARDKEYBOARDHIDDEN_YES);
                 ((DefaultSoftKeyboardZH) mInputViewManager).setHardKeyboardHidden(hidden);
-                    ((TextCandidatesViewManager)
-                     mCandidatesViewManager).setHardKeyboardHidden(hidden);
+                ((TextCandidatesViewManager)
+                 mCandidatesViewManager).setHardKeyboardHidden(hidden);
             }
         } catch (Exception ex) {
             /* do nothing if an error occurs. */
@@ -527,7 +552,7 @@
         case OpenWnnEvent.CHANGE_MODE:
             changeEngineMode(ev.mode);
             if (ev.mode != ENGINE_MODE_SYMBOL) {
-            	initializeScreen();
+                initializeScreen();
                 state = new EngineState();
                 state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
                 updateEngineState(state);
@@ -546,12 +571,12 @@
             return true;
 
         case OpenWnnEvent.CHANGE_INPUT_VIEW:
-        	setInputView(onCreateInputView());
+            setInputView(onCreateInputView());
             return true;
 
         case OpenWnnEvent.CANDIDATE_VIEW_TOUCH:
             boolean ret;
-                ret = ((TextCandidatesViewManager)mCandidatesViewManager).onTouchSync();
+            ret = ((TextCandidatesViewManager)mCandidatesViewManager).onTouchSync();
             return ret;
 
         default:
@@ -575,27 +600,31 @@
             return false;
         }
         
-        /* notice a break the sequence of input to the converter */
-        View candidateView = mCandidatesViewManager.getCurrentView();
-        if ((candidateView != null) && !candidateView.isShown()
-            && (mComposingText.size(0) == 0)) {
-            if (isEnableL2Converter()) {
-                disableAutoDeleteSpace(ev);
-                mConverter.breakSequence();
-            }
-        }
+        if (!((ev.code == OpenWnnEvent.COMMIT_COMPOSING_TEXT)
+              || ((keyEvent != null)
+                  && ((keyCode == KeyEvent.KEYCODE_SHIFT_LEFT)
+                      || (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)
+                      || (keyCode == KeyEvent.KEYCODE_ALT_LEFT)
+                      || (keyCode == KeyEvent.KEYCODE_ALT_RIGHT)
+                      || (keyEvent.isAltPressed() && (keyCode == KeyEvent.KEYCODE_SPACE)))))) {
+
+            clearCommitInfo();
+        }       
 
         /* change back the dictionary if necessary */
         if (!((ev.code == OpenWnnEvent.SELECT_CANDIDATE)
               || (ev.code == OpenWnnEvent.LIST_CANDIDATES_NORMAL)
-        		|| (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL)
-        		|| ((keyEvent != null)
-        				&& ((keyCode == KeyEvent.KEYCODE_ALT_LEFT)
-        						||(keyCode == KeyEvent.KEYCODE_ALT_RIGHT)
-        						||(keyEvent.isAltPressed() && (keyCode == KeyEvent.KEYCODE_SPACE)))))) {
-        	state = new EngineState();
-        	state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
-        	updateEngineState(state);
+              || (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL)
+              || ((keyEvent != null)
+                  && ((keyCode == KeyEvent.KEYCODE_SHIFT_LEFT)
+                      ||(keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)
+                      ||(keyCode == KeyEvent.KEYCODE_ALT_LEFT)
+                      ||(keyCode == KeyEvent.KEYCODE_ALT_RIGHT)
+                      ||(keyEvent.isAltPressed() && (keyCode == KeyEvent.KEYCODE_SPACE)))))) {
+
+            state = new EngineState();
+            state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
+            updateEngineState(state);
         }
 
         if (ev.code == OpenWnnEvent.LIST_CANDIDATES_FULL) {
@@ -696,16 +725,28 @@
             ret = processKeyEvent(keyEvent);
             if (!ret) {
                 mInputConnection.sendKeyEvent(keyEvent);
-				mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent.getKeyCode()));
+                mInputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent.getKeyCode()));
                 ret = true;
             }
             break;
 
         case OpenWnnEvent.SELECT_CANDIDATE:
+            boolean hasSetInfo = false;
+            if (isEnableL2Converter()) {
+                setCommitInfo(ev.word.candidate.length());
+                hasSetInfo = true;
+            }
             if (isEnglishPrediction()) {
                 mComposingText.clear();
             }
             mStatus = commitText(ev.word);
+            if (hasSetInfo) {
+                checkCommitInfo();
+            }
+
+            if (mEngineState.isSymbolList()) {
+                mEnableAutoDeleteSpace = false;
+            }
             break;
 
         case OpenWnnEvent.CONVERT:           
@@ -745,8 +786,8 @@
     /**
      * Create a {@link StrSegment} from a character code.
      * <br>
-     * @param charCode		 A character code
-     * @return 			{@link StrSegment} created; {@code null} if an error occurs.
+     * @param charCode           A character code
+     * @return                  {@link StrSegment} created; {@code null} if an error occurs.
      */
     private StrSegment createStrSegment(int charCode) {
         if (charCode == 0) {
@@ -758,8 +799,8 @@
     /**
      * Key event handler.
      *
-     * @param ev  	A key event
-     * @return 	{@code true} if the event is handled in this method.
+     * @param ev        A key event
+     * @return  {@code true} if the event is handled in this method.
      */
     private boolean processKeyEvent(KeyEvent ev) {
         int key = ev.getKeyCode();
@@ -910,7 +951,7 @@
                 return true;
 
             case KeyEvent.KEYCODE_DPAD_LEFT:
-            	if (!isEnableL2Converter()) {
+                if (!isEnableL2Converter()) {
                     commitText(false);
                     return false;
                 } else {
@@ -919,7 +960,7 @@
                 }
 
             case KeyEvent.KEYCODE_DPAD_RIGHT:
-            	if (!isEnableL2Converter()) {
+                if (!isEnableL2Converter()) {
                     commitText(false);
                     return false;
                 } else {
@@ -929,7 +970,24 @@
 
             case KeyEvent.KEYCODE_DPAD_CENTER:
             case KeyEvent.KEYCODE_ENTER:
+                boolean hasSetInfo = false;
+            	if (isEnableL2Converter()) {
+                    if (isEnglishPrediction()) {
+                        setCommitInfo(mComposingText.toString(mTargetLayer).length());
+                    } else {
+                        int layer = mTargetLayer;
+                        int cursor = mComposingText.getCursor(layer);
+                        if (0 < cursor) {
+                            String tmp = mComposingText.toString(layer, 0, cursor - 1);
+                            setCommitInfo(tmp.length());
+                        }
+                    }
+                    hasSetInfo = true;
+                }
                 mStatus = commitText(true);
+            	if (hasSetInfo) {
+                    checkCommitInfo();
+                }
                 return true;
 
             case KeyEvent.KEYCODE_CALL:
@@ -991,13 +1049,11 @@
             mHardShift = 0;
             updateMetaKeyStateDisplay();
             if (mEngineState.isEnglish()) {
-            
-            	((DefaultSoftKeyboardZH) mInputViewManager).changeKeyMode(DefaultSoftKeyboard.KEYMODE_CN_PINYIN);
-            	mConverter = mConverterZHCN;
+                ((DefaultSoftKeyboardZH) mInputViewManager).changeKeyMode(DefaultSoftKeyboard.KEYMODE_CN_PINYIN);
+                mConverter = mConverterZHCN;
             } else {
-            
-            	((DefaultSoftKeyboardZH) mInputViewManager).changeKeyMode(DefaultSoftKeyboard.KEYMODE_CN_ALPHABET);
-            	mConverter = mConverterEN;
+                ((DefaultSoftKeyboardZH) mInputViewManager).changeKeyMode(DefaultSoftKeyboard.KEYMODE_CN_ALPHABET);
+                mConverter = mConverterEN;
             }
             mCandidatesViewManager.clearCandidates();
 
@@ -1015,9 +1071,12 @@
                 commitText(" ");
                 mCandidatesViewManager.clearCandidates();
             } else {
+                setCommitInfo(mComposingText.toString(mTargetLayer).length());
                 commitText(true);
                 commitSpaceJustOne();
+                checkCommitInfo();
             }
+            mEnableAutoDeleteSpace = false;
 
         } else {
             /* start consecutive clause conversion if Chinese mode */
@@ -1033,8 +1092,8 @@
     /**
      * Handle the character code from the hardware keyboard except the space key.
      *
-     * @param str  		The input character
-     * @param caps 		The state of Caps.
+     * @param str               The input character
+     * @param caps              The state of Caps.
      */
     private void processHardwareKeyboardInputChar(StrSegment str, int caps) {
         if (isEnableL2Converter()) {
@@ -1080,7 +1139,7 @@
             public void run() {
                 int candidates = 0;
                 int cursor = mComposingText.getCursor(ComposingText.LAYER1);
-            if (isEnableL2Converter() || mEngineState.isSymbolList()) {
+                if (isEnableL2Converter() || mEngineState.isSymbolList()) {
                     if (mExactMatchMode) {
                         /* exact matching */
                         candidates = mConverter.predict(mComposingText, 0, cursor);
@@ -1140,7 +1199,7 @@
             }
         } else {
             if (mComposingText.getCursor(ComposingText.LAYER1)
-                    < mComposingText.size(ComposingText.LAYER1)) {
+                < mComposingText.size(ComposingText.LAYER1)) {
                 mComposingText.moveCursor(ComposingText.LAYER1, 1);
             }
         }
@@ -1155,8 +1214,8 @@
      * Handle a key event which is not right or left key when the
      * composing text is empty and some candidates are shown.
      *
-     * @param ev  	A key event
-     * @return		{@code true} if this consumes the event; {@code false} if not.
+     * @param ev        A key event
+     * @return          {@code true} if this consumes the event; {@code false} if not.
      */
     boolean processKeyEventNoInputCandidateShown(KeyEvent ev) {
         boolean ret = true;
@@ -1177,7 +1236,7 @@
             
         case KeyEvent.KEYCODE_DPAD_CENTER:
         case KeyEvent.KEYCODE_BACK:
-        	ret = true;
+            ret = true;
             break;
         
         default:
@@ -1208,7 +1267,7 @@
     /**
      * Update views and the display of the composing text.
      *
-     * @param layer  			 Display layer of the composing text
+     * @param layer                      Display layer of the composing text
      * @param updateCandidates  {@code true} to update the candidates view
      * @param updateEmptyText   {@code false} to update the composing text if it is not empty; {@code true} to update always.
      */
@@ -1314,7 +1373,7 @@
      * Commit the displaying composing text.
      *
      * @param learn  {@code true} to register the committed string to the learning dictionary.
-     * @return 		IME's status after commit
+     * @return          IME's status after commit
      */
     private int commitText(boolean learn) {
         if (isEnglishPrediction()) {
@@ -1352,6 +1411,11 @@
      * Commit all uncommitted words.
      */
     private void commitAllText() {
+        boolean hasSetInfo = false;
+        if (isEnableL2Converter()) {
+            setCommitInfo(mComposingText.toString(mTargetLayer).length());
+            hasSetInfo = true;
+        }
         if (mEngineState.isConvertState()) {
             commitConvertingText();
         } else {
@@ -1359,13 +1423,16 @@
                                      mComposingText.size(ComposingText.LAYER1));
             mStatus = commitText(true);
         }
+        if (hasSetInfo) {
+            checkCommitInfo();
+        }
     }
 
     /**
      * Commit a word.
      *
-     * @param word		A word to commit
-     * @return			IME's status after commit
+     * @param word              A word to commit
+     * @return                  IME's status after commit
      */
     private int commitText(WnnWord word) {
         if (mConverter != null) {
@@ -1381,6 +1448,8 @@
      */
     private void commitText(String str) {
         mInputConnection.commitText(str, (FIX_CURSOR_TEXT_END ? 1 : str.length()));
+        mPrevCommitText.append(str);
+        mCommitLength += str.length();
         mEnableAutoDeleteSpace = true;
         updateViewStatusForPrediction(false, false);
     }
@@ -1388,13 +1457,15 @@
     /**
      * Commit a string through {@link InputConnection}.
      *
-     * @param string	A string to commit
-     * @return			IME's status after commit
+     * @param string    A string to commit
+     * @return                  IME's status after commit
      */
     private int commitTextThroughInputConnection(String string) {
         int layer = mTargetLayer;
 
         mInputConnection.commitText(string, (FIX_CURSOR_TEXT_END ? 1 : string.length()));
+        mPrevCommitText.append(string);
+        
         int cursor = mComposingText.getCursor(layer);
         if (cursor > 0) {
             mComposingText.deleteStrSegment(layer, 0, mComposingText.getCursor(layer) - 1);
@@ -1429,13 +1500,14 @@
     /**
      * Commit a string through {@link InputConnection}.
      *
-     * @param word		A word to commit
-     * @return			IME's status after commit
+     * @param word              A word to commit
+     * @return                  IME's status after commit
      */
     private int commitTextThroughInputConnection(WnnWord word) {
         String string = word.candidate;
         int layer = mTargetLayer;
         mInputConnection.commitText(string, (FIX_CURSOR_TEXT_END ? 1 : string.length()));
+        mPrevCommitText.append(string);
 
         int cursor = word.stroke.length();
         int position = mComposingText.getCursor(layer);
@@ -1477,7 +1549,7 @@
     /**
      * Returns whether it is English prediction mode or not.
      *
-     * @return 	{@code true} if it is English prediction mode; otherwise, {@code false}.
+     * @return  {@code true} if it is English prediction mode; otherwise, {@code false}.
      */
     private boolean isEnglishPrediction() {
         return (mEngineState.isEnglish() && isEnableL2Converter());
@@ -1497,16 +1569,17 @@
         case ENGINE_MODE_OPT_TYPE_QWERTY:
             state.keyboard = EngineState.KEYBOARD_QWERTY;
             updateEngineState(state);
+            clearCommitInfo();
             return;
 
         case ENGINE_MODE_OPT_TYPE_12KEY:
             state.keyboard = EngineState.KEYBOARD_12KEY;
             updateEngineState(state);
+            clearCommitInfo();
             return;
 
         case ENGINE_MODE_SYMBOL:
             if (mEnableSymbolList && !mDirectInputMode) {
-                initializeScreen();
                 state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_SYMBOL;
                 updateEngineState(state);
                 updateViewStatusForPrediction(true, true);
@@ -1517,8 +1590,6 @@
             break;
         }
 
-        initializeScreen();
-
         state = new EngineState();
         state.temporaryMode = EngineState.TEMPORARY_DICTIONARY_MODE_NONE;
         updateEngineState(state);
@@ -1711,7 +1782,7 @@
             break;
         }
  
-        switch (target) {
+        switch (mode) {
         case OpenWnnEngineZHCN.DIC_LANG_ZHCN:
         case OpenWnnEngineZHCN.DIC_LANG_EN:
             mPrevDictionarySet = mode;
@@ -1809,19 +1880,22 @@
                 commitText(new String(chars));
             } else {
                 if (isEnglishPrediction()) {
+                    setCommitInfo(mComposingText.toString(mTargetLayer).length());
                     commitText(true);
                     commitSpaceJustOne();
+                    checkCommitInfo();
                 } else {
                     startConvert(EngineState.CONVERT_TYPE_RENBUN);
                 }
             }
+            mEnableAutoDeleteSpace = false;
         } else {
             commitConvertingText();
 
             /* Auto-commit a word if it is English and Qwerty mode */
             boolean commit = false;
             if (isEnglishPrediction()
-                    && (mEngineState.keyboard == EngineState.KEYBOARD_QWERTY)) {
+                && (mEngineState.keyboard == EngineState.KEYBOARD_QWERTY)) {
 
                 Matcher m = mEnglishAutoCommitDelimiter.matcher(new String(chars));
                 if (m.matches()) {
@@ -1850,7 +1924,7 @@
     /**
      * Start consecutive clause conversion or EISU-KANA conversion mode.
      *
-     * @param convertType 		The conversion type({@code EngineState.CONVERT_TYPE_*})
+     * @param convertType               The conversion type({@code EngineState.CONVERT_TYPE_*})
      */
     private void startConvert(int convertType) {
         if (!isEnableL2Converter()) {
@@ -1902,7 +1976,9 @@
             if (m.matches()) {
                 if ((seq.charAt(0) == ' ') && mEnableAutoDeleteSpace) {
                     mInputConnection.deleteSurroundingText(2, 0);
-                    mInputConnection.commitText(seq.subSequence(1, 2), 1);
+                    CharSequence str = seq.subSequence(1, 2);
+                    mInputConnection.commitText(str, 1);
+                    mPrevCommitText.append(str);
                 }
 
                 mDelayUpdateHandler.removeCallbacks(updatePredictionRunnable);
@@ -1931,8 +2007,8 @@
     /**
      * Get the shift key state from the editor.
      *
-     * @param editor	The editor
-     * @return 		State ID of the shift key (0:off, 1:on)
+     * @param editor    The editor
+     * @return          State ID of the shift key (0:off, 1:on)
      */
     protected int getShiftKeyState(EditorInfo editor) {
         return (getCurrentInputConnection().getCursorCapsMode(editor.inputType) == 0) ? 0 : 1;
@@ -2001,7 +2077,7 @@
      * Fits an editor info.
      * 
      * @param preferences  The preference data.
-     * @param info  		The editor info.
+     * @param info              The editor info.
      */
     private void fitInputType(SharedPreferences preference, EditorInfo info) {
         if (info.inputType == EditorInfo.TYPE_NULL) {
@@ -2072,12 +2148,12 @@
             mEnableEmoji = true;
         }
         if (mEnableEmoji) {
-        	mConverterEN.setFilter(null);
-        	mConverterZHCN.setFilter(null);
+            mConverterEN.setFilter(null);
+            mConverterZHCN.setFilter(null);
         } else {
-        	mFilter.setFilter(CandidateFilter.FILTER_EMOJI);
-        	mConverterEN.setFilter(mFilter);
-        	mConverterZHCN.setFilter(mFilter);
+            mFilter.setFilter(CandidateFilter.FILTER_EMOJI);
+            mConverterEN.setFilter(mFilter);
+            mConverterZHCN.setFilter(mFilter);
         }
 
         EngineState state = new EngineState();
@@ -2141,52 +2217,14 @@
     /**
      * Whether the tail of the string is alphabet or not.
      *
-     * @param  str  	The string
-     * @return 		{@code true} if the tail is alphabet; {@code false} if otherwise.
+     * @param  str      The string
+     * @return          {@code true} if the tail is alphabet; {@code false} if otherwise.
      */
     private boolean isAlphabetLast(String str) {
         Matcher m = ENGLISH_CHARACTER.matcher(str);
         return m.matches();
     }
 
-    /**
-     * Disable auto-delete-space.
-     * 
-     * @param ev  An event
-     */
-    private void disableAutoDeleteSpace(OpenWnnEvent ev) {
-        if (mEnableAutoDeleteSpace) {
-            if (!isEnglishPrediction()) {
-                mEnableAutoDeleteSpace = false;
-                return;
-            }
-
-            String input = null;
-            if (ev.code == OpenWnnEvent.TOGGLE_CHAR) {
-                input = ev.toggleTable[0];
-            }
-            
-            try {
-                if ((ev.code == OpenWnnEvent.INPUT_KEY) || (ev.code == OpenWnnEvent.INPUT_SOFT_KEY)) {
-                    input = new String(Character.toChars(ev.keyEvent.getUnicodeChar(0)));
-                } else if (ev.code == OpenWnnEvent.INPUT_CHAR) {
-                	input = new String(ev.chars);
-                }
-            } catch (Exception e) {
-                input = null;
-            }
-            
-            if (input != null) {
-                Matcher m = mEnglishAutoCommitDelimiter.matcher(input);
-                if (!m.matches()) {
-                    mEnableAutoDeleteSpace = false;
-                }
-            } else {
-                mEnableAutoDeleteSpace = false;
-            }
-        }
-    }
-
     /** @see jp.co.omronsoft.openwnn.OpenWnn#onFinishInput */
     @Override public void onFinishInput() {
         if (mInputConnection != null) {
@@ -2212,13 +2250,13 @@
         return true;
     }
 
-	/**
-	 * Handling KeyEvent(KEYUP)
-	 * <br>
-	 * This method is called from {@link #onEvent()}.
-	 *
-	 * @param ev   An up key event
-	 */
+    /**
+     * Handling KeyEvent(KEYUP)
+     * <br>
+     * This method is called from {@link #onEvent()}.
+     *
+     * @param ev   An up key event
+     */
     private void onKeyUpEvent(KeyEvent ev) {
         int key = ev.getKeyCode();
         if(!mShiftPressing){
@@ -2237,6 +2275,41 @@
         }
     }
 
+    /**
+     * Remember the commit test's info.
+     * @param length  length of commit text
+     */
+    private void setCommitInfo(int length) {
+        if (length == 0) {
+            return;
+        }
+        mCommitLength = length;
+        mCommitStartCursor = mLastSelectionEnd - mComposingText.size(mTargetLayer);
+    }
+    
+    /**
+     * Clear the commit text's info.
+     */
+    private void clearCommitInfo() {
+        mCommitLength = 0;
+        mCommitStartCursor = 0;
+    }
+
+    /**
+     * Verify the commit text.
+     */
+    private void checkCommitInfo() {
+        if (mCommitLength == 0) {
+            return;
+        }
+
+        int composingLength = mComposingText.toString(mTargetLayer).length();
+        CharSequence seq = mInputConnection.getTextBeforeCursor(mCommitLength + composingLength, 0);
+        seq = seq.subSequence(0, seq.length() - composingLength);
+        if (!seq.equals(mPrevCommitText.toString())) {
+            clearCommitInfo();
+    	}
+    }
 }
 
 
diff --git a/src/jp/co/omronsoft/openwnn/SymbolList.java b/src/jp/co/omronsoft/openwnn/SymbolList.java
index 625c414..7eb6a6f 100644
--- a/src/jp/co/omronsoft/openwnn/SymbolList.java
+++ b/src/jp/co/omronsoft/openwnn/SymbolList.java
@@ -56,12 +56,12 @@
     public static final String SYMBOL_CHINESE = "c1";
 
     /** Key string to get EMOJI symbol list for Japanese */
-	public static final String SYMBOL_JAPANESE_EMOJI = "j_emoji";
+    public static final String SYMBOL_JAPANESE_EMOJI = "j_emoji";
     /** Key string to get face mark list for Japanese */
-	public static final String SYMBOL_JAPANESE_FACE  = "j_face";
+    public static final String SYMBOL_JAPANESE_FACE  = "j_face";
 
     /** The name of XML tag key */
-	private static final String XMLTAG_KEY = "string";
+    private static final String XMLTAG_KEY = "string";
 
     /*
      * DEFINITION OF VARIABLES
@@ -76,7 +76,7 @@
     private ArrayList<String> mCurrentList;
 
     /** Iterator for getting symbols from the list */
-	private Iterator<String> mCurrentListIterator;
+    private Iterator<String> mCurrentListIterator;
 
     /*
      * DEFINITION OF METHODS
@@ -116,14 +116,14 @@
 
         mCurrentList = null;
     }
-	
+    
     /**
      * Get a attribute value from a XML resource.
      *
-     * @param xrp	XML resource
-     * @param name	The attribute name
+     * @param xrp   XML resource
+     * @param name  The attribute name
      *
-     * @return 	The value of the attribute
+     * @return  The value of the attribute
      */
     private String getXmlAttribute(XmlResourceParser xrp, String name) {
         int resId = xrp.getAttributeResourceValue(null, name, 0);
@@ -137,10 +137,10 @@
     /**
      * Load a symbols list from XML resource.
      *
-     * @param id  	XML resource ID
-     * @return		The symbols list
+     * @param id    XML resource ID
+     * @return      The symbols list
      */
-	private ArrayList<String> getXmlfile(int id) {
+    private ArrayList<String> getXmlfile(int id) {
         ArrayList<String> list = new ArrayList<String>();
 
         XmlResourceParser xrp = mWnn.getResources().getXml(id);
@@ -183,10 +183,10 @@
      **********************************************************************/
     /** @see jp.co.omronsoft.openwnn.WnnEngine#init */
     public void init() {}
-	
+    
     /** @see jp.co.omronsoft.openwnn.WnnEngine#close */
     public void close() {}
-	
+    
     /** @see jp.co.omronsoft.openwnn.WnnEngine#predict */
     public int predict(ComposingText text, int minLen, int maxLen) {
         /* ignore if there is no list for the type */
@@ -199,7 +199,7 @@
         mCurrentListIterator = mCurrentList.iterator();
         return 1;
     }
-	
+    
     /** @see jp.co.omronsoft.openwnn.WnnEngine#convert */
     public int convert(ComposingText text) {
         return 0;
@@ -210,7 +210,7 @@
 
     /** @see jp.co.omronsoft.openwnn.WnnEngine#searchWords */
     public int searchWords(WnnWord word) {return 0;}
-	
+    
     /** @see jp.co.omronsoft.openwnn.WnnEngine#getNextCandidate */
     public WnnWord getNextCandidate() {
         if (mCurrentListIterator == null || !mCurrentListIterator.hasNext()) {
@@ -220,16 +220,16 @@
         WnnWord word = new WnnWord(str, str);
         return word;
     }
-	
+    
     /** @see jp.co.omronsoft.openwnn.WnnEngine#learn */
     public boolean learn(WnnWord word) {return false;}
-	
+    
     /** @see jp.co.omronsoft.openwnn.WnnEngine#addWord */
     public int addWord(WnnWord word) {return 0;}
 
     /** @see jp.co.omronsoft.openwnn.WnnEngine#deleteWord */
     public boolean deleteWord(WnnWord word) {return false;}
-	
+    
     /** @see jp.co.omronsoft.openwnn.WnnEngine#setPreferences */
     public void setPreferences(SharedPreferences pref) {}
 
diff --git a/src/jp/co/omronsoft/openwnn/TextCandidatesViewManager.java b/src/jp/co/omronsoft/openwnn/TextCandidatesViewManager.java
index 8de4669..83bec26 100644
--- a/src/jp/co/omronsoft/openwnn/TextCandidatesViewManager.java
+++ b/src/jp/co/omronsoft/openwnn/TextCandidatesViewManager.java
@@ -174,12 +174,13 @@
         this.mEndPositionArray = new ArrayList<Integer>();
         this.mPositionToWordIndexArray = new ArrayList<Integer>();
         this.mWnnWordArray = new ArrayList<WnnWord>();
+        this.mAutoHideMode = true;
     }
 
     /**
      * Set auto-hide mode.
-     * @param hide		{@code true} if the view will hidden when no candidate exists;
-     *					{@code false} if the view is always shown.
+     * @param hide      {@code true} if the view will hidden when no candidate exists;
+     *                  {@code false} if the view is always shown.
      */
     public void setAutoHide(boolean hide) {
         mAutoHideMode = hide;
@@ -208,7 +209,7 @@
         mViewBodyText.setGravity(Gravity.TOP);
         
         mReadMoreText = (TextView)mViewBody.findViewById(R.id.read_more_text);
-    	mReadMoreText.setText(mWnn.getResources().getString(R.string.read_more));
+        mReadMoreText.setText(mWnn.getResources().getString(R.string.read_more));
         mReadMoreText.setTextSize(24.0f);
 
         mPortrait = (height > 450)? true : false;
@@ -231,38 +232,47 @@
         if (readMore) {
             displayCandidates(this.mConverter, false, -1);
         } else { 
-        	if (type == CandidatesViewManager.VIEW_TYPE_NORMAL) {
+            if (type == CandidatesViewManager.VIEW_TYPE_NORMAL) {
                 mIsFullView = false;
-        	    if (mDisplayEndOffset > 0) {
+                if (mDisplayEndOffset > 0) {
                     int maxLine = getMaxLine();
                     displayCandidates(this.mConverter, false, maxLine);
-       	        } else {
-       	        	setReadMore();
-       	        }
-       	    }
+                } else {
+                    setReadMore();
+                }
+            } else {
+                if (mViewBody.isShown()) {
+                	mWnn.setCandidatesViewShown(false);
+                }
+            }
         }
     }
 
     /**
      * Set the view layout
      *
-     * @param type		View type
-     * @return			{@code true} if display is updated; {@code false} if otherwise
+     * @param type      View type
+     * @return          {@code true} if display is updated; {@code false} if otherwise
      */
     private boolean setViewLayout(int type) {
         mViewType = type;
         boolean readMore = false;
         int height;
         if (type == CandidatesViewManager.VIEW_TYPE_CLOSE) {
-            height = 1;
-        } else if (mPortrait) {
+        	mViewBody.setVisibility(View.GONE);
+            return false;
+        }
+        
+        mViewBody.setVisibility(View.VISIBLE);
+
+        if (mPortrait) {
             if (type == CandidatesViewManager.VIEW_TYPE_NORMAL) {
                 mViewBodyScroll.scrollTo(0, 0);
                 height = LINE_HEIGHT * LINE_NUM_PORTRAIT;
                 mViewBodyText.setMaxLines(LINE_NUM_PORTRAIT);
                 mViewBodyText.setLines(LINE_NUM_PORTRAIT);
                 if (mWordCount > 1) {
-                    int displayEndCount = (mWordCountInNormalView != -1)	? mWordCountInNormalView : mWordCount;
+                    int displayEndCount = (mWordCountInNormalView != -1)    ? mWordCountInNormalView : mWordCount;
                     int endPosition = mEndPositionArray.get(displayEndCount - 1);
                     mViewBodyText.setText(mCandidates.subSequence(0, endPosition));
                     mViewBodyText.setSelection(0, 0);
@@ -282,7 +292,7 @@
                 mViewBodyText.setMaxLines(LINE_NUM_LANDSCAPE);
                 mViewBodyText.setLines(LINE_NUM_LANDSCAPE);
                 if (mWordCount > 1) {
-                    int displayEndCount = (mWordCountInNormalView != -1)	? mWordCountInNormalView : mWordCount;
+                    int displayEndCount = (mWordCountInNormalView != -1)    ? mWordCountInNormalView : mWordCount;
                     int endPosition = mEndPositionArray.get(displayEndCount - 1);
                     mViewBodyText.setText(mCandidates.subSequence(0, endPosition));
                     mViewBodyText.setSelection(0, 0);
@@ -311,7 +321,7 @@
 
     /** @see CandidatesViewManager#displayCandidates */
     public void displayCandidates(WnnEngine converter) {
-    	mCanReadMore = false;
+        mCanReadMore = false;
         mDisplayEndOffset = 0;
         mIsFullView = false;
         int maxLine = getMaxLine();
@@ -349,8 +359,8 @@
     /**
      * Count lines using {@link Paint#measureText}.
      *
-     * @param text		The text to display
-     * @return  		Number of lines
+     * @param text      The text to display
+     * @return          Number of lines
      */
     private int countLineUsingMeasureText(CharSequence text) {
         StringBuffer tmpText = new StringBuffer(text);
@@ -404,7 +414,7 @@
         StringBuffer tmp = new StringBuffer();
         tmp.append(mCandidates);
         if ((!dispFirst) && (mLastWord != null) && (mLastWord.candidate.length() != 0)) {
-        	mLineWordCount = -1;
+            mLineWordCount = -1;
 
             StringBuffer displayText = createDisplayText(mLastWord, maxLine);
 
@@ -415,9 +425,9 @@
                 mWnnWordArray.add(mWordCount, mLastWord);
                 int i = 0;
                 for (i = 0 ; i < tmp.length(); i++) {
-                	if (!displayText.subSequence(i, i + 1).equals("\n")) {
-                		break;
-                	}
+                    if (!displayText.subSequence(i, i + 1).equals("\n")) {
+                        break;
+                    }
                 }
                 mStartPositionArray.add(mWordCount, tmp.length() + i);
                 tmp.append(displayText);
@@ -436,15 +446,15 @@
 
             displayText = createDisplayText(result, maxLine);
             if (displayText == null) {
-            	continue;
+                continue;
             }
             
             mWnnWordArray.add(mWordCount, result);
             int i = 0;
             for (i = 0 ; i < tmp.length(); i++) {
-            	if (!displayText.subSequence(i, i + 1).equals("\n")) {
-            		break;
-            	}
+                if (!displayText.subSequence(i, i + 1).equals("\n")) {
+                    break;
+                }
             }
             mStartPositionArray.add(mWordCount, tmp.length() + i);
             tmp.append(displayText);
@@ -455,7 +465,7 @@
             if (mIsFullView) {
                 continue;
             }
-	    
+        
             mViewBodyText.setText(tmp);
             int lineNum = mViewBodyText.getLineCount();
             if (lineNum == 0) {
@@ -465,14 +475,13 @@
                 }
             }
             if (dispFirst &&  lineNum > maxLine) {
-            
                 if (mWordCount == 1) {
-                	setViewLayout(CandidatesViewManager.VIEW_TYPE_FULL);
-                	maxLine = -1;
+                    setViewLayout(CandidatesViewManager.VIEW_TYPE_FULL);
+                    maxLine = -1;
                     mIsFullView = true;
                     continue;
-                }            	
-            	
+                }               
+                
                 mCanReadMore = true;
 
                     mLastWord = result;
@@ -488,10 +497,9 @@
                 mWordCountInNormalView = mWordCount;
                 break;
             } else {
-            
                 if (mWordCount == 1) {
-                	setViewLayout(CandidatesViewManager.VIEW_TYPE_NORMAL);
-                }            	
+                    setViewLayout(CandidatesViewManager.VIEW_TYPE_NORMAL);
+                }               
             }
         }
         
@@ -501,11 +509,11 @@
         int j = 0;
         for (int i = 0; i < mWordCount; i++) {
             while (j <= mEndPositionArray.get(i)) {
-            	if (j < mStartPositionArray.get(i)) {
+                if (j < mStartPositionArray.get(i)) {
                     mPositionToWordIndexArray.add(j,-1);
-            	} else {
+                } else {
                     mPositionToWordIndexArray.add(j,i);
-            	}
+                }
                 j++;
             }
             mPositionToWordIndexArray.add(j,-1);    
@@ -525,10 +533,10 @@
         endPosition += CANDIDATE_SEPARATOR.length();
 
         if (mDisplayEndOffset > 0 && maxLine != -1) {
-        	mCanReadMore = true;
-        	String str = mCandidates.substring(0, mDisplayEndOffset);
-        	StringBuffer sub = new StringBuffer(str);
-        	sub.append(CANDIDATE_SEPARATOR);
+            mCanReadMore = true;
+            String str = mCandidates.substring(0, mDisplayEndOffset);
+            StringBuffer sub = new StringBuffer(str);
+            sub.append(CANDIDATE_SEPARATOR);
             mViewBodyText.setText(sub.subSequence(0, mDisplayEndOffset + CANDIDATE_SEPARATOR.length()));
         } else {
             mViewBodyText.setText(mCandidates.subSequence(0, endPosition));
@@ -554,19 +562,19 @@
      */
     private void setReadMore() {
         if (mCanReadMore && !mIsFullView && !mCandidateDeleteState) {
-        	mReadMoreText.setHeight(mViewHeight);
-        	mReadMoreText.setVisibility(View.VISIBLE);
+            mReadMoreText.setHeight(mViewHeight);
+            mReadMoreText.setVisibility(View.VISIBLE);
         } else {
-        	mReadMoreText.setVisibility(View.GONE);
+            mReadMoreText.setVisibility(View.GONE);
         }
     }
-    	
+        
     /**
      * Create the string to show in the candidate window.
      *
-     * @param word 		A candidate word
-     * @param maxLine	The maximum number of line in the candidate window
-     * @return 		The string to show
+     * @param word      A candidate word
+     * @param maxLine   The maximum number of line in the candidate window
+     * @return      The string to show
      */
     private StringBuffer createDisplayText(WnnWord word, int maxLine) {
         StringBuffer tmp = new StringBuffer();
@@ -579,22 +587,20 @@
         float separatorLength = measureText(p, CANDIDATE_SEPARATOR, 0, CANDIDATE_SEPARATOR.length());
         boolean isFirstWordOfLine = (mLineLength == 0);
 
-   	    int maxWidth = 0;
-  	    int lineLength = 0;
-  	    lineLength += newLineLength;
-  	   
-  	    maxWidth += width - separatorLength;
-  	    
-  	    mLineLength += newLineLength;
+        int maxWidth = 0;
+        int lineLength = 0;
+        lineLength += newLineLength;
+        maxWidth += width - separatorLength;
+        
+        mLineLength += newLineLength;
         mLineLength += separatorLength;
-  	    mLineWordCount++;
+        mLineWordCount++;
 
-  	   
-    	if (mLineWordCount == 0) {
-    		mLineLength = lineLength;
-    		mLineLength += separatorLength;
-    	}
-    	
+        if (mLineWordCount == 0) {
+            mLineLength = lineLength;
+            mLineLength += separatorLength;
+        }
+        
         if (!isFirstWordOfLine && (width < mLineLength) && mLineWordCount != 0) {
             tmp.append("\n");
             mLineLength = lineLength;
@@ -606,61 +612,59 @@
 
     
     /**
-	 * Adjust the width of specified string
+     * Adjust the width of specified string
      *
-     * @param word				A candidate word
-     * @param tmp				A work area
-     * @param newLineLength		The line length to show
-     * @param maxwidth			The maximum number of width that can be displayed in the candidate window
-     * @param maxLine			The maximum number of line in the candidate window
-     * @return 				The string to show
+     * @param word              A candidate word
+     * @param tmp               A work area
+     * @param newLineLength     The line length to show
+     * @param maxwidth          The maximum number of width that can be displayed in the candidate window
+     * @param maxLine           The maximum number of line in the candidate window
+     * @return              The string to show
      */
     private StringBuffer adjustDisplaySize(WnnWord word, StringBuffer tmp, int newLineLength, int maxWidth, int maxLine) {
         StringBuffer string = new StringBuffer(tmp);
-  	   
         if (newLineLength > maxWidth) {
             TextPaint p = mViewBodyText.getPaint();
             float separatorLength = measureText(p, CANDIDATE_SEPARATOR, 0, CANDIDATE_SEPARATOR.length());
-  	        int length = word.candidate.length();
-  	        int size = 0;
-  	        int count = 0;
-  	        int line = 0;
-  	        float LineLength = 0;
-  	        for (int i = 0 ; i < length;i++) {
-  	            string.append(word.candidate.charAt(i));
-   	            LineLength = measureText(p, string, count, count + 1);
-   	            size += LineLength;
-  	            if (size > maxWidth) {
-  	            	line++;
+            int length = word.candidate.length();
+            int size = 0;
+            int count = 0;
+            int line = 0;
+            float LineLength = 0;
+            for (int i = 0 ; i < length;i++) {
+                string.append(word.candidate.charAt(i));
+                LineLength = measureText(p, string, count, count + 1);
+                size += LineLength;
+                if (size > maxWidth) {
+                    line++;
                     string.delete(string.length() - 1, string.length());
                     if (mDisplayEndOffset == 0 && line == maxLine && mWordCount == 0) {
-                    	mDisplayEndOffset = count;
+                        mDisplayEndOffset = count;
                     }
-     	           
                     string.append("\n");
                     string.append(word.candidate.charAt(i));
-     	            size = 0;
-     	            count++;
-       	            LineLength = measureText(p, string, count, count + 1);
-       	            size += LineLength;
-  	    	    }
-   	            count++;
-  	        }
+                    size = 0;
+                    count++;
+                    LineLength = measureText(p, string, count, count + 1);
+                    size += LineLength;
+                }
+                count++;
+            }
 
             mLineWordCount = 0;
             mLineLength = newLineLength;
             mLineLength += separatorLength;
         } else {
-        	string.append(word.candidate);
+            string.append(word.candidate);
         }
         return string;
     }
-    	
-    	
+        
+        
     /** @see CandidatesViewManager#clearCandidates */
     public void clearCandidates() {
         mViewBodyText.setText("");
-	
+    
         mCandidates.delete(0, mCandidates.length());
         mWordCount = 0;
         mWordCountInNormalView = -1;
@@ -669,10 +673,12 @@
         mPositionToWordIndexArray.clear();
         mWnnWordArray.clear();
 
-    	mLineLength = 0;
-    	mLineWordCount = -1;
+        mLineLength = 0;
+        mLineWordCount = -1;
 
-        setViewLayout(CandidatesViewManager.VIEW_TYPE_NORMAL);
+        if (mAutoHideMode) {
+            setViewLayout(CandidatesViewManager.VIEW_TYPE_CLOSE);
+        }
 
         if (mCandidateDeleteState) {
             mViewBodyScroll.removeAllViews();
@@ -685,7 +691,7 @@
         if (mAutoHideMode && mViewBody.isShown()) {
             mWnn.setCandidatesViewShown(false);
         }
-        if(!mAutoHideMode){
+        if (!mAutoHideMode) {
             mCanReadMore = false;
             setReadMore();
         }
@@ -726,7 +732,7 @@
     /**
      * Process CANDIDATE_VIEW_TOUCH event.
      * 
-     * @return		{@code true} if event is processed; {@code false} if otherwise
+     * @return      {@code true} if event is processed; {@code false} if otherwise
      */
     public boolean onTouchSync() {
         if (!mHasCreatedCandidateList) {
@@ -758,28 +764,28 @@
     /**
      * Convert a coordinate into the offset of character
      *
-     * @param x 	The horizontal position
-     * @param y		The vertical position
-     * @return 	The offset of character
+     * @param x     The horizontal position
+     * @param y     The vertical position
+     * @return  The offset of character
      */
-	public int getOffset(int x,int y){
-	    Layout layout = mViewBodyText.getLayout();
-	    int line = layout.getLineForVertical(y);
-	    
-	    if( y >= layout.getLineTop(line+1) ){
-	    	return layout.getText().length();
-	    }
+    public int getOffset(int x,int y){
+        Layout layout = mViewBodyText.getLayout();
+        int line = layout.getLineForVertical(y);
+        
+        if( y >= layout.getLineTop(line+1) ){
+            return layout.getText().length();
+        }
 
-	    int offset = layout.getOffsetForHorizontal(line,x);
+        int offset = layout.getOffsetForHorizontal(line,x);
         offset -= TOUCH_ADJUSTED_VALUE;
         if (offset < 0) {
             offset = 0;
         }
-	    return offset;
-	}
+        return offset;
+    }
 
-	/** from GestureDetector.OnGestureListener class */
-	public boolean onDown(MotionEvent arg0) {
+    /** from GestureDetector.OnGestureListener class */
+    public boolean onDown(MotionEvent arg0) {
         if (!mCandidateDeleteState) {
             int position = getOffset((int)arg0.getX(),(int)arg0.getY());
             int wordIndex = mPositionToWordIndexArray.get(position);
@@ -787,7 +793,7 @@
                 int startPosition = mStartPositionArray.get(wordIndex);
                 int endPosition = 0;
                 if (mDisplayEndOffset > 0 && getViewType() == CandidatesViewManager.VIEW_TYPE_NORMAL) {
-                	endPosition = mDisplayEndOffset + CANDIDATE_SEPARATOR.length();
+                    endPosition = mDisplayEndOffset + CANDIDATE_SEPARATOR.length();
                 } else {
                     endPosition = mEndPositionArray.get(wordIndex);
                 }
@@ -797,11 +803,11 @@
                 mHasStartedSelect = true;
             }
         }
-		return true;
-	}
+        return true;
+    }
 
     /** from GestureDetector.OnGestureListener class */
-	public boolean onFling(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) {
+    public boolean onFling(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) {
 
         if (mCandidateDeleteState) {
             return false;
@@ -828,11 +834,11 @@
             }
         }
 
-		return consumed;
-	}
+        return consumed;
+    }
 
     /** from GestureDetector.OnGestureListener class */
-	public void onLongPress(MotionEvent arg0) {
+    public void onLongPress(MotionEvent arg0) {
         if (!mHasStartedSelect) {
             return;
         }
@@ -853,7 +859,7 @@
                 mLinerLayout = new  LinearLayout(mViewBodyScroll.getContext());
                 mLinerLayout.setOrientation(LinearLayout.VERTICAL);
                 Resources r = mViewBodyScroll.getContext().getResources();
-              	int color = r.getColor(R.color.candidate_background);
+                int color = r.getColor(R.color.candidate_background);
                 mLinerLayout.setBackgroundColor(color);
                 TextView text = new TextView(mViewBodyScroll.getContext());
                 text.setText(mWord.candidate);
@@ -873,20 +879,20 @@
                 mViewBodyScroll.addView(mLinerLayout);
             }
         }
-	}
+    }
 
     /** from GestureDetector.OnGestureListener class */
-	public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
-			float arg3) {
-		return false;
-	}
+    public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
+            float arg3) {
+        return false;
+    }
 
     /** from GestureDetector.OnGestureListener class */
-	public void onShowPress(MotionEvent arg0) {
-	}
+    public void onShowPress(MotionEvent arg0) {
+    }
 
     /** from GestureDetector.OnGestureListener class */
-	public boolean onSingleTapUp(MotionEvent arg0) {
+    public boolean onSingleTapUp(MotionEvent arg0) {
         if (!mHasStartedSelect) {
             return true;
         }
@@ -909,15 +915,15 @@
                 }
             }
         }
-		return false;
-	}
-	
+        return false;
+    }
+    
     /**
      * Create the select button.
      *
      * @return Button The button object
      */
-	private Button createSelectButton(){
+    private Button createSelectButton(){
         final Button selectB;
         selectB= new Button(mViewBodyScroll.getContext()) {
             public boolean onTouchEvent(MotionEvent me) {
@@ -929,10 +935,9 @@
                     break;
                 case MotionEvent.ACTION_UP:
                 default:
-                	d.clearColorFilter();
+                    d.clearColorFilter();
                     break;
                 }
-            
                 return ret;
             }
         };
@@ -943,14 +948,14 @@
         });
         selectB.setText(mSelectBottonText);
         return selectB;
-	}
+    }
 
     /**
      * Create the cancel button
      *
-     * @return Button 		the button object
+     * @return Button       the button object
      */
-	private Button createCancelButton(){
+    private Button createCancelButton(){
         final Button cancelB;
         cancelB= new Button(mViewBodyScroll.getContext()) {
             public boolean onTouchEvent(MotionEvent me) {
@@ -962,18 +967,16 @@
                     break;
                 case MotionEvent.ACTION_UP:
                 default:
-                	d.clearColorFilter();
+                    d.clearColorFilter();
                     break;
                 }
-            
                 return ret;
             }
         };
         cancelB.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
-            	setViewLayout(CandidatesViewManager.VIEW_TYPE_NORMAL);
+                setViewLayout(CandidatesViewManager.VIEW_TYPE_NORMAL);
                 mViewBodyScroll.removeAllViews();
-            
                 mCandidateDeleteState = false;
                 mWnn.onEvent(new OpenWnnEvent(OpenWnnEvent.UPDATE_CANDIDATE));
                 mViewBodyScroll.addView(mViewBodyText);
@@ -981,13 +984,13 @@
         });
         cancelB.setText(mCancelBottonText);
         return cancelB;
-	}
+    }
 
 
     /**
      * Set the show state of hardware keyboard
      * 
-     * @param hidden 	{@code true} if the hardware keyboard is not shown
+     * @param hidden    {@code true} if the hardware keyboard is not shown
      */
     public void setHardKeyboardHidden(boolean hidden) {
         mHardKeyboardHidden = hidden;
@@ -997,11 +1000,11 @@
      * Retrieve the width of string to draw
      * (Emoji is supported by this method)
      * 
-     * @param paint 		The information to draw
-     * @param text			The string
-     * @param start			The start position (specified by the number of character)
-     * @param end 			The end position (specified by the number of character)
-     * @return 			The width of string to draw
+     * @param paint         The information to draw
+     * @param text          The string
+     * @param start         The start position (specified by the number of character)
+     * @param end           The end position (specified by the number of character)
+     * @return          The width of string to draw
      */ 
     public int measureText(TextPaint paint, CharSequence text, int start, int end) {
         return (int)Styled.measureText(paint, new TextPaint(), text, start, end, null);
diff --git a/src/jp/co/omronsoft/openwnn/UserDictionaryToolsEdit.java b/src/jp/co/omronsoft/openwnn/UserDictionaryToolsEdit.java
index bd3355e..40e780f 100644
--- a/src/jp/co/omronsoft/openwnn/UserDictionaryToolsEdit.java
+++ b/src/jp/co/omronsoft/openwnn/UserDictionaryToolsEdit.java
@@ -138,11 +138,11 @@
         Intent intent = getIntent();
         String action = intent.getAction();
         if (action.equals(Intent.ACTION_INSERT)) {
-        	/* add a word */
+            /* add a word */
             mEntryButton.setEnabled(false);
             mRequestState = STATE_INSERT;
         } else if (action.equals(Intent.ACTION_EDIT)) {
-        	/* edit a word */
+            /* edit a word */
             mEntryButton.setEnabled(true);
             mReadEditText.setText(((TextView)sFocusingView).getText());
             mCandidateEditText.setText(((TextView)sFocusingPairView).getText());
@@ -153,7 +153,7 @@
             mBeforeEditWnnWord.stroke = ((TextView)sFocusingView).getText().toString();
             mBeforeEditWnnWord.candidate = ((TextView)sFocusingPairView).getText().toString();
         } else {
-        	/* finish if it is unknown request */
+            /* finish if it is unknown request */
             Log.e("OpenWnn", "onCreate() : Invaled Get Intent. ID=" + intent);
             finish();
             return;
@@ -187,11 +187,11 @@
             public void beforeTextChanged(CharSequence s, int start, int count, int after) {
             }
             public void onTextChanged(CharSequence s, int start, int before, int count) {
-            	if ((mReadEditText.getText().toString().length() != 0) && 
+                if ((mReadEditText.getText().toString().length() != 0) && 
                     (mCandidateEditText.getText().toString().length() != 0)) {
-            		mEntryButton.setEnabled(true);
+                    mEntryButton.setEnabled(true);
                 } else {
-                	mEntryButton.setEnabled(false);
+                    mEntryButton.setEnabled(false);
                 }
             }
         });
@@ -218,21 +218,21 @@
         mEntryButton.setEnabled(false);
         mCancelButton.setEnabled(false);
 
-    	switch (v.getId()) {
+        switch (v.getId()) {
             case R.id.addButton:
-            	/* save the word */
+                /* save the word */
                 doSaveAction();
                 break;
  
             case R.id.cancelButton:
-            	/* cancel the edit */
+                /* cancel the edit */
                 doRevertAction();
                 break;
 
             default:
                 Log.e("OpenWnn", "onClick: Get Invalid ButtonID. ID=" + v.getId());
                 finish();
-            	return;
+                return;
         }
     }
 
@@ -243,7 +243,7 @@
 
         switch (mRequestState) {
         case STATE_INSERT:
-        	/* register a word */
+            /* register a word */
             if (inputDataCheck(mReadEditText) && inputDataCheck(mCandidateEditText)) {
                     String stroke = mReadEditText.getText().toString();
                     String candidate = mCandidateEditText.getText().toString();
@@ -254,7 +254,7 @@
             break;
             
         case STATE_EDIT:
-        	/* edit a word (=delete the word selected & add the word edited) */
+            /* edit a word (=delete the word selected & add the word edited) */
             if (inputDataCheck(mReadEditText) && inputDataCheck(mCandidateEditText)) {
                 deleteDictionary(mBeforeEditWnnWord);
                     String stroke = mReadEditText.getText().toString();
@@ -290,7 +290,7 @@
     @Override protected Dialog onCreateDialog(int id) {
         switch (id) {
             case DIALOG_CONTROL_WORDS_DUPLICATE:
-            	/* there is the same word in the dictionary */
+                /* there is the same word in the dictionary */
                 return new AlertDialog.Builder(UserDictionaryToolsEdit.this)
                         .setIcon(android.R.drawable.ic_dialog_alert)
                         .setMessage(R.string.user_dictionary_words_duplication_message)
@@ -304,8 +304,8 @@
                         .create();
 
             case DIALOG_CONTROL_OVER_MAX_TEXT_SIZE:
-               	/* the length of the word exceeds the limit */
-            	return new AlertDialog.Builder(UserDictionaryToolsEdit.this)
+                /* the length of the word exceeds the limit */
+                return new AlertDialog.Builder(UserDictionaryToolsEdit.this)
                         .setIcon(android.R.drawable.ic_dialog_alert)
                         .setMessage(R.string.user_dictionary_over_max_text_size_message)
                         .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@@ -323,9 +323,9 @@
     /**
      * Add the word
      *
-     * @param  stroke    	The stroke of the word
-     * @param  candidate 	The string of the word
-     * @return           	{@code true} if success; {@code false} if fail.
+     * @param  stroke       The stroke of the word
+     * @param  candidate    The string of the word
+     * @return              {@code true} if success; {@code false} if fail.
      */
     private boolean addDictionary(String stroke, String candidate) {
 
diff --git a/src/jp/co/omronsoft/openwnn/UserDictionaryToolsList.java b/src/jp/co/omronsoft/openwnn/UserDictionaryToolsList.java
index 322f655..e0182bf 100644
--- a/src/jp/co/omronsoft/openwnn/UserDictionaryToolsList.java
+++ b/src/jp/co/omronsoft/openwnn/UserDictionaryToolsList.java
@@ -493,8 +493,8 @@
     /**
      * Delete the specified word
      *
-     * @param  searchword	The information of searching
-     * @return 			{@code true} if success; {@code false} if fail.
+     * @param  searchword   The information of searching
+     * @return          {@code true} if success; {@code false} if fail.
      */
     public boolean deleteWord(WnnWord searchword) {
         OpenWnnEvent event = new OpenWnnEvent(OpenWnnEvent.LIST_WORDS_IN_USER_DICTIONARY,
@@ -620,10 +620,10 @@
     /**
      * Create the list of words.
      *
-     * @param  position		Start position to create the list
-     * @param  max			Maximum number of words to display
-     * @param  self			UserDictionaryToolsList
-     * @return 			{@code true} if more words undisplayed; {@code false} if no more.
+     * @param  position     Start position to create the list
+     * @param  max          Maximum number of words to display
+     * @param  self         UserDictionaryToolsList
+     * @return          {@code true} if more words undisplayed; {@code false} if no more.
      */
     private boolean createWordList(int position ,int max, UserDictionaryToolsList self) {
         boolean ret = true;
@@ -697,7 +697,3 @@
         return ret;
     }
 }
-
-
-
-
diff --git a/src/jp/co/omronsoft/openwnn/WnnDictionary.java b/src/jp/co/omronsoft/openwnn/WnnDictionary.java
index 019b50a..c83d140 100644
--- a/src/jp/co/omronsoft/openwnn/WnnDictionary.java
+++ b/src/jp/co/omronsoft/openwnn/WnnDictionary.java
@@ -23,93 +23,93 @@
  * @author Copyright (C) 2008-2009, OMRON SOFTWARE CO., LTD.  All Rights Reserved.
  */
 public interface WnnDictionary {
-	/*
-	 * DEFINITION OF CONSTANTS
-	 */
+    /*
+     * DEFINITION OF CONSTANTS
+     */
     /**
-	 * Predefined approximate pattern set (capital letters from small letters).
+     * Predefined approximate pattern set (capital letters from small letters).
      * 
      * This pattern includes the rules for ambiguous searching capital letters from small letters.<br>
      * ex. "a" to "A", "b" to "B", ... , "z" to "Z"
      */
-	public static final int APPROX_PATTERN_EN_TOUPPER               = 0;
+    public static final int APPROX_PATTERN_EN_TOUPPER               = 0;
     /**
-	 * Predefined approximate pattern set (small letters from capital letters).
+     * Predefined approximate pattern set (small letters from capital letters).
      *
      * This pattern includes the rules for ambiguous searching small letters from capital letters.<br>
      * ex. "A" to "a", "B" to "b", ... , "Z" to "z"
      */
-	public static final int APPROX_PATTERN_EN_TOLOWER               = 1;
+    public static final int APPROX_PATTERN_EN_TOLOWER               = 1;
     /**
-	 * Predefined approximate pattern set (QWERTY neighbor keys).
+     * Predefined approximate pattern set (QWERTY neighbor keys).
      *
      * This pattern includes the rules for ambiguous searching neighbor keys on QWERTY keyboard.
      * Only alphabet letters are defined; numerical or symbol letters are not defined as the rules.<br>
      * ex. "a" to "q"/"w"/"s"/"z", "b" to "v"/"g"/"h"/"n", ... ,"z" to "a"/"s"/"x"
      */
-	public static final int APPROX_PATTERN_EN_QWERTY_NEAR           = 2;
+    public static final int APPROX_PATTERN_EN_QWERTY_NEAR           = 2;
     /**
-	 * Predefined approximate pattern set (QWERTY neighbor keys/capital letters).
+     * Predefined approximate pattern set (QWERTY neighbor keys/capital letters).
      *
      * This pattern includes the rules for ambiguous searching capital letters of neighbor keys on QWERTY keyboard.
      * Only alphabet letters are defined; numerical or symbol letters are not defined as the rules.<br>
      * ex. "a" to "Q"/"W"/"S"/"Z", "b" to "V"/"G"/"H"/"N", ... ,"z" to "A"/"S"/"X"
      */
-	public static final int APPROX_PATTERN_EN_QWERTY_NEAR_UPPER     = 3;
+    public static final int APPROX_PATTERN_EN_QWERTY_NEAR_UPPER     = 3;
     /**
-	 * Predefined approximate pattern set (for Japanese 12-key keyboard).
+     * Predefined approximate pattern set (for Japanese 12-key keyboard).
      *
      * This pattern includes the standard rules for Japanese multi-tap 12-key keyboard.
      * ex. "&#x306F;" to "&#x3070;"/"&#x3071;", "&#x3064;" to "&#x3063;"/"&#x3065;"
      */
-	public static final int APPROX_PATTERN_JAJP_12KEY_NORMAL        = 4;
+    public static final int APPROX_PATTERN_JAJP_12KEY_NORMAL        = 4;
 
-	/** Search operation mode (exact matching). */
-	public static final int SEARCH_EXACT                            = 0;
-	/** Search operation mode (prefix matching). */
-	public static final int SEARCH_PREFIX                           = 1;
-	/** Search operation mode (link search). */
-	public static final int SEARCH_LINK                             = 2;
+    /** Search operation mode (exact matching). */
+    public static final int SEARCH_EXACT                            = 0;
+    /** Search operation mode (prefix matching). */
+    public static final int SEARCH_PREFIX                           = 1;
+    /** Search operation mode (link search). */
+    public static final int SEARCH_LINK                             = 2;
 
-	/** Sort order (frequency in descending). */
-	public static final int ORDER_BY_FREQUENCY                      = 0;
-	/** Sort order (character code of key string in ascending). */
-	public static final int ORDER_BY_KEY                            = 1;
+    /** Sort order (frequency in descending). */
+    public static final int ORDER_BY_FREQUENCY                      = 0;
+    /** Sort order (character code of key string in ascending). */
+    public static final int ORDER_BY_KEY                            = 1;
 
-	/** Type of a part of speech (V1) */
+    /** Type of a part of speech (V1) */
     public static final int POS_TYPE_V1                             = 0;
-	/** Type of a part of speech (V2) */
+    /** Type of a part of speech (V2) */
     public static final int POS_TYPE_V2                             = 1;
-	/** Type of a part of speech (V3) */
+    /** Type of a part of speech (V3) */
     public static final int POS_TYPE_V3                             = 2;
-	/** Type of a part of speech (Top of sentence) */
+    /** Type of a part of speech (Top of sentence) */
     public static final int POS_TYPE_BUNTOU                         = 3;
-	/** Type of a part of speech (Single chinese character) */
+    /** Type of a part of speech (Single chinese character) */
     public static final int POS_TYPE_TANKANJI                       = 4;
-	/** Type of a part of speech (Numeric) */
+    /** Type of a part of speech (Numeric) */
     public static final int POS_TYPE_SUUJI                          = 5;
-	/** Type of a part of speech (Noun) */
+    /** Type of a part of speech (Noun) */
     public static final int POS_TYPE_MEISI                          = 6;
-	/** Type of a part of speech (Person's name) */
+    /** Type of a part of speech (Person's name) */
     public static final int POS_TYPE_JINMEI                         = 7;
-	/** Type of a part of speech (Place name) */
+    /** Type of a part of speech (Place name) */
     public static final int POS_TYPE_CHIMEI                         = 8;
-	/** Type of a part of speech (Symbol) */
+    /** Type of a part of speech (Symbol) */
     public static final int POS_TYPE_KIGOU                          = 9;
 
-	/** Index of the user dictionary for {@link #setDictionary(int, int, int)} */
+    /** Index of the user dictionary for {@link #setDictionary(int, int, int)} */
     public static final int INDEX_USER_DICTIONARY                   = -1;
     /** Index of the learn dictionary for {@link #setDictionary(int, int, int)} */
     public static final int INDEX_LEARN_DICTIONARY                  = -2;
 
-	
-	/**
-	 * Whether this dictionary module is active.
-	 * @return {@code true} if this dictionary module is active; {@code false} if not.
-	 */
-	public boolean isActive();
-	
-	/**
+    
+    /**
+     * Whether this dictionary module is active.
+     * @return {@code true} if this dictionary module is active; {@code false} if not.
+     */
+    public boolean isActive();
+    
+    /**
      * Set "in use" state.
      *
      * When the flag set true, the user dictionary is locked.
@@ -118,75 +118,75 @@
      */
     public void setInUseState( boolean flag );
 
-	/**
-	 * Clear all dictionary settings.
+    /**
+     * Clear all dictionary settings.
      *
-	 * All the dictionaries are set to be unused.
+     * All the dictionaries are set to be unused.
      *
-	 * @return			0 if success; minus value(error code) if fail.
-	 */
-	public int clearDictionary( );
+     * @return          0 if success; minus value(error code) if fail.
+     */
+    public int clearDictionary( );
 
-	/**
-	 * Sets a dictionary information for using specified dictionary.
+    /**
+     * Sets a dictionary information for using specified dictionary.
      *
      * <p>
-	 * A dictionary information contains parameters:<br>
+     * A dictionary information contains parameters:<br>
      * {@code base} is the bias of frequency for the dictionary.<br>
      * {@code high} is the upper limit of frequency for the dictionary.
      * </p>
      * Searched word's frequency in the dictionary is mapped to the range from {@code base} to {@code high}.
      * <br>
      * The maximum value of {@code base} and {@code high} is 1000.
-	 * To set a dictionary unused, specify -1 to {@code base} and {@code high}.
+     * To set a dictionary unused, specify -1 to {@code base} and {@code high}.
      *
-	 * @param index		A dictionary index
-	 * @param base		The base frequency for the dictionary
-	 * @param high		The maximum frequency for the dictionary
-	 * @return			0 if success; minus value(error code) if fail.
-	 */
-	public int setDictionary(int index, int base, int high );
+     * @param index     A dictionary index
+     * @param base      The base frequency for the dictionary
+     * @param high      The maximum frequency for the dictionary
+     * @return          0 if success; minus value(error code) if fail.
+     */
+    public int setDictionary(int index, int base, int high );
 
-	/**
-	 * Clears approximate patterns.
+    /**
+     * Clears approximate patterns.
      *
-	 * This clears all approximate search patterns in the search condition.
-	 */
-	public void clearApproxPattern( );
+     * This clears all approximate search patterns in the search condition.
+     */
+    public void clearApproxPattern( );
 
-	/**
-	 * Sets a approximate pattern.
+    /**
+     * Sets a approximate pattern.
      *
-	 * This adds an approximate search pattern(replacement of character) to the search condition.
+     * This adds an approximate search pattern(replacement of character) to the search condition.
      * The pattern rule is defined as replacing a character({@code src}) to characters({@code dst}).
      * <br>
      * The length of {@code src} must be 1 and the length of {@code dst} must be lower than 4.<br>
      * The maximum count of approximate patterns is 255.
      *
-	 * @param src		A character replace from
-	 * @param dst		Characters replace to
-	 * @return			0 if success; minus value(error code) if fail.
-	 */
-	public int setApproxPattern( String src, String dst );
+     * @param src       A character replace from
+     * @param dst       Characters replace to
+     * @return          0 if success; minus value(error code) if fail.
+     */
+    public int setApproxPattern( String src, String dst );
 
-	/**
-	 * Sets a predefined approximate pattern.
+    /**
+     * Sets a predefined approximate pattern.
      *
-	 * The patterns included predefined approximate search pattern set specified by
-	 * {@code approxPattern} are added to the search condition.
-	 *
-	 * @param approxPattern		A predefined approximate pattern set
+     * The patterns included predefined approximate search pattern set specified by
+     * {@code approxPattern} are added to the search condition.
+     *
+     * @param approxPattern     A predefined approximate pattern set
      * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOUPPER
      * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_TOLOWER
      * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR
      * @see jp.co.omronsoft.openwnn.WnnDictionary#APPROX_PATTERN_EN_QWERTY_NEAR_UPPER
      *
-	 * @return					0 if success; minus value(error code) if fail.
-	 */
-	public int setApproxPattern( int approxPattern );
+     * @return                  0 if success; minus value(error code) if fail.
+     */
+    public int setApproxPattern( int approxPattern );
 
-	/**
-	 * Search words from dictionaries with specified conditions.
+    /**
+     * Search words from dictionaries with specified conditions.
      * <p>
      * To get the searched word's information, use {@link #getNextWord()}.<br>
      * If a same word existed in the set of dictionary, the search result may contain some same words.<br>
@@ -211,22 +211,22 @@
      * </table>
      * </p>
      *
-	 * @param operation		The search operation
+     * @param operation     The search operation
      * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_EXACT
      * @see jp.co.omronsoft.openwnn.WnnDictionary#SEARCH_PREFIX
-	 * @param order			The sort order
+     * @param order         The sort order
      * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_FREQUENCY
      * @see jp.co.omronsoft.openwnn.WnnDictionary#ORDER_BY_KEY
-	 * @param keyString		The key string
+     * @param keyString     The key string
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#getNextWord
      *
-	 * @return				0 if no word is found; 1 if some words found; minus value if a error occurs.
-	 */
-	public int searchWord(int operation, int order, String keyString );
+     * @return              0 if no word is found; 1 if some words found; minus value if a error occurs.
+     */
+    public int searchWord(int operation, int order, String keyString );
 
     /**
-	 * Search words from dictionaries with specified conditions and previous word.
+     * Search words from dictionaries with specified conditions and previous word.
      * <p>
      * For using link search function, specify the {@code wnnWord} as previous word and
      * set {@code SEARCH_LINK} mode to {@code operation}. The other arguments are
@@ -235,54 +235,54 @@
      * If the prediction dictionary for reading is set to use, the previous word must contain
      * the {@code stroke} and the {@code candidate} information. If the prediction dictionary
      * for part of speech is set to use, the previous word must contain the {@code partOfSpeech} information.
-	 *
+     *
      * @param wnnWord       The previous word
      * @see jp.co.omronsoft.openwnn.WnnDictionary#searchWord
      * 
-	 * @return				0 if no word is found; 1 if some words found; minus value if a error occurs.
+     * @return              0 if no word is found; 1 if some words found; minus value if a error occurs.
      */
-	public int searchWord(int operation, int order, String keyString, WnnWord wnnWord );
+    public int searchWord(int operation, int order, String keyString, WnnWord wnnWord );
 
-	/**
-	 * Retrieve a searched word information.
+    /**
+     * Retrieve a searched word information.
      *
      * It returns a word information from top of the {@code searchWord()}'s result.
      * To get all word's information of the result, call this method repeatedly until it returns null.
      *
-	 * @return				An instance of WnnWord; null if no result or an error occurs.
-	 */
-	public WnnWord getNextWord( );
+     * @return              An instance of WnnWord; null if no result or an error occurs.
+     */
+    public WnnWord getNextWord( );
 
-	/**
-	 * Retrieve a searched word information with condition of length.
+    /**
+     * Retrieve a searched word information with condition of length.
      *
      * It returns a word information from top of the {@code searchWord()}'s result.
      * To get all word's information of the result, call this method repeatedly until it returns null.
      *
-     * @param length	>0 if only the result of specified length is retrieved; 0 if no condition exist
-	 * @return			An instance of WnnWord; null if no result or an error occurs.
-	 */
-	public WnnWord getNextWord( int length );
+     * @param length    >0 if only the result of specified length is retrieved; 0 if no condition exist
+     * @return          An instance of WnnWord; null if no result or an error occurs.
+     */
+    public WnnWord getNextWord( int length );
 
     /**
      * Retrieve all word in the user dictionary.
      *
-     * @return			The array of WnnWord objects.
+     * @return          The array of WnnWord objects.
      */
     public WnnWord[] getUserDictionaryWords( );
 
     /**
      * Retrieve the connect matrix.
      *
-     * @return			The array of the connect matrix; null if an error occurs.
+     * @return          The array of the connect matrix; null if an error occurs.
      */
     public byte[][] getConnectMatrix( );
 
     /**
      * Retrieve the part of speech information specified POS type.
      *
-     * @param type		The type of a part of speech
-     * @return			The part of speech information; null if invalid type is specified or  an error occurs.
+     * @param type      The type of a part of speech
+     * @return          The part of speech information; null if invalid type is specified or  an error occurs.
      *
      * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V1
      * @see jp.co.omronsoft.openwnn.WnnDictionary#POS_TYPE_V2
@@ -300,60 +300,60 @@
     /**
      * Clear the user dictionary.
      * 
-     * @return		0 if no error occur; <0 if an error occur
+     * @return      0 if no error occur; <0 if an error occur
      */
     public int clearUserDictionary();
     /**
      * Clear the learn dictionary.
      * 
-     * @return		0 if no error occur; <0 if an error occur
+     * @return      0 if no error occur; <0 if an error occur
      */
     public int clearLearnDictionary();
 
     /**
      * Add the words to user dictionary.
      *
-     * @param word		The array of word
-     * @return			0 if no error occur; <0 if an error occur
+     * @param word      The array of word
+     * @return          0 if no error occur; <0 if an error occur
      */
     public int addWordToUserDictionary( WnnWord[] word );
     /**
      * Add the word to user dictionary.
      *
-     * @param word		The word
-     * @return			0 if no error occur; <0 if an error occur
+     * @param word      The word
+     * @return          0 if no error occur; <0 if an error occur
      */
     public int addWordToUserDictionary( WnnWord word );
 
     /**
      * Remove the words from user dictionary.
      *
-     * @param word  	The array of word
-     * @return			0 if no error occur; <0 if an error occur
+     * @param word      The array of word
+     * @return          0 if no error occur; <0 if an error occur
      */
     public int removeWordFromUserDictionary( WnnWord[] word );
     /**
      * Remove the word from user dictionary.
      *
-     * @param word  	The word
-     * @return			0 if no error occur; <0 if an error occur
+     * @param word      The word
+     * @return          0 if no error occur; <0 if an error occur
      */
     public int removeWordFromUserDictionary( WnnWord word );
 
     /**
      * Learn the word.
      *
-     * @param word  	The word for learning
-     * @return			0 if no error occur; <0 if an error occur
+     * @param word      The word for learning
+     * @return          0 if no error occur; <0 if an error occur
      */
     public int learnWord( WnnWord word );
 
     /**
      * Learn the word with connection.
      *
-     * @param word          	The word for learning
-     * @param previousWord		The word for link learning
-     * @return					0 if no error occur; <0 if an error occur
+     * @param word              The word for learning
+     * @param previousWord      The word for link learning
+     * @return                  0 if no error occur; <0 if an error occur
      */
     public int learnWord( WnnWord word, WnnWord previousWord );
 }
diff --git a/src/jp/co/omronsoft/openwnn/WnnEngine.java b/src/jp/co/omronsoft/openwnn/WnnEngine.java
index 491475b..4d23966 100644
--- a/src/jp/co/omronsoft/openwnn/WnnEngine.java
+++ b/src/jp/co/omronsoft/openwnn/WnnEngine.java
@@ -53,10 +53,10 @@
     /**
      * Predict words/phrases.
      * <br>
-     * @param text   	The input string
-     * @param minLen 	The minimum length of a word to predict (0  : no limit)
-     * @param maxLen 	The maximum length of a word to predict (-1 : no limit)
-     * @return			Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
+     * @param text      The input string
+     * @param minLen    The minimum length of a word to predict (0  : no limit)
+     * @param maxLen    The maximum length of a word to predict (-1 : no limit)
+     * @return          Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
      */
     public int predict(ComposingText text, int minLen, int maxLen);
 
@@ -70,24 +70,24 @@
      * The result of conversion is set into the layer 2 in the {@link ComposingText}.
      * To get other candidates of each clause, call {@link #makeCandidateListOf(int)}.
      *
-     * @param text   	The input string
-     * @return 		Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
+     * @param text      The input string
+     * @return      Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
      */
     public int convert(ComposingText text);
 
     /**
      * Search words from the dictionaries.
      * <br>
-     * @param key  		The search key (stroke)
-     * @return 		Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
+     * @param key       The search key (stroke)
+     * @return      Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
      */
     public int searchWords(String key);
 
     /**
      * Search words from the dictionaries.
      * <br>
-     * @param word  	A word to search
-     * @return			Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
+     * @param word      A word to search
+     * @return          Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
      */
     public int searchWords(WnnWord word);
 
@@ -101,14 +101,14 @@
      * {@link #makeCandidateListOf(int)}, in increasing character code order for
      * {@code searchWords()}.
      *
-     * @return			The candidate; {@code null} if there is no more candidate.
+     * @return          The candidate; {@code null} if there is no more candidate.
      */
     public WnnWord getNextCandidate();
 
     /**
      * Retrieve the list of registered words.
      * <br>
-     * @return			{@code null} if no word is registered; the array of {@link WnnWord} if some words is registered.
+     * @return          {@code null} if no word is registered; the array of {@link WnnWord} if some words is registered.
      */
     public WnnWord[] getUserDictionaryWords();
 
@@ -119,41 +119,41 @@
      * candidates to the learning dictionary or update the frequency
      * of the word.
      *
-     * @param word		The selected word
-     * @return			{@code true} if success; {@code false} if fail or not supported.
+     * @param word      The selected word
+     * @return          {@code true} if success; {@code false} if fail or not supported.
      */
     public boolean learn(WnnWord word);
 
     /**
      * Register a word to the user's dictionary.
      * <br>
-     * @param word		A word to register
-     * @return			Number of registered words in the user's dictionary after the operation; minus value if a error occurs.
+     * @param word      A word to register
+     * @return          Number of registered words in the user's dictionary after the operation; minus value if a error occurs.
      */
     public int addWord(WnnWord word);
 
     /**
      * Delete a word from the user's dictionary.
      * <br>
-     * @param word		A word to delete
-     * @return			{@code true} if success; {@code false} if fail or not supported.
+     * @param word      A word to delete
+     * @return          {@code true} if success; {@code false} if fail or not supported.
      */
     public boolean deleteWord(WnnWord word);
 
     /**
      * Delete all words from the user's dictionary.
      * <br>
-     * @param dictionary	{@code DICTIONARY_TYPE_LEARN} or {@code DICTIONARY_TYPE_USER}
-     * @return				{@code true} if success; {@code false} if fail or not supported.
+     * @param dictionary    {@code DICTIONARY_TYPE_LEARN} or {@code DICTIONARY_TYPE_USER}
+     * @return              {@code true} if success; {@code false} if fail or not supported.
      */
     public boolean initializeDictionary(int dictionary);
 
     /**
      * Delete all words from the user's dictionary of the specified language.
      * <br>
-     * @param dictionary		{@code DICTIONARY_TYPE_LEARN} or {@code DICTIONARY_TYPE_USER}
-     * @param type				Dictionary type (language, etc...)
-     * @return					{@code true} if success; {@code false} if fail or not supported.
+     * @param dictionary        {@code DICTIONARY_TYPE_LEARN} or {@code DICTIONARY_TYPE_USER}
+     * @param type              Dictionary type (language, etc...)
+     * @return                  {@code true} if success; {@code false} if fail or not supported.
      */
     public boolean initializeDictionary(int dictionary, int type);
 
@@ -183,7 +183,7 @@
      * To get the elements of the list, call {@link #getNextCandidate()}.
      *
      * @param clausePosition  The position of a clause
-     * @return					Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
+     * @return                  Plus value if there are candidates; 0 if there is no candidate; minus value if a error occurs.
      */
     public int makeCandidateListOf(int clausePosition);
 }
diff --git a/src/jp/co/omronsoft/openwnn/WnnWord.java b/src/jp/co/omronsoft/openwnn/WnnWord.java
index 86c5a57..fb2f7c6 100644
--- a/src/jp/co/omronsoft/openwnn/WnnWord.java
+++ b/src/jp/co/omronsoft/openwnn/WnnWord.java
@@ -22,14 +22,14 @@
  * @author Copyright (C) 2008-2009, OMRON SOFTWARE CO., LTD.  All Rights Reserved.
  */
 public class WnnWord {
-	/** The word's Id */
-	public int      id;
-	/** The string of this word. */
-	public String   candidate;
-	/** The reading of this word. */
-	public String   stroke;
-	/** The score of this word. */
-	public int      frequency;
+    /** The word's Id */
+    public int      id;
+    /** The string of this word. */
+    public String   candidate;
+    /** The reading of this word. */
+    public String   stroke;
+    /** The score of this word. */
+    public int      frequency;
     /** The part of speech this word. */
     public WnnPOS   partOfSpeech;
     /** The attribute of this word when it is assumed a candidate. */
diff --git a/src/jp/co/omronsoft/openwnn/ZH/DefaultSoftKeyboardZH.java b/src/jp/co/omronsoft/openwnn/ZH/DefaultSoftKeyboardZH.java
index 96fa418..139c4a8 100644
--- a/src/jp/co/omronsoft/openwnn/ZH/DefaultSoftKeyboardZH.java
+++ b/src/jp/co/omronsoft/openwnn/ZH/DefaultSoftKeyboardZH.java
@@ -176,6 +176,11 @@
 
     /** @see jp.co.omronsoft.openwnn.DefaultSoftKeyboard#onKey */
     @Override public void onKey(int primaryCode, int[] keyCodes) {
+
+        if (mDisableKeyInput) {
+            return;
+        }
+
         switch (primaryCode) {
         case KEYCODE_QWERTY_TOGGLE_MODE:
             nextKeyMode();
@@ -268,6 +273,8 @@
         mEnableAutoCaps = pref.getBoolean("auto_caps", true);
         mFixedKeyMode = INVALID_KEYMODE;
         mPreferenceKeyMode = INVALID_KEYMODE;
+        mNoInput = true;
+        mDisableKeyInput = false;
 
         switch (inputType & EditorInfo.TYPE_MASK_CLASS) {
 
@@ -312,7 +319,9 @@
     /** @see jp.co.omronsoft.openwnn.DefaultSoftKeyboard#onUpdateState */
     @Override public void onUpdateState(OpenWnn parent) {
         super.onUpdateState(parent);
-        setShiftByEditorInfo();
+        if (!mCapsLock) {
+            setShiftByEditorInfo();
+        }
     }
 
     /**
