diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt index 411996a8f..27291e8c1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt @@ -45,6 +45,7 @@ import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.ui.components.toasts.ThrowableToastMsg +import com.vitorpamplona.amethyst.ui.components.toasts.ThrowableToastMsg2 import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.Size16dp import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer @@ -72,6 +73,27 @@ fun InformationDialog( InformationDialog(title = stringRes(obj.titleResId), textContent = str, moreInfo = stack, buttonColors, onDismiss) } +@Composable +fun InformationDialog( + obj: ThrowableToastMsg2, + buttonColors: ButtonColors = ButtonDefaults.buttonColors(), + onDismiss: () -> Unit, +) { + val str = stringRes(obj.description) + + val stack = + remember(obj) { + val writer = StringWriter() + writer.append("\n") + + obj.throwable.printStackTrace(PrintWriter(writer)) + + writer.toString() + } + + InformationDialog(title = stringRes(obj.titleResId), textContent = str, moreInfo = stack, buttonColors, onDismiss) +} + @Composable fun InformationDialog( title: String, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt index 89c945c91..d7289698d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/DisplayErrorMessages.kt @@ -82,6 +82,12 @@ fun DisplayErrorMessages( } } + is ThrowableToastMsg2 -> { + InformationDialog(obj) { + toastManager.clearToasts() + } + } + is MultiErrorToastMsg -> { MultiUserErrorMessageDialog(obj, accountViewModel, nav) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ThrowableToastMsg.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ThrowableToastMsg.kt index 99d24adaa..4148e4a81 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ThrowableToastMsg.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ThrowableToastMsg.kt @@ -28,3 +28,10 @@ class ThrowableToastMsg( val msg: String? = null, val throwable: Throwable, ) : ToastMsg() + +@Immutable +class ThrowableToastMsg2( + val titleResId: Int, + val description: Int, + val throwable: Throwable, +) : ToastMsg() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ToastManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ToastManager.kt index a19b889a0..dad9a09f8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ToastManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/toasts/ToastManager.kt @@ -62,6 +62,14 @@ class ToastManager { toasts.tryEmit(ThrowableToastMsg(titleResId, message, throwable)) } + fun toast( + titleResId: Int, + description: Int, + throwable: Throwable, + ) { + toasts.tryEmit(ThrowableToastMsg2(titleResId, description, throwable)) + } + fun toast( titleResId: Int, resourceId: Int, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 0e83f65e5..59351fc05 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -962,6 +962,12 @@ class AccountViewModel( Log.w("AccountViewModel", "AutomaticallyUnauthorizedException", e) } catch (e: SignerExceptions.RunningOnBackgroundWithoutAutomaticPermissionException) { Log.w("AccountViewModel", "TimedOutRunningOnBackgroundWithoutAutomaticPermissionExceptionException", e) + } catch (e: IllegalStateException) { + toastManager.toast( + R.string.signer_not_found_exception, + R.string.signer_illegal_state_exception_description, + e, + ) } } } diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index 965229207..216f20f77 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -68,7 +68,8 @@ Signer not found Was the Signer app uninstalled? Check if the signer is installed and has this account. Log off and Log in again of the signer app has changed. - + Signer misbehaved + External signer returned a payload that is strange for the request. There might be a bug on either Amethyst or the Signer. Zaps View count