From d34347bd4b8e196f0935e432951e5c7136ad235f Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Thu, 31 Jan 2013 14:47:36 -0800 Subject: [PATCH] [Rlog79b] Save channel name during internal use The feedback string is used as a channel name in internal builds. Add a flag that lets it be saved between calls to make it easier to generate test data. Change-Id: I5c6149b1e68239cd968b6852d03cc240ddde99ca --- .../research/FeedbackFragment.java | 4 +-- .../inputmethod/research/ResearchLogger.java | 35 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/java/src/com/android/inputmethod/research/FeedbackFragment.java b/java/src/com/android/inputmethod/research/FeedbackFragment.java index 69ddf82ea..39f9c87a0 100644 --- a/java/src/com/android/inputmethod/research/FeedbackFragment.java +++ b/java/src/com/android/inputmethod/research/FeedbackFragment.java @@ -36,8 +36,8 @@ import com.android.inputmethod.latin.R; public class FeedbackFragment extends Fragment implements OnClickListener { private static final String TAG = FeedbackFragment.class.getSimpleName(); - private static final String KEY_FEEDBACK_STRING = "FeedbackString"; - private static final String KEY_INCLUDE_ACCOUNT_NAME = "IncludeAccountName"; + public static final String KEY_FEEDBACK_STRING = "FeedbackString"; + public static final String KEY_INCLUDE_ACCOUNT_NAME = "IncludeAccountName"; public static final String KEY_HAS_USER_RECORDING = "HasRecording"; private EditText mEditText; diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 096f03202..535ce28f4 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() {