mirror of
https://github.com/bitwarden/android.git
synced 2026-08-01 18:53:39 -05:00
BIT-712: Adding UI for the FastMail service (#459)
This commit is contained in:
committed by
Álison Fernandes
parent
c94b303abc
commit
ab03c83cb3
+22
-1
@@ -868,7 +868,14 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
}
|
||||
|
||||
is ServiceType.FastMail -> {
|
||||
// TODO: FastMail Service Implementation (BIT-712)
|
||||
BitwardenPasswordField(
|
||||
label = stringResource(id = R.string.api_key_required_parenthesis),
|
||||
value = usernameTypeState.selectedServiceType.apiKey,
|
||||
onValueChange = forwardedEmailAliasHandlers.onFastMailApiKeyTextChange,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
|
||||
is ServiceType.FirefoxRelay -> {
|
||||
@@ -1207,6 +1214,7 @@ private class ForwardedEmailAliasHandlers(
|
||||
val onAddyIoAccessTokenTextChange: (String) -> Unit,
|
||||
val onAddyIoDomainNameTextChange: (String) -> Unit,
|
||||
val onDuckDuckGoApiKeyTextChange: (String) -> Unit,
|
||||
val onFastMailApiKeyTextChange: (String) -> Unit,
|
||||
val onFirefoxRelayAccessTokenTextChange: (String) -> Unit,
|
||||
) {
|
||||
companion object {
|
||||
@@ -1264,6 +1272,19 @@ private class ForwardedEmailAliasHandlers(
|
||||
),
|
||||
)
|
||||
},
|
||||
onFastMailApiKeyTextChange = { newApiKey ->
|
||||
viewModel.trySendAction(
|
||||
GeneratorAction
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.ForwardedEmailAlias
|
||||
.FastMail
|
||||
.ApiKeyTextChange(
|
||||
apiKey = newApiKey,
|
||||
),
|
||||
)
|
||||
},
|
||||
onFirefoxRelayAccessTokenTextChange = { newAccessToken ->
|
||||
viewModel.trySendAction(
|
||||
GeneratorAction
|
||||
|
||||
+60
@@ -126,6 +126,10 @@ class GeneratorViewModel @Inject constructor(
|
||||
handleDuckDuckGoTextInputChange(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.MainType.Username.UsernameType.ForwardedEmailAlias.FastMail.ApiKeyTextChange -> {
|
||||
handleFastMailTextInputChange(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.MainType.Username.UsernameType.ForwardedEmailAlias.FirefoxRelay.AccessTokenTextChange -> {
|
||||
handleFirefoxRelayTextInputChange(action)
|
||||
}
|
||||
@@ -692,6 +696,25 @@ class GeneratorViewModel @Inject constructor(
|
||||
|
||||
//endregion DuckDuckGo Service Specific Handlers
|
||||
|
||||
//region FastMail Service Specific Handlers
|
||||
|
||||
private fun handleFastMailTextInputChange(
|
||||
action: GeneratorAction
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.ForwardedEmailAlias
|
||||
.FastMail
|
||||
.ApiKeyTextChange,
|
||||
) {
|
||||
updateFastMailServiceType { fastMailServiceType ->
|
||||
val newApiKey = action.apiKey
|
||||
fastMailServiceType.copy(apiKey = newApiKey)
|
||||
}
|
||||
}
|
||||
|
||||
//endregion FastMail Service Specific Handlers
|
||||
|
||||
//region FirefoxRelay Service Specific Handlers
|
||||
|
||||
private fun handleFirefoxRelayTextInputChange(
|
||||
@@ -917,6 +940,30 @@ class GeneratorViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun updateFastMailServiceType(
|
||||
crossinline block: (FastMail) -> FastMail,
|
||||
) {
|
||||
updateGeneratorMainTypeUsername { currentUsernameType ->
|
||||
if (currentUsernameType.selectedType !is ForwardedEmailAlias) {
|
||||
return@updateGeneratorMainTypeUsername currentUsernameType
|
||||
}
|
||||
|
||||
val currentServiceType = (currentUsernameType.selectedType).selectedServiceType
|
||||
if (currentServiceType !is FastMail) {
|
||||
return@updateGeneratorMainTypeUsername currentUsernameType
|
||||
}
|
||||
|
||||
val updatedServiceType = block(currentServiceType)
|
||||
|
||||
currentUsernameType.copy(
|
||||
selectedType = ForwardedEmailAlias(
|
||||
selectedServiceType = updatedServiceType,
|
||||
obfuscatedText = currentUsernameType.selectedType.obfuscatedText,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun updateFirefoxRelayServiceType(
|
||||
crossinline block: (FirefoxRelay) -> FirefoxRelay,
|
||||
) {
|
||||
@@ -1624,6 +1671,19 @@ sealed class GeneratorAction {
|
||||
data class ApiKeyTextChange(val apiKey: String) : DuckDuckGo()
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents actions specifically related to the FastMail service.
|
||||
*/
|
||||
sealed class FastMail : ForwardedEmailAlias() {
|
||||
|
||||
/**
|
||||
* Fired when the api key input text is changed.
|
||||
*
|
||||
* @property apiKey The new api key text.
|
||||
*/
|
||||
data class ApiKeyTextChange(val apiKey: String) : FastMail()
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents actions specifically related to the FirefoxRelay service.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user