aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/research/ResearchLogger.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/research/ResearchLogger.java')
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java71
1 files changed, 61 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index da410010f..364ab2da2 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -115,6 +115,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
// private info.
private static final boolean LOG_FULL_TEXTVIEW_CONTENTS = false
&& ProductionFlag.IS_EXPERIMENTAL_DEBUG;
+ // Whether the feedback dialog preserves the editable text across invocations. Should be false
+ // for normal research builds so users do not have to delete the same feedback string they
+ // entered earlier. Should be true for builds internal to a development team so when the text
+ // field holds a channel name, the developer does not have to re-enter it when using the
+ // feedback mechanism to generate multiple tests.
+ private static final boolean FEEDBACK_DIALOG_SHOULD_PRESERVE_TEXT_FIELD = false;
public static final boolean DEFAULT_USABILITY_STUDY_MODE = false;
/* package */ static boolean sIsLogging = false;
private static final int OUTPUT_FORMAT_VERSION = 5;
@@ -140,6 +146,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private static final String WHITESPACE_SEPARATORS = " \t\n\r";
private static final int MAX_INPUTVIEW_LENGTH_TO_CAPTURE = 8192; // must be >=1
private static final String PREF_RESEARCH_LOGGER_UUID_STRING = "pref_research_logger_uuid";
+ private static final String PREF_RESEARCH_SAVED_CHANNEL = "pref_research_saved_channel";
private static final ResearchLogger sInstance = new ResearchLogger();
private static String sAccountType = null;
@@ -591,12 +598,20 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mFeedbackLogBuffer = null;
mFeedbackLog = null;
- Intent intent = new Intent();
+ final Intent intent = new Intent();
intent.setClass(mLatinIME, FeedbackActivity.class);
- if (mFeedbackDialogBundle != null) {
- Log.d(TAG, "putting extra in feedbackdialogbundle");
- intent.putExtras(mFeedbackDialogBundle);
+ if (mFeedbackDialogBundle == null) {
+ // Restore feedback field with channel name
+ final Bundle bundle = new Bundle();
+ bundle.putBoolean(FeedbackFragment.KEY_INCLUDE_ACCOUNT_NAME, true);
+ bundle.putBoolean(FeedbackFragment.KEY_HAS_USER_RECORDING, false);
+ if (FEEDBACK_DIALOG_SHOULD_PRESERVE_TEXT_FIELD) {
+ final String savedChannelName = mPrefs.getString(PREF_RESEARCH_SAVED_CHANNEL, "");
+ bundle.putString(FeedbackFragment.KEY_FEEDBACK_STRING, savedChannelName);
+ }
+ mFeedbackDialogBundle = bundle;
}
+ intent.putExtras(mFeedbackDialogBundle);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
latinIME.startActivity(intent);
}
@@ -787,6 +802,18 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
}, 1000);
}
+
+ if (FEEDBACK_DIALOG_SHOULD_PRESERVE_TEXT_FIELD) {
+ // Use feedback string as a channel name to label feedback strings. Here we record the
+ // string for prepopulating the field next time.
+ final String channelName = feedbackContents;
+ if (mPrefs == null) {
+ return;
+ }
+ final Editor e = mPrefs.edit();
+ e.putString(PREF_RESEARCH_SAVED_CHANNEL, channelName);
+ e.apply();
+ }
}
public void uploadNow() {
@@ -819,7 +846,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
private boolean isAllowedToLog() {
- return !mIsPasswordView && !mIsLoggingSuspended && sIsLogging && !mInFeedbackDialog;
+ return !mIsPasswordView && !mIsLoggingSuspended && sIsLogging && !mInFeedbackDialog
+ && !isReplaying();
}
public void requestIndicatorRedraw() {
@@ -832,15 +860,30 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mMainKeyboardView.invalidateAllKeys();
}
+ private boolean isReplaying() {
+ return mReplayer.isReplaying();
+ }
+
+ private int getIndicatorColor() {
+ if (isMakingUserRecording()) {
+ return Color.YELLOW;
+ }
+ if (isReplaying()) {
+ return Color.GREEN;
+ }
+ return Color.RED;
+ }
+
public void paintIndicator(KeyboardView view, Paint paint, Canvas canvas, int width,
int height) {
// TODO: Reimplement using a keyboard background image specific to the ResearchLogger
// and remove this method.
// The check for MainKeyboardView ensures that the indicator only decorates the main
// keyboard, not every keyboard.
- if (IS_SHOWING_INDICATOR && isAllowedToLog() && view instanceof MainKeyboardView) {
+ if (IS_SHOWING_INDICATOR && (isAllowedToLog() || isReplaying())
+ && view instanceof MainKeyboardView) {
final int savedColor = paint.getColor();
- paint.setColor(isMakingUserRecording() ? Color.YELLOW : Color.RED);
+ paint.setColor(getIndicatorColor());
final Style savedStyle = paint.getStyle();
paint.setStyle(Style.STROKE);
final float savedStrokeWidth = paint.getStrokeWidth();
@@ -960,15 +1003,23 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
}
+ /**
+ * Publish all the logUnits in the logBuffer, without doing any privacy filtering.
+ */
/* package for test */ void publishLogBuffer(final LogBuffer logBuffer,
- final ResearchLog researchLog, final boolean isIncludingPrivateData) {
- publishLogUnits(logBuffer.getLogUnits(), researchLog, isIncludingPrivateData);
+ final ResearchLog researchLog, final boolean canIncludePrivateData) {
+ publishLogUnits(logBuffer.getLogUnits(), researchLog, canIncludePrivateData);
}
private static final LogStatement LOGSTATEMENT_LOG_SEGMENT_OPENING =
new LogStatement("logSegmentStart", false, false, "isIncludingPrivateData");
private static final LogStatement LOGSTATEMENT_LOG_SEGMENT_CLOSING =
new LogStatement("logSegmentEnd", false, false);
+ /**
+ * Publish all LogUnits in a list.
+ *
+ * Any privacy checks should be performed before calling this method.
+ */
/* package for test */ void publishLogUnits(final List<LogUnit> logUnits,
final ResearchLog researchLog, final boolean canIncludePrivateData) {
final LogUnit openingLogUnit = new LogUnit();
@@ -1349,7 +1400,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
final int index, final String suggestion, final boolean isBatchMode) {
final ResearchLogger researchLogger = getInstance();
if (!replacedWord.equals(suggestion.toString())) {
- // The user choose something other than what was already there.
+ // The user chose something other than what was already there.
researchLogger.setCurrentLogUnitContainsCorrection();
researchLogger.setCurrentLogUnitCorrectionType(LogUnit.CORRECTIONTYPE_TYPO);
}