diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/Extensions.kt b/app/src/main/java/pl/szczodrzynski/edziennik/Extensions.kt
index 02dd918b..48076d0b 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/Extensions.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/Extensions.kt
@@ -43,6 +43,8 @@ import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher
import pl.szczodrzynski.edziennik.data.db.modules.teams.Team
import pl.szczodrzynski.edziennik.utils.models.Time
import pl.szczodrzynski.navlib.getColorFromRes
+import java.io.PrintWriter
+import java.io.StringWriter
import java.math.BigInteger
import java.security.MessageDigest
import java.text.SimpleDateFormat
@@ -682,3 +684,10 @@ val String.firstLettersName: String
}
return nameShort
}
+
+val Throwable.stackTraceString: String
+ get() {
+ val sw = StringWriter()
+ printStackTrace(PrintWriter(sw))
+ return sw.toString()
+ }
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt
index 0f184605..66dcd766 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt
@@ -8,9 +8,12 @@ import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.graphics.ColorUtils
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
+import pl.szczodrzynski.edziennik.App
import pl.szczodrzynski.edziennik.R
import pl.szczodrzynski.edziennik.data.api.models.ApiError
+import pl.szczodrzynski.edziennik.stackTraceString
import pl.szczodrzynski.navlib.getColorFromAttr
class ErrorSnackbar(val activity: AppCompatActivity) {
@@ -26,7 +29,22 @@ class ErrorSnackbar(val activity: AppCompatActivity) {
this.coordinator = coordinatorLayout
snackbar = Snackbar.make(coordinator, R.string.snackbar_error_text, Snackbar.LENGTH_INDEFINITE)
snackbar?.setAction(R.string.more) {
+ if (errors.isNotEmpty()) {
+ val message = errors.map {
+ if (App.devMode) it.throwable?.stackTraceString
+ ?: it.throwable?.localizedMessage ?: ""
+ else it.throwable?.localizedMessage
+ }.joinToString("\n")
+ MaterialAlertDialogBuilder(activity)
+ .setTitle(R.string.dialog_error_details_title)
+ .setMessage(message)
+ .setPositiveButton(R.string.ok) { dialog, _ ->
+ errors.clear()
+ dialog.dismiss()
+ }
+ .show()
+ }
}
val bgColor = ColorUtils.compositeColors(
getColorFromAttr(activity, R.attr.colorOnSurface) and 0xcfffffff.toInt(),
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f60689e5..e1dd3e8e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1130,4 +1130,5 @@
Zaloguj się - Edudziennik
Użyj danych, którymi logujesz się do wersji komputerowej Edudziennika.
Logowanie do Edudziennika
+ Szczegóły błędu