diff --git a/app/src/main/java/org/sirekanyan/outline/ui/AboutDialog.kt b/app/src/main/java/org/sirekanyan/outline/ui/AboutDialog.kt index f21ac99..6e52cbb 100644 --- a/app/src/main/java/org/sirekanyan/outline/ui/AboutDialog.kt +++ b/app/src/main/java/org/sirekanyan/outline/ui/AboutDialog.kt @@ -1,6 +1,7 @@ package org.sirekanyan.outline.ui import android.content.Intent +import android.content.Intent.ACTION_SENDTO import android.net.Uri import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.fillMaxWidth @@ -8,6 +9,7 @@ import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.ClickableText import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Email import androidx.compose.material.icons.filled.Info import androidx.compose.material3.AlertDialog import androidx.compose.material3.Icon @@ -16,8 +18,11 @@ import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextOverflow @@ -25,6 +30,8 @@ import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import org.sirekanyan.outline.BuildConfig import org.sirekanyan.outline.R +import org.sirekanyan.outline.ext.logDebug +import org.sirekanyan.outline.ext.showToast import org.sirekanyan.outline.ui.icons.IconOpenInNew import org.sirekanyan.outline.ui.icons.IconPlayStore @@ -57,24 +64,41 @@ fun AboutDialogContent(onDismiss: () -> Unit) { onDismissRequest = onDismiss, confirmButton = { val context = LocalContext.current + val clipboard = LocalClipboardManager.current + AboutItem(Icons.Default.Email, "Send feedback") { + val email = "outline@sirekanyan.org" + val intent = Intent(ACTION_SENDTO, Uri.parse("mailto:$email")) + try { + context.startActivity(intent) + } catch (exception: Exception) { + logDebug("Cannot find email app", exception) + clipboard.setText(AnnotatedString(email)) + context.showToast("Email is copied") + } + } val playUri = "https://play.google.com/store/apps/details?id=${context.packageName}" - TextButton( - onClick = { - context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(playUri))) - onDismiss() - }, - modifier = Modifier.fillMaxWidth().heightIn(min = 56.dp), - border = BorderStroke(1.dp, MaterialTheme.colorScheme.primary), - ) { - Icon(IconPlayStore, null, Modifier.padding(horizontal = 4.dp)) - Text( - text = "Rate on Play Store", - modifier = Modifier.weight(1f).padding(horizontal = 8.dp), - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - Icon(IconOpenInNew, null, Modifier.padding(horizontal = 8.dp)) + AboutItem(IconPlayStore, "Rate on Play Store") { + context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(playUri))) + onDismiss() } }, ) } + +@Composable +private fun AboutItem(icon: ImageVector, text: String, onClick: () -> Unit) { + TextButton( + onClick = onClick, + modifier = Modifier.fillMaxWidth().heightIn(min = 56.dp), + border = BorderStroke(1.dp, MaterialTheme.colorScheme.primary), + ) { + Icon(icon, null, Modifier.padding(horizontal = 4.dp)) + Text( + text = text, + modifier = Modifier.weight(1f).padding(horizontal = 8.dp), + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + Icon(IconOpenInNew, null, Modifier.padding(horizontal = 8.dp)) + } +}