Initial release of GPS2Audio
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
package de.waypointaudio.ui
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import de.waypointaudio.R
|
||||
|
||||
/**
|
||||
* Info-Dialog: Zeigt App-Name, Beschreibung, Entwickler, E-Mail, Version
|
||||
* und eine kurze Zusammenfassung der Apache License 2.0.
|
||||
*/
|
||||
@Composable
|
||||
fun AboutDialog(onDismiss: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.about_title),
|
||||
style = MaterialTheme.typography.headlineSmall
|
||||
)
|
||||
},
|
||||
text = {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(vertical = 4.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
// App name + description
|
||||
Text(
|
||||
text = stringResource(R.string.about_app_name),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.about_description),
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
// Version
|
||||
AboutRow(
|
||||
label = stringResource(R.string.about_version_label),
|
||||
value = stringResource(R.string.about_version)
|
||||
)
|
||||
|
||||
// Developer
|
||||
AboutRow(
|
||||
label = stringResource(R.string.about_developer_label),
|
||||
value = stringResource(R.string.about_developer)
|
||||
)
|
||||
|
||||
// Email - preserved exactly as provided by developer
|
||||
AboutRow(
|
||||
label = stringResource(R.string.about_email_label),
|
||||
value = stringResource(R.string.about_email)
|
||||
)
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
// License
|
||||
Text(
|
||||
text = stringResource(R.string.about_license_label),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.about_license_name),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.about_license_summary),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.about_license_url),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
// Matrix contact
|
||||
Text(
|
||||
text = stringResource(R.string.about_matrix_label),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.about_matrix_description),
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
|
||||
// Matrix ID as selectable text
|
||||
Text(
|
||||
text = stringResource(R.string.about_matrix_id),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
|
||||
// QR code
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(top = 4.dp)
|
||||
.background(
|
||||
color = Color.White,
|
||||
shape = MaterialTheme.shapes.small
|
||||
)
|
||||
.padding(8.dp)
|
||||
.align(Alignment.CenterHorizontally)
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.matrix_contact_qr),
|
||||
contentDescription = stringResource(R.string.about_matrix_qr_content_description),
|
||||
modifier = Modifier.size(200.dp)
|
||||
)
|
||||
}
|
||||
|
||||
// Clickable button to open Matrix chat in browser or Matrix client
|
||||
val openCd = stringResource(R.string.about_matrix_open_cd)
|
||||
val matrixUrl = stringResource(R.string.about_matrix_url)
|
||||
Button(
|
||||
onClick = {
|
||||
val intent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse(matrixUrl)
|
||||
)
|
||||
try {
|
||||
context.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// Fallback: explicit chooser for browser
|
||||
try {
|
||||
context.startActivity(Intent.createChooser(intent, null))
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
// No browser/client available - silently ignore
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.semantics { contentDescription = openCd }
|
||||
) {
|
||||
Text(text = stringResource(R.string.about_matrix_open_button))
|
||||
}
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.about_copyright),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text(stringResource(R.string.about_close))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AboutRow(label: String, value: String) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||
)
|
||||
Text(
|
||||
text = value,
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user