Merge "Add logging for UI"
commit
b2447f73bc
|
@ -59,7 +59,7 @@
|
|||
android:persistent="true"
|
||||
android:entryValues="@array/keyboard_layout_modes_values"
|
||||
android:entries="@array/keyboard_layout_modes"
|
||||
android:defaultValue="2"
|
||||
android:defaultValue="3"
|
||||
/>
|
||||
|
||||
<PreferenceScreen
|
||||
|
|
|
@ -46,6 +46,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
public static final int KEYBOARDMODE_IM = R.id.mode_im;
|
||||
public static final int KEYBOARDMODE_WEB = R.id.mode_webentry;
|
||||
|
||||
public static final String DEFAULT_LAYOUT_ID = "3";
|
||||
public static final String PREF_KEYBOARD_LAYOUT = "keyboard_layout";
|
||||
private static final int[] LAYOUTS = new int [] {
|
||||
R.layout.input, R.layout.input2, R.layout.input3, R.layout.input4, R.layout.input5,
|
||||
R.layout.input6
|
||||
};
|
||||
|
||||
private static final int SYMBOLS_MODE_STATE_NONE = 0;
|
||||
private static final int SYMBOLS_MODE_STATE_BEGIN = 1;
|
||||
private static final int SYMBOLS_MODE_STATE_SYMBOL = 2;
|
||||
|
@ -57,12 +64,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
KEYBOARDMODE_EMAIL,
|
||||
KEYBOARDMODE_IM,
|
||||
KEYBOARDMODE_WEB};
|
||||
private static final String PREF_KEYBOARD_LAYOUT = "keyboard_layout";
|
||||
private static final int[] LAYOUTS = new int [] {
|
||||
R.layout.input, R.layout.input2, R.layout.input3, R.layout.input4, R.layout.input5,
|
||||
R.layout.input6
|
||||
};
|
||||
private static final String DEFAULT_LAYOUT_ID = "0";
|
||||
|
||||
Context mContext;
|
||||
LatinIME mInputMethodService;
|
||||
|
|
|
@ -32,7 +32,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
// DEFAULT_LOG_ENABLED should be false when released to public.
|
||||
private static final boolean DEFAULT_LOG_ENABLED = true;
|
||||
|
||||
private static final long MINIMUMSENDINTERVAL = 60 * DateUtils.SECOND_IN_MILLIS; // 60 sec
|
||||
private static final long MINIMUMSENDINTERVAL = 300 * DateUtils.SECOND_IN_MILLIS; // 300 sec
|
||||
private static final long MINIMUMCOUNTINTERVAL = 20 * DateUtils.SECOND_IN_MILLIS; // 20 sec
|
||||
private static final char SEPARATER = ';';
|
||||
private static final int ID_CLICKSUGGESTION = 0;
|
||||
|
@ -42,6 +42,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
private static final int ID_DELETE_COUNT = 4;
|
||||
private static final int ID_WORD_COUNT = 5;
|
||||
private static final int ID_ACTUAL_CHAR_COUNT = 6;
|
||||
private static final int ID_THEME_ID = 7;
|
||||
|
||||
private static final String PREF_ENABLE_LOG = "enable_log";
|
||||
|
||||
|
@ -60,6 +61,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
private long mLastTimeSend;
|
||||
private long mLastTimeCountEntry;
|
||||
|
||||
private String mThemeId;
|
||||
private int mDeleteCount;
|
||||
private int mInputCount;
|
||||
private int mWordCount;
|
||||
|
@ -103,6 +105,8 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
mPrivacyLogBuffer = new ArrayList<LogEntry>();
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sLogEnabled = prefs.getBoolean(PREF_ENABLE_LOG, DEFAULT_LOG_ENABLED);
|
||||
mThemeId = prefs.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,
|
||||
KeyboardSwitcher.DEFAULT_LAYOUT_ID);
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
|
@ -140,8 +144,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
|
||||
private void addCountEntry(long time) {
|
||||
mLogBuffer.add(
|
||||
new LogEntry (time, ID_DELETE_COUNT,
|
||||
mLogBuffer.add(new LogEntry (time, ID_DELETE_COUNT,
|
||||
new String[] {String.valueOf(mDeleteCount)}));
|
||||
mLogBuffer.add(new LogEntry (time, ID_INPUT_COUNT,
|
||||
new String[] {String.valueOf(mInputCount)}));
|
||||
|
@ -155,6 +158,11 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
mActualCharCount = 0;
|
||||
}
|
||||
|
||||
private void addThemeIdEntry(long time) {
|
||||
mLogBuffer.add(new LogEntry (time, ID_THEME_ID,
|
||||
new String[] {mThemeId}));
|
||||
}
|
||||
|
||||
private void flushPrivacyLogSafely() {
|
||||
long now = System.currentTimeMillis();
|
||||
Collections.sort(mPrivacyLogBuffer);
|
||||
|
@ -176,6 +184,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
if (mLastTimeActive - mLastTimeCountEntry > MINIMUMCOUNTINTERVAL
|
||||
|| (mDeleteCount == 0 && mInputCount == 0)) {
|
||||
addCountEntry(mLastTimeActive);
|
||||
addThemeIdEntry(mLastTimeActive);
|
||||
}
|
||||
mDeleteCount += (Integer)data;
|
||||
break;
|
||||
|
@ -183,6 +192,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
if (mLastTimeActive - mLastTimeCountEntry > MINIMUMCOUNTINTERVAL
|
||||
|| (mDeleteCount == 0 && mInputCount == 0)) {
|
||||
addCountEntry(mLastTimeActive);
|
||||
addThemeIdEntry(mLastTimeActive);
|
||||
}
|
||||
mInputCount += (Integer)data;
|
||||
break;
|
||||
|
@ -223,14 +233,16 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
|
||||
private void commitInternal() {
|
||||
flushPrivacyLogSafely();
|
||||
addCountEntry(System.currentTimeMillis());
|
||||
long now = System.currentTimeMillis();
|
||||
addCountEntry(now);
|
||||
addThemeIdEntry(now);
|
||||
String s = LogSerializer.createStringFromEntries(mLogBuffer);
|
||||
if (DBG) {
|
||||
Log.d(TAG, "Commit log: " + s);
|
||||
}
|
||||
mDropBox.addText(TAG, s);
|
||||
reset();
|
||||
mLastTimeSend = System.currentTimeMillis();
|
||||
mLastTimeSend = now;
|
||||
}
|
||||
|
||||
private synchronized void sendLogToDropBox(int tag, Object s) {
|
||||
|
@ -260,6 +272,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
} else {
|
||||
sLogEnabled = false;
|
||||
}
|
||||
} else if (KeyboardSwitcher.PREF_KEYBOARD_LAYOUT.equals(key)) {
|
||||
mThemeId = sharedPreferences.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,
|
||||
KeyboardSwitcher.DEFAULT_LAYOUT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue