From d3f718fccdd47863a9c564b3e25eba5f95d40bee Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Thu, 31 Jan 2013 14:31:53 -0800 Subject: [PATCH] [Rlog79a] Disallow empty feedback messages Change-Id: I30f7c07606e466c3c9538adad94024d00f0901de --- java/res/values/research_strings.xml | 3 +++ .../research/FeedbackFragment.java | 20 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/java/res/values/research_strings.xml b/java/res/values/research_strings.xml index 2d9dad1cc..f67943eee 100644 --- a/java/res/values/research_strings.xml +++ b/java/res/values/research_strings.xml @@ -23,4 +23,7 @@ + + + The feedback field must not be empty. diff --git a/java/src/com/android/inputmethod/research/FeedbackFragment.java b/java/src/com/android/inputmethod/research/FeedbackFragment.java index 11a833a85..69ddf82ea 100644 --- a/java/src/com/android/inputmethod/research/FeedbackFragment.java +++ b/java/src/com/android/inputmethod/research/FeedbackFragment.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.text.Editable; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -28,6 +29,7 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; +import android.widget.Toast; import com.android.inputmethod.latin.R; @@ -96,12 +98,18 @@ public class FeedbackFragment extends Fragment implements OnClickListener { } else if (view == mSendButton) { final Editable editable = mEditText.getText(); final String feedbackContents = editable.toString(); - final boolean isIncludingAccountName = isIncludingAccountName(); - researchLogger.sendFeedback(feedbackContents, - false /* isIncludingHistory */, isIncludingAccountName, hasUserRecording()); - getActivity().finish(); - researchLogger.setFeedbackDialogBundle(null); - researchLogger.onLeavingSendFeedbackDialog(); + if (TextUtils.isEmpty(feedbackContents)) { + Toast.makeText(getActivity(), + R.string.research_feedback_empty_feedback_error_message, + Toast.LENGTH_LONG).show(); + } else { + final boolean isIncludingAccountName = isIncludingAccountName(); + researchLogger.sendFeedback(feedbackContents, + false /* isIncludingHistory */, isIncludingAccountName, hasUserRecording()); + getActivity().finish(); + researchLogger.setFeedbackDialogBundle(null); + researchLogger.onLeavingSendFeedbackDialog(); + } } else if (view == mCancelButton) { Log.d(TAG, "Finishing"); getActivity().finish();