From e930bcb9688c2fecd92482e482e10fe25e4d07b6 Mon Sep 17 00:00:00 2001 From: euxane Date: Wed, 18 Sep 2024 23:41:13 +0200 Subject: activities/base: add optional documentation link in error dialogs --- .../java/org/pacien/tincapp/activities/BaseActivity.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt index 18787a8..6f18565 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt @@ -98,7 +98,18 @@ abstract class BaseActivity : AppCompatActivity() { fun notify(@StringRes msg: Int) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show() fun notify(msg: String) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show() - fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) - .setTitle(R.string.generic_title_error).setMessage(msg) - .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit }.show() + fun showErrorDialog(@StringRes msg: Int, docTopic: String? = null) = + showErrorDialog(getString(msg), docTopic) + + fun showErrorDialog(msg: String, docTopic: String? = null): AlertDialog = + AlertDialog.Builder(this) + .setTitle(R.string.generic_title_error).setMessage(msg) + .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit } + .apply { + if (docTopic != null) + setNeutralButton(R.string.notification_error_action_open_manual) { _, _ -> + App.openURL(getString(R.string.app_doc_url_format, docTopic)) + } + } + .show() } -- cgit v1.2.3