Skip to content

Commit

Permalink
Reorder About section on Main screen
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusRodCosta committed Mar 28, 2024
1 parent ced4c3f commit c19a26a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
Expand Down Expand Up @@ -176,27 +181,24 @@ fun HowToUseContent(isLandscape: Boolean = false) {
HowToUseRow(4, stringResource(R.string.how_to_use_step_4))
AppBasicDivider()
AppListHeader(title = stringResource(R.string.how_to_use_about_title))
AboutRow(
AboutRowWithURL(
stringResource(R.string.how_to_use_app_donation),
url = stringResource(R.string.donation_url),
"%s"
)
AboutRowWithURL(
stringResource(R.string.how_to_use_about),
url = stringResource(R.string.github_profile_url)
url = stringResource(R.string.github_profile_url),
"Mateus Rodrigues Costa",
false
)
AboutRow(
String.format(
stringResource(R.string.how_to_use_github), stringResource(

R.string.source_code_url
)
), url = stringResource(R.string.source_code_url)
stringResource(R.string.how_to_use_app_icon_credits)
)
AboutRow(
stringResource(R.string.how_to_use_app_icon_credits), url = null
)
AboutRow(
String.format(
stringResource(R.string.how_to_use_app_donation), stringResource(
R.string.donation_url
)
), url = stringResource(R.string.donation_url)
AboutRowWithURL(
stringResource(R.string.how_to_use_github),
url = stringResource(R.string.source_code_url),
"%s"
)
}
}
Expand All @@ -218,9 +220,8 @@ fun HowToUseRow(num: Int?, string: String) {
}

@Composable
fun AboutRow(string: String, url: String?) {
val localUriHandler = LocalUriHandler.current
GenericRow(onClick = { if (url != null) localUriHandler.openUri(url) }) {
fun AboutRow(string: String) {
GenericRow {
Text(
string,
style = MaterialTheme.typography.bodyLarge,
Expand All @@ -229,6 +230,32 @@ fun AboutRow(string: String, url: String?) {
}
}


@Composable
fun AboutRowWithURL(
string: String, url: String, linkPlacement: String, replaceWithUrl: Boolean = true
) {
val localUriHandler = LocalUriHandler.current
val stringPieces = string.split(linkPlacement)
GenericRow(onClick = { localUriHandler.openUri(url) }) {
Text(
buildAnnotatedString {
append(stringPieces[0])
withStyle(
style = SpanStyle(
color = Color.Blue, textDecoration = TextDecoration.Underline
)
) {
if (replaceWithUrl) append(url) else append(linkPlacement)
}
if (stringPieces.size >= 2) append(stringPieces[1])
},
style = MaterialTheme.typography.bodyLarge,
softWrap = true,
)
}
}

@Composable
fun GenericRow(onClick: () -> Unit = {}, content: @Composable() (RowScope.() -> Unit)) {
Box(modifier = Modifier
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<string name="how_to_use_step_3">Uma tela com detalhes do arquivo será mostrada, toque em "Salvar"</string>
<string name="how_to_use_step_4">O seletor de arquivos será exibido, selecione onde e com qual nome salvar</string>
<string name="how_to_use_about_title">Sobre</string>
<string name="how_to_use_about">Desenvolvido por Mateus Rodrigues Costa, licenciado sob AGPLv3+</string>
<string name="how_to_use_github">Código-fonte disponível no Github em %s</string>
<string name="how_to_use_app_icon_credits">Design do ícone do app por @swyzera</string>
<string name="how_to_use_app_donation">Gostou do app? Considere doar! Para mais detalhes, acesse %s</string>
<string name="how_to_use_about">Desenvolvido por Mateus Rodrigues Costa</string>
<string name="how_to_use_app_icon_credits">Design do ícone do app por @swyzera</string>
<string name="how_to_use_github">Código-fonte disponível no Github em %s, licenciado sob AGPLv3+</string>

<string name="settings">Configurações</string>

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<string name="how_to_use_step_3">A screen with details about the file will open, press Save</string>
<string name="how_to_use_step_4">The file picker will open, select where to save and the filename</string>
<string name="how_to_use_about_title">About</string>
<string name="how_to_use_about">Developed by Mateus Rodrigues Costa, licensed under AGPLv3+</string>
<string name="how_to_use_github">Source code available on Github at %s</string>
<string name="how_to_use_app_icon_credits">App icon designed by @swyzera</string>
<string name="how_to_use_app_donation">Like the app? Consider donating! For more information, visit %s</string>
<string name="how_to_use_about">Developed by Mateus Rodrigues Costa</string>
<string name="how_to_use_app_icon_credits">App icon designed by @swyzera</string>
<string name="how_to_use_github">Source code available on Github at %s, licensed under AGPLv3+</string>

<string name="settings">Settings</string>

Expand Down

0 comments on commit c19a26a

Please sign in to comment.