reconcile pinyin project with p4 CL 143093 and new name
diff --git a/Android.mk b/Android.mk
index 5053e7d..64224ae 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1 +1,25 @@
-include $(call all-subdir-makefiles)
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+         $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := PinyinIME
+
+LOCAL_JNI_SHARED_LIBRARIES := libjni_pinyinime
+
+LOCAL_STATIC_JAVA_LIBRARIES := com.android.inputmethod.pinyin.lib
+
+LOCAL_CERTIFICATE := shared
+
+# Make sure our dictionary file is not compressed, so we can read it with
+# a raw file descriptor.
+LOCAL_AAPT_FLAGS := -0 .dat
+
+include $(BUILD_PACKAGE)
+
+MY_PATH := $(LOCAL_PATH)
+
+include $(MY_PATH)/jni/Android.mk
+include $(MY_PATH)/lib/Android.mk
diff --git a/PinyinIME/AndroidManifest.xml b/AndroidManifest.xml
similarity index 100%
rename from PinyinIME/AndroidManifest.xml
rename to AndroidManifest.xml
diff --git a/PinyinIME/Android.mk b/PinyinIME/Android.mk
deleted file mode 100644
index 64224ae..0000000
--- a/PinyinIME/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-         $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := PinyinIME
-
-LOCAL_JNI_SHARED_LIBRARIES := libjni_pinyinime
-
-LOCAL_STATIC_JAVA_LIBRARIES := com.android.inputmethod.pinyin.lib
-
-LOCAL_CERTIFICATE := shared
-
-# Make sure our dictionary file is not compressed, so we can read it with
-# a raw file descriptor.
-LOCAL_AAPT_FLAGS := -0 .dat
-
-include $(BUILD_PACKAGE)
-
-MY_PATH := $(LOCAL_PATH)
-
-include $(MY_PATH)/jni/Android.mk
-include $(MY_PATH)/lib/Android.mk
diff --git a/PinyinIME/jni/Android.mk b/jni/Android.mk
similarity index 100%
rename from PinyinIME/jni/Android.mk
rename to jni/Android.mk
diff --git a/PinyinIME/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp b/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp
similarity index 94%
rename from PinyinIME/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp
rename to jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp
index 4362c30..dcb63a1 100644
--- a/PinyinIME/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp
+++ b/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp
@@ -51,10 +51,15 @@
   jbyte *fsd = (*env).GetByteArrayElements(fn_sys_dict, 0);
   jbyte *fud = (*env).GetByteArrayElements(fn_usr_dict, 0);
 
-  if (im_open_decoder((const char*)fsd, (const char*)fud))
-    return JNI_TRUE;
+  jboolean jret = JNI_FALSE;
 
-  return JNI_FALSE;
+  if (im_open_decoder((const char*)fsd, (const char*)fud))
+    jret = JNI_TRUE;
+
+  (*env).ReleaseByteArrayElements(fn_sys_dict, fsd, 0);
+  (*env).ReleaseByteArrayElements(fn_usr_dict, fud, 0);
+
+  return jret;
 }
 
 JNIEXPORT jboolean JNICALL nativeImOpenDecoderFd(JNIEnv* env, jclass jclazz,
@@ -65,14 +70,17 @@
   jint fd = env->GetIntField(fd_sys_dict, gFileDescriptorOffsets.mDescriptor);
   jbyte *fud = (*env).GetByteArrayElements(fn_usr_dict, 0);
 
+  jboolean jret = JNI_FALSE;
+
   int newfd = dup(fd);
-  if (im_open_decoder_fd(newfd, startoffset, length, (const char*)fud)) {
-    close(newfd);
-    return JNI_TRUE;
-  }
+  if (im_open_decoder_fd(newfd, startoffset, length, (const char*)fud))
+    jret = JNI_TRUE;
 
   close(newfd);
-  return JNI_FALSE;
+
+  (*env).ReleaseByteArrayElements(fn_usr_dict, fud, 0);
+
+  return jret;
 }
 
 JNIEXPORT void JNICALL nativeImSetMaxLens(JNIEnv* env, jclass jclazz,
@@ -92,10 +100,14 @@
                                       jbyteArray pybuf, jint pylen) {
   jbyte *array_body = (*env).GetByteArrayElements(pybuf, 0);
 
-  if (NULL == array_body)
-    return 0;
+  jint jret = 0;
+  if (NULL != array_body) {
+    jret = im_search((const char*)array_body, pylen);
+  }
 
-  return im_search((const char*)array_body, pylen);
+  (*env).ReleaseByteArrayElements(pybuf, array_body, 0);
+
+  return jret;
 }
 
 JNIEXPORT jint JNICALL nativeImDelSearch(JNIEnv* env, jclass jclazz, jint pos,
@@ -157,6 +169,9 @@
   arr_body[0] = len; // element 0 is used to store the length of buffer.
   for (size_t i = 0; i <= len; i++)
     arr_body[i + 1] = spl_start[i];
+
+  (*env).ReleaseIntArrayElements(arr, arr_body, 0);
+
   return arr;
 }
 
@@ -213,6 +228,8 @@
 
   predict_len = im_get_predicts(fixed_buf, predict_buf);
 
+  (*env).ReleaseStringChars(fixed_str, fixed_ptr);
+
   return predict_len;
 }
 
@@ -232,9 +249,14 @@
 JNIEXPORT jboolean JNICALL nativeSyncBegin(JNIEnv *env, jclass clazz,
                                            jbyteArray dict_file) {
   jbyte *file_name = (*env).GetByteArrayElements(dict_file, 0);
+
+  jboolean jret = JNI_FALSE;
   if (true == sync_worker.begin((const char *)file_name))
-    return JNI_TRUE;
-  return JNI_FALSE;
+    jret = JNI_TRUE;
+
+  (*env).ReleaseByteArrayElements(dict_file, file_name, 0);
+
+  return jret;
 }
 
 JNIEXPORT jboolean JNICALL nativeSyncFinish(JNIEnv *env, jclass clazz) {
diff --git a/PinyinIME/jni/command/Makefile b/jni/command/Makefile
similarity index 100%
rename from PinyinIME/jni/command/Makefile
rename to jni/command/Makefile
diff --git a/PinyinIME/jni/command/pinyinime_dictbuilder.cpp b/jni/command/pinyinime_dictbuilder.cpp
similarity index 100%
rename from PinyinIME/jni/command/pinyinime_dictbuilder.cpp
rename to jni/command/pinyinime_dictbuilder.cpp
diff --git a/PinyinIME/jni/data/rawdict_utf16_65105_freq.txt b/jni/data/rawdict_utf16_65105_freq.txt
similarity index 100%
rename from PinyinIME/jni/data/rawdict_utf16_65105_freq.txt
rename to jni/data/rawdict_utf16_65105_freq.txt
Binary files differ
diff --git a/PinyinIME/jni/data/valid_utf16.txt b/jni/data/valid_utf16.txt
similarity index 100%
rename from PinyinIME/jni/data/valid_utf16.txt
rename to jni/data/valid_utf16.txt
Binary files differ
diff --git a/PinyinIME/jni/include/atomdictbase.h b/jni/include/atomdictbase.h
similarity index 100%
rename from PinyinIME/jni/include/atomdictbase.h
rename to jni/include/atomdictbase.h
diff --git a/PinyinIME/jni/include/dictbuilder.h b/jni/include/dictbuilder.h
similarity index 100%
rename from PinyinIME/jni/include/dictbuilder.h
rename to jni/include/dictbuilder.h
diff --git a/PinyinIME/jni/include/dictdef.h b/jni/include/dictdef.h
similarity index 100%
rename from PinyinIME/jni/include/dictdef.h
rename to jni/include/dictdef.h
diff --git a/PinyinIME/jni/include/dictlist.h b/jni/include/dictlist.h
similarity index 100%
rename from PinyinIME/jni/include/dictlist.h
rename to jni/include/dictlist.h
diff --git a/PinyinIME/jni/include/dicttrie.h b/jni/include/dicttrie.h
similarity index 100%
rename from PinyinIME/jni/include/dicttrie.h
rename to jni/include/dicttrie.h
diff --git a/PinyinIME/jni/include/lpicache.h b/jni/include/lpicache.h
similarity index 100%
rename from PinyinIME/jni/include/lpicache.h
rename to jni/include/lpicache.h
diff --git a/PinyinIME/jni/include/matrixsearch.h b/jni/include/matrixsearch.h
similarity index 99%
rename from PinyinIME/jni/include/matrixsearch.h
rename to jni/include/matrixsearch.h
index b9cf061..f581d30 100644
--- a/PinyinIME/jni/include/matrixsearch.h
+++ b/jni/include/matrixsearch.h
@@ -250,6 +250,9 @@
 
   void free_resource();
 
+  // Reset the search space totally.
+  bool reset_search0();
+
   // Reset the search space from ch_pos step. For example, if the original
   // input Pinyin is "an", reset_search(1) will reset the search space to the
   // result of "a". If the given position is out of range, return false.
diff --git a/PinyinIME/jni/include/mystdlib.h b/jni/include/mystdlib.h
similarity index 100%
rename from PinyinIME/jni/include/mystdlib.h
rename to jni/include/mystdlib.h
diff --git a/PinyinIME/jni/include/ngram.h b/jni/include/ngram.h
similarity index 100%
rename from PinyinIME/jni/include/ngram.h
rename to jni/include/ngram.h
diff --git a/PinyinIME/jni/include/pinyinime.h b/jni/include/pinyinime.h
similarity index 100%
rename from PinyinIME/jni/include/pinyinime.h
rename to jni/include/pinyinime.h
diff --git a/PinyinIME/jni/include/searchutility.h b/jni/include/searchutility.h
similarity index 100%
rename from PinyinIME/jni/include/searchutility.h
rename to jni/include/searchutility.h
diff --git a/PinyinIME/jni/include/spellingtable.h b/jni/include/spellingtable.h
similarity index 100%
rename from PinyinIME/jni/include/spellingtable.h
rename to jni/include/spellingtable.h
diff --git a/PinyinIME/jni/include/spellingtrie.h b/jni/include/spellingtrie.h
similarity index 100%
rename from PinyinIME/jni/include/spellingtrie.h
rename to jni/include/spellingtrie.h
diff --git a/PinyinIME/jni/include/splparser.h b/jni/include/splparser.h
similarity index 100%
rename from PinyinIME/jni/include/splparser.h
rename to jni/include/splparser.h
diff --git a/PinyinIME/jni/include/sync.h b/jni/include/sync.h
similarity index 100%
rename from PinyinIME/jni/include/sync.h
rename to jni/include/sync.h
diff --git a/PinyinIME/jni/include/userdict.h b/jni/include/userdict.h
similarity index 100%
rename from PinyinIME/jni/include/userdict.h
rename to jni/include/userdict.h
diff --git a/PinyinIME/jni/include/utf16char.h b/jni/include/utf16char.h
similarity index 100%
rename from PinyinIME/jni/include/utf16char.h
rename to jni/include/utf16char.h
diff --git a/PinyinIME/jni/include/utf16reader.h b/jni/include/utf16reader.h
similarity index 100%
rename from PinyinIME/jni/include/utf16reader.h
rename to jni/include/utf16reader.h
diff --git a/PinyinIME/jni/share/dictbuilder.cpp b/jni/share/dictbuilder.cpp
similarity index 98%
rename from PinyinIME/jni/share/dictbuilder.cpp
rename to jni/share/dictbuilder.cpp
index b2e989c..6f0bd4f 100644
--- a/PinyinIME/jni/share/dictbuilder.cpp
+++ b/jni/share/dictbuilder.cpp
@@ -491,7 +491,6 @@
       i--;
       continue;
     }
-    //    printf("i: %d\n", i);
   }
 
   delete [] valid_hzs;
@@ -579,7 +578,6 @@
 
   get_top_lemmas();
 
-  // printf("Now begin construct tree\n");
 #ifdef ___DO_STATISTICS___
   stat_init();
 #endif
@@ -775,8 +773,6 @@
   if (level >= kMaxLemmaSize || item_end <= item_start)
     return false;
 
-  // printf("++ enter recursive\n");
-
   // 1. Scan for how many sons
   size_t parent_son_num = 0;
   // LemmaNode *son_1st = NULL;
@@ -853,8 +849,6 @@
   lma_last_start = lemma_arr_ + item_start;
   spl_idx_node = lma_last_start->spl_idx_arr[level];
 
-  //  printf("++ spl_idx_node: %d\n", spl_idx_node);
-
   size_t homo_num = 0;
   if (lma_last_start->spl_idx_arr[level + 1] == 0)
     homo_num = 1;
@@ -888,8 +882,6 @@
         homo_idx_num_gt1_ += homo_num;
       }
 
-      // printf("++ homo_num: %d\n++ lmaids: ", homo_num);
-
       if (homo_num > 0) {
         LemmaIdType* idx_buf = homo_idx_buf_ + homo_idx_num_eq1_ +
               homo_idx_num_gt1_ - homo_num;
@@ -903,10 +895,8 @@
 
         for (size_t homo_pos = 0; homo_pos < homo_num; homo_pos++) {
           idx_buf[homo_pos] = lemma_arr_[item_start_next + homo_pos].idx_by_hz;
-          // printf("[%d] %d ", item_start_next + homo_pos,  idx_buf[homo_pos]);
         }
 
-        // printf("\n");
 #ifdef ___DO_STATISTICS___
         if (homo_num > max_homobuf_len_[level])
           max_homobuf_len_[level] = homo_num;
diff --git a/PinyinIME/jni/share/dictlist.cpp b/jni/share/dictlist.cpp
similarity index 100%
rename from PinyinIME/jni/share/dictlist.cpp
rename to jni/share/dictlist.cpp
diff --git a/PinyinIME/jni/share/dicttrie.cpp b/jni/share/dicttrie.cpp
similarity index 100%
rename from PinyinIME/jni/share/dicttrie.cpp
rename to jni/share/dicttrie.cpp
diff --git a/PinyinIME/jni/share/lpicache.cpp b/jni/share/lpicache.cpp
similarity index 100%
rename from PinyinIME/jni/share/lpicache.cpp
rename to jni/share/lpicache.cpp
diff --git a/PinyinIME/jni/share/matrixsearch.cpp b/jni/share/matrixsearch.cpp
similarity index 95%
rename from PinyinIME/jni/share/matrixsearch.cpp
rename to jni/share/matrixsearch.cpp
index d13a4c4..dd19f59 100644
--- a/PinyinIME/jni/share/matrixsearch.cpp
+++ b/jni/share/matrixsearch.cpp
@@ -139,7 +139,7 @@
     user_dict_->set_total_lemma_count_of_others(NGram::kSysDictTotalFreq);
   }
 
-  reset_search(0, true, true, true);
+  reset_search0();
 
   inited_ = true;
   return true;
@@ -163,7 +163,7 @@
     user_dict_->set_total_lemma_count_of_others(NGram::kSysDictTotalFreq);
   }
 
-  reset_search(0, true, true, true);
+  reset_search0();
 
   inited_ = true;
   return true;
@@ -198,16 +198,13 @@
 bool MatrixSearch::reset_search() {
   if (!inited_)
     return false;
-  return reset_search(0, true, true, true);
+  return reset_search0();
 }
 
-bool MatrixSearch::reset_search(size_t ch_pos, bool clear_fixed_this_step,
-                                bool clear_dmi_this_step,
-                                bool clear_mtrx_this_step) {
-  if (!inited_ || ch_pos > pys_decoded_len_ || ch_pos >= kMaxRowNum)
-    return false;
+bool MatrixSearch::reset_search0() {
+    if (!inited_)
+        return false;
 
-  if (0 == ch_pos) {
     pys_decoded_len_ = 0;
     mtrx_nd_pool_used_ = 0;
     dmi_pool_used_ = 0;
@@ -238,6 +235,18 @@
     dict_trie_->reset_milestones(0, 0);
     if (NULL != user_dict_)
       user_dict_->reset_milestones(0, 0);
+
+    return true;
+}
+
+bool MatrixSearch::reset_search(size_t ch_pos, bool clear_fixed_this_step,
+                                bool clear_dmi_this_step,
+                                bool clear_mtrx_this_step) {
+  if (!inited_ || ch_pos > pys_decoded_len_ || ch_pos >= kMaxRowNum)
+    return false;
+
+  if (0 == ch_pos) {
+    reset_search0();
   } else {
     // Prepare mile stones of this step to clear.
     MileStoneHandle *dict_handles_to_clear = NULL;
@@ -281,7 +290,10 @@
     }
 
     // Modify fixed_hzs_
-    if (fixed_hzs_ > 0 && kLemmaIdComposing != lma_id_[0]) {
+    if (fixed_hzs_ > 0 &&
+        ((kLemmaIdComposing != lma_id_[0]) ||
+         (kLemmaIdComposing == lma_id_[0] &&
+          spl_start_[c_phrase_.length] <= ch_pos))) {
       size_t fixed_ch_pos = ch_pos;
       if (clear_fixed_this_step)
         fixed_ch_pos = fixed_ch_pos > 0 ? fixed_ch_pos - 1 : 0;
@@ -350,8 +362,47 @@
       for (uint16 re_pos = fixed_ch_pos; re_pos < ch_pos; re_pos++) {
         add_char(pys_[re_pos]);
       }
-    } else if (kLemmaIdComposing == lma_id_[0]) {
-      // Do nothing for the composing phrase.
+    } else if (fixed_hzs_ > 0 && kLemmaIdComposing == lma_id_[0]) {
+      for (uint16 subpos = 0; subpos < c_phrase_.sublma_num; subpos++) {
+        uint16 splpos_begin = c_phrase_.sublma_start[subpos];
+        uint16 splpos_end = c_phrase_.sublma_start[subpos + 1];
+        for (uint16 splpos = splpos_begin; splpos < splpos_end; splpos++) {
+          // If ch_pos is in this spelling
+          uint16 spl_start = c_phrase_.spl_start[splpos];
+          uint16 spl_end = c_phrase_.spl_start[splpos + 1];
+          if (ch_pos >= spl_start && ch_pos < spl_end) {
+            // Clear everything after this position
+            c_phrase_.chn_str[splpos] = static_cast<char16>('\0');
+            c_phrase_.sublma_start[subpos + 1] = splpos;
+            c_phrase_.sublma_num = subpos + 1;
+            c_phrase_.length = splpos;
+
+            if (splpos == splpos_begin) {
+              c_phrase_.sublma_num = subpos;
+            }
+          }
+        }
+      }
+
+      // Extend the composing phrase.
+      reset_search0();
+      dmi_c_phrase_ = true;
+      uint16 c_py_pos = 0;
+      while (c_py_pos < spl_start_[c_phrase_.length]) {
+        bool b_ac_tmp = add_char(pys_[c_py_pos]);
+        assert(b_ac_tmp);
+        c_py_pos++;
+      }
+      dmi_c_phrase_ = false;
+
+      lma_id_num_ = 1;
+      fixed_lmas_ = 1;
+      fixed_lmas_no1_[0] = 0;  // A composing string is always modified.
+      fixed_hzs_ = c_phrase_.length;
+      lma_start_[1] = fixed_hzs_;
+      lma_id_[0] = kLemmaIdComposing;
+      matrix_[spl_start_[fixed_hzs_]].mtrx_nd_fixed = mtrx_nd_pool_ +
+          matrix_[spl_start_[fixed_hzs_]].mtrx_nd_pos;
     }
   }
 
@@ -431,9 +482,23 @@
   if (!inited_)
     return 0;
 
+  size_t reset_pos = pos;
+
   // Out of range for both Pinyin mode and Spelling id mode.
   if (pys_decoded_len_ <= pos) {
     del_in_pys(pos, 1);
+
+    reset_pos = pys_decoded_len_;
+    // Decode the string after the un-decoded position
+    while ('\0' != pys_[reset_pos]) {
+      if (!add_char(pys_[reset_pos])) {
+        pys_decoded_len_ = reset_pos;
+        break;
+      }
+      reset_pos++;
+    }
+    get_spl_start_id();
+    prepare_candidates();
     return pys_decoded_len_;
   }
 
@@ -444,9 +509,7 @@
   // Begin to handle two modes respectively.
   // Pinyin mode by default
   size_t c_py_len = 0;  // The length of composing phrase's Pinyin
-  size_t reset_pos = pos;
   size_t del_py_len = 1;
-  size_t stop_pos = pys_decoded_len_;
   if (!is_pos_in_splid) {
     // Pinyin mode is only allowed to delete beyond the fixed lemmas.
     if (fixed_lmas_ > 0 && pos < spl_start_[lma_start_[fixed_lmas_]])
@@ -490,7 +553,7 @@
     // The composing phrase is valid, reset all search space,
     // and begin a new search which will only extend the composing
     // phrase.
-    reset_search(0, true, true, true);
+    reset_search0();
 
     dmi_c_phrase_ = true;
     // Extend the composing phrase.
@@ -517,8 +580,7 @@
   }
 
   // Decode the string after the delete position.
-  stop_pos -= del_py_len;
-  while (reset_pos < stop_pos) {
+  while ('\0' != pys_[reset_pos]) {
     if (!add_char(pys_[reset_pos])) {
       pys_decoded_len_ = reset_pos;
       break;
@@ -528,7 +590,7 @@
 
   get_spl_start_id();
   prepare_candidates();
-  return c_py_len;
+  return pys_decoded_len_;
 }
 
 size_t MatrixSearch::get_candidate_num() {
@@ -1591,7 +1653,8 @@
 
     char16 str[kMaxLemmaSize + 1];
     uint16 str_len = get_lemma_str(idxs[id_num], str, kMaxLemmaSize + 1);
-    if (str_len > 0 && max_len - ret_pos > str_len) {
+    if (str_len > 0 && ((!only_unfixed && max_len - ret_pos > str_len) ||
+        (only_unfixed && max_len - ret_pos + fixed_hzs_ > str_len))) {
       if (!only_unfixed)
         utf16_strncpy(cand_str + ret_pos, str, str_len);
       else if (ret_pos >= fixed_hzs_)
diff --git a/PinyinIME/jni/share/mystdlib.cpp b/jni/share/mystdlib.cpp
similarity index 100%
rename from PinyinIME/jni/share/mystdlib.cpp
rename to jni/share/mystdlib.cpp
diff --git a/PinyinIME/jni/share/ngram.cpp b/jni/share/ngram.cpp
similarity index 100%
rename from PinyinIME/jni/share/ngram.cpp
rename to jni/share/ngram.cpp
diff --git a/PinyinIME/jni/share/pinyinime.cpp b/jni/share/pinyinime.cpp
similarity index 100%
rename from PinyinIME/jni/share/pinyinime.cpp
rename to jni/share/pinyinime.cpp
diff --git a/PinyinIME/jni/share/searchutility.cpp b/jni/share/searchutility.cpp
similarity index 100%
rename from PinyinIME/jni/share/searchutility.cpp
rename to jni/share/searchutility.cpp
diff --git a/PinyinIME/jni/share/spellingtable.cpp b/jni/share/spellingtable.cpp
similarity index 100%
rename from PinyinIME/jni/share/spellingtable.cpp
rename to jni/share/spellingtable.cpp
diff --git a/PinyinIME/jni/share/spellingtrie.cpp b/jni/share/spellingtrie.cpp
similarity index 100%
rename from PinyinIME/jni/share/spellingtrie.cpp
rename to jni/share/spellingtrie.cpp
diff --git a/PinyinIME/jni/share/splparser.cpp b/jni/share/splparser.cpp
similarity index 100%
rename from PinyinIME/jni/share/splparser.cpp
rename to jni/share/splparser.cpp
diff --git a/PinyinIME/jni/share/sync.cpp b/jni/share/sync.cpp
similarity index 100%
rename from PinyinIME/jni/share/sync.cpp
rename to jni/share/sync.cpp
diff --git a/PinyinIME/jni/share/userdict.cpp b/jni/share/userdict.cpp
similarity index 100%
rename from PinyinIME/jni/share/userdict.cpp
rename to jni/share/userdict.cpp
diff --git a/PinyinIME/jni/share/utf16char.cpp b/jni/share/utf16char.cpp
similarity index 100%
rename from PinyinIME/jni/share/utf16char.cpp
rename to jni/share/utf16char.cpp
diff --git a/PinyinIME/jni/share/utf16reader.cpp b/jni/share/utf16reader.cpp
similarity index 100%
rename from PinyinIME/jni/share/utf16reader.cpp
rename to jni/share/utf16reader.cpp
diff --git a/PinyinIME/lib/Android.mk b/lib/Android.mk
similarity index 100%
rename from PinyinIME/lib/Android.mk
rename to lib/Android.mk
diff --git a/PinyinIME/lib/com/android/inputmethod/pinyin/IPinyinDecoderService.aidl b/lib/com/android/inputmethod/pinyin/IPinyinDecoderService.aidl
similarity index 100%
rename from PinyinIME/lib/com/android/inputmethod/pinyin/IPinyinDecoderService.aidl
rename to lib/com/android/inputmethod/pinyin/IPinyinDecoderService.aidl
diff --git a/PinyinIME/res/drawable/app_icon.png b/res/drawable/app_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/app_icon.png
rename to res/drawable/app_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/arrow_bg.xml b/res/drawable/arrow_bg.xml
similarity index 100%
rename from PinyinIME/res/drawable/arrow_bg.xml
rename to res/drawable/arrow_bg.xml
diff --git a/PinyinIME/res/drawable/arrow_left.png b/res/drawable/arrow_left.png
similarity index 100%
rename from PinyinIME/res/drawable/arrow_left.png
rename to res/drawable/arrow_left.png
Binary files differ
diff --git a/PinyinIME/res/drawable/arrow_right.png b/res/drawable/arrow_right.png
similarity index 100%
rename from PinyinIME/res/drawable/arrow_right.png
rename to res/drawable/arrow_right.png
Binary files differ
diff --git a/PinyinIME/res/drawable/candidate_balloon_bg.9.png b/res/drawable/candidate_balloon_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/candidate_balloon_bg.9.png
rename to res/drawable/candidate_balloon_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/candidate_hl_bg.9.png b/res/drawable/candidate_hl_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/candidate_hl_bg.9.png
rename to res/drawable/candidate_hl_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/candidates_area_bg.9.png b/res/drawable/candidates_area_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/candidates_area_bg.9.png
rename to res/drawable/candidates_area_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/candidates_vertical_line.png b/res/drawable/candidates_vertical_line.png
similarity index 100%
rename from PinyinIME/res/drawable/candidates_vertical_line.png
rename to res/drawable/candidates_vertical_line.png
Binary files differ
diff --git a/PinyinIME/res/drawable/cands_container_bg.9.png b/res/drawable/cands_container_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/cands_container_bg.9.png
rename to res/drawable/cands_container_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/comma_full_icon.png b/res/drawable/comma_full_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/comma_full_icon.png
rename to res/drawable/comma_full_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/comma_full_popup_icon.png b/res/drawable/comma_full_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/comma_full_popup_icon.png
rename to res/drawable/comma_full_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/composing_area_bg.9.png b/res/drawable/composing_area_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/composing_area_bg.9.png
rename to res/drawable/composing_area_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/composing_area_cursor.png b/res/drawable/composing_area_cursor.png
similarity index 100%
rename from PinyinIME/res/drawable/composing_area_cursor.png
rename to res/drawable/composing_area_cursor.png
Binary files differ
diff --git a/PinyinIME/res/drawable/composing_hl_bg.9.png b/res/drawable/composing_hl_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/composing_hl_bg.9.png
rename to res/drawable/composing_hl_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/delete_icon.png b/res/drawable/delete_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/delete_icon.png
rename to res/drawable/delete_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/delete_popup_icon.png b/res/drawable/delete_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/delete_popup_icon.png
rename to res/drawable/delete_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/dun_icon.png b/res/drawable/dun_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/dun_icon.png
rename to res/drawable/dun_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/dun_popup_icon.png b/res/drawable/dun_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/dun_popup_icon.png
rename to res/drawable/dun_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_00.png b/res/drawable/emotion_icon_00.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_00.png
rename to res/drawable/emotion_icon_00.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_00_popup.png b/res/drawable/emotion_icon_00_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_00_popup.png
rename to res/drawable/emotion_icon_00_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_01.png b/res/drawable/emotion_icon_01.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_01.png
rename to res/drawable/emotion_icon_01.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_01_popup.png b/res/drawable/emotion_icon_01_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_01_popup.png
rename to res/drawable/emotion_icon_01_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_02.png b/res/drawable/emotion_icon_02.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_02.png
rename to res/drawable/emotion_icon_02.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_02_popup.png b/res/drawable/emotion_icon_02_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_02_popup.png
rename to res/drawable/emotion_icon_02_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_03.png b/res/drawable/emotion_icon_03.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_03.png
rename to res/drawable/emotion_icon_03.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_03_popup.png b/res/drawable/emotion_icon_03_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_03_popup.png
rename to res/drawable/emotion_icon_03_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_04.png b/res/drawable/emotion_icon_04.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_04.png
rename to res/drawable/emotion_icon_04.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_04_popup.png b/res/drawable/emotion_icon_04_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_04_popup.png
rename to res/drawable/emotion_icon_04_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_05.png b/res/drawable/emotion_icon_05.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_05.png
rename to res/drawable/emotion_icon_05.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_05_popup.png b/res/drawable/emotion_icon_05_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_05_popup.png
rename to res/drawable/emotion_icon_05_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_06.png b/res/drawable/emotion_icon_06.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_06.png
rename to res/drawable/emotion_icon_06.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_06_popup.png b/res/drawable/emotion_icon_06_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_06_popup.png
rename to res/drawable/emotion_icon_06_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_10.png b/res/drawable/emotion_icon_10.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_10.png
rename to res/drawable/emotion_icon_10.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_10_popup.png b/res/drawable/emotion_icon_10_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_10_popup.png
rename to res/drawable/emotion_icon_10_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_11.png b/res/drawable/emotion_icon_11.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_11.png
rename to res/drawable/emotion_icon_11.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_11_popup.png b/res/drawable/emotion_icon_11_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_11_popup.png
rename to res/drawable/emotion_icon_11_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_12.png b/res/drawable/emotion_icon_12.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_12.png
rename to res/drawable/emotion_icon_12.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_12_popup.png b/res/drawable/emotion_icon_12_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_12_popup.png
rename to res/drawable/emotion_icon_12_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_13.png b/res/drawable/emotion_icon_13.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_13.png
rename to res/drawable/emotion_icon_13.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_13_popup.png b/res/drawable/emotion_icon_13_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_13_popup.png
rename to res/drawable/emotion_icon_13_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_14.png b/res/drawable/emotion_icon_14.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_14.png
rename to res/drawable/emotion_icon_14.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_14_popup.png b/res/drawable/emotion_icon_14_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_14_popup.png
rename to res/drawable/emotion_icon_14_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_15.png b/res/drawable/emotion_icon_15.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_15.png
rename to res/drawable/emotion_icon_15.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_15_popup.png b/res/drawable/emotion_icon_15_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_15_popup.png
rename to res/drawable/emotion_icon_15_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_16.png b/res/drawable/emotion_icon_16.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_16.png
rename to res/drawable/emotion_icon_16.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_16_popup.png b/res/drawable/emotion_icon_16_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_16_popup.png
rename to res/drawable/emotion_icon_16_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_20.png b/res/drawable/emotion_icon_20.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_20.png
rename to res/drawable/emotion_icon_20.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_20_popup.png b/res/drawable/emotion_icon_20_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_20_popup.png
rename to res/drawable/emotion_icon_20_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_21.png b/res/drawable/emotion_icon_21.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_21.png
rename to res/drawable/emotion_icon_21.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_21_popup.png b/res/drawable/emotion_icon_21_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_21_popup.png
rename to res/drawable/emotion_icon_21_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_22.png b/res/drawable/emotion_icon_22.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_22.png
rename to res/drawable/emotion_icon_22.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_22_popup.png b/res/drawable/emotion_icon_22_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_22_popup.png
rename to res/drawable/emotion_icon_22_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_23.png b/res/drawable/emotion_icon_23.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_23.png
rename to res/drawable/emotion_icon_23.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_23_popup.png b/res/drawable/emotion_icon_23_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_23_popup.png
rename to res/drawable/emotion_icon_23_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_24.png b/res/drawable/emotion_icon_24.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_24.png
rename to res/drawable/emotion_icon_24.png
Binary files differ
diff --git a/PinyinIME/res/drawable/emotion_icon_24_popup.png b/res/drawable/emotion_icon_24_popup.png
similarity index 100%
rename from PinyinIME/res/drawable/emotion_icon_24_popup.png
rename to res/drawable/emotion_icon_24_popup.png
Binary files differ
diff --git a/PinyinIME/res/drawable/enter_icon.png b/res/drawable/enter_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/enter_icon.png
rename to res/drawable/enter_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/enter_popup_icon.png b/res/drawable/enter_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/enter_popup_icon.png
rename to res/drawable/enter_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/ime_en.png b/res/drawable/ime_en.png
similarity index 100%
rename from PinyinIME/res/drawable/ime_en.png
rename to res/drawable/ime_en.png
Binary files differ
diff --git a/PinyinIME/res/drawable/ime_pinyin.png b/res/drawable/ime_pinyin.png
similarity index 100%
rename from PinyinIME/res/drawable/ime_pinyin.png
rename to res/drawable/ime_pinyin.png
Binary files differ
diff --git a/PinyinIME/res/drawable/key_balloon_bg.9.png b/res/drawable/key_balloon_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/key_balloon_bg.9.png
rename to res/drawable/key_balloon_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/light_key_bg.9.png b/res/drawable/light_key_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/light_key_bg.9.png
rename to res/drawable/light_key_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/light_key_hl_bg.9.png b/res/drawable/light_key_hl_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/light_key_hl_bg.9.png
rename to res/drawable/light_key_hl_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/light_key_up_bg.9.png b/res/drawable/light_key_up_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/light_key_up_bg.9.png
rename to res/drawable/light_key_up_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/light_key_up_hl_bg.9.png b/res/drawable/light_key_up_hl_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/light_key_up_hl_bg.9.png
rename to res/drawable/light_key_up_hl_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/miniskb_bg.9.png b/res/drawable/miniskb_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/miniskb_bg.9.png
rename to res/drawable/miniskb_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/normal_key_bg.9.png b/res/drawable/normal_key_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/normal_key_bg.9.png
rename to res/drawable/normal_key_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/normal_key_hl_bg.9.png b/res/drawable/normal_key_hl_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/normal_key_hl_bg.9.png
rename to res/drawable/normal_key_hl_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num0.png b/res/drawable/num0.png
similarity index 100%
rename from PinyinIME/res/drawable/num0.png
rename to res/drawable/num0.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num1.png b/res/drawable/num1.png
similarity index 100%
rename from PinyinIME/res/drawable/num1.png
rename to res/drawable/num1.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num2.png b/res/drawable/num2.png
similarity index 100%
rename from PinyinIME/res/drawable/num2.png
rename to res/drawable/num2.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num3.png b/res/drawable/num3.png
similarity index 100%
rename from PinyinIME/res/drawable/num3.png
rename to res/drawable/num3.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num4.png b/res/drawable/num4.png
similarity index 100%
rename from PinyinIME/res/drawable/num4.png
rename to res/drawable/num4.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num5.png b/res/drawable/num5.png
similarity index 100%
rename from PinyinIME/res/drawable/num5.png
rename to res/drawable/num5.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num6.png b/res/drawable/num6.png
similarity index 100%
rename from PinyinIME/res/drawable/num6.png
rename to res/drawable/num6.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num7.png b/res/drawable/num7.png
similarity index 100%
rename from PinyinIME/res/drawable/num7.png
rename to res/drawable/num7.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num8.png b/res/drawable/num8.png
similarity index 100%
rename from PinyinIME/res/drawable/num8.png
rename to res/drawable/num8.png
Binary files differ
diff --git a/PinyinIME/res/drawable/num9.png b/res/drawable/num9.png
similarity index 100%
rename from PinyinIME/res/drawable/num9.png
rename to res/drawable/num9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/numalt.png b/res/drawable/numalt.png
similarity index 100%
rename from PinyinIME/res/drawable/numalt.png
rename to res/drawable/numalt.png
Binary files differ
diff --git a/PinyinIME/res/drawable/numpound.png b/res/drawable/numpound.png
similarity index 100%
rename from PinyinIME/res/drawable/numpound.png
rename to res/drawable/numpound.png
Binary files differ
diff --git a/PinyinIME/res/drawable/numstar.png b/res/drawable/numstar.png
similarity index 100%
rename from PinyinIME/res/drawable/numstar.png
rename to res/drawable/numstar.png
Binary files differ
diff --git a/PinyinIME/res/drawable/period_full_icon.png b/res/drawable/period_full_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/period_full_icon.png
rename to res/drawable/period_full_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/period_full_popup_icon.png b/res/drawable/period_full_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/period_full_popup_icon.png
rename to res/drawable/period_full_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/period_icon.png b/res/drawable/period_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/period_icon.png
rename to res/drawable/period_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/period_popup_icon.png b/res/drawable/period_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/period_popup_icon.png
rename to res/drawable/period_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/search_icon.png b/res/drawable/search_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/search_icon.png
rename to res/drawable/search_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/search_popup_icon.png b/res/drawable/search_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/search_popup_icon.png
rename to res/drawable/search_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/shift_off_icon.png b/res/drawable/shift_off_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/shift_off_icon.png
rename to res/drawable/shift_off_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/shift_off_popup_icon.png b/res/drawable/shift_off_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/shift_off_popup_icon.png
rename to res/drawable/shift_off_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/shift_on_icon.png b/res/drawable/shift_on_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/shift_on_icon.png
rename to res/drawable/shift_on_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/shift_on_popup_icon.png b/res/drawable/shift_on_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/shift_on_popup_icon.png
rename to res/drawable/shift_on_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/skb_bg.png b/res/drawable/skb_bg.png
similarity index 100%
rename from PinyinIME/res/drawable/skb_bg.png
rename to res/drawable/skb_bg.png
Binary files differ
diff --git a/PinyinIME/res/drawable/skb_container_bg.9.png b/res/drawable/skb_container_bg.9.png
similarity index 100%
rename from PinyinIME/res/drawable/skb_container_bg.9.png
rename to res/drawable/skb_container_bg.9.png
Binary files differ
diff --git a/PinyinIME/res/drawable/smiley_icon.png b/res/drawable/smiley_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/smiley_icon.png
rename to res/drawable/smiley_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/smiley_popup_icon.png b/res/drawable/smiley_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/smiley_popup_icon.png
rename to res/drawable/smiley_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/space_icon.png b/res/drawable/space_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/space_icon.png
rename to res/drawable/space_icon.png
Binary files differ
diff --git a/PinyinIME/res/drawable/space_popup_icon.png b/res/drawable/space_popup_icon.png
similarity index 100%
rename from PinyinIME/res/drawable/space_popup_icon.png
rename to res/drawable/space_popup_icon.png
Binary files differ
diff --git a/PinyinIME/res/layout/candidates_container.xml b/res/layout/candidates_container.xml
similarity index 100%
rename from PinyinIME/res/layout/candidates_container.xml
rename to res/layout/candidates_container.xml
diff --git a/PinyinIME/res/layout/floating_container.xml b/res/layout/floating_container.xml
similarity index 100%
rename from PinyinIME/res/layout/floating_container.xml
rename to res/layout/floating_container.xml
diff --git a/PinyinIME/res/layout/skb_container.xml b/res/layout/skb_container.xml
similarity index 100%
rename from PinyinIME/res/layout/skb_container.xml
rename to res/layout/skb_container.xml
diff --git a/PinyinIME/res/raw/dict_pinyin.dat b/res/raw/dict_pinyin.dat
similarity index 100%
rename from PinyinIME/res/raw/dict_pinyin.dat
rename to res/raw/dict_pinyin.dat
Binary files differ
diff --git a/PinyinIME/res/values-land/dimens.xml b/res/values-land/dimens.xml
similarity index 100%
rename from PinyinIME/res/values-land/dimens.xml
rename to res/values-land/dimens.xml
diff --git a/PinyinIME/res/values-port/dimens.xml b/res/values-port/dimens.xml
similarity index 100%
rename from PinyinIME/res/values-port/dimens.xml
rename to res/values-port/dimens.xml
diff --git a/PinyinIME/res/values-zh/bools.xml b/res/values-zh/bools.xml
similarity index 100%
rename from PinyinIME/res/values-zh/bools.xml
rename to res/values-zh/bools.xml
diff --git a/PinyinIME/res/values/colors.xml b/res/values/colors.xml
similarity index 100%
rename from PinyinIME/res/values/colors.xml
rename to res/values/colors.xml
diff --git a/PinyinIME/res/values/dimens.xml b/res/values/dimens.xml
similarity index 100%
rename from PinyinIME/res/values/dimens.xml
rename to res/values/dimens.xml
diff --git a/PinyinIME/res/values/strings.xml b/res/values/strings.xml
similarity index 100%
rename from PinyinIME/res/values/strings.xml
rename to res/values/strings.xml
diff --git a/PinyinIME/res/xml/method.xml b/res/xml/method.xml
similarity index 100%
rename from PinyinIME/res/xml/method.xml
rename to res/xml/method.xml
diff --git a/PinyinIME/res/xml/settings.xml b/res/xml/settings.xml
similarity index 100%
rename from PinyinIME/res/xml/settings.xml
rename to res/xml/settings.xml
diff --git a/PinyinIME/res/xml/skb_phone.xml b/res/xml/skb_phone.xml
similarity index 100%
rename from PinyinIME/res/xml/skb_phone.xml
rename to res/xml/skb_phone.xml
diff --git a/PinyinIME/res/xml/skb_qwerty.xml b/res/xml/skb_qwerty.xml
similarity index 100%
rename from PinyinIME/res/xml/skb_qwerty.xml
rename to res/xml/skb_qwerty.xml
diff --git a/PinyinIME/res/xml/skb_smiley.xml b/res/xml/skb_smiley.xml
similarity index 100%
rename from PinyinIME/res/xml/skb_smiley.xml
rename to res/xml/skb_smiley.xml
diff --git a/PinyinIME/res/xml/skb_sym1.xml b/res/xml/skb_sym1.xml
similarity index 100%
rename from PinyinIME/res/xml/skb_sym1.xml
rename to res/xml/skb_sym1.xml
diff --git a/PinyinIME/res/xml/skb_sym2.xml b/res/xml/skb_sym2.xml
similarity index 100%
rename from PinyinIME/res/xml/skb_sym2.xml
rename to res/xml/skb_sym2.xml
diff --git a/PinyinIME/res/xml/skb_template1.xml b/res/xml/skb_template1.xml
similarity index 100%
rename from PinyinIME/res/xml/skb_template1.xml
rename to res/xml/skb_template1.xml
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/BalloonHint.java b/src/com/android/inputmethod/pinyin/BalloonHint.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/BalloonHint.java
rename to src/com/android/inputmethod/pinyin/BalloonHint.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/CandidateView.java b/src/com/android/inputmethod/pinyin/CandidateView.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/CandidateView.java
rename to src/com/android/inputmethod/pinyin/CandidateView.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/CandidateViewListener.java b/src/com/android/inputmethod/pinyin/CandidateViewListener.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/CandidateViewListener.java
rename to src/com/android/inputmethod/pinyin/CandidateViewListener.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/CandidatesContainer.java b/src/com/android/inputmethod/pinyin/CandidatesContainer.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/CandidatesContainer.java
rename to src/com/android/inputmethod/pinyin/CandidatesContainer.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/ComposingView.java b/src/com/android/inputmethod/pinyin/ComposingView.java
similarity index 98%
rename from PinyinIME/src/com/android/inputmethod/pinyin/ComposingView.java
rename to src/com/android/inputmethod/pinyin/ComposingView.java
index b781cda..f70af45 100644
--- a/PinyinIME/src/com/android/inputmethod/pinyin/ComposingView.java
+++ b/src/com/android/inputmethod/pinyin/ComposingView.java
@@ -264,6 +264,7 @@
             mPaint.setColor(mStrColorIdle);
             int oriPos = activeCmpsLen;
             if (cursorPos > activeCmpsLen) {
+                if (cursorPos > cmpsStr.length()) cursorPos = cmpsStr.length();
                 canvas.drawText(cmpsStr, oriPos, cursorPos, x, y, mPaint);
                 x += mPaint.measureText(cmpsStr, oriPos, cursorPos);
 
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/EnglishInputProcessor.java b/src/com/android/inputmethod/pinyin/EnglishInputProcessor.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/EnglishInputProcessor.java
rename to src/com/android/inputmethod/pinyin/EnglishInputProcessor.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/Environment.java b/src/com/android/inputmethod/pinyin/Environment.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/Environment.java
rename to src/com/android/inputmethod/pinyin/Environment.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/InputModeSwitcher.java b/src/com/android/inputmethod/pinyin/InputModeSwitcher.java
similarity index 97%
rename from PinyinIME/src/com/android/inputmethod/pinyin/InputModeSwitcher.java
rename to src/com/android/inputmethod/pinyin/InputModeSwitcher.java
index 96b59c3..7167182 100644
--- a/PinyinIME/src/com/android/inputmethod/pinyin/InputModeSwitcher.java
+++ b/src/com/android/inputmethod/pinyin/InputModeSwitcher.java
@@ -543,9 +543,6 @@
                 english = true;
             } else if (v == EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
                 mShortMessageField = true;
-            } else if ((editorInfo.imeOptions &
-                    EditorInfo.IME_MASK_ACTION) == EditorInfo.IME_ACTION_SEARCH) {
-                newInputMode = MODE_HKB_CHINESE;
             }
             break;
         default:
@@ -594,13 +591,10 @@
                     || v == EditorInfo.TYPE_TEXT_VARIATION_URI) {
                 // If the application request English mode, we switch to it.
                 newInputMode = MODE_SKB_ENGLISH_LOWER;
-            } else if (v == EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
-                newInputMode = MODE_SKB_CHINESE;
-                mShortMessageField = true;
-            } else if ((editorInfo.imeOptions &
-                    EditorInfo.IME_MASK_ACTION) == EditorInfo.IME_ACTION_SEARCH) {
-                newInputMode = MODE_SKB_CHINESE;
             } else {
+                if (v == EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
+                    mShortMessageField = true;
+                }
                 // If the application do not request English mode, we will
                 // try to keep the previous mode.
                 int skbLayout = (mInputMode & MASK_SKB_LAYOUT);
@@ -615,7 +609,17 @@
             }
             break;
         default:
-            newInputMode = MODE_SKB_CHINESE;
+            // Try to keep the previous mode.
+            int skbLayout = (mInputMode & MASK_SKB_LAYOUT);
+            newInputMode = mInputMode;
+            if (0 == skbLayout) {
+                if ((mInputMode & MASK_LANGUAGE) == MASK_LANGUAGE_CN) {
+                    newInputMode = MODE_SKB_CHINESE;
+                } else {
+                    newInputMode = MODE_SKB_ENGLISH_LOWER;
+                }
+            }
+            break;
         }
 
         mEditorInfo = editorInfo;
@@ -708,7 +712,7 @@
         mInputMode = newInputMode;
 
         int skbLayout = (mInputMode & MASK_SKB_LAYOUT);
-        if (MASK_SKB_LAYOUT_QWERTY == skbLayout) {
+        if (MASK_SKB_LAYOUT_QWERTY == skbLayout || 0 == skbLayout) {
             mRecentLauageInputMode = mInputMode;
         }
 
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/KeyMapDream.java b/src/com/android/inputmethod/pinyin/KeyMapDream.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/KeyMapDream.java
rename to src/com/android/inputmethod/pinyin/KeyMapDream.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/PinyinDecoderService.java b/src/com/android/inputmethod/pinyin/PinyinDecoderService.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/PinyinDecoderService.java
rename to src/com/android/inputmethod/pinyin/PinyinDecoderService.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/PinyinIME.java b/src/com/android/inputmethod/pinyin/PinyinIME.java
similarity index 95%
rename from PinyinIME/src/com/android/inputmethod/pinyin/PinyinIME.java
rename to src/com/android/inputmethod/pinyin/PinyinIME.java
index 8d7dcce..9ac2c2d 100644
--- a/PinyinIME/src/com/android/inputmethod/pinyin/PinyinIME.java
+++ b/src/com/android/inputmethod/pinyin/PinyinIME.java
@@ -235,17 +235,7 @@
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
-        int count = event.getRepeatCount();
-        if (0 == count) {
-            if (processKey(event, false)) return true;
-        } else {
-            boolean processed = false;
-            while (count > 0) {
-                processed |= processKey(event, true);
-                count--;
-            }
-            if (processed) return true;
-        }
+        if (processKey(event, 0 != event.getRepeatCount())) return true;
         return super.onKeyDown(keyCode, event);
     }
 
@@ -265,7 +255,7 @@
             if (!realAction) return true;
 
             updateIcon(mInputModeSwitcher.switchLanguageWithHkb());
-            resetToIdleState(true);
+            resetToIdleState(false);
 
             int allMetaState = KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON
                     | KeyEvent.META_ALT_RIGHT_ON | KeyEvent.META_SHIFT_ON
@@ -462,6 +452,27 @@
 
     private boolean processStateInput(int keyChar, int keyCode, KeyEvent event,
             boolean realAction) {
+        // If ALT key is pressed, input alternative key. But if the
+        // alternative key is quote key, it will be used for input a splitter
+        // in Pinyin string.
+        if (event.isAltPressed()) {
+            if ('\'' != event.getUnicodeChar(event.getMetaState())) {
+                if (realAction) {
+                    char fullwidth_char = KeyMapDream.getChineseLabel(keyCode);
+                    if (0 != fullwidth_char) {
+                        commitResultText(mDecInfo
+                                .getCurrentFullSent(mCandidatesContainer
+                                        .getActiveCandiatePos()) +
+                                        String.valueOf(fullwidth_char));
+                        resetToIdleState(false);
+                    }
+                }
+                return true;
+            } else {
+                keyChar = '\'';
+            }
+        }
+
         if (keyChar >= 'a' && keyChar <= 'z' || keyChar == '\''
                 && !mDecInfo.charBeforeCursorIsSeparator()
                 || keyCode == KeyEvent.KEYCODE_DEL) {
@@ -513,13 +524,13 @@
             if (!realAction) return true;
             if (mInputModeSwitcher.isEnterNoramlState()) {
                 commitResultText(mDecInfo.getOrigianlSplStr().toString());
-                resetToIdleState(true);
+                resetToIdleState(false);
             } else {
                 commitResultText(mDecInfo
                         .getCurrentFullSent(mCandidatesContainer
                                 .getActiveCandiatePos()));
                 sendKeyChar('\n');
-                resetToIdleState(true);
+                resetToIdleState(false);
             }
             return true;
         } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER
@@ -529,7 +540,7 @@
             return true;
         } else if (keyCode == KeyEvent.KEYCODE_BACK) {
             if (!realAction) return true;
-            resetToIdleState(true);
+            resetToIdleState(false);
             requestHideSelf(0);
             return true;
         }
@@ -540,6 +551,18 @@
             KeyEvent event, boolean realAction) {
         if (!realAction) return true;
 
+        // If ALT key is pressed, input alternative key.
+        if (event.isAltPressed()) {
+            char fullwidth_char = KeyMapDream.getChineseLabel(keyCode);
+            if (0 != fullwidth_char) {
+                commitResultText(mDecInfo.getCandidate(mCandidatesContainer
+                                .getActiveCandiatePos()) +
+                                String.valueOf(fullwidth_char));
+                resetToIdleState(false);
+            }
+            return true;
+        }
+
         // In this status, when user presses keys in [a..z], the status will
         // change to input state.
         if (keyChar >= 'a' && keyChar <= 'z') {
@@ -569,7 +592,7 @@
         } else if (keyCode == KeyEvent.KEYCODE_BACK) {
             resetToIdleState(false);
             requestHideSelf(0);
-        } else if (keyCode >= KeyEvent.KEYCODE_1 
+        } else if (keyCode >= KeyEvent.KEYCODE_1
                 && keyCode <= KeyEvent.KEYCODE_9) {
             int activePos = keyCode - KeyEvent.KEYCODE_1;
             int currentPage = mCandidatesContainer.getCurrentPage();
@@ -595,6 +618,32 @@
             KeyEvent event, boolean realAction) {
         if (!realAction) return true;
 
+        ComposingView.ComposingStatus cmpsvStatus =
+                mComposingView.getComposingStatus();
+
+        // If ALT key is pressed, input alternative key. But if the
+        // alternative key is quote key, it will be used for input a splitter
+        // in Pinyin string.
+        if (event.isAltPressed()) {
+            if ('\'' != event.getUnicodeChar(event.getMetaState())) {
+                char fullwidth_char = KeyMapDream.getChineseLabel(keyCode);
+                if (0 != fullwidth_char) {
+                    String retStr;
+                    if (ComposingView.ComposingStatus.SHOW_STRING_LOWERCASE ==
+                            cmpsvStatus) {
+                        retStr = mDecInfo.getOrigianlSplStr().toString();
+                    } else {
+                        retStr = mDecInfo.getComposingStr();
+                    }
+                    commitResultText(retStr + String.valueOf(fullwidth_char));
+                    resetToIdleState(false);
+                }
+                return true;
+            } else {
+                keyChar = '\'';
+            }
+        }
+
         if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
             if (!mDecInfo.selectionFinished()) {
                 changeToStateInput(true);
@@ -606,9 +655,6 @@
                 .isEnterNoramlState())
                 || keyCode == KeyEvent.KEYCODE_DPAD_CENTER
                 || keyCode == KeyEvent.KEYCODE_SPACE) {
-            ComposingView.ComposingStatus cmpsvStatus = mComposingView
-                    .getComposingStatus();
-
             if (ComposingView.ComposingStatus.SHOW_STRING_LOWERCASE == cmpsvStatus) {
                 String str = mDecInfo.getOrigianlSplStr().toString();
                 if (!tryInputRawUnicode(str)) {
@@ -734,7 +780,7 @@
 
     private void commitResultText(String resultText) {
         InputConnection ic = getCurrentInputConnection();
-        if (null != ic) ic.commitText(resultText, resultText.length());
+        if (null != ic) ic.commitText(resultText, 1);
         if (null != mComposingView) {
             mComposingView.setVisibility(View.INVISIBLE);
             mComposingView.invalidate();
@@ -929,7 +975,7 @@
 
         if (sKey.isUserDefKey()) {
             updateIcon(mInputModeSwitcher.switchModeForUserKey(keyCode));
-            resetToIdleState(true);
+            resetToIdleState(false);
             mSkbContainer.updateInputMode();
         } else {
             if (sKey.isKeyCodeKey()) {
@@ -968,7 +1014,7 @@
             // back to the previous soft keyboard automatically.
             if (!mSkbContainer.isCurrentSkbSticky()) {
                 updateIcon(mInputModeSwitcher.requestBackToPreviousSkb());
-                resetToIdleState(true);
+                resetToIdleState(false);
                 mSkbContainer.updateInputMode();
             }
         }
@@ -1689,9 +1735,13 @@
         }
 
         public String getCurrentFullSent(int activeCandPos) {
-            String retStr = mFullSent.substring(0, mFixedLen);
-            retStr += mCandidatesList.get(activeCandPos);
-            return retStr;
+            try {
+                String retStr = mFullSent.substring(0, mFixedLen);
+                retStr += mCandidatesList.get(activeCandPos);
+                return retStr;
+            } catch (Exception e) {
+                return "";
+            }
         }
 
         public void resetCandidates() {
@@ -1818,6 +1868,9 @@
                 }
             } catch (RemoteException e) {
                 Log.w(TAG, "PinyinDecoderService died", e);
+            } catch (Exception e) {
+                mTotalChoicesNum = 0;
+                mComposingStr = "";
             }
             // Prepare page 0.
             if (!mFinishSelection) {
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/Settings.java b/src/com/android/inputmethod/pinyin/Settings.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/Settings.java
rename to src/com/android/inputmethod/pinyin/Settings.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SettingsActivity.java b/src/com/android/inputmethod/pinyin/SettingsActivity.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SettingsActivity.java
rename to src/com/android/inputmethod/pinyin/SettingsActivity.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SkbContainer.java b/src/com/android/inputmethod/pinyin/SkbContainer.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SkbContainer.java
rename to src/com/android/inputmethod/pinyin/SkbContainer.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SkbPool.java b/src/com/android/inputmethod/pinyin/SkbPool.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SkbPool.java
rename to src/com/android/inputmethod/pinyin/SkbPool.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SkbTemplate.java b/src/com/android/inputmethod/pinyin/SkbTemplate.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SkbTemplate.java
rename to src/com/android/inputmethod/pinyin/SkbTemplate.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SoftKey.java b/src/com/android/inputmethod/pinyin/SoftKey.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SoftKey.java
rename to src/com/android/inputmethod/pinyin/SoftKey.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyToggle.java b/src/com/android/inputmethod/pinyin/SoftKeyToggle.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyToggle.java
rename to src/com/android/inputmethod/pinyin/SoftKeyToggle.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboard.java b/src/com/android/inputmethod/pinyin/SoftKeyboard.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboard.java
rename to src/com/android/inputmethod/pinyin/SoftKeyboard.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboardView.java b/src/com/android/inputmethod/pinyin/SoftKeyboardView.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboardView.java
rename to src/com/android/inputmethod/pinyin/SoftKeyboardView.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/SoundManager.java b/src/com/android/inputmethod/pinyin/SoundManager.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/SoundManager.java
rename to src/com/android/inputmethod/pinyin/SoundManager.java
diff --git a/PinyinIME/src/com/android/inputmethod/pinyin/XmlKeyboardLoader.java b/src/com/android/inputmethod/pinyin/XmlKeyboardLoader.java
similarity index 100%
rename from PinyinIME/src/com/android/inputmethod/pinyin/XmlKeyboardLoader.java
rename to src/com/android/inputmethod/pinyin/XmlKeyboardLoader.java