diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6d12f168b5..e09ebf73e9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -115,11 +115,11 @@
android:theme="@android:style/Theme.NoDisplay" />
+ android:theme="@style/AutofillCallbackTheme" />
when (event) {
- is AutofillTotpCopyEvent.CompleteAutofill -> {
- handleCompleteAutofill(event)
- }
-
- is AutofillTotpCopyEvent.FinishActivity -> {
- finishActivity()
- }
+ is AutofillCallbackEvent.CompleteAutofill -> handleCompleteAutofill(event)
+ is AutofillCallbackEvent.FinishActivity -> finishActivity()
}
}
.launchIn(lifecycleScope)
@@ -69,7 +60,7 @@ class AutofillTotpCopyActivity : AppCompatActivity() {
/**
* Complete autofill with the provided data.
*/
- private fun handleCompleteAutofill(event: AutofillTotpCopyEvent.CompleteAutofill) {
+ private fun handleCompleteAutofill(event: AutofillCallbackEvent.CompleteAutofill) {
autofillCompletionManager.completeAutofill(
activity = this,
cipherView = event.cipherView,
diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/AutofillTotpCopyViewModel.kt b/app/src/main/kotlin/com/x8bit/bitwarden/AutofillCallbackViewModel.kt
similarity index 79%
rename from app/src/main/kotlin/com/x8bit/bitwarden/AutofillTotpCopyViewModel.kt
rename to app/src/main/kotlin/com/x8bit/bitwarden/AutofillCallbackViewModel.kt
index 3b6e74f16e..1aa1e2cb1e 100644
--- a/app/src/main/kotlin/com/x8bit/bitwarden/AutofillTotpCopyViewModel.kt
+++ b/app/src/main/kotlin/com/x8bit/bitwarden/AutofillCallbackViewModel.kt
@@ -5,7 +5,7 @@ import androidx.lifecycle.viewModelScope
import com.bitwarden.ui.platform.base.BaseViewModel
import com.bitwarden.vault.CipherView
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
-import com.x8bit.bitwarden.data.autofill.util.getTotpCopyIntentOrNull
+import com.x8bit.bitwarden.data.autofill.util.getAutofillCallbackIntentOrNull
import com.x8bit.bitwarden.data.platform.util.launchWithTimeout
import com.x8bit.bitwarden.data.vault.manager.model.GetCipherResult
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
@@ -22,23 +22,23 @@ import javax.inject.Inject
private const val CIPHER_WAIT_TIMEOUT_MILLIS: Long = 500
/**
- * A view model that handles logic for the [AutofillTotpCopyActivity].
+ * A view model that handles logic for the [AutofillCallbackActivity].
*/
@HiltViewModel
-class AutofillTotpCopyViewModel @Inject constructor(
+class AutofillCallbackViewModel @Inject constructor(
private val authRepository: AuthRepository,
private val vaultRepository: VaultRepository,
-) : BaseViewModel(Unit) {
+) : BaseViewModel(Unit) {
private val activeUserId: String? get() = authRepository.activeUserId
- override fun handleAction(action: AutofillTotpCopyAction): Unit = when (action) {
- is AutofillTotpCopyAction.IntentReceived -> handleIntentReceived(action)
+ override fun handleAction(action: AutofillCallbackAction): Unit = when (action) {
+ is AutofillCallbackAction.IntentReceived -> handleIntentReceived(action)
}
/**
* Process the received intent and alert the activity of what to do next.
*/
- private fun handleIntentReceived(action: AutofillTotpCopyAction.IntentReceived) {
+ private fun handleIntentReceived(action: AutofillCallbackAction.IntentReceived) {
viewModelScope
.launchWithTimeout(
timeoutBlock = {
@@ -50,7 +50,7 @@ class AutofillTotpCopyViewModel @Inject constructor(
// Extract TOTP copy data from the intent.
val cipherId = action
.intent
- .getTotpCopyIntentOrNull()
+ .getAutofillCallbackIntentOrNull()
?.cipherId
if (cipherId == null) {
@@ -78,7 +78,7 @@ class AutofillTotpCopyViewModel @Inject constructor(
is GetCipherResult.Success -> {
Timber.d("Autofill -- Cipher found")
- sendEvent(AutofillTotpCopyEvent.CompleteAutofill(result.cipherView))
+ sendEvent(AutofillCallbackEvent.CompleteAutofill(result.cipherView))
}
}
}
@@ -88,7 +88,7 @@ class AutofillTotpCopyViewModel @Inject constructor(
* Send an event to the activity that signals it to finish.
*/
private fun finishActivity() {
- sendEvent(AutofillTotpCopyEvent.FinishActivity)
+ sendEvent(AutofillCallbackEvent.FinishActivity)
}
private suspend fun isVaultLocked(): Boolean {
@@ -105,30 +105,30 @@ class AutofillTotpCopyViewModel @Inject constructor(
}
/**
- * Represents actions that can be sent to the [AutofillTotpCopyViewModel].
+ * Represents actions that can be sent to the [AutofillCallbackViewModel].
*/
-sealed class AutofillTotpCopyAction {
+sealed class AutofillCallbackAction {
/**
* An [intent] has been received and is ready to be processed.
*/
data class IntentReceived(
val intent: Intent,
- ) : AutofillTotpCopyAction()
+ ) : AutofillCallbackAction()
}
/**
- * Represents events emitted by the [AutofillTotpCopyViewModel].
+ * Represents events emitted by the [AutofillCallbackViewModel].
*/
-sealed class AutofillTotpCopyEvent {
+sealed class AutofillCallbackEvent {
/**
* Complete autofill with the provided [cipherView].
*/
data class CompleteAutofill(
val cipherView: CipherView,
- ) : AutofillTotpCopyEvent()
+ ) : AutofillCallbackEvent()
/**
* Finish the activity.
*/
- data object FinishActivity : AutofillTotpCopyEvent()
+ data object FinishActivity : AutofillCallbackEvent()
}
diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt
index 3cc10947b4..14d1643e9d 100644
--- a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt
+++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt
@@ -8,7 +8,7 @@ import com.x8bit.bitwarden.data.autofill.model.FilledData
import com.x8bit.bitwarden.data.autofill.model.FilledPartition
import com.x8bit.bitwarden.data.autofill.util.buildDataset
import com.x8bit.bitwarden.data.autofill.util.buildVaultItemDataset
-import com.x8bit.bitwarden.data.autofill.util.createTotpCopyIntentSender
+import com.x8bit.bitwarden.data.autofill.util.createAutofillCallbackIntentSender
import com.x8bit.bitwarden.data.autofill.util.fillableAutofillIds
import timber.log.Timber
@@ -65,8 +65,8 @@ class FillResponseBuilderImpl : FillResponseBuilder {
}
/**
- * Convert this [FilledPartition] and [autofillAppInfo] into an [IntentSender] if totp is enabled
- * and there the [FilledPartition.autofillCipher] has a valid cipher id.
+ * Convert this [FilledPartition] and [autofillAppInfo] into an [IntentSender] if the
+ * [FilledPartition.autofillCipher] has a valid cipher id.
*/
private fun FilledPartition.toAuthIntentSenderOrNull(
autofillAppInfo: AutofillAppInfo,
@@ -74,8 +74,7 @@ private fun FilledPartition.toAuthIntentSenderOrNull(
autofillCipher
.cipherId
?.let { cipherId ->
- // We always do this even if there is no TOTP code because we want to log the events
- createTotpCopyIntentSender(
+ createAutofillCallbackIntentSender(
cipherId = cipherId,
context = autofillAppInfo.context,
)
diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/model/AutofillCallbackData.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/model/AutofillCallbackData.kt
new file mode 100644
index 0000000000..68984b7c5f
--- /dev/null
+++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/model/AutofillCallbackData.kt
@@ -0,0 +1,14 @@
+package com.x8bit.bitwarden.data.autofill.model
+
+import android.os.Parcelable
+import kotlinx.parcelize.Parcelize
+
+/**
+ * Represents data for the autofill flow via authentication intents.
+ *
+ * @property cipherId The ID of the cipher associated with this Autofill instance.
+ */
+@Parcelize
+data class AutofillCallbackData(
+ val cipherId: String,
+) : Parcelable
diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/model/AutofillTotpCopyData.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/model/AutofillTotpCopyData.kt
deleted file mode 100644
index 42633a9229..0000000000
--- a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/model/AutofillTotpCopyData.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.x8bit.bitwarden.data.autofill.model
-
-import android.os.Parcelable
-import kotlinx.parcelize.Parcelize
-
-/**
- * Represents data for a TOTP copying during the autofill flow via authentication intents.
- *
- * @property cipherId The cipher for which we are copying a TOTP to the clipboard.
- */
-@Parcelize
-data class AutofillTotpCopyData(
- val cipherId: String,
-) : Parcelable
diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/util/AutofillIntentUtils.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/util/AutofillIntentUtils.kt
index aa25b37bc5..e0a7ac3413 100644
--- a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/util/AutofillIntentUtils.kt
+++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/util/AutofillIntentUtils.kt
@@ -13,17 +13,17 @@ import android.view.autofill.AutofillManager
import androidx.core.os.bundleOf
import com.bitwarden.annotation.OmitFromCoverage
import com.bitwarden.ui.platform.util.getSafeParcelableExtra
-import com.x8bit.bitwarden.AutofillTotpCopyActivity
+import com.x8bit.bitwarden.AutofillCallbackActivity
import com.x8bit.bitwarden.MainActivity
import com.x8bit.bitwarden.data.autofill.model.AutofillAppInfo
+import com.x8bit.bitwarden.data.autofill.model.AutofillCallbackData
import com.x8bit.bitwarden.data.autofill.model.AutofillSaveItem
import com.x8bit.bitwarden.data.autofill.model.AutofillSelectionData
-import com.x8bit.bitwarden.data.autofill.model.AutofillTotpCopyData
import kotlin.random.Random
private const val AUTOFILL_SAVE_ITEM_DATA_KEY = "autofill-save-item-data"
private const val AUTOFILL_SELECTION_DATA_KEY = "autofill-selection-data"
-private const val AUTOFILL_TOTP_COPY_DATA_KEY = "autofill-totp-copy-data"
+private const val AUTOFILL_CALLBACK_DATA_KEY = "autofill-callback-data"
private const val AUTOFILL_BUNDLE_KEY = "autofill-bundle-key"
/**
@@ -54,21 +54,21 @@ fun createAutofillSelectionIntent(
}
/**
- * Creates an [IntentSender] built with the data required for performing a TOTP copying during
- * the autofill flow.
+ * Creates an [IntentSender] built with the data required for performing an Autofill callback
+ * during the autofill flow.
*/
-fun createTotpCopyIntentSender(
+fun createAutofillCallbackIntentSender(
cipherId: String,
context: Context,
): IntentSender {
val intent = Intent(
context,
- AutofillTotpCopyActivity::class.java,
+ AutofillCallbackActivity::class.java,
)
.putExtra(
AUTOFILL_BUNDLE_KEY,
bundleOf(
- AUTOFILL_TOTP_COPY_DATA_KEY to AutofillTotpCopyData(cipherId = cipherId),
+ AUTOFILL_CALLBACK_DATA_KEY to AutofillCallbackData(cipherId = cipherId),
),
)
return PendingIntent
@@ -142,12 +142,12 @@ fun Intent.getAutofillSelectionDataOrNull(): AutofillSelectionData? =
?.getSafeParcelableExtra(AUTOFILL_SELECTION_DATA_KEY)
/**
- * Checks if the given [Intent] contains data for TOTP copying. The [AutofillTotpCopyData] will be
+ * Checks if the given [Intent] contains Autofill callback data. The [AutofillCallbackData] will be
* returned when present.
*/
-fun Intent.getTotpCopyIntentOrNull(): AutofillTotpCopyData? =
+fun Intent.getAutofillCallbackIntentOrNull(): AutofillCallbackData? =
getBundleExtra(AUTOFILL_BUNDLE_KEY)
- ?.getSafeParcelableExtra(AUTOFILL_TOTP_COPY_DATA_KEY)
+ ?.getSafeParcelableExtra(AUTOFILL_CALLBACK_DATA_KEY)
/**
* Checks if the given [Activity] was created for Autofill. This is useful to avoid locking the
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 5df1866c1c..253ce794cd 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -18,8 +18,8 @@
- @color/ic_launcher_background
-
-