diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2023-03-27 17:45:35 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2023-03-27 17:53:10 +0530 |
commit | 8b97a4a3f1dc799d327dbb7ac631d266a7a986a4 (patch) | |
tree | 63a37d740baef9757c0b90f0679fdcf1e7ce200a /autofill-parser/src/main/java/com | |
parent | 6931f2d7f51fd5d4ed48a6548744c656bf333b6b (diff) |
refactor: migrate to androidx.core APIs for `Bundle`/`Intent` API changes
Diffstat (limited to 'autofill-parser/src/main/java/com')
-rw-r--r-- | autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt index 4f14907c..08eab3ff 100644 --- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt +++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt @@ -7,12 +7,12 @@ package com.github.androidpasswordstore.autofillparser import android.app.assist.AssistStructure import android.os.Build import android.os.Bundle -import android.os.Parcelable import android.service.autofill.Dataset import android.service.autofill.Field import android.view.autofill.AutofillId import android.view.autofill.AutofillValue import androidx.annotation.RequiresApi +import androidx.core.os.BundleCompat import logcat.LogPriority.ERROR import logcat.asLog import logcat.logcat @@ -57,18 +57,36 @@ public sealed class AutofillScenario<out T : Any> { return try { Builder<AutofillId>() .apply { - username = clientState.getParcelableCompat(BUNDLE_KEY_USERNAME_ID) + username = + BundleCompat.getParcelable( + clientState, + BUNDLE_KEY_USERNAME_ID, + AutofillId::class.java + ) fillUsername = clientState.getBoolean(BUNDLE_KEY_FILL_USERNAME) - otp = clientState.getParcelableCompat(BUNDLE_KEY_OTP_ID) + otp = BundleCompat.getParcelable(clientState, BUNDLE_KEY_OTP_ID, AutofillId::class.java) currentPassword.addAll( - clientState.getParcelableArrayListCompat(BUNDLE_KEY_CURRENT_PASSWORD_IDS) + BundleCompat.getParcelableArrayList( + clientState, + BUNDLE_KEY_CURRENT_PASSWORD_IDS, + AutofillId::class.java + ) ?: emptyList() ) newPassword.addAll( - clientState.getParcelableArrayListCompat(BUNDLE_KEY_NEW_PASSWORD_IDS) ?: emptyList() + BundleCompat.getParcelableArrayList( + clientState, + BUNDLE_KEY_NEW_PASSWORD_IDS, + AutofillId::class.java + ) + ?: emptyList() ) genericPassword.addAll( - clientState.getParcelableArrayListCompat(BUNDLE_KEY_GENERIC_PASSWORD_IDS) + BundleCompat.getParcelableArrayList( + clientState, + BUNDLE_KEY_GENERIC_PASSWORD_IDS, + AutofillId::class.java + ) ?: emptyList() ) } @@ -78,24 +96,6 @@ public sealed class AutofillScenario<out T : Any> { null } } - - private inline fun <reified T> Bundle.getParcelableCompat(key: String): T? { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - getParcelable(key, T::class.java) - } else { - @Suppress("DEPRECATION") getParcelable(key) - } - } - - private inline fun <reified T : Parcelable> Bundle.getParcelableArrayListCompat( - key: String - ): ArrayList<T>? { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - getParcelableArrayList(key, T::class.java) - } else { - @Suppress("DEPRECATION") getParcelableArrayList(key) - } - } } internal class Builder<T : Any> { |