Skip to content

Commit

Permalink
Merge branch 'main' into 1.16.0-rc
Browse files Browse the repository at this point in the history
  • Loading branch information
jd1378 committed Jul 9, 2024
2 parents f3da325 + 51d7a38 commit 38eafb5
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 162 deletions.
317 changes: 155 additions & 162 deletions app/src/main/java/io/github/jd1378/otphelper/ui/screens/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ 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.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material3.Button
Expand Down Expand Up @@ -46,9 +48,9 @@ fun Settings(
upPress: () -> Unit,
viewModel: SettingsViewModel
) {

val userSettings by viewModel.userSettings.collectAsState()
val context = LocalContext.current
val userSettings by viewModel.userSettings.collectAsState()
val scrollState = rememberScrollState()

Scaffold(
modifier = Modifier.fillMaxSize(),
Expand All @@ -62,198 +64,189 @@ fun Settings(
modifier =
Modifier.fillMaxSize()
.padding(padding)
.padding(horizontal = dimensionResource(R.dimen.padding_page)),
.padding(horizontal = dimensionResource(R.dimen.padding_page))
.verticalScroll(scrollState),
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.padding_sections)),
) {
Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_sections)),
) {
SettingPageLink(
modifier =
Modifier.clickable {
onNavigateToRoute(MainDestinations.LANGUAGE_SELECTION_ROUTE, false)
},
title = stringResource(R.string.language),
subtitle = getCurrentLocale().displayLanguage,
)
SettingPageLink(
modifier =
Modifier.clickable {
onNavigateToRoute(MainDestinations.LANGUAGE_SELECTION_ROUTE, false)
},
title = stringResource(R.string.language),
subtitle = getCurrentLocale().displayLanguage,
)

SettingPageLink(
modifier =
Modifier.clickable {
onNavigateToRoute(MainDestinations.SENSITIVE_PHRASES_ROUTE, false)
},
title = stringResource(R.string.sensitive_phrases),
)
SettingPageLink(
modifier =
Modifier.clickable {
onNavigateToRoute(MainDestinations.SENSITIVE_PHRASES_ROUTE, false)
},
title = stringResource(R.string.sensitive_phrases),
)

Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
shape = MaterialTheme.shapes.large,
Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
shape = MaterialTheme.shapes.large,
) {
Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_settings)),
modifier =
Modifier.padding(
horizontal = dimensionResource(R.dimen.padding_li_h),
vertical = dimensionResource(R.dimen.padding_li_v),
),
) {
Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_settings)),
modifier =
Modifier.padding(
horizontal = dimensionResource(R.dimen.padding_li_h),
vertical = dimensionResource(R.dimen.padding_li_v),
),
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
) {
Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
SettingLabel(stringResource(R.string.auto_copy))
Switch(
modifier = Modifier.height(32.dp),
checked = userSettings.isAutoCopyEnabled,
onCheckedChange = { viewModel.onAutoCopyToggle() })
}

SettingHelp(stringResource(R.string.auto_copy_help))
SettingLabel(stringResource(R.string.auto_copy))
Switch(
modifier = Modifier.height(32.dp),
checked = userSettings.isAutoCopyEnabled,
onCheckedChange = { viewModel.onAutoCopyToggle() })
}

Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
SettingLabel(stringResource(R.string.send_detected_notif))
Switch(
modifier = Modifier.height(32.dp),
checked = userSettings.isPostNotifEnabled,
onCheckedChange = { viewModel.onPostNotifToggle() })
}
SettingHelp(stringResource(R.string.send_detected_notif_help))
}
SettingHelp(stringResource(R.string.auto_copy_help))
}

Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
Column(
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
SettingLabel(stringResource(R.string.show_toast))
Switch(
modifier = Modifier.height(32.dp),
checked = userSettings.isCopiedToastEnabled,
onCheckedChange = { viewModel.onCopiedToastToggle() })
}
SettingHelp(
stringResource(
R.string.show_toast_help,
stringResource(R.string.code_copied_to_clipboard)))
SettingLabel(stringResource(R.string.send_detected_notif))
Switch(
modifier = Modifier.height(32.dp),
checked = userSettings.isPostNotifEnabled,
onCheckedChange = { viewModel.onPostNotifToggle() })
}
SettingHelp(stringResource(R.string.send_detected_notif_help))
}

Button(
Column(
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
) {
Row(
modifier = Modifier.fillMaxWidth(),
elevation =
ButtonDefaults.elevatedButtonElevation(
defaultElevation = 1.dp,
pressedElevation = 0.dp,
disabledElevation = 0.dp,
),
onClick = { viewModel.onSendTestNotifPressed(context) },
colors =
ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(
stringResource(R.string.send_test_notification),
fontWeight = FontWeight.Medium)
SettingLabel(stringResource(R.string.show_toast))
Switch(
modifier = Modifier.height(32.dp),
checked = userSettings.isCopiedToastEnabled,
onCheckedChange = { viewModel.onCopiedToastToggle() })
}
SettingHelp(
stringResource(
R.string.show_toast_help,
stringResource(R.string.code_copied_to_clipboard)))
}

Button(
modifier = Modifier.fillMaxWidth(),
elevation =
ButtonDefaults.elevatedButtonElevation(
defaultElevation = 1.dp,
pressedElevation = 0.dp,
disabledElevation = 0.dp,
),
onClick = { viewModel.onSendTestNotifPressed(context) },
colors =
ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer),
) {
Text(
stringResource(R.string.send_test_notification), fontWeight = FontWeight.Medium)
}
}
}

Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
shape = MaterialTheme.shapes.large,
Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
shape = MaterialTheme.shapes.large,
) {
Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_settings)),
modifier =
Modifier.padding(
horizontal = dimensionResource(R.dimen.padding_li_h),
vertical = dimensionResource(R.dimen.padding_li_v),
),
) {
Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_settings)),
modifier =
Modifier.padding(
horizontal = dimensionResource(R.dimen.padding_li_h),
vertical = dimensionResource(R.dimen.padding_li_v),
),
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
) {
Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
SettingLabel(stringResource(R.string.history))
Switch(
modifier = Modifier.height(32.dp),
checked = !userSettings.isHistoryDisabled,
onCheckedChange = { viewModel.onHistoryToggle(context) })
}
SettingHelp(stringResource(R.string.history_help))
}

Column(
verticalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
SettingLabel(stringResource(R.string.replace_code_in_history))
Switch(
enabled = !userSettings.isHistoryDisabled,
modifier = Modifier.height(32.dp),
checked = userSettings.shouldReplaceCodeInHistory,
onCheckedChange = { viewModel.onShouldReplaceCodeInHistoryToggle() })
}

SettingHelp(stringResource(R.string.replace_code_in_history_help))
SettingLabel(stringResource(R.string.history))
Switch(
modifier = Modifier.height(32.dp),
checked = !userSettings.isHistoryDisabled,
onCheckedChange = { viewModel.onHistoryToggle(context) })
}
SettingHelp(stringResource(R.string.history_help))
}
}

Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
shape = MaterialTheme.shapes.large,
onClick = { onNavigateToRoute(MainDestinations.ABOUT_ROUTE, false) },
) {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
) {
Row(
modifier =
Modifier.padding(
horizontal = dimensionResource(R.dimen.padding_settings),
vertical = dimensionResource(R.dimen.padding_medium),
),
horizontalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = stringResource(R.string.about))
Text(stringResource(R.string.about))
SettingLabel(stringResource(R.string.replace_code_in_history))
Switch(
enabled = !userSettings.isHistoryDisabled,
modifier = Modifier.height(32.dp),
checked = userSettings.shouldReplaceCodeInHistory,
onCheckedChange = { viewModel.onShouldReplaceCodeInHistoryToggle() })
}

SettingHelp(stringResource(R.string.replace_code_in_history_help))
}
}
}

Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
shape = MaterialTheme.shapes.large,
onClick = { onNavigateToRoute(MainDestinations.ABOUT_ROUTE, false) },
) {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Row(
modifier =
Modifier.padding(
horizontal = dimensionResource(R.dimen.padding_settings),
vertical = dimensionResource(R.dimen.padding_medium),
),
horizontalArrangement =
Arrangement.spacedBy(dimensionResource(R.dimen.padding_xs)),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = stringResource(R.string.about))
Text(stringResource(R.string.about))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/30000.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
- Created settings page and moved settings inside
- Moved language to settings
- You can now disable "Copied to clipboard!" toast from settings.
- You can now add your own sensitive phrases!
- Made notification a little more compact to prevent clipping on some phones

0 comments on commit 38eafb5

Please sign in to comment.