-
-
Notifications
You must be signed in to change notification settings - Fork 135
Add basic About page for app #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fe745c8
Add basic About page for app
tylxr59 015b279
Privacy policy now links to PRIVACY.md
tylxr59 ad21e2a
Strings cleanup
tylxr59 332c0ed
Add more logo formats (including ImageVector)
Stypox 81fef7e
Another version of the about screen
Stypox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
187 changes: 187 additions & 0 deletions
187
app/src/main/kotlin/org/stypox/dicio/ui/about/AboutScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| @file:OptIn(ExperimentalMaterial3Api::class) | ||
|
|
||
| package org.stypox.dicio.ui.about | ||
|
|
||
| import androidx.annotation.StringRes | ||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.layout.wrapContentSize | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.filled.BugReport | ||
| import androidx.compose.material.icons.filled.Code | ||
| import androidx.compose.material.icons.filled.ContentCopy | ||
| import androidx.compose.material.icons.filled.Group | ||
| import androidx.compose.material.icons.filled.Policy | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.TopAppBar | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.vector.ImageVector | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.font.FontWeight | ||
| import androidx.compose.ui.text.style.TextAlign | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import org.stypox.dicio.BuildConfig | ||
| import org.stypox.dicio.R | ||
| import org.stypox.dicio.error.ErrorActivity | ||
| import org.stypox.dicio.settings.ui.SettingsItem | ||
| import org.stypox.dicio.ui.theme.AppTheme | ||
| import org.stypox.dicio.util.ShareUtils | ||
|
|
||
| @Composable | ||
| fun AboutScreen( | ||
| navigationIcon: @Composable () -> Unit, | ||
| ) { | ||
| val context = LocalContext.current | ||
|
|
||
| Scaffold( | ||
| topBar = { | ||
| TopAppBar( | ||
| title = { Text(stringResource(R.string.about)) }, | ||
| navigationIcon = navigationIcon, | ||
| ) | ||
| }, | ||
| ) { paddingValues -> | ||
| LazyColumn( | ||
| contentPadding = PaddingValues(bottom = 4.dp), | ||
| modifier = Modifier.padding(paddingValues) | ||
| ) { | ||
| item { | ||
| Column( | ||
| modifier = Modifier | ||
| .padding(start = 16.dp, end = 16.dp, bottom = 16.dp) | ||
| .fillMaxWidth() | ||
| .wrapContentSize(Alignment.Center), | ||
| horizontalAlignment = Alignment.CenterHorizontally | ||
| ) { | ||
| Image( | ||
| imageVector = DicioSquircleIcon, | ||
| contentDescription = stringResource(R.string.app_name), | ||
| modifier = Modifier.size(64.dp) | ||
| ) | ||
| Spacer(Modifier.height(4.dp)) | ||
| Text( | ||
| text = stringResource(R.string.app_name), | ||
| style = MaterialTheme.typography.titleLarge, | ||
| textAlign = TextAlign.Center | ||
| ) | ||
| val versionTextSizeUnit = MaterialTheme.typography.titleMedium.fontSize.value.dp | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.spacedBy(versionTextSizeUnit * 0.25f), | ||
| modifier = Modifier.clickable( | ||
| onClickLabel = stringResource(R.string.about_version_copy) | ||
| ) { ShareUtils.copyToClipboard(context, getVersionInfoString()) } | ||
| ) { | ||
| Text( | ||
| text = stringResource( | ||
| R.string.about_version, | ||
| BuildConfig.VERSION_NAME, | ||
| BuildConfig.VERSION_CODE | ||
| ), | ||
| style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Light), | ||
| textAlign = TextAlign.Center | ||
| ) | ||
| Icon( | ||
| imageVector = Icons.Default.ContentCopy, | ||
| contentDescription = null, | ||
| modifier = Modifier.size(versionTextSizeUnit * 0.8f) | ||
| ) | ||
| } | ||
| Text( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| text = stringResource(R.string.about_description), | ||
| textAlign = TextAlign.Center | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| item { | ||
| AboutItem( | ||
| title = R.string.about_repository_title, | ||
| icon = Icons.Default.Code, | ||
| description = R.string.about_repository_description, | ||
| link = R.string.about_repository_link | ||
| ) | ||
| } | ||
|
|
||
| item { | ||
| AboutItem( | ||
| title = R.string.about_issues_title, | ||
| icon = Icons.Default.BugReport, | ||
| description = R.string.about_issues_description, | ||
| link = R.string.about_issues_link | ||
| ) | ||
| } | ||
|
|
||
| item { | ||
| AboutItem( | ||
| title = R.string.about_contributing_title, | ||
| icon = Icons.Default.Group, | ||
| description = R.string.about_contributing_description, | ||
| link = R.string.about_contributing_link | ||
| ) | ||
| } | ||
|
|
||
| item { | ||
| AboutItem( | ||
| title = R.string.about_privacy_title, | ||
| icon = Icons.Default.Policy, | ||
| description = R.string.about_privacy_description, | ||
| link = R.string.about_privacy_link | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| fun AboutItem( | ||
| @StringRes title: Int, | ||
| icon: ImageVector, | ||
| @StringRes description: Int, | ||
| @StringRes link: Int | ||
| ) { | ||
| val context = LocalContext.current | ||
| SettingsItem( | ||
| title = stringResource(title), | ||
| icon = icon, | ||
| description = stringResource(description), | ||
| modifier = Modifier.clickable { | ||
| ShareUtils.openUrlInBrowser(context, context.getString(link)) | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| private fun getVersionInfoString(): String { | ||
| return "${BuildConfig.APPLICATION_ID} ${BuildConfig.VERSION_NAME} (" + | ||
| "${BuildConfig.VERSION_CODE}) running on ${ErrorActivity.getOsInfo()}" | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun AboutScreenPreview() { | ||
| AppTheme { | ||
| AboutScreen( | ||
| navigationIcon = {}, | ||
| ) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this page could be simplified by creating a helper function for each category. Might be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I did that now, good idea