Add candidates of manually picked suggestions
Change-Id: Ieed585be5f4e88509cdcc31f5d82474cb06add6amain
parent
0175d7da21
commit
dd58fe92d1
|
@ -83,7 +83,6 @@ public class CandidateView extends View {
|
||||||
private int mDescent;
|
private int mDescent;
|
||||||
private boolean mScrolled;
|
private boolean mScrolled;
|
||||||
private boolean mShowingAddToDictionary;
|
private boolean mShowingAddToDictionary;
|
||||||
private CharSequence mWordToAddToDictionary;
|
|
||||||
private CharSequence mAddToDictionaryHint;
|
private CharSequence mAddToDictionaryHint;
|
||||||
|
|
||||||
private int mTargetScrollX;
|
private int mTargetScrollX;
|
||||||
|
@ -220,7 +219,6 @@ public class CandidateView extends View {
|
||||||
}
|
}
|
||||||
int x = 0;
|
int x = 0;
|
||||||
final int count = Math.min(mSuggestions.size(), MAX_SUGGESTIONS);
|
final int count = Math.min(mSuggestions.size(), MAX_SUGGESTIONS);
|
||||||
final int width = getWidth();
|
|
||||||
final Rect bgPadding = mBgPadding;
|
final Rect bgPadding = mBgPadding;
|
||||||
final Paint paint = mPaint;
|
final Paint paint = mPaint;
|
||||||
final int touchX = mTouchX;
|
final int touchX = mTouchX;
|
||||||
|
@ -325,7 +323,6 @@ public class CandidateView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddToDictionaryHint(CharSequence word) {
|
public void showAddToDictionaryHint(CharSequence word) {
|
||||||
mWordToAddToDictionary = word;
|
|
||||||
ArrayList<CharSequence> suggestions = new ArrayList<CharSequence>();
|
ArrayList<CharSequence> suggestions = new ArrayList<CharSequence>();
|
||||||
suggestions.add(word);
|
suggestions.add(word);
|
||||||
suggestions.add(mAddToDictionaryHint);
|
suggestions.add(mAddToDictionaryHint);
|
||||||
|
@ -377,7 +374,13 @@ public class CandidateView extends View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* package */ List<CharSequence> getSuggestions() {
|
||||||
|
return mSuggestions;
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
// Don't call mSuggestions.clear() because it's being used for logging
|
||||||
|
// in LatinIME.pickSuggestionManually().
|
||||||
mSuggestions = EMPTY_LIST;
|
mSuggestions = EMPTY_LIST;
|
||||||
mTouchX = OUT_OF_BOUNDS;
|
mTouchX = OUT_OF_BOUNDS;
|
||||||
mSelectedString = null;
|
mSelectedString = null;
|
||||||
|
|
|
@ -1521,6 +1521,7 @@ public class LatinIME extends InputMethodService
|
||||||
|
|
||||||
public void pickSuggestionManually(int index, CharSequence suggestion) {
|
public void pickSuggestionManually(int index, CharSequence suggestion) {
|
||||||
if (mAfterVoiceInput && mShowingVoiceSuggestions) mVoiceInput.logNBestChoose(index);
|
if (mAfterVoiceInput && mShowingVoiceSuggestions) mVoiceInput.logNBestChoose(index);
|
||||||
|
List<CharSequence> suggestions = mCandidateView.getSuggestions();
|
||||||
|
|
||||||
if (mAfterVoiceInput && !mShowingVoiceSuggestions) {
|
if (mAfterVoiceInput && !mShowingVoiceSuggestions) {
|
||||||
mVoiceInput.flushAllTextModificationCounters();
|
mVoiceInput.flushAllTextModificationCounters();
|
||||||
|
@ -1554,8 +1555,8 @@ public class LatinIME extends InputMethodService
|
||||||
|| isSuggestedPunctuation(suggestion.charAt(0)))) {
|
|| isSuggestedPunctuation(suggestion.charAt(0)))) {
|
||||||
// Word separators are suggested before the user inputs something.
|
// Word separators are suggested before the user inputs something.
|
||||||
// So, LatinImeLogger logs "" as a user's input.
|
// So, LatinImeLogger logs "" as a user's input.
|
||||||
LatinImeLogger.logOnClickSuggestion(
|
LatinImeLogger.logOnManualSuggestion(
|
||||||
"", suggestion.toString(), index);
|
"", suggestion.toString(), index, suggestions);
|
||||||
onKey(suggestion.charAt(0), null);
|
onKey(suggestion.charAt(0), null);
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
ic.endBatchEdit();
|
ic.endBatchEdit();
|
||||||
|
@ -1568,8 +1569,8 @@ public class LatinIME extends InputMethodService
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED);
|
checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED);
|
||||||
}
|
}
|
||||||
LatinImeLogger.logOnClickSuggestion(
|
LatinImeLogger.logOnManualSuggestion(mComposing.toString(), suggestion.toString(),
|
||||||
mComposing.toString(), suggestion.toString(), index);
|
index, suggestions);
|
||||||
TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion);
|
TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion);
|
||||||
// Follow it with a space
|
// Follow it with a space
|
||||||
if (mAutoSpace) {
|
if (mAutoSpace) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private static final String TAG = "LatinIMELogs";
|
private static final String TAG = "LatinIMELogs";
|
||||||
|
@ -47,7 +48,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
private static final long MINIMUMSENDSIZE = 40;
|
private static final long MINIMUMSENDSIZE = 40;
|
||||||
private static final char SEPARATER = ';';
|
private static final char SEPARATER = ';';
|
||||||
private static final char NULL_CHAR = '\uFFFC';
|
private static final char NULL_CHAR = '\uFFFC';
|
||||||
private static final int ID_CLICKSUGGESTION = 0;
|
private static final int ID_MANUALSUGGESTION = 0;
|
||||||
private static final int ID_AUTOSUGGESTIONCANCELLED = 1;
|
private static final int ID_AUTOSUGGESTIONCANCELLED = 1;
|
||||||
private static final int ID_AUTOSUGGESTION = 2;
|
private static final int ID_AUTOSUGGESTION = 2;
|
||||||
private static final int ID_INPUT_COUNT = 3;
|
private static final int ID_INPUT_COUNT = 3;
|
||||||
|
@ -58,7 +59,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
private static final int ID_SETTING_AUTO_COMPLETE = 8;
|
private static final int ID_SETTING_AUTO_COMPLETE = 8;
|
||||||
private static final int ID_VERSION = 9;
|
private static final int ID_VERSION = 9;
|
||||||
private static final int ID_EXCEPTION = 10;
|
private static final int ID_EXCEPTION = 10;
|
||||||
private static final int ID_SUGGESTIONCOUNT = 11;
|
private static final int ID_MANUALSUGGESTIONCOUNT = 11;
|
||||||
|
private static final int ID_AUTOSUGGESTIONCANCELLEDCOUNT = 12;
|
||||||
|
private static final int ID_AUTOSUGGESTIONCOUNT = 13;
|
||||||
|
|
||||||
private static final String PREF_ENABLE_LOG = "enable_logging";
|
private static final String PREF_ENABLE_LOG = "enable_logging";
|
||||||
private static final String PREF_DEBUG_MODE = "debug_mode";
|
private static final String PREF_DEBUG_MODE = "debug_mode";
|
||||||
|
@ -88,6 +91,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
private int mInputCount;
|
private int mInputCount;
|
||||||
private int mWordCount;
|
private int mWordCount;
|
||||||
private int[] mAutoSuggestCountPerDic = new int[Suggest.DIC_TYPE_LAST_ID + 1];
|
private int[] mAutoSuggestCountPerDic = new int[Suggest.DIC_TYPE_LAST_ID + 1];
|
||||||
|
private int[] mManualSuggestCountPerDic = new int[Suggest.DIC_TYPE_LAST_ID + 1];
|
||||||
private int mAutoCancelledCount;
|
private int mAutoCancelledCount;
|
||||||
// ActualCharCount includes all characters that were completed.
|
// ActualCharCount includes all characters that were completed.
|
||||||
private int mActualCharCount;
|
private int mActualCharCount;
|
||||||
|
@ -126,6 +130,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
mWordCount = 0;
|
mWordCount = 0;
|
||||||
mActualCharCount = 0;
|
mActualCharCount = 0;
|
||||||
Arrays.fill(mAutoSuggestCountPerDic, 0);
|
Arrays.fill(mAutoSuggestCountPerDic, 0);
|
||||||
|
Arrays.fill(mManualSuggestCountPerDic, 0);
|
||||||
mAutoCancelledCount = 0;
|
mAutoCancelledCount = 0;
|
||||||
mLogBuffer = new ArrayList<LogEntry>();
|
mLogBuffer = new ArrayList<LogEntry>();
|
||||||
mPrivacyLogBuffer = new ArrayList<LogEntry>();
|
mPrivacyLogBuffer = new ArrayList<LogEntry>();
|
||||||
|
@ -147,6 +152,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
mWordCount = 0;
|
mWordCount = 0;
|
||||||
mActualCharCount = 0;
|
mActualCharCount = 0;
|
||||||
Arrays.fill(mAutoSuggestCountPerDic, 0);
|
Arrays.fill(mAutoSuggestCountPerDic, 0);
|
||||||
|
Arrays.fill(mManualSuggestCountPerDic, 0);
|
||||||
mAutoCancelledCount = 0;
|
mAutoCancelledCount = 0;
|
||||||
mLogBuffer.clear();
|
mLogBuffer.clear();
|
||||||
mPrivacyLogBuffer.clear();
|
mPrivacyLogBuffer.clear();
|
||||||
|
@ -191,12 +197,22 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
if (sLOGPRINT) {
|
if (sLOGPRINT) {
|
||||||
Log.d(TAG, "log suggest counts. (1)");
|
Log.d(TAG, "log suggest counts. (1)");
|
||||||
}
|
}
|
||||||
String[] s = new String[mAutoSuggestCountPerDic.length + 1];
|
String[] s = new String[mAutoSuggestCountPerDic.length];
|
||||||
s[0] = String.valueOf(mAutoCancelledCount);
|
for (int i = 0; i < s.length; ++i) {
|
||||||
for (int i = 1; i < s.length; ++i) {
|
s[i] = String.valueOf(mAutoSuggestCountPerDic[i]);
|
||||||
s[i] = String.valueOf(mAutoSuggestCountPerDic[i - 1]);
|
|
||||||
}
|
}
|
||||||
mLogBuffer.add(new LogEntry(time, ID_SUGGESTIONCOUNT, s));
|
mLogBuffer.add(new LogEntry(time, ID_AUTOSUGGESTIONCOUNT, s));
|
||||||
|
|
||||||
|
mLogBuffer.add(new LogEntry(time, ID_AUTOSUGGESTIONCANCELLEDCOUNT,
|
||||||
|
new String[] {String.valueOf(mAutoCancelledCount)}));
|
||||||
|
s = new String[mManualSuggestCountPerDic.length];
|
||||||
|
for (int i = 0; i < s.length; ++i) {
|
||||||
|
s[i] = String.valueOf(mManualSuggestCountPerDic[i]);
|
||||||
|
}
|
||||||
|
mLogBuffer.add(new LogEntry(time, ID_MANUALSUGGESTIONCOUNT, s));
|
||||||
|
Arrays.fill(mAutoSuggestCountPerDic, 0);
|
||||||
|
Arrays.fill(mManualSuggestCountPerDic, 0);
|
||||||
|
mAutoCancelledCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addThemeIdEntry(long time) {
|
private void addThemeIdEntry(long time) {
|
||||||
|
@ -272,7 +288,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
mInputCount += (Integer)data;
|
mInputCount += (Integer)data;
|
||||||
break;
|
break;
|
||||||
case ID_CLICKSUGGESTION:
|
case ID_MANUALSUGGESTION:
|
||||||
case ID_AUTOSUGGESTION:
|
case ID_AUTOSUGGESTION:
|
||||||
++mWordCount;
|
++mWordCount;
|
||||||
String[] dataStrings = (String[]) data;
|
String[] dataStrings = (String[]) data;
|
||||||
|
@ -354,7 +370,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
private void commitInternalAndStopSelf() {
|
private void commitInternalAndStopSelf() {
|
||||||
Log.e(TAG, "Exception was caused and let's die.");
|
Log.e(TAG, "Exception was caused and let's die.");
|
||||||
commitInternal();
|
commitInternal();
|
||||||
((LatinIME) mContext).stopSelf();
|
LatinIME ime = ((LatinIME) mContext);
|
||||||
|
ime.hideWindow();
|
||||||
|
ime.stopSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void sendLogToDropBox(int tag, Object s) {
|
private synchronized void sendLogToDropBox(int tag, Object s) {
|
||||||
|
@ -416,14 +434,36 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Handle CharSequence instead of String
|
// TODO: Handle CharSequence instead of String
|
||||||
public static void logOnClickSuggestion(String before, String after, int position) {
|
public static void logOnManualSuggestion(String before, String after, int position
|
||||||
|
, List<CharSequence> suggestions) {
|
||||||
if (sLogEnabled) {
|
if (sLogEnabled) {
|
||||||
|
if (!sSuggestDicMap.containsKey(after)) {
|
||||||
|
if (DBG) {
|
||||||
|
Log.e(TAG, "logOnManualSuggestion was cancelled: came from unknown source.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int dicTypeId = sSuggestDicMap.get(after);
|
||||||
|
sLatinImeLogger.mManualSuggestCountPerDic[dicTypeId]++;
|
||||||
|
sSuggestDicMap.clear();
|
||||||
|
if (dicTypeId != Suggest.DIC_MAIN) {
|
||||||
|
if (DBG) {
|
||||||
|
Log.d(TAG, "logOnManualSuggestion was cancelled: didn't come from main dic.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (before.equals(after)) {
|
if (before.equals(after)) {
|
||||||
before = "";
|
before = "";
|
||||||
after = "";
|
after = "";
|
||||||
}
|
}
|
||||||
String[] strings = new String[] {before, after, String.valueOf(position)};
|
String[] strings = new String[3 + suggestions.size()];
|
||||||
sLatinImeLogger.sendLogToDropBox(ID_CLICKSUGGESTION, strings);
|
strings[0] = before;
|
||||||
|
strings[1] = after;
|
||||||
|
strings[2] = String.valueOf(position);
|
||||||
|
for (int i = 0; i < suggestions.size(); ++i) {
|
||||||
|
strings[i + 3] = suggestions.get(i).toString();
|
||||||
|
}
|
||||||
|
sLatinImeLogger.sendLogToDropBox(ID_MANUALSUGGESTION, strings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue