mirror of
https://github.com/bitwarden/android.git
synced 2024-11-26 03:16:10 +03:00
BIT-1955: Autofill Brings User to the Incorrect Page on Pre Android 11 (#1157)
This commit is contained in:
parent
b2f8d89de4
commit
f9edd70beb
2 changed files with 23 additions and 5 deletions
|
@ -9,6 +9,7 @@ import android.content.Intent
|
|||
import android.content.IntentSender
|
||||
import android.service.autofill.Dataset
|
||||
import android.view.autofill.AutofillManager
|
||||
import androidx.core.os.bundleOf
|
||||
import com.x8bit.bitwarden.AutofillTotpCopyActivity
|
||||
import com.x8bit.bitwarden.MainActivity
|
||||
import com.x8bit.bitwarden.data.autofill.model.AutofillAppInfo
|
||||
|
@ -21,6 +22,7 @@ import com.x8bit.bitwarden.data.platform.util.getSafeParcelableExtra
|
|||
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_BUNDLE_KEY = "autofill-bundle-key"
|
||||
|
||||
/**
|
||||
* Creates an [Intent] in order to send the user to a manual selection process for autofill.
|
||||
|
@ -36,10 +38,9 @@ fun createAutofillSelectionIntent(
|
|||
)
|
||||
.apply {
|
||||
putExtra(
|
||||
AUTOFILL_SELECTION_DATA_KEY,
|
||||
AutofillSelectionData(
|
||||
type = type,
|
||||
uri = uri,
|
||||
AUTOFILL_BUNDLE_KEY,
|
||||
bundleOf(
|
||||
AUTOFILL_SELECTION_DATA_KEY to AutofillSelectionData(type = type, uri = uri),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -132,7 +133,8 @@ fun Intent.getAutofillSaveItemOrNull(): AutofillSaveItem? =
|
|||
* The [AutofillSelectionData] will be returned when present.
|
||||
*/
|
||||
fun Intent.getAutofillSelectionDataOrNull(): AutofillSelectionData? =
|
||||
this.getSafeParcelableExtra(AUTOFILL_SELECTION_DATA_KEY)
|
||||
getBundleExtra(AUTOFILL_BUNDLE_KEY)
|
||||
?.getSafeParcelableExtra(AUTOFILL_SELECTION_DATA_KEY)
|
||||
|
||||
/**
|
||||
* Checks if the given [Intent] contains data for TOTP copying. The [AutofillTotpCopyData] will be
|
||||
|
|
|
@ -4,6 +4,7 @@ package com.x8bit.bitwarden.data.platform.util
|
|||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage
|
||||
|
||||
|
@ -21,3 +22,18 @@ inline fun <reified T> Intent.getSafeParcelableExtra(name: String): T? =
|
|||
@Suppress("DEPRECATION")
|
||||
getParcelableExtra(name)
|
||||
}
|
||||
|
||||
/**
|
||||
* A means of retrieving a [Parcelable] from a [Bundle] using the given [name] in a manner that
|
||||
* is safe across SDK versions.
|
||||
*/
|
||||
inline fun <reified T> Bundle.getSafeParcelableExtra(name: String): T? =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
getParcelable(
|
||||
name,
|
||||
T::class.java,
|
||||
)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
getParcelable(name)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue