aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java8
-rw-r--r--native/Android.mk5
-rw-r--r--native/src/bigram_dictionary.cpp2
-rw-r--r--native/src/defines.h11
-rw-r--r--native/src/unigram_dictionary.cpp8
5 files changed, 26 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index 565b01d5a..96225f2e9 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -193,6 +193,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
public void layoutStrip(SuggestedWords suggestions, int maxWidth, int maxCount) {
final int size = suggestions.size();
+ if (size == 0) return;
setupTexts(suggestions, size, mAutoCorrectHighlight);
mCountInStrip = Math.min(maxCount, size);
mScaleX = 1.0f;
@@ -244,7 +245,12 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mTexts.clear();
for (int i = 0; i < count; i++) {
final CharSequence suggestion = suggestions.getWord(i);
- if (suggestion == null) continue;
+ if (suggestion == null) {
+ // Skip an empty suggestion, but we need to add a place-holder for it in order
+ // to avoid an exception in the loop in updateSuggestions().
+ mTexts.add("");
+ continue;
+ }
final boolean isAutoCorrect = suggestions.mHasMinimalSuggestion
&& ((i == 1 && !suggestions.mTypedWordValid)
diff --git a/native/Android.mk b/native/Android.mk
index fc6f19671..bc246a990 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -34,6 +34,10 @@ ifeq ($(FLAG_DBG), true)
TARGETING_UNBUNDLED_FROYO := false
endif
+ifeq ($(FLAG_DO_PROFILE), true)
+ TARGETING_UNBUNDLED_FROYO := false
+endif
+
ifeq ($(TARGETING_UNBUNDLED_FROYO), true)
LOCAL_NDK_VERSION := 4
LOCAL_SDK_VERSION := 8
@@ -46,6 +50,7 @@ LOCAL_MODULE_TAGS := user
ifeq ($(FLAG_DO_PROFILE), true)
$(warning Making profiling version of native library)
LOCAL_CFLAGS += -DFLAG_DO_PROFILE
+ LOCAL_SHARED_LIBRARIES := libcutils libutils
else # FLAG_DO_PROFILE
ifeq ($(FLAG_DBG), true)
$(warning Making debug version of native library)
diff --git a/native/src/bigram_dictionary.cpp b/native/src/bigram_dictionary.cpp
index d11aee28e..6ed4d0982 100644
--- a/native/src/bigram_dictionary.cpp
+++ b/native/src/bigram_dictionary.cpp
@@ -45,8 +45,8 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
#ifdef FLAG_DBG
char s[length + 1];
for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
LOGI("Bigram: Found word = %s, freq = %d :", s, frequency);
+#endif
}
// Find the right insertion point
diff --git a/native/src/defines.h b/native/src/defines.h
index a516190af..bea83b2c5 100644
--- a/native/src/defines.h
+++ b/native/src/defines.h
@@ -18,8 +18,16 @@
#ifndef LATINIME_DEFINES_H
#define LATINIME_DEFINES_H
+#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
+#include <cutils/log.h>
+#else
+#define LOGE(fmt, ...)
+#define LOGI(fmt, ...)
+#endif
+
#ifdef FLAG_DO_PROFILE
// Profiler
+#include <cutils/log.h>
#include <time.h>
#define PROF_BUF_SIZE 100
static double profile_buf[PROF_BUF_SIZE];
@@ -92,8 +100,7 @@ static void prof_out(void) {
#define DEBUG_PROXIMITY_INFO true
#else // FLAG_DBG
-#define LOGE(fmt, ...)
-#define LOGI(fmt, ...)
+
#define DEBUG_DICT false
#define DEBUG_DICT_FULL false
#define DEBUG_SHOW_FOUND_WORD false
diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp
index 698584e54..5e72c764f 100644
--- a/native/src/unigram_dictionary.cpp
+++ b/native/src/unigram_dictionary.cpp
@@ -172,8 +172,8 @@ int UnigramDictionary::getSuggestions(const ProximityInfo *proximityInfo, const
short unsigned int* w = mOutputChars + j * MAX_WORD_LENGTH;
char s[MAX_WORD_LENGTH];
for (int i = 0; i <= MAX_WORD_LENGTH; i++) s[i] = w[i];
-#endif
LOGI("%s %i", s, mFrequencies[j]);
+#endif
}
LOGI("Next letters: ");
for (int k = 0; k < NEXT_LETTERS_SIZE; k++) {
@@ -301,8 +301,8 @@ bool UnigramDictionary::addWord(unsigned short *word, int length, int frequency)
#ifdef FLAG_DBG
char s[length + 1];
for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
LOGI("Found word = %s, freq = %d", s, frequency);
+#endif
}
if (length > MAX_WORD_LENGTH) {
if (DEBUG_DICT) {
@@ -325,8 +325,8 @@ bool UnigramDictionary::addWord(unsigned short *word, int length, int frequency)
#ifdef FLAG_DBG
char s[length + 1];
for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
LOGI("Added word = %s, freq = %d, %d", s, frequency, S_INT_MAX);
+#endif
}
memmove((char*) mFrequencies + (insertAt + 1) * sizeof(mFrequencies[0]),
(char*) mFrequencies + insertAt * sizeof(mFrequencies[0]),
@@ -809,9 +809,9 @@ inline int UnigramDictionary::getMostFrequentWordLike(const int startInputIndex,
char s[inputLength + 1];
for (int i = 0; i < inputLength; ++i) s[i] = word[i];
s[inputLength] = 0;
-#endif
LOGI("New missing space word found: %d > %d (%s), %d, %d",
newFreq, maxFreq, s, inputLength, depth);
+#endif
}
maxFreq = newFreq;
}