-
Notifications
You must be signed in to change notification settings - Fork 4
Integrate AboutLibraries to display open-source licenses in Settings #64
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
Changes from 3 commits
bd21878
95349a8
75b99e8
6f3b337
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package com.rickyhu.hushkeyboard.libraries | ||
|
|
||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.IconButton | ||
| 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.Modifier | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer | ||
| import com.rickyhu.hushkeyboard.R | ||
|
|
||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @Composable | ||
| fun LibrariesScreen(onBackClick: () -> Unit = {}) { | ||
| Scaffold( | ||
| topBar = { | ||
| TopAppBar( | ||
| title = { | ||
| Text( | ||
| text = stringResource(R.string.libraries), | ||
| style = MaterialTheme.typography.headlineMedium, | ||
| ) | ||
| }, | ||
| navigationIcon = { | ||
| IconButton(onClick = onBackClick) { | ||
| Icon( | ||
| painter = painterResource(R.drawable.ic_return), | ||
| contentDescription = stringResource(R.string.libraries), | ||
| ) | ||
| } | ||
| }, | ||
| ) | ||
| }, | ||
| ) { padding -> | ||
| LibrariesContainer( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(padding), | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package com.rickyhu.hushkeyboard.settings | |
|
|
||
| import androidx.annotation.VisibleForTesting | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
|
|
@@ -12,6 +13,7 @@ import androidx.compose.foundation.shape.CircleShape | |
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.HorizontalDivider | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.ListItem | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.material3.Text | ||
|
|
@@ -38,7 +40,10 @@ import com.rickyhu.hushkeyboard.theme.HushKeyboardTheme | |
| import org.koin.androidx.compose.koinViewModel | ||
|
|
||
| @Composable | ||
| fun SettingsScreen(viewModel: SettingsViewModel = koinViewModel()) { | ||
| fun SettingsScreen( | ||
| viewModel: SettingsViewModel = koinViewModel(), | ||
| onLibrariesClick: () -> Unit = {}, | ||
| ) { | ||
| val state by viewModel.settingsState.collectAsState(SettingsState()) | ||
|
|
||
| SettingsContent( | ||
|
|
@@ -49,6 +54,7 @@ fun SettingsScreen(viewModel: SettingsViewModel = koinViewModel()) { | |
| onSmartDeleteChanged = viewModel::updateSmartDelete, | ||
| onAddSpaceBetweenNotationChanged = viewModel::updateAddSpaceBetweenNotation, | ||
| onVibrateOnTapChanged = viewModel::updateVibrateOnTap, | ||
| onLibrariesClick = onLibrariesClick, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -63,6 +69,7 @@ fun SettingsContent( | |
| onSmartDeleteChanged: (smartDelete: Boolean) -> Unit, | ||
| onAddSpaceBetweenNotationChanged: (addSpaceAfterNotation: Boolean) -> Unit, | ||
| onVibrateOnTapChanged: (vibrateOnTap: Boolean) -> Unit, | ||
| onLibrariesClick: () -> Unit = {}, | ||
| ) { | ||
| val context = LocalContext.current | ||
|
|
||
|
|
@@ -197,6 +204,17 @@ fun SettingsContent( | |
| trailing = { Text(versionName) }, | ||
| ) | ||
|
|
||
| ListItem( | ||
| headlineContent = { Text(stringResource(R.string.libraries)) }, | ||
| leadingContent = { | ||
| Icon( | ||
| painter = painterResource(R.drawable.ic_library), | ||
| contentDescription = stringResource(R.string.libraries), | ||
| ) | ||
| }, | ||
| modifier = Modifier.clickable { onLibrariesClick() }, | ||
| ) | ||
|
Comment on lines
+207
to
+216
|
||
|
|
||
| UrlLauncherListItem( | ||
| title = stringResource(R.string.donate), | ||
| url = stringResource(R.string.buy_me_a_coffee_url), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="#000000"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M18,2H6C4.9,2 4,2.9 4,4v16c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4C20,2.9 19.1,2 18,2zM9,4h2v5l-1,-0.75L9,9V4zM18,20H6V4h1v9l3,-2.25L13,13V4h5v16z" /> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| <string name="version">Version</string> | ||
| <string name="version_unknown">Unknown Version</string> | ||
| <string name="hush_keyboard_github">https://github.com/ricky9667/HushKeyboard</string> | ||
| <string name="libraries">Open-source libraries</string> | ||
|
||
| <string name="donate">Donate</string> | ||
| <string name="buy_me_a_coffee_url">https://coff.ee/ricky9667</string> | ||
|
|
||
|
|
||
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.
The content description for the back button should be more descriptive. Using "Libraries" as the content description for a back/return button is misleading for accessibility.
Consider using a more appropriate description like "Navigate back" or "Back" that accurately describes the action performed when the button is pressed, rather than repeating the screen title.