diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManager.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManager.kt index ff00823ca77..9bf19e45937 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManager.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManager.kt @@ -135,6 +135,38 @@ interface IntentManager { requestCode: Int, ): PendingIntent + /** + * Creates a pending intent to use when providing [androidx.credentials.provider.CreateEntry] + * instances for Password credential creation. + */ + fun createPasswordCreationPendingIntent( + action: String, + userId: String, + requestCode: Int, + ): PendingIntent + + /** + * Creates a pending intent to use when providing + * [androidx.credentials.provider.CredentialEntry] instances for Password credential filling. + */ + fun createPasswordGetCredentialPendingIntent( + action: String, + userId: String, + credentialId: String, + cipherId: String, + requestCode: Int, + ): PendingIntent + + /** + * Creates a pending intent to use when providing + * [androidx.credentials.provider.AuthenticationAction] instances for Password credential filling. + */ + fun createPasswordUnlockPendingIntent( + action: String, + userId: String, + requestCode: Int, + ): PendingIntent + /** * Open the default email app on device. */ diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManagerImpl.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManagerImpl.kt index e5308803270..1124cdb13cf 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManagerImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/manager/intent/IntentManagerImpl.kt @@ -294,6 +294,61 @@ class IntentManagerImpl( ) } + override fun createPasswordCreationPendingIntent( + action: String, + userId: String, + requestCode: Int, + ): PendingIntent { + val intent = Intent(action) + .setPackage(context.packageName) + .putExtra(EXTRA_KEY_USER_ID, userId) + + return PendingIntent.getActivity( + /* context = */ context, + /* requestCode = */ requestCode, + /* intent = */ intent, + /* flags = */ PendingIntent.FLAG_UPDATE_CURRENT.toPendingIntentMutabilityFlag(), + ) + } + + override fun createPasswordGetCredentialPendingIntent( + action: String, + userId: String, + credentialId: String, + cipherId: String, + requestCode: Int + ): PendingIntent { + val intent = Intent(action) + .setPackage(context.packageName) + .putExtra(EXTRA_KEY_USER_ID, userId) + .putExtra(EXTRA_KEY_CREDENTIAL_ID, credentialId) + .putExtra(EXTRA_KEY_CIPHER_ID, cipherId) + + return PendingIntent.getActivity( + /* context = */ context, + /* requestCode = */ requestCode, + /* intent = */ intent, + /* flags = */ PendingIntent.FLAG_UPDATE_CURRENT.toPendingIntentMutabilityFlag(), + ) + } + + override fun createPasswordUnlockPendingIntent( + action: String, + userId: String, + requestCode: Int, + ): PendingIntent { + val intent = Intent(action) + .setPackage(context.packageName) + .putExtra(EXTRA_KEY_USER_ID, userId) + + return PendingIntent.getActivity( + /* context = */ context, + /* requestCode = */ requestCode, + /* intent = */ intent, + /* flags = */ PendingIntent.FLAG_UPDATE_CURRENT.toPendingIntentMutabilityFlag(), + ) + } + override fun startDefaultEmailApplication() { val intent = Intent(Intent.ACTION_MAIN) intent.addCategory(Intent.CATEGORY_APP_EMAIL)