Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ enum class SearchableItemType {
VAULT_IDENTITIES,
VAULT_SECURE_NOTES,
VAULT_SSH_KEYS,
VAULT_BANK_ACCOUNTS,
VAULT_DRIVERS_LICENSES,
VAULT_PASSPORTS,
VAULT_COLLECTIONS,
VAULT_NO_FOLDER,
VAULT_FOLDER,
Expand Down Expand Up @@ -69,6 +72,9 @@ fun SavedStateHandle.toSearchArgs(): SearchArgs {
SearchableItemType.VAULT_IDENTITIES -> SearchType.Vault.Identities
SearchableItemType.VAULT_SECURE_NOTES -> SearchType.Vault.SecureNotes
SearchableItemType.VAULT_SSH_KEYS -> SearchType.Vault.SshKeys
SearchableItemType.VAULT_BANK_ACCOUNTS -> SearchType.Vault.BankAccounts
SearchableItemType.VAULT_DRIVERS_LICENSES -> SearchType.Vault.DriversLicenses
SearchableItemType.VAULT_PASSPORTS -> SearchType.Vault.Passports
SearchableItemType.VAULT_NO_FOLDER -> SearchType.Vault.NoFolder
SearchableItemType.VAULT_TRASH -> SearchType.Vault.Trash
SearchableItemType.VAULT_VERIFICATION_CODES -> SearchType.Vault.VerificationCodes
Expand Down Expand Up @@ -136,6 +142,9 @@ private fun SearchType.toSearchableItemType(): SearchableItemType =
SearchType.Vault.Trash -> SearchableItemType.VAULT_TRASH
SearchType.Vault.VerificationCodes -> SearchableItemType.VAULT_VERIFICATION_CODES
SearchType.Vault.SshKeys -> SearchableItemType.VAULT_SSH_KEYS
SearchType.Vault.BankAccounts -> SearchableItemType.VAULT_BANK_ACCOUNTS
SearchType.Vault.DriversLicenses -> SearchableItemType.VAULT_DRIVERS_LICENSES
SearchType.Vault.Passports -> SearchableItemType.VAULT_PASSPORTS
SearchType.Vault.Archive -> SearchableItemType.VAULT_ARCHIVE
}

Expand All @@ -155,5 +164,8 @@ private fun SearchType.toIdOrNull(): String? =
SearchType.Vault.Trash -> null
SearchType.Vault.VerificationCodes -> null
SearchType.Vault.SshKeys -> null
SearchType.Vault.BankAccounts -> null
SearchType.Vault.DriversLicenses -> null
SearchType.Vault.Passports -> null
SearchType.Vault.Archive -> null
}
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,36 @@ sealed class SearchTypeData : Parcelable {
get() = BitwardenString.search_x.asText(BitwardenString.ssh_keys.asText())
}

/**
* Indicates that we should be searching only bank account ciphers.
*/
data object BankAccounts : Vault() {
override val title: Text
get() = BitwardenString.search.asText()
.concat(" ".asText())
.concat(BitwardenString.bank_accounts.asText())
}

/**
* Indicates that we should be searching only driver's license ciphers.
*/
data object DriversLicenses : Vault() {
override val title: Text
get() = BitwardenString.search.asText()
.concat(" ".asText())
.concat(BitwardenString.drivers_licenses.asText())
}

/**
* Indicates that we should be searching only passport ciphers.
*/
data object Passports : Vault() {
override val title: Text
get() = BitwardenString.search.asText()
.concat(" ".asText())
.concat(BitwardenString.passports.asText())
}

/**
* Indicates that we should be searching only ciphers in the given collection.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ sealed class SearchType : Parcelable {
*/
data object SshKeys : Vault()

/**
* Indicates that we should be searching only bank account ciphers.
*/
data object BankAccounts : Vault()

/**
* Indicates that we should be searching only driver's license ciphers.
*/
data object DriversLicenses : Vault()

/**
* Indicates that we should be searching only passport ciphers.
*/
data object Passports : Vault()

/**
* Indicates that we should be searching only ciphers in the given collection.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
SearchTypeData.Vault.Trash -> this
SearchTypeData.Vault.VerificationCodes -> this
SearchTypeData.Vault.SshKeys -> this
SearchTypeData.Vault.BankAccounts -> this
SearchTypeData.Vault.DriversLicenses -> this
SearchTypeData.Vault.Passports -> this
}

/**
Expand Down Expand Up @@ -125,6 +128,13 @@
is SearchTypeData.Vault.Logins -> type is CipherListViewType.Login && isActive
is SearchTypeData.Vault.SecureNotes -> type is CipherListViewType.SecureNote && isActive
is SearchTypeData.Vault.SshKeys -> type is CipherListViewType.SshKey && isActive
// TODO: Update filters when SDK adds CipherListViewType variants

Check warning on line 131 in app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchTypeDataExtensions.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=bitwarden_android&issues=AZ267bNwvzCEHiylrIpI&open=AZ267bNwvzCEHiylrIpI&pullRequest=6830
// (PM-34060, PM-32691, PM-32694).
is SearchTypeData.Vault.BankAccounts,
is SearchTypeData.Vault.DriversLicenses,
is SearchTypeData.Vault.Passports,
-> false

is SearchTypeData.Vault.VerificationCodes -> login?.totp != null && isActive
is SearchTypeData.Vault.Trash -> deletedDate != null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ fun SearchType.toSearchTypeData(): SearchTypeData =
SearchType.Vault.Trash -> SearchTypeData.Vault.Trash
SearchType.Vault.VerificationCodes -> SearchTypeData.Vault.VerificationCodes
SearchType.Vault.SshKeys -> SearchTypeData.Vault.SshKeys
SearchType.Vault.BankAccounts -> SearchTypeData.Vault.BankAccounts
SearchType.Vault.DriversLicenses -> SearchTypeData.Vault.DriversLicenses
SearchType.Vault.Passports -> SearchTypeData.Vault.Passports
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ enum class ItemListingType {
SECURE_NOTE,
CARD,
SSH_KEY,
BANK_ACCOUNT,
DRIVERS_LICENSE,
PASSPORT,
TRASH,
FOLDER,
COLLECTION,
Expand All @@ -115,6 +118,7 @@ data class VaultItemListingArgs(
/**
* Constructs a [VaultItemListingArgs] from the [SavedStateHandle] and internal route data.
*/
@Suppress("CyclomaticComplexMethod")
fun SavedStateHandle.toVaultItemListingArgs(): VaultItemListingArgs {
val route = this.toRoute<VaultItemListingRoute>()
return VaultItemListingArgs(
Expand All @@ -125,6 +129,9 @@ fun SavedStateHandle.toVaultItemListingArgs(): VaultItemListingArgs {
ItemListingType.IDENTITY -> VaultItemListingType.Identity
ItemListingType.SECURE_NOTE -> VaultItemListingType.SecureNote
ItemListingType.SSH_KEY -> VaultItemListingType.SshKey
ItemListingType.BANK_ACCOUNT -> VaultItemListingType.BankAccount
ItemListingType.DRIVERS_LICENSE -> VaultItemListingType.DriversLicense
ItemListingType.PASSPORT -> VaultItemListingType.Passport
ItemListingType.TRASH -> VaultItemListingType.Trash
ItemListingType.SEND_FILE -> VaultItemListingType.SendFile
ItemListingType.SEND_TEXT -> VaultItemListingType.SendText
Expand Down Expand Up @@ -302,6 +309,9 @@ private fun VaultItemListingType.toItemListingType(): ItemListingType {
is VaultItemListingType.SendFile -> ItemListingType.SEND_FILE
is VaultItemListingType.SendText -> ItemListingType.SEND_TEXT
is VaultItemListingType.SshKey -> ItemListingType.SSH_KEY
is VaultItemListingType.BankAccount -> ItemListingType.BANK_ACCOUNT
is VaultItemListingType.DriversLicense -> ItemListingType.DRIVERS_LICENSE
is VaultItemListingType.Passport -> ItemListingType.PASSPORT
}
}

Expand All @@ -318,4 +328,7 @@ private fun VaultItemListingType.toIdOrNull(): String? =
is VaultItemListingType.SendFile -> null
is VaultItemListingType.SendText -> null
is VaultItemListingType.SshKey -> null
is VaultItemListingType.BankAccount -> null
is VaultItemListingType.DriversLicense -> null
is VaultItemListingType.Passport -> null
}
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,9 @@ data class VaultItemListingState(
ItemListingType.Vault.Login,
ItemListingType.Vault.SecureNote,
ItemListingType.Vault.SshKey,
ItemListingType.Vault.BankAccount,
ItemListingType.Vault.DriversLicense,
ItemListingType.Vault.Passport,
ItemListingType.Vault.Trash,
ItemListingType.Send.SendFile,
ItemListingType.Send.SendText,
Expand Down Expand Up @@ -3349,6 +3352,33 @@ data class VaultItemListingState(
override val hasFab: Boolean get() = false
}

/**
* A Bank account item listing.
*/
data object BankAccount : Vault() {
override val titleText: Text
get() = BitwardenString.bank_accounts.asText()
override val hasFab: Boolean get() = true
}

/**
* A Driver's license item listing.
*/
data object DriversLicense : Vault() {
override val titleText: Text
get() = BitwardenString.drivers_licenses.asText()
override val hasFab: Boolean get() = true
}

/**
* A Passport item listing.
*/
data object Passport : Vault() {
override val titleText: Text
get() = BitwardenString.passports.asText()
override val hasFab: Boolean get() = true
}

/**
* An archive item listing.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@
type is CipherListViewType.SshKey && isActive
}

// TODO: Update filters when SDK adds CipherListViewType variants for

Check warning on line 81 in app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataExtensions.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=bitwarden_android&issues=AZ267bGOvzCEHiylrIpD&open=AZ267bGOvzCEHiylrIpD&pullRequest=6830
// bank account, driver's license, and passport (PM-34060, PM-32691, PM-32694).
is VaultItemListingState.ItemListingType.Vault.BankAccount,
is VaultItemListingState.ItemListingType.Vault.DriversLicense,
is VaultItemListingState.ItemListingType.Vault.Passport,
-> false

is VaultItemListingState.ItemListingType.Vault.Trash -> {
deletedDate != null
}
Expand Down Expand Up @@ -242,6 +249,18 @@
BitwardenString.no_ssh_keys
}

VaultItemListingState.ItemListingType.Vault.BankAccount -> {
BitwardenString.no_bank_accounts
}

VaultItemListingState.ItemListingType.Vault.DriversLicense -> {
BitwardenString.no_drivers_licenses
}

VaultItemListingState.ItemListingType.Vault.Passport -> {
BitwardenString.no_passports
}

VaultItemListingState.ItemListingType.Vault.Archive -> {
BitwardenString.no_archives_message
}
Expand Down Expand Up @@ -270,6 +289,9 @@
VaultItemListingState.ItemListingType.Vault.Login,
VaultItemListingState.ItemListingType.Vault.SecureNote,
VaultItemListingState.ItemListingType.Vault.SshKey,
VaultItemListingState.ItemListingType.Vault.BankAccount,
VaultItemListingState.ItemListingType.Vault.DriversLicense,
VaultItemListingState.ItemListingType.Vault.Passport,
-> null

VaultItemListingState.ItemListingType.Vault.Archive -> {
Expand Down Expand Up @@ -303,6 +325,18 @@
BitwardenString.new_ssh_key
}

VaultItemListingState.ItemListingType.Vault.BankAccount -> {
BitwardenString.new_bank_account
}

VaultItemListingState.ItemListingType.Vault.DriversLicense -> {
BitwardenString.new_drivers_license
}

VaultItemListingState.ItemListingType.Vault.Passport -> {
BitwardenString.new_passport
}

else -> BitwardenString.new_item
}
.asText()
Expand All @@ -319,6 +353,9 @@
VaultItemListingState.ItemListingType.Vault.Login,
VaultItemListingState.ItemListingType.Vault.SecureNote,
VaultItemListingState.ItemListingType.Vault.SshKey,
VaultItemListingState.ItemListingType.Vault.BankAccount,
VaultItemListingState.ItemListingType.Vault.DriversLicense,
VaultItemListingState.ItemListingType.Vault.Passport,
-> null

VaultItemListingState.ItemListingType.Vault.Archive -> {
Expand Down Expand Up @@ -399,6 +436,9 @@
is VaultItemListingState.ItemListingType.Send.SendFile -> this
is VaultItemListingState.ItemListingType.Send.SendText -> this
is VaultItemListingState.ItemListingType.Vault.SshKey -> this
is VaultItemListingState.ItemListingType.Vault.BankAccount -> this
is VaultItemListingState.ItemListingType.Vault.DriversLicense -> this
is VaultItemListingState.ItemListingType.Vault.Passport -> this
is VaultItemListingState.ItemListingType.Vault.Archive -> this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ fun VaultItemListingState.ItemListingType.toSearchType(): SearchType =
is VaultItemListingState.ItemListingType.Vault.Login -> SearchType.Vault.Logins
is VaultItemListingState.ItemListingType.Vault.SecureNote -> SearchType.Vault.SecureNotes
is VaultItemListingState.ItemListingType.Vault.SshKey -> SearchType.Vault.SshKeys
is VaultItemListingState.ItemListingType.Vault.BankAccount -> SearchType.Vault.BankAccounts
is VaultItemListingState.ItemListingType.Vault.DriversLicense -> {
SearchType.Vault.DriversLicenses
}

is VaultItemListingState.ItemListingType.Vault.Passport -> SearchType.Vault.Passports

is VaultItemListingState.ItemListingType.Vault.Trash -> SearchType.Vault.Trash
is VaultItemListingState.ItemListingType.Vault.Collection -> {
SearchType.Vault.Collection(collectionId = collectionId)
Expand Down Expand Up @@ -49,6 +56,18 @@ fun VaultItemListingState.ItemListingType.Vault.toVaultItemCipherType(): VaultIt
is VaultItemListingState.ItemListingType.Vault.Identity -> VaultItemCipherType.IDENTITY
is VaultItemListingState.ItemListingType.Vault.SecureNote -> VaultItemCipherType.SECURE_NOTE
is VaultItemListingState.ItemListingType.Vault.SshKey -> VaultItemCipherType.SSH_KEY
is VaultItemListingState.ItemListingType.Vault.BankAccount -> {
VaultItemCipherType.BANK_ACCOUNT
}

is VaultItemListingState.ItemListingType.Vault.DriversLicense -> {
VaultItemCipherType.DRIVERS_LICENSE
}

is VaultItemListingState.ItemListingType.Vault.Passport -> {
VaultItemCipherType.PASSPORT
}

is VaultItemListingState.ItemListingType.Vault.Login -> VaultItemCipherType.LOGIN
is VaultItemListingState.ItemListingType.Vault.Collection -> VaultItemCipherType.LOGIN
is VaultItemListingState.ItemListingType.Vault.Folder -> VaultItemCipherType.LOGIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ fun VaultItemListingType.toItemListingType(): VaultItemListingState.ItemListingT
is VaultItemListingType.Login -> VaultItemListingState.ItemListingType.Vault.Login
is VaultItemListingType.SecureNote -> VaultItemListingState.ItemListingType.Vault.SecureNote
is VaultItemListingType.SshKey -> VaultItemListingState.ItemListingType.Vault.SshKey
is VaultItemListingType.BankAccount -> {
VaultItemListingState.ItemListingType.Vault.BankAccount
}

is VaultItemListingType.DriversLicense -> {
VaultItemListingState.ItemListingType.Vault.DriversLicense
}

is VaultItemListingType.Passport -> {
VaultItemListingState.ItemListingType.Vault.Passport
}

is VaultItemListingType.Archive -> VaultItemListingState.ItemListingType.Vault.Archive
is VaultItemListingType.Trash -> VaultItemListingState.ItemListingType.Vault.Trash
is VaultItemListingType.Collection -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.x8bit.bitwarden.ui.vault.feature.itemtypeselection

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import com.bitwarden.ui.platform.base.util.composableWithSlideTransitions
import com.x8bit.bitwarden.ui.vault.model.VaultItemCipherType
import kotlinx.serialization.Serializable

/**
* The type-safe route for the item type selection screen.
*/
@Serializable
data object ItemTypeSelectionRoute

/**
* Add the item type selection destination to the nav graph.
*/
fun NavGraphBuilder.itemTypeSelectionDestination(
onNavigateBack: () -> Unit,
onNavigateToAddItem: (VaultItemCipherType) -> Unit,
) {
composableWithSlideTransitions<ItemTypeSelectionRoute> {
ItemTypeSelectionScreen(
onNavigateBack = onNavigateBack,
onNavigateToAddItem = onNavigateToAddItem,
)
}
}

/**
* Navigate to the item type selection screen.
*/
fun NavController.navigateToItemTypeSelection(
navOptions: NavOptions? = null,
) {
this.navigate(route = ItemTypeSelectionRoute, navOptions = navOptions)
}
Loading
Loading