From ddc1a634aff318448b56154e293462641a7768e8 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 24 Oct 2024 15:33:15 -0400 Subject: [PATCH 1/5] First pass at warning A8C users --- .../android/ui/ActivityLauncher.java | 24 +++++++++++++++++++ WordPress/src/main/res/values/strings.xml | 2 ++ 2 files changed, 26 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java index 25516bc695c5..60892cfe7638 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java @@ -16,6 +16,8 @@ import androidx.core.app.TaskStackBuilder; import androidx.fragment.app.Fragment; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import org.wordpress.android.BuildConfig; import org.wordpress.android.R; import org.wordpress.android.WordPress; @@ -1311,6 +1313,9 @@ public static void viewHelp(@NonNull Context context, @NonNull Origin origin, @N } public static void viewFeedbackForm(@NonNull Context context) { + if (warnIfIdentityA8C(context)) { + return; + } // TODO verify tracks event with iOS AnalyticsTracker.track(Stat.FEEDBACK_FORM_OPENED); Intent intent = new Intent(context, FeedbackFormActivity.class); @@ -1322,6 +1327,25 @@ public static void viewZendeskTickets(@NonNull Context context, viewHelpInNewStack(context, Origin.ZENDESK_NOTIFICATION, selectedSite, null); } + /** + * Warn A8C users that they can't create Zendesk tickets, returns true if warning shown + */ + @NonNull + private static Boolean warnIfIdentityA8C(@NonNull Context context) { + String supportEmail = "nbradbury@automattic.com"; // TODO AppPrefs.getSupportEmail(); + if (supportEmail.contains("@automattic.com")) { + new MaterialAlertDialogBuilder(context) + .setTitle(R.string.warning) + .setMessage(R.string.support_warn_if_user_a8c) + .setPositiveButton(R.string.close, (dialog, id) -> { + dialog.dismiss(); + }) + .show(); + return true; + } + return false; + } + public static void viewSSLCerts(Context context, String certificateString) { Intent intent = new Intent(context, SSLCertsViewActivity.class); intent.putExtra(SSLCertsViewActivity.CERT_DETAILS_KEYS, certificateString.replaceAll("\n", "
")); diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 71bef371351f..09c6660d9450 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -112,6 +112,7 @@ Free Dismiss Sending + Warning Not now Skip @@ -1143,6 +1144,7 @@ Unable to create temporary file Add attachments If you need support, please get in touch using the \"Help & Support\" screen + Automattic email account detected. Please login with a non-Automattic email to submit or view support tickets. Remove item %1$d From 9f0645dc0f6fca70265e6ea80856761a131523f3 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 24 Oct 2024 15:43:13 -0400 Subject: [PATCH 2/5] Second pass at warning A8C users --- .../java/org/wordpress/android/ui/ActivityLauncher.java | 2 +- .../java/org/wordpress/android/ui/accounts/HelpActivity.kt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java index 60892cfe7638..4b1ccdf3b895 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java @@ -1331,7 +1331,7 @@ public static void viewZendeskTickets(@NonNull Context context, * Warn A8C users that they can't create Zendesk tickets, returns true if warning shown */ @NonNull - private static Boolean warnIfIdentityA8C(@NonNull Context context) { + public static Boolean warnIfIdentityA8C(@NonNull Context context) { String supportEmail = "nbradbury@automattic.com"; // TODO AppPrefs.getSupportEmail(); if (supportEmail.contains("@automattic.com")) { new MaterialAlertDialogBuilder(context) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt index c804645a87fe..22c28d58a5c0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt @@ -169,6 +169,9 @@ class HelpActivity : LocaleAwareActivity() { } private fun launchSupportWidget() { + if (ActivityLauncher.warnIfIdentityA8C(this)) { + return + } val intent = SupportWebViewActivity.createIntent( this, originFromExtras, @@ -179,6 +182,9 @@ class HelpActivity : LocaleAwareActivity() { } private fun createNewZendeskTicket() { + if (ActivityLauncher.warnIfIdentityA8C(this)) { + return + } zendeskHelper.createNewTicket( this, originFromExtras, From 0fc0f742e62e2dfb86e2465d6e97e0ada103a514 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 24 Oct 2024 15:47:20 -0400 Subject: [PATCH 3/5] Make warning non-blocking --- .../org/wordpress/android/ui/ActivityLauncher.java | 10 +++------- .../org/wordpress/android/ui/accounts/HelpActivity.kt | 9 +++------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java index 4b1ccdf3b895..c635ea3a165d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java @@ -1313,9 +1313,7 @@ public static void viewHelp(@NonNull Context context, @NonNull Origin origin, @N } public static void viewFeedbackForm(@NonNull Context context) { - if (warnIfIdentityA8C(context)) { - return; - } + warnIfIdentityA8C(context); // TODO verify tracks event with iOS AnalyticsTracker.track(Stat.FEEDBACK_FORM_OPENED); Intent intent = new Intent(context, FeedbackFormActivity.class); @@ -1328,10 +1326,10 @@ public static void viewZendeskTickets(@NonNull Context context, } /** - * Warn A8C users that they can't create Zendesk tickets, returns true if warning shown + * Warn A8C users that they can't create Zendesk tickets */ @NonNull - public static Boolean warnIfIdentityA8C(@NonNull Context context) { + public static void warnIfIdentityA8C(@NonNull Context context) { String supportEmail = "nbradbury@automattic.com"; // TODO AppPrefs.getSupportEmail(); if (supportEmail.contains("@automattic.com")) { new MaterialAlertDialogBuilder(context) @@ -1341,9 +1339,7 @@ public static Boolean warnIfIdentityA8C(@NonNull Context context) { dialog.dismiss(); }) .show(); - return true; } - return false; } public static void viewSSLCerts(Context context, String certificateString) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt index 22c28d58a5c0..d2fdeeaa7964 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt @@ -169,9 +169,7 @@ class HelpActivity : LocaleAwareActivity() { } private fun launchSupportWidget() { - if (ActivityLauncher.warnIfIdentityA8C(this)) { - return - } + ActivityLauncher.warnIfIdentityA8C(this) val intent = SupportWebViewActivity.createIntent( this, originFromExtras, @@ -182,9 +180,7 @@ class HelpActivity : LocaleAwareActivity() { } private fun createNewZendeskTicket() { - if (ActivityLauncher.warnIfIdentityA8C(this)) { - return - } + ActivityLauncher.warnIfIdentityA8C(this) zendeskHelper.createNewTicket( this, originFromExtras, @@ -199,6 +195,7 @@ class HelpActivity : LocaleAwareActivity() { } private fun showZendeskTickets() { + ActivityLauncher.warnIfIdentityA8C(this) zendeskHelper.showAllTickets( this, originFromExtras, From f4b78ed73f7d4fde62254270bbd5d9f501c3ec69 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 24 Oct 2024 15:48:48 -0400 Subject: [PATCH 4/5] Include @a8c --- .../main/java/org/wordpress/android/ui/ActivityLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java index c635ea3a165d..df3c3fd6e368 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java @@ -1331,7 +1331,7 @@ public static void viewZendeskTickets(@NonNull Context context, @NonNull public static void warnIfIdentityA8C(@NonNull Context context) { String supportEmail = "nbradbury@automattic.com"; // TODO AppPrefs.getSupportEmail(); - if (supportEmail.contains("@automattic.com")) { + if (supportEmail.contains("@automattic.com") || supportEmail.contains("@a8c.com")) { new MaterialAlertDialogBuilder(context) .setTitle(R.string.warning) .setMessage(R.string.support_warn_if_user_a8c) From 0cf121a76d74260b7bf1b6422151c5a98aa40f13 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 24 Oct 2024 15:56:41 -0400 Subject: [PATCH 5/5] Use a toast instead of a dialog --- .../org/wordpress/android/ui/ActivityLauncher.java | 14 ++++---------- WordPress/src/main/res/values/strings.xml | 3 +-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java index df3c3fd6e368..58ffda36dcf1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java @@ -16,8 +16,6 @@ import androidx.core.app.TaskStackBuilder; import androidx.fragment.app.Fragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.BuildConfig; import org.wordpress.android.R; import org.wordpress.android.WordPress; @@ -97,6 +95,7 @@ import org.wordpress.android.ui.posts.PostsListActivity; import org.wordpress.android.ui.posts.RemotePreviewLogicHelper.RemotePreviewType; import org.wordpress.android.ui.prefs.AccountSettingsActivity; +import org.wordpress.android.ui.prefs.AppPrefs; import org.wordpress.android.ui.prefs.AppSettingsActivity; import org.wordpress.android.ui.prefs.BlogPreferencesActivity; import org.wordpress.android.ui.prefs.MyProfileActivity; @@ -129,6 +128,7 @@ import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.ToastUtils; +import org.wordpress.android.util.ToastUtils.Duration; import org.wordpress.android.util.UriWrapper; import org.wordpress.android.util.UrlUtils; import org.wordpress.android.util.WPActivityUtils; @@ -1330,15 +1330,9 @@ public static void viewZendeskTickets(@NonNull Context context, */ @NonNull public static void warnIfIdentityA8C(@NonNull Context context) { - String supportEmail = "nbradbury@automattic.com"; // TODO AppPrefs.getSupportEmail(); + String supportEmail = AppPrefs.getSupportEmail(); if (supportEmail.contains("@automattic.com") || supportEmail.contains("@a8c.com")) { - new MaterialAlertDialogBuilder(context) - .setTitle(R.string.warning) - .setMessage(R.string.support_warn_if_user_a8c) - .setPositiveButton(R.string.close, (dialog, id) -> { - dialog.dismiss(); - }) - .show(); + ToastUtils.showToast(context, R.string.support_warn_if_user_a8c, Duration.LONG); } } diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 09c6660d9450..da67d914d3ab 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -112,7 +112,6 @@ Free Dismiss Sending - Warning Not now Skip @@ -1144,7 +1143,7 @@ Unable to create temporary file Add attachments If you need support, please get in touch using the \"Help & Support\" screen - Automattic email account detected. Please login with a non-Automattic email to submit or view support tickets. + Automattic email accounts can\'t submit or view support tickets Remove item %1$d