From 32ea128da0d297e1754ad710cd2f5881526cd760 Mon Sep 17 00:00:00 2001 From: Hee Tatt Ooi <hee.tatt.ooi@sap.com> Date: Fri, 19 Jun 2020 16:25:39 +0200 Subject: [PATCH] =?UTF-8?q?Specific=20error=20message=20for=20pending=20Go?= =?UTF-8?q?ogle=20Play=20Services=20and=20Google=20Mo=E2=80=A6=20(#648)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Specific error message for pending Google Play Services and Google Mobile Services update * Added details to error message * adjusted links * added final strings * fixed ktlint issues Co-authored-by: Jakob Möller <jakob.moeller@sap.com> Co-authored-by: Muschko <marc.muschko@sap.com> Co-authored-by: Philipp Woessner <philipp.woessner@sap.com> --- .../reporting/ErrorReportReceiver.kt | 14 ++++++----- .../exception/reporting/ExceptionReporter.kt | 24 +++++++++++++++---- .../exception/reporting/ReportingConstants.kt | 2 ++ .../de/rki/coronawarnapp/util/DialogHelper.kt | 9 +++---- .../src/main/res/values-de/strings.xml | 3 ++- .../src/main/res/values-en/strings.xml | 2 ++ .../src/main/res/values/strings.xml | 2 ++ 7 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt index ff37fe4dd..22654e28d 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt @@ -36,20 +36,22 @@ class ErrorReportReceiver(private val activity: Activity) : BroadcastReceiver() message = context.resources.getString(resId) } + val stack = intent.getStringExtra(ReportingConstants.ERROR_REPORT_STACK_EXTRA) + val title = context.resources.getString(R.string.errors_generic_headline) + val confirm = context.resources.getString(R.string.errors_generic_button_positive) + val details = context.resources.getString(R.string.errors_generic_button_negative) + + var detailsTitle = context.resources.getString(R.string.errors_generic_details_headline) + if (intent.hasExtra(ReportingConstants.ERROR_REPORT_API_EXCEPTION_CODE)) { val apiStatusCode = intent.getIntExtra( ReportingConstants.ERROR_REPORT_API_EXCEPTION_CODE, ErrorCodes.REPORTED_EXCEPTION_UNKNOWN_PROBLEM.code ) + message += "($apiStatusCode)" } - val stack = intent.getStringExtra(ReportingConstants.ERROR_REPORT_STACK_EXTRA) - val title = context.resources.getString(R.string.errors_generic_headline) - val confirm = context.resources.getString(R.string.errors_generic_button_positive) - val details = context.resources.getString(R.string.errors_generic_button_negative) - val detailsTitle = context.resources.getString(R.string.errors_generic_details_headline) - val errorTitle = context.resources.getString(R.string.errors_generic_details_headline) .toUpperCase(Locale.ROOT) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt index 3ad303932..1d0e0cac0 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt @@ -6,6 +6,7 @@ import com.google.android.gms.common.api.ApiException import de.rki.coronawarnapp.CoronaWarnApplication import de.rki.coronawarnapp.R import de.rki.coronawarnapp.exception.ExceptionCategory +import de.rki.coronawarnapp.exception.reporting.ReportingConstants.STATUS_CODE_GOOGLE_UPDATE_NEEDED import java.io.PrintWriter import java.io.StringWriter @@ -28,20 +29,33 @@ fun Throwable.report( this.resId?.let { intent.putExtra(ReportingConstants.ERROR_REPORT_RES_ID, it) } } + var stackExtra = "" + // override the message with a generic one if it is an ApiException if (this is ApiException) { + + var errorMessage = R.string.errors_communication_with_api + + if (this.statusCode == STATUS_CODE_GOOGLE_UPDATE_NEEDED) { + errorMessage = R.string.errors_google_update_needed + } + intent.putExtra( ReportingConstants.ERROR_REPORT_RES_ID, - R.string.errors_communication_with_api + errorMessage ) intent.putExtra(ReportingConstants.ERROR_REPORT_CODE_EXTRA, ErrorCodes.API_EXCEPTION.code) intent.putExtra(ReportingConstants.ERROR_REPORT_API_EXCEPTION_CODE, this.statusCode) } - val sw = StringWriter() - this.printStackTrace() - this.printStackTrace(PrintWriter(sw)) - intent.putExtra(ReportingConstants.ERROR_REPORT_STACK_EXTRA, sw.toString()) + if (stackExtra.isEmpty()) { + val sw = StringWriter() + this.printStackTrace() + this.printStackTrace(PrintWriter(sw)) + stackExtra = sw.toString() + } + + intent.putExtra(ReportingConstants.ERROR_REPORT_STACK_EXTRA, stackExtra) LocalBroadcastManager.getInstance(CoronaWarnApplication.getAppContext()).sendBroadcast(intent) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt index be711c013..446fa7ba2 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt @@ -11,4 +11,6 @@ object ReportingConstants { const val ERROR_REPORT_API_EXCEPTION_CODE = "api-exception-code" const val ERROR_REPORT_RES_ID = "res-id" val ERROR_REPORT_UNKNOWN_ERROR = ErrorCodes.REPORTED_EXCEPTION_UNKNOWN_PROBLEM.code + + const val STATUS_CODE_GOOGLE_UPDATE_NEEDED = 17 } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/DialogHelper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/DialogHelper.kt index 7f3bdd2af..fb3171270 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/DialogHelper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/DialogHelper.kt @@ -1,13 +1,13 @@ package de.rki.coronawarnapp.util import android.app.Activity -import android.app.Activity.RESULT_OK import android.text.SpannableString import android.text.method.LinkMovementMethod import android.text.util.Linkify import android.widget.TextView import androidx.appcompat.app.AlertDialog import de.rki.coronawarnapp.R +import java.util.regex.Pattern object DialogHelper { @@ -92,16 +92,17 @@ object DialogHelper { } private fun getMessage(activity: Activity, message: String?): TextView { - // create spannable and add links + // create spannable and add links, removed stack trace links into nowhere val spannable = SpannableString(message) - Linkify.addLinks(spannable, Linkify.WEB_URLS) + val httpPattern: Pattern = Pattern.compile("[a-z]+://[^ \\n]*") + Linkify.addLinks(spannable, httpPattern, "") // get padding for all sides val paddingStartEnd = activity.resources.getDimension(R.dimen.spacing_normal).toInt() val paddingLeftRight = activity.resources.getDimension(R.dimen.spacing_small).toInt() // create a textview with clickable links from the spannable val textView = TextView(activity) textView.text = spannable - textView.autoLinkMask = RESULT_OK + textView.linksClickable = true textView.movementMethod = LinkMovementMethod.getInstance() textView.setPadding(paddingStartEnd, paddingLeftRight, paddingStartEnd, paddingLeftRight) textView.setTextAppearance(R.style.body1) diff --git a/Corona-Warn-App/src/main/res/values-de/strings.xml b/Corona-Warn-App/src/main/res/values-de/strings.xml index 2288d8e61..3b257b5ed 100644 --- a/Corona-Warn-App/src/main/res/values-de/strings.xml +++ b/Corona-Warn-App/src/main/res/values-de/strings.xml @@ -840,7 +840,6 @@ <string name="submission_contact_step_2_body">"Test per TAN-Eingabe in der App registrieren"</string> <!-- YTXT: Body text for operating hours in contact page--> <string name="submission_contact_operating_hours_body">"Sprachen:\nDeutsch, Englisch, Türkisch\n\nErreichbarkeit:\nMo - So: Täglich 24 Stunden\n\nDer Anruf ist kostenfrei."</string> - <!-- XACT: Submission contact page title --> <string name="submission_contact_accessibility_title">"TAN-Anfrage per Telefonanruf"</string> <!-- XACT: Content Description for submission contact step 1, number has to sync with the display number --> @@ -938,6 +937,8 @@ <string name="errors_communication_with_api">"Fehler bei Kommunikation mit Google API"</string> <!-- XTXT: error dialog - detailed text if there is an error during external navigation / external action --> <string name="errors_external_action">"Diese Aktion ist aktuell leider nicht verfügbar. Bitte kontaktieren Sie die Hotline."</string> + <!-- XTXT: error dialog - phone still needs Google Play Services or Google Mobile Services update --> + <string name="errors_google_update_needed">"Ihre Corona-Warn-App ist korrekt installiert. Leider fehlen Ihrem Smartphone die "Benachrichtigungen zu möglicher Begegnung mit COVID-19-Infizierten" und Sie können die Corona-Warn-App nicht nutzen. Weitere Informationen finden Sie in unseren FAQ: https://www.coronawarn.app/de/faq/ \n"</string> <!-- #################################### Generic Error Messages diff --git a/Corona-Warn-App/src/main/res/values-en/strings.xml b/Corona-Warn-App/src/main/res/values-en/strings.xml index 3d3655093..6a17bd219 100644 --- a/Corona-Warn-App/src/main/res/values-en/strings.xml +++ b/Corona-Warn-App/src/main/res/values-en/strings.xml @@ -937,6 +937,8 @@ <string name="errors_communication_with_api">"Error when communicating with Google API"</string> <!-- XTXT: error dialog - detailed text if there is an error during external navigation / external action --> <string name="errors_external_action">"You cannot perform this action. Please contact the hotline."</string> + <!-- XTXT: error dialog - phone still needs Google Play Services or Google Mobile Services update --> + <string name="errors_google_update_needed">"Your Corona-Warn-App was installed correctly. Unfortunately, COVID-19 Exposure Notifications is currently not available on your device and you cannot use the Corona-Warn-App. Further information is available on our FAQ page: https://www.coronawarn.app/en/faq/ \n"</string> <!-- #################################### Generic Error Messages diff --git a/Corona-Warn-App/src/main/res/values/strings.xml b/Corona-Warn-App/src/main/res/values/strings.xml index 3d3655093..6a17bd219 100644 --- a/Corona-Warn-App/src/main/res/values/strings.xml +++ b/Corona-Warn-App/src/main/res/values/strings.xml @@ -937,6 +937,8 @@ <string name="errors_communication_with_api">"Error when communicating with Google API"</string> <!-- XTXT: error dialog - detailed text if there is an error during external navigation / external action --> <string name="errors_external_action">"You cannot perform this action. Please contact the hotline."</string> + <!-- XTXT: error dialog - phone still needs Google Play Services or Google Mobile Services update --> + <string name="errors_google_update_needed">"Your Corona-Warn-App was installed correctly. Unfortunately, COVID-19 Exposure Notifications is currently not available on your device and you cannot use the Corona-Warn-App. Further information is available on our FAQ page: https://www.coronawarn.app/en/faq/ \n"</string> <!-- #################################### Generic Error Messages -- GitLab