aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authoreuxane2024-09-18 23:41:13 +0200
committereuxane2024-09-18 23:41:13 +0200
commite930bcb9688c2fecd92482e482e10fe25e4d07b6 (patch)
tree8bb1d1ad2cbe1b4e483953116dd0f5c0b2998a94 /app/src/main
parentb33eee5c34c75688c96d6cd874d82e55dab30491 (diff)
downloadtincapp-e930bcb9688c2fecd92482e482e10fe25e4d07b6.tar.gz
activities/base: add optional documentation link in error dialogs
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt17
1 files changed, 14 insertions, 3 deletions
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() {
98 fun notify(@StringRes msg: Int) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show() 98 fun notify(@StringRes msg: Int) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show()
99 fun notify(msg: String) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show() 99 fun notify(msg: String) = Snackbar.make(rootView, msg, Snackbar.LENGTH_LONG).show()
100 100
101 fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) 101 fun showErrorDialog(@StringRes msg: Int, docTopic: String? = null) =
102 .setTitle(R.string.generic_title_error).setMessage(msg) 102 showErrorDialog(getString(msg), docTopic)
103 .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit }.show() 103
104 fun showErrorDialog(msg: String, docTopic: String? = null): AlertDialog =
105 AlertDialog.Builder(this)
106 .setTitle(R.string.generic_title_error).setMessage(msg)
107 .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit }
108 .apply {
109 if (docTopic != null)
110 setNeutralButton(R.string.notification_error_action_open_manual) { _, _ ->
111 App.openURL(getString(R.string.app_doc_url_format, docTopic))
112 }
113 }
114 .show()
104} 115}