From dbb8b75a4bd201f8472a511ef77ca2ed05bd808b Mon Sep 17 00:00:00 2001 From: Paul Westbrook Date: Thu, 11 Jul 2013 10:49:25 -0700 Subject: [PATCH] Fix feedback from Email settings Bug: 9428466 Change-Id: I6816976b858a6a15da7d643320983208287a463a --- .../email/activity/setup/AccountSettings.java | 21 +++++++++++++++++-- .../android/email/provider/EmailProvider.java | 5 ++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/com/android/email/activity/setup/AccountSettings.java b/src/com/android/email/activity/setup/AccountSettings.java index 0d8a1f87c..fbea8586c 100644 --- a/src/com/android/email/activity/setup/AccountSettings.java +++ b/src/com/android/email/activity/setup/AccountSettings.java @@ -118,6 +118,8 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl private long mDeletingAccountId = -1; private boolean mShowDebugMenu; private List
mGeneratedHeaders; + private Uri mFeedbackUri; + private MenuItem mFeedbackMenuItem; // Async Tasks private LoadAccountListTask mLoadAccountListTask; @@ -223,6 +225,8 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl updateAccounts(); } }; + + mFeedbackUri = Utils.getValidUri(getString(R.string.email_feedback_uri)); } @Override @@ -268,9 +272,23 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.settings_menu, menu); + + mFeedbackMenuItem = menu.findItem(R.id.feedback_menu_item); return true; } + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + super.onPrepareOptionsMenu(menu); + + if (mFeedbackMenuItem != null) { + // We only want to enable the feedback menu item, if there is a valid feedback uri + mFeedbackMenuItem.setVisible(!Uri.EMPTY.equals(mFeedbackUri)); + } + return true; + } + + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -285,8 +303,7 @@ public class AccountSettings extends PreferenceActivity implements FeedbackEnabl onAddNewAccount(); break; case R.id.feedback_menu_item: - final Uri feedbackUri = Utils.getValidUri(getString(R.string.email_feedback_uri)); - Utils.sendFeedback(this, feedbackUri, false /* reportingProblem */); + Utils.sendFeedback(this, mFeedbackUri, false /* reportingProblem */); break; default: return super.onOptionsItemSelected(item); diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 1563fa879..e81f986f6 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -2036,7 +2036,10 @@ public class EmailProvider extends ContentProvider { final String feedbackUri = context.getString(R.string.email_feedback_uri); if (!TextUtils.isEmpty(feedbackUri)) { - builder.add(UIProvider.AccountColumns.SEND_FEEDBACK_INTENT_URI, feedbackUri); + // This string needs to be in single quotes, as it will be used as a constant + // in a sql expression + builder.add(UIProvider.AccountColumns.SEND_FEEDBACK_INTENT_URI, + "'" + feedbackUri + "'"); } sAccountListMap = builder.build();