mirror of
https://github.com/AChep/keyguard-app.git
synced 2024-12-12 08:26:31 +01:00
improvement: Show a tip that you can generate disposable emails #724
This commit is contained in:
parent
a6eaf9178e
commit
72904b484b
@ -230,6 +230,9 @@
|
|||||||
<string name="bitwarden_premium_required">Requires Bitwarden premium</string>
|
<string name="bitwarden_premium_required">Requires Bitwarden premium</string>
|
||||||
<string name="bitwarden_unofficial_server">Unofficial Bitwarden server</string>
|
<string name="bitwarden_unofficial_server">Unofficial Bitwarden server</string>
|
||||||
|
|
||||||
|
<string name="pro_tip">Pro tip: <xliff:g id="tip" example="Wake up early and work a lot!">%1$s</xliff:g></string>
|
||||||
|
<string name="pro_tip_generate_email_relay_title">Generate disposable emails for the better privacy.</string>
|
||||||
|
|
||||||
<string name="account_last_synced_at">Last synced at <xliff:g id="date" example="1 January 1970 12:30">%1$s</xliff:g></string>
|
<string name="account_last_synced_at">Last synced at <xliff:g id="date" example="1 January 1970 12:30">%1$s</xliff:g></string>
|
||||||
<string name="account_action_change_name_title">Change name</string>
|
<string name="account_action_change_name_title">Change name</string>
|
||||||
<string name="account_action_change_color_title">Change color</string>
|
<string name="account_action_change_color_title">Change color</string>
|
||||||
|
@ -92,6 +92,8 @@ import com.artemchep.keyguard.res.Res
|
|||||||
import com.artemchep.keyguard.res.*
|
import com.artemchep.keyguard.res.*
|
||||||
import com.artemchep.keyguard.ui.ContextItem
|
import com.artemchep.keyguard.ui.ContextItem
|
||||||
import com.artemchep.keyguard.ui.FlatItemAction
|
import com.artemchep.keyguard.ui.FlatItemAction
|
||||||
|
import com.artemchep.keyguard.ui.FlatSimpleNote
|
||||||
|
import com.artemchep.keyguard.ui.SimpleNote
|
||||||
import com.artemchep.keyguard.ui.buildContextItems
|
import com.artemchep.keyguard.ui.buildContextItems
|
||||||
import com.artemchep.keyguard.ui.icons.KeyguardIcons
|
import com.artemchep.keyguard.ui.icons.KeyguardIcons
|
||||||
import com.artemchep.keyguard.ui.icons.icon
|
import com.artemchep.keyguard.ui.icons.icon
|
||||||
@ -1700,12 +1702,40 @@ private fun RememberStateFlowScope.flowOfGeneratorType(
|
|||||||
typesAllFlow,
|
typesAllFlow,
|
||||||
typeFlow,
|
typeFlow,
|
||||||
) { allTypes, type ->
|
) { allTypes, type ->
|
||||||
|
val shouldShowEmailRelayProTip = allTypes.none { it is GeneratorType2.EmailRelay }
|
||||||
|
|
||||||
val typeTitle = translate(type.title)
|
val typeTitle = translate(type.title)
|
||||||
val typeItems = buildContextItems {
|
val typeItems = buildContextItems {
|
||||||
|
var prevGroup: String? = null
|
||||||
allTypes.forEachIndexed { index, item ->
|
allTypes.forEachIndexed { index, item ->
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
val groupChanged = allTypes[index - 1].group != item.group
|
val groupChanged = prevGroup != item.group
|
||||||
if (groupChanged) {
|
if (groupChanged) {
|
||||||
|
if (
|
||||||
|
prevGroup == GENERATOR_TYPE_GROUP_USERNAME &&
|
||||||
|
shouldShowEmailRelayProTip
|
||||||
|
) {
|
||||||
|
val tipBody = translate(Res.string.pro_tip_generate_email_relay_title)
|
||||||
|
val tip = translate(Res.string.pro_tip, tipBody)
|
||||||
|
|
||||||
|
val note = SimpleNote(
|
||||||
|
text = tip,
|
||||||
|
type = SimpleNote.Type.INFO,
|
||||||
|
)
|
||||||
|
this += ContextItem.Custom {
|
||||||
|
FlatSimpleNote(
|
||||||
|
type = note.type,
|
||||||
|
text = note.text,
|
||||||
|
onClick = {
|
||||||
|
val route = EmailRelayListRoute
|
||||||
|
val intent = NavigationIntent.NavigateToRoute(route)
|
||||||
|
navigate(intent)
|
||||||
|
},
|
||||||
|
icon = false,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this += when (item.group) {
|
this += when (item.group) {
|
||||||
GENERATOR_TYPE_GROUP_INTEGRATION ->
|
GENERATOR_TYPE_GROUP_INTEGRATION ->
|
||||||
ContextItem.Section(
|
ContextItem.Section(
|
||||||
@ -1738,6 +1768,8 @@ private fun RememberStateFlowScope.flowOfGeneratorType(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevGroup = item.group
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GeneratorState.Type(
|
GeneratorState.Type(
|
||||||
|
@ -62,6 +62,7 @@ fun FlatSimpleNote(
|
|||||||
content: (@Composable ColumnScope.() -> Unit)? = null,
|
content: (@Composable ColumnScope.() -> Unit)? = null,
|
||||||
onClick: (() -> Unit)? = null,
|
onClick: (() -> Unit)? = null,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
|
icon: Boolean = true,
|
||||||
) {
|
) {
|
||||||
val tintColor = when (type) {
|
val tintColor = when (type) {
|
||||||
SimpleNote.Type.OK -> MaterialTheme.colorScheme.ok
|
SimpleNote.Type.OK -> MaterialTheme.colorScheme.ok
|
||||||
@ -86,23 +87,28 @@ fun FlatSimpleNote(
|
|||||||
backgroundColor = surfaceColor
|
backgroundColor = surfaceColor
|
||||||
.combineAlpha(DisabledEmphasisAlpha),
|
.combineAlpha(DisabledEmphasisAlpha),
|
||||||
contentColor = contentColor,
|
contentColor = contentColor,
|
||||||
leading = {
|
leading = if (icon) {
|
||||||
if (leading != null) {
|
// composable
|
||||||
leading.invoke(this)
|
leading@{
|
||||||
return@FlatItemLayout
|
if (leading != null) {
|
||||||
}
|
leading.invoke(this)
|
||||||
|
return@leading
|
||||||
|
}
|
||||||
|
|
||||||
val imageVector = when (type) {
|
val imageVector = when (type) {
|
||||||
SimpleNote.Type.OK -> Icons.Outlined.Check
|
SimpleNote.Type.OK -> Icons.Outlined.Check
|
||||||
SimpleNote.Type.INFO -> Icons.Outlined.Info
|
SimpleNote.Type.INFO -> Icons.Outlined.Info
|
||||||
SimpleNote.Type.WARNING -> Icons.Outlined.Warning
|
SimpleNote.Type.WARNING -> Icons.Outlined.Warning
|
||||||
SimpleNote.Type.ERROR -> Icons.Outlined.ErrorOutline
|
SimpleNote.Type.ERROR -> Icons.Outlined.ErrorOutline
|
||||||
|
}
|
||||||
|
Icon(
|
||||||
|
imageVector = imageVector,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = tintColor,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Icon(
|
} else {
|
||||||
imageVector = imageVector,
|
null
|
||||||
contentDescription = null,
|
|
||||||
tint = tintColor,
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
content = {
|
content = {
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user