mirror of
https://github.com/bitwarden/android.git
synced 2024-11-26 03:16:10 +03:00
Add helper handle methods for MainType and Internal actions (#989)
This commit is contained in:
parent
c3724605b8
commit
5a6be93644
1 changed files with 42 additions and 49 deletions
|
@ -105,33 +105,22 @@ class GeneratorViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength", "LongMethod")
|
||||
override fun handleAction(action: GeneratorAction) {
|
||||
when (action) {
|
||||
is GeneratorAction.PasswordHistoryClick -> {
|
||||
handlePasswordHistoryClick()
|
||||
}
|
||||
|
||||
is GeneratorAction.CloseClick -> {
|
||||
handleCloseClick()
|
||||
}
|
||||
|
||||
is GeneratorAction.SelectClick -> {
|
||||
handleSelectClick()
|
||||
}
|
||||
|
||||
is GeneratorAction.RegenerateClick -> {
|
||||
handleRegenerationClick()
|
||||
}
|
||||
|
||||
is GeneratorAction.CopyClick -> {
|
||||
handleCopyClick()
|
||||
}
|
||||
|
||||
is GeneratorAction.MainTypeOptionSelect -> {
|
||||
handleMainTypeOptionSelect(action)
|
||||
}
|
||||
is GeneratorAction.PasswordHistoryClick -> handlePasswordHistoryClick()
|
||||
is GeneratorAction.CloseClick -> handleCloseClick()
|
||||
is GeneratorAction.SelectClick -> handleSelectClick()
|
||||
is GeneratorAction.RegenerateClick -> handleRegenerationClick()
|
||||
is GeneratorAction.CopyClick -> handleCopyClick()
|
||||
is GeneratorAction.MainTypeOptionSelect -> handleMainTypeOptionSelect(action)
|
||||
is GeneratorAction.MainType -> handleMainTypeAction(action)
|
||||
is GeneratorAction.Internal -> handleInternalAction(action)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
private fun handleMainTypeAction(action: GeneratorAction.MainType) {
|
||||
when (action) {
|
||||
is GeneratorAction.MainType.Passcode.PasscodeTypeOptionSelect -> {
|
||||
handlePasscodeTypeOptionSelect(action)
|
||||
}
|
||||
|
@ -144,30 +133,6 @@ class GeneratorViewModel @Inject constructor(
|
|||
handlePassphraseSpecificAction(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedPasswordResult -> {
|
||||
handleUpdateGeneratedPasswordResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedPassphraseResult -> {
|
||||
handleUpdateGeneratedPassphraseResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedPlusAddessedUsernameResult -> {
|
||||
handleUpdatePlusAddressedGeneratedUsernameResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedCatchAllUsernameResult -> {
|
||||
handleUpdateCatchAllGeneratedUsernameResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedRandomWordUsernameResult -> {
|
||||
handleUpdateRandomWordGeneratedUsernameResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedForwardedServiceUsernameResult -> {
|
||||
handleUpdateForwardedServiceGeneratedUsernameResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.MainType.Username.UsernameTypeOptionSelect -> {
|
||||
handleUsernameTypeOptionSelect(action)
|
||||
}
|
||||
|
@ -214,6 +179,34 @@ class GeneratorViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleInternalAction(action: GeneratorAction.Internal) {
|
||||
when (action) {
|
||||
is GeneratorAction.Internal.UpdateGeneratedPasswordResult -> {
|
||||
handleUpdateGeneratedPasswordResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedPassphraseResult -> {
|
||||
handleUpdateGeneratedPassphraseResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedPlusAddessedUsernameResult -> {
|
||||
handleUpdatePlusAddressedGeneratedUsernameResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedCatchAllUsernameResult -> {
|
||||
handleUpdateCatchAllGeneratedUsernameResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedRandomWordUsernameResult -> {
|
||||
handleUpdateRandomWordGeneratedUsernameResult(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.Internal.UpdateGeneratedForwardedServiceUsernameResult -> {
|
||||
handleUpdateForwardedServiceGeneratedUsernameResult(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//endregion Initialization and Overrides
|
||||
|
||||
//region Top Level Handlers
|
||||
|
@ -2111,7 +2104,7 @@ sealed class GeneratorAction {
|
|||
/**
|
||||
* Represents the action to learn more.
|
||||
*/
|
||||
data object TooltipClick : GeneratorAction()
|
||||
data object TooltipClick : UsernameType()
|
||||
|
||||
/**
|
||||
* Represents actions specifically related to Forwarded Email Alias.
|
||||
|
|
Loading…
Reference in a new issue