diff options
Diffstat (limited to 'app/src')
4 files changed, 17 insertions, 36 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/autofill/AutofillPublisherChangedActivity.kt b/app/src/main/java/app/passwordstore/ui/autofill/AutofillPublisherChangedActivity.kt index 6d348a23..25075746 100644 --- a/app/src/main/java/app/passwordstore/ui/autofill/AutofillPublisherChangedActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/autofill/AutofillPublisherChangedActivity.kt @@ -17,6 +17,7 @@ import android.text.format.DateUtils import android.view.View import android.view.autofill.AutofillManager import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.IntentCompat import app.passwordstore.R import app.passwordstore.databinding.ActivityOreoAutofillPublisherChangedBinding import app.passwordstore.util.autofill.AutofillMatcher @@ -24,7 +25,6 @@ import app.passwordstore.util.autofill.AutofillPublisherChangedException import app.passwordstore.util.extensions.asLog import app.passwordstore.util.extensions.getApplicationInfoCompat import app.passwordstore.util.extensions.getPackageInfoCompat -import app.passwordstore.util.extensions.getParcelableExtraCompat import app.passwordstore.util.extensions.viewBinding import com.github.androidpasswordstore.autofillparser.FormOrigin import com.github.androidpasswordstore.autofillparser.computeCertificatesHash @@ -97,7 +97,11 @@ class AutofillPublisherChangedActivity : AppCompatActivity() { FormOrigin.App(appPackage) ) val fillResponse = - intent.getParcelableExtraCompat<FillResponse>(EXTRA_FILL_RESPONSE_AFTER_RESET) + IntentCompat.getParcelableExtra( + intent, + EXTRA_FILL_RESPONSE_AFTER_RESET, + FillResponse::class.java + ) setResult( RESULT_OK, Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillResponse) } diff --git a/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt b/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt index e4a9de8c..30e2b1b0 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt @@ -8,9 +8,9 @@ package app.passwordstore.ui.settings import android.os.Bundle import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity +import androidx.core.os.BundleCompat import app.passwordstore.R import app.passwordstore.databinding.ActivityPreferenceRecyclerviewBinding -import app.passwordstore.util.extensions.getParcelableCompat import app.passwordstore.util.extensions.viewBinding import com.google.android.material.dialog.MaterialAlertDialogBuilder import de.Maxr1998.modernpreferences.Preference @@ -84,9 +84,14 @@ class SettingsActivity : AppCompatActivity() { getString(subScreen.titleRes) } } - savedInstanceState - ?.getParcelableCompat<PreferencesAdapter.SavedState>("adapter") - ?.let(adapter::loadSavedState) + if (savedInstanceState != null) { + BundleCompat.getParcelable( + savedInstanceState, + "adapter", + PreferencesAdapter.SavedState::class.java + ) + ?.let(adapter::loadSavedState) + } binding.preferenceRecyclerView.adapter = adapter } diff --git a/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt b/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt index 2c9dbc9f..d3e840c7 100644 --- a/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt +++ b/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt @@ -16,8 +16,6 @@ import android.content.pm.PackageManager import android.content.pm.PackageManager.ApplicationInfoFlags import android.content.pm.PackageManager.PackageInfoFlags import android.os.Build -import android.os.Bundle -import android.os.Parcelable import android.util.Base64 import android.util.TypedValue import android.view.View @@ -140,32 +138,6 @@ fun String.base64(): String { return Base64.encodeToString(encodeToByteArray(), Base64.NO_WRAP) } -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) - } -} - -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) - } -} - -inline fun <reified T : Parcelable> Intent.getParcelableExtraCompat(key: String): T? { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - getParcelableExtra(key, T::class.java) - } else { - @Suppress("DEPRECATION") getParcelableExtra(key) - } -} - fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int): PackageInfo { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { getPackageInfo(packageName, PackageInfoFlags.of(flags.toLong())) diff --git a/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt b/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt index 5bbeba50..ec1e654e 100644 --- a/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt +++ b/app/src/main/java/app/passwordstore/util/services/PasswordExportService.kt @@ -13,11 +13,11 @@ import android.net.Uri import android.os.Build import android.os.IBinder import androidx.core.app.NotificationCompat +import androidx.core.content.IntentCompat import androidx.core.content.getSystemService import androidx.documentfile.provider.DocumentFile import app.passwordstore.R import app.passwordstore.data.repo.PasswordRepository -import app.passwordstore.util.extensions.getParcelableExtraCompat import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.Calendar @@ -30,7 +30,7 @@ class PasswordExportService : Service() { if (intent != null) { when (intent.action) { ACTION_EXPORT_PASSWORD -> { - val uri = intent.getParcelableExtraCompat<Uri>("uri") + val uri = IntentCompat.getParcelableExtra(intent, "uri", Uri::class.java) if (uri != null) { val targetDirectory = DocumentFile.fromTreeUri(applicationContext, uri) |