Clean up ResearchLogger log method

Change-Id: I06c30aab462ce5b17157ff71d5d76f9755178080
This commit is contained in:
Tadashi G. Takaoka 2013-08-01 18:23:06 +09:00
parent b7f6260195
commit 54dd1bed52
2 changed files with 32 additions and 35 deletions

View File

@ -1047,35 +1047,30 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
} }
public boolean processMotionEvent(final MotionEvent me) { public boolean processMotionEvent(final MotionEvent me) {
final int action = me.getActionMasked();
final int pointerCount = me.getPointerCount();
final long eventTime = me.getEventTime();
final int index = me.getActionIndex();
final int id = me.getPointerId(index);
final int x = (int)me.getX(index);
final int y = (int)me.getY(index);
// TODO: This might be moved to the tracker.processMotionEvent() call below.
if (LatinImeLogger.sUsabilityStudy) { if (LatinImeLogger.sUsabilityStudy) {
UsabilityStudyLogUtils.writeMotionEvent(me); UsabilityStudyLogUtils.writeMotionEvent(me);
} }
// TODO: This should be moved to the tracker.processMotionEvent() call below.
// Currently the same "move" event is being logged twice. // Currently the same "move" event is being logged twice.
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.mainKeyboardView_processMotionEvent( ResearchLogger.mainKeyboardView_processMotionEvent(me);
me, action, eventTime, index, id, x, y);
} }
final int action = me.getActionMasked();
final long eventTime = me.getEventTime();
if (action == MotionEvent.ACTION_MOVE) { if (action == MotionEvent.ACTION_MOVE) {
for (int i = 0; i < pointerCount; i++) { final int pointerCount = me.getPointerCount();
final int pointerId = me.getPointerId(i); for (int index = 0; index < pointerCount; index++) {
final PointerTracker tracker = PointerTracker.getPointerTracker( final int id = me.getPointerId(index);
pointerId, this); final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
final int px = (int)me.getX(i); final int x = (int)me.getX(index);
final int py = (int)me.getY(i); final int y = (int)me.getY(index);
tracker.onMoveEvent(px, py, eventTime, me); tracker.onMoveEvent(x, y, eventTime, me);
} }
} else { } else {
final int index = me.getActionIndex();
final int id = me.getPointerId(index);
final int x = (int)me.getX(index);
final int y = (int)me.getY(index);
final PointerTracker tracker = PointerTracker.getPointerTracker(id, this); final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
tracker.processMotionEvent(action, x, y, eventTime, this); tracker.processMotionEvent(action, x, y, eventTime, this);
} }

View File

@ -1066,22 +1066,24 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private static final LogStatement LOGSTATEMENT_MAIN_KEYBOARD_VIEW_PROCESS_MOTION_EVENT = private static final LogStatement LOGSTATEMENT_MAIN_KEYBOARD_VIEW_PROCESS_MOTION_EVENT =
new LogStatement("MotionEvent", true, false, "action", new LogStatement("MotionEvent", true, false, "action",
LogStatement.KEY_IS_LOGGING_RELATED, "motionEvent"); LogStatement.KEY_IS_LOGGING_RELATED, "motionEvent");
public static void mainKeyboardView_processMotionEvent(final MotionEvent me, final int action, public static void mainKeyboardView_processMotionEvent(final MotionEvent me) {
final long eventTime, final int index, final int id, final int x, final int y) { if (me == null) {
if (me != null) { return;
final String actionString = LoggingUtils.getMotionEventActionTypeString(action); }
final ResearchLogger researchLogger = getInstance(); final int action = me.getActionMasked();
researchLogger.enqueueEvent(LOGSTATEMENT_MAIN_KEYBOARD_VIEW_PROCESS_MOTION_EVENT, final long eventTime = me.getEventTime();
actionString, false /* IS_LOGGING_RELATED */, MotionEvent.obtain(me)); final String actionString = LoggingUtils.getMotionEventActionTypeString(action);
if (action == MotionEvent.ACTION_DOWN) { final ResearchLogger researchLogger = getInstance();
// Subtract 1 from eventTime so the down event is included in the later researchLogger.enqueueEvent(LOGSTATEMENT_MAIN_KEYBOARD_VIEW_PROCESS_MOTION_EVENT,
// LogUnit, not the earlier (the test is for inequality). actionString, false /* IS_LOGGING_RELATED */, MotionEvent.obtain(me));
researchLogger.setSavedDownEventTime(eventTime - 1); if (action == MotionEvent.ACTION_DOWN) {
} // Subtract 1 from eventTime so the down event is included in the later
// Refresh the timer in case we are capturing user feedback. // LogUnit, not the earlier (the test is for inequality).
if (researchLogger.isMakingUserRecording()) { researchLogger.setSavedDownEventTime(eventTime - 1);
researchLogger.resetRecordingTimer(); }
} // Refresh the timer in case we are capturing user feedback.
if (researchLogger.isMakingUserRecording()) {
researchLogger.resetRecordingTimer();
} }
} }