diff --git a/app/src/main/java/com/battlelancer/seriesguide/preferences/AboutActivity.kt b/app/src/main/java/com/battlelancer/seriesguide/preferences/AboutActivity.kt index c6a25ffa62..20c1a98913 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/preferences/AboutActivity.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/preferences/AboutActivity.kt @@ -4,10 +4,26 @@ import android.os.Bundle import android.view.MenuItem import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.annotation.StringRes +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SmallTopAppBar import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import com.battlelancer.seriesguide.R import com.battlelancer.seriesguide.ui.SeriesGuidePreferences +import com.battlelancer.seriesguide.util.Utils import com.google.android.material.composethemeadapter3.Mdc3Theme /** @@ -21,20 +37,59 @@ class AboutActivity : ComponentActivity() { setContent { Mdc3Theme { - About() + About( + onBackPressed = { onBackPressed() }, + onOpenWebsite = { viewUrl(R.string.url_website) }, + onOpenPrivacyPolicy = { viewUrl(R.string.url_privacy) } + ) } } } + @OptIn(ExperimentalMaterial3Api::class) @Composable - fun About() { - Text(text = "About SeriesGuide") + fun About( + onBackPressed: () -> Unit, + onOpenWebsite: () -> Unit, + onOpenPrivacyPolicy: () -> Unit + ) { + Scaffold( + topBar = { + SmallTopAppBar( + title = { Text(text = stringResource(id = R.string.prefs_category_about)) }, + navigationIcon = { + IconButton(onClick = onBackPressed) { + Icon( + imageVector = Icons.Filled.ArrowBack, + contentDescription = stringResource(id = R.string.navigate_back) + ) + } + } + ) + }, + content = { scaffoldPadding -> + Box(modifier = Modifier.padding(scaffoldPadding)) { + Column() { + Button(onClick = onOpenWebsite) { + Text(text = stringResource(id = R.string.website)) + } + Button(onClick = onOpenPrivacyPolicy) { + Text(text = stringResource(id = R.string.privacy_policy)) + } + } + } + } + ) } @Preview @Composable fun AboutPreview() { - About() + About( + {}, + {}, + {} + ) } // private fun setupActionBar() { @@ -53,4 +108,8 @@ class AboutActivity : ComponentActivity() { } } + private fun viewUrl(@StringRes urlResId: Int) { + Utils.launchWebsite(this, getString(urlResId)) + } + } \ No newline at end of file