mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-04 05:17:36 +03:00
fix: Resolve dependencies and small changes
This commit is contained in:
parent
d5310e5c58
commit
65d7fdbf7e
65 changed files with 254 additions and 252 deletions
|
@ -41,8 +41,8 @@ import com.kunzisoft.keepass.database.helper.SearchHelper
|
|||
import com.kunzisoft.keepass.model.RegisterInfo
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.WebDomain
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
|
|
|
@ -67,7 +67,7 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
|
|||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.tasks.AttachmentFileBinderManager
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.openUrl
|
||||
import com.kunzisoft.keepass.utils.UuidUtil
|
||||
import com.kunzisoft.keepass.view.changeControlColor
|
||||
|
|
|
@ -90,7 +90,7 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
|
|||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.tasks.AttachmentFileBinderManager
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.getDocumentFile
|
||||
import com.kunzisoft.keepass.view.ToolbarAction
|
||||
import com.kunzisoft.keepass.view.asError
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.kunzisoft.keepass.database.helper.SearchHelper
|
|||
import com.kunzisoft.keepass.magikeyboard.MagikeyboardService
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.WebDomain
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,7 +68,7 @@ import com.kunzisoft.keepass.tasks.ActionRunnable
|
|||
import com.kunzisoft.keepass.utils.DexUtil
|
||||
import com.kunzisoft.keepass.utils.MagikeyboardUtil
|
||||
import com.kunzisoft.keepass.utils.MenuUtil
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.UriHelper.parseUri
|
||||
import com.kunzisoft.keepass.utils.UriUtil.isContributingUser
|
||||
import com.kunzisoft.keepass.utils.UriUtil.openUrl
|
||||
|
|
|
@ -100,11 +100,11 @@ import com.kunzisoft.keepass.settings.SettingsActivity
|
|||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.BACK_PREVIOUS_KEYBOARD_ACTION
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.putParcelableList
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.putParcelableList
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.openUrl
|
||||
import com.kunzisoft.keepass.view.AddNodeButtonView
|
||||
import com.kunzisoft.keepass.view.NavigationDatabaseView
|
||||
|
|
|
@ -46,8 +46,8 @@ import com.kunzisoft.keepass.database.element.icon.IconImage
|
|||
import com.kunzisoft.keepass.database.element.icon.IconImageCustom
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.tasks.BinaryDatabaseManager
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.getDocumentFile
|
||||
import com.kunzisoft.keepass.utils.UriUtil.openUrl
|
||||
import com.kunzisoft.keepass.view.asError
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.kunzisoft.keepass.activities.legacy.DatabaseLockActivity
|
|||
import com.kunzisoft.keepass.database.ContextualDatabase
|
||||
import com.kunzisoft.keepass.database.element.Attachment
|
||||
import com.kunzisoft.keepass.tasks.BinaryDatabaseManager
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import kotlin.math.max
|
||||
|
||||
class ImageViewerActivity : DatabaseLockActivity() {
|
||||
|
|
|
@ -72,8 +72,8 @@ import com.kunzisoft.keepass.settings.SettingsAdvancedUnlockActivity
|
|||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.utils.BACK_PREVIOUS_KEYBOARD_ACTION
|
||||
import com.kunzisoft.keepass.utils.MenuUtil
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.getUri
|
||||
import com.kunzisoft.keepass.view.MainCredentialView
|
||||
import com.kunzisoft.keepass.view.asError
|
||||
|
|
|
@ -25,7 +25,7 @@ import android.text.SpannableStringBuilder
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
|
||||
|
||||
class DatabaseChangedDialogFragment : DatabaseDialogFragment() {
|
||||
|
|
|
@ -35,7 +35,7 @@ import com.google.android.material.textfield.TextInputLayout
|
|||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.Field
|
||||
import com.kunzisoft.keepass.database.element.security.ProtectedString
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
|
||||
|
||||
class EntryCustomFieldDialogFragment: DatabaseDialogFragment() {
|
||||
|
|
|
@ -27,7 +27,7 @@ import android.text.SpannableStringBuilder
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
|
||||
/**
|
||||
* Custom Dialog to confirm big file to upload
|
||||
|
|
|
@ -35,7 +35,7 @@ import com.kunzisoft.keepass.database.ContextualDatabase
|
|||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.model.GroupInfo
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||
import com.kunzisoft.keepass.utils.UuidUtil
|
||||
import com.kunzisoft.keepass.view.DateTimeFieldView
|
||||
|
|
|
@ -39,7 +39,7 @@ import com.kunzisoft.keepass.database.ContextualDatabase
|
|||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.model.GroupInfo
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.view.DateTimeEditFieldView
|
||||
import com.kunzisoft.keepass.view.InheritedCompletionView
|
||||
import com.kunzisoft.keepass.view.TagsCompletionView
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.kunzisoft.keepass.database.ContextualDatabase
|
|||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImageCustom
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.viewmodels.IconPickerViewModel
|
||||
|
||||
class IconEditDialogFragment : DatabaseDialogFragment() {
|
||||
|
|
|
@ -28,7 +28,7 @@ import androidx.appcompat.app.AlertDialog
|
|||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.helpers.ExternalFileHelper
|
||||
import com.kunzisoft.keepass.database.MainCredential
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.getDocumentFile
|
||||
import com.kunzisoft.keepass.view.MainCredentialView
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import androidx.appcompat.app.AlertDialog
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.MainCredential
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
|
||||
class PasswordEncodingDialogFragment : DialogFragment() {
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import android.text.SpannableStringBuilder
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.Attachment
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
|
||||
/**
|
||||
* Custom Dialog to confirm big file to upload
|
||||
|
|
|
@ -44,7 +44,7 @@ import com.kunzisoft.keepass.otp.OtpElement.Companion.MIN_TOTP_PERIOD
|
|||
import com.kunzisoft.keepass.otp.OtpTokenType
|
||||
import com.kunzisoft.keepass.otp.OtpType
|
||||
import com.kunzisoft.keepass.otp.TokenCalculator
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.isContributingUser
|
||||
import com.kunzisoft.keepass.utils.UriUtil.openUrl
|
||||
import java.util.*
|
||||
|
|
|
@ -42,8 +42,8 @@ import com.kunzisoft.keepass.model.AttachmentState
|
|||
import com.kunzisoft.keepass.model.EntryAttachmentState
|
||||
import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.model.StreamDirection
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.putParcelableList
|
||||
import com.kunzisoft.keepass.utils.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.putParcelableList
|
||||
import com.kunzisoft.keepass.view.TagsCompletionView
|
||||
import com.kunzisoft.keepass.view.TemplateEditView
|
||||
import com.kunzisoft.keepass.view.collapse
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.kunzisoft.keepass.autofill.AutofillComponent
|
|||
import com.kunzisoft.keepass.autofill.AutofillHelper
|
||||
import com.kunzisoft.keepass.model.RegisterInfo
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getEnumExtra
|
||||
import com.kunzisoft.keepass.utils.putEnumExtra
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ import com.kunzisoft.keepass.model.SearchInfo
|
|||
import com.kunzisoft.keepass.settings.AutofillSettingsActivity
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
|
|
|
@ -26,7 +26,7 @@ import android.os.Parcelable
|
|||
import android.service.autofill.FillRequest
|
||||
import android.view.inputmethod.InlineSuggestionsRequest
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
/**
|
||||
* Utility class only to prevent java.lang.NoClassDefFoundError for old Android version and new lib compilation
|
||||
|
|
|
@ -24,7 +24,7 @@ import android.os.Parcel
|
|||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.MasterCredential
|
||||
import com.kunzisoft.keepass.hardware.HardwareKey
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.UriHelper.getUriInputStream
|
||||
import com.kunzisoft.keepass.utils.readEnum
|
||||
import com.kunzisoft.keepass.utils.writeEnum
|
||||
|
|
|
@ -24,7 +24,7 @@ import android.net.Uri
|
|||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.text.format.Formatter
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.viewmodels.FileDatabaseInfo
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.kunzisoft.keepass.model.AttachmentState
|
|||
import com.kunzisoft.keepass.model.EntryAttachmentState
|
||||
import com.kunzisoft.keepass.model.StreamDirection
|
||||
import com.kunzisoft.keepass.tasks.BinaryDatabaseManager
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.getDocumentFile
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
|
@ -31,9 +31,9 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
|
|||
import com.kunzisoft.keepass.timeout.ClipboardHelper
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper.NEVER
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.putParcelableList
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.putParcelableList
|
||||
|
||||
class ClipboardEntryNotificationService : LockNotificationService() {
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ import com.kunzisoft.keepass.timeout.TimeoutHelper
|
|||
import com.kunzisoft.keepass.utils.DATABASE_START_TASK_ACTION
|
||||
import com.kunzisoft.keepass.utils.DATABASE_STOP_TASK_ACTION
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.putParcelableList
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableList
|
||||
import com.kunzisoft.keepass.utils.putParcelableList
|
||||
import com.kunzisoft.keepass.utils.closeDatabase
|
||||
import com.kunzisoft.keepass.viewmodels.FileDatabaseInfo
|
||||
import kotlinx.coroutines.*
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.kunzisoft.keepass.model.EntryInfo
|
|||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
|
||||
class KeyboardEntryNotificationService : LockNotificationService() {
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ import com.kunzisoft.keepass.services.DatabaseTaskNotificationService
|
|||
import com.kunzisoft.keepass.settings.preference.*
|
||||
import com.kunzisoft.keepass.settings.preferencedialogfragment.*
|
||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getSerializableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getSerializableCompat
|
||||
import com.kunzisoft.keepass.viewmodels.DatabaseViewModel
|
||||
|
||||
class NestedDatabaseSettingsFragment : NestedSettingsFragment(), DatabaseRetrieval {
|
||||
|
|
|
@ -28,7 +28,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.settings.preferencedialogfragment.adapter.AutofillBlocklistAdapter
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableArrayCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableArrayCompat
|
||||
import java.util.*
|
||||
import kotlin.Comparator
|
||||
import kotlin.collections.HashSet
|
||||
|
@ -37,8 +37,9 @@ abstract class AutofillBlocklistPreferenceDialogFragmentCompat
|
|||
: InputPreferenceDialogFragmentCompat(),
|
||||
AutofillBlocklistAdapter.ItemDeletedCallback<SearchInfo> {
|
||||
|
||||
private var persistedItems = TreeSet<SearchInfo>(
|
||||
Comparator { o1, o2 -> o1.toString().compareTo(o2.toString()) })
|
||||
private var persistedItems = TreeSet<SearchInfo> { o1, o2 ->
|
||||
o1.toString().compareTo(o2.toString())
|
||||
}
|
||||
|
||||
private var filterAdapter: AutofillBlocklistAdapter<SearchInfo>? = null
|
||||
|
||||
|
@ -65,7 +66,7 @@ abstract class AutofillBlocklistPreferenceDialogFragmentCompat
|
|||
override fun onBindDialogView(view: View) {
|
||||
super.onBindDialogView(view)
|
||||
|
||||
setOnInputTextEditorActionListener(TextView.OnEditorActionListener { _, actionId, _ ->
|
||||
setOnInputTextEditorActionListener { _, actionId, _ ->
|
||||
when (actionId) {
|
||||
EditorInfo.IME_ACTION_DONE -> {
|
||||
if (inputText.isEmpty()) {
|
||||
|
@ -77,9 +78,10 @@ abstract class AutofillBlocklistPreferenceDialogFragmentCompat
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
val addItemButton = view.findViewById<View>(R.id.add_item_button)
|
||||
addItemButton?.setOnClickListener {
|
||||
|
|
|
@ -32,7 +32,6 @@ import com.kunzisoft.keepass.BuildConfig
|
|||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
|
||||
import com.kunzisoft.keepass.education.Education
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.UriHelper.withContentScheme
|
||||
import com.kunzisoft.keepass.utils.UriHelper.withFileScheme
|
||||
import java.io.File
|
||||
|
|
|
@ -12,7 +12,7 @@ import android.widget.TextView
|
|||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.UriUtil.getDocumentFile
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.kunzisoft.keepass.model.EntryInfo
|
|||
import com.kunzisoft.keepass.otp.OtpElement
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
|
||||
abstract class TemplateAbstractView<
|
||||
|
|
|
@ -6,7 +6,7 @@ import androidx.lifecycle.MutableLiveData
|
|||
import androidx.lifecycle.ViewModel
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImageCustom
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImageStandard
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
|
||||
class IconPickerViewModel: ViewModel() {
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.os.Parcel
|
|||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryByte
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
|
||||
data class Attachment(var name: String,
|
||||
|
|
|
@ -21,8 +21,8 @@ package com.kunzisoft.keepass.database.element
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readStringParcelableMap
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.writeStringParcelableMap
|
||||
import com.kunzisoft.keepass.utils.readStringParcelableMap
|
||||
import com.kunzisoft.keepass.utils.writeStringParcelableMap
|
||||
import java.util.*
|
||||
|
||||
class CustomData : Parcelable {
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.kunzisoft.keepass.database.element
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
class CustomDataItem : Parcelable {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package com.kunzisoft.keepass.database.element
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readSerializableCompat
|
||||
import com.kunzisoft.keepass.utils.readSerializableCompat
|
||||
import com.kunzisoft.keepass.utils.readEnum
|
||||
import com.kunzisoft.keepass.utils.writeEnum
|
||||
import org.joda.time.Duration
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.os.Parcel
|
|||
import android.os.ParcelUuid
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.database.DatabaseVersioned
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.*
|
||||
|
||||
class DeletedObject : Parcelable {
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.kunzisoft.keepass.database.element.node.Type
|
|||
import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.otp.OtpElement
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.StringUtil.toFormattedColorInt
|
||||
import com.kunzisoft.keepass.utils.StringUtil.toFormattedColorString
|
||||
import java.util.UUID
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.kunzisoft.keepass.database.element
|
|||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.security.ProtectedString
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
class Field : Parcelable {
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.kunzisoft.keepass.database.element.icon.IconImage
|
|||
import com.kunzisoft.keepass.database.element.node.*
|
||||
import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.model.GroupInfo
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.kunzisoft.keepass.database.element.node.NodeId
|
|||
import com.kunzisoft.keepass.database.element.node.NodeIdUUID
|
||||
import com.kunzisoft.keepass.database.element.node.NodeKDBInterface
|
||||
import com.kunzisoft.keepass.database.element.node.Type
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,11 +36,11 @@ import com.kunzisoft.keepass.database.element.node.NodeIdUUID
|
|||
import com.kunzisoft.keepass.database.element.node.NodeKDBXInterface
|
||||
import com.kunzisoft.keepass.database.element.node.Type
|
||||
import com.kunzisoft.keepass.database.element.security.ProtectedString
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readStringIntMap
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readStringParcelableMap
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.writeStringIntMap
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.writeStringParcelableMap
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readStringIntMap
|
||||
import com.kunzisoft.keepass.utils.readStringParcelableMap
|
||||
import com.kunzisoft.keepass.utils.writeStringIntMap
|
||||
import com.kunzisoft.keepass.utils.writeStringParcelableMap
|
||||
import com.kunzisoft.keepass.utils.UnsignedLong
|
||||
import java.util.Date
|
||||
import java.util.UUID
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.kunzisoft.keepass.database.element.node.NodeId
|
|||
import com.kunzisoft.keepass.database.element.node.NodeIdInt
|
||||
import com.kunzisoft.keepass.database.element.node.NodeKDBInterface
|
||||
import com.kunzisoft.keepass.database.element.node.Type
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.*
|
||||
|
||||
class GroupKDB : GroupVersioned<Int, UUID, GroupKDB, EntryKDB>, NodeKDBInterface {
|
||||
|
|
|
@ -31,8 +31,8 @@ import com.kunzisoft.keepass.database.element.node.NodeId
|
|||
import com.kunzisoft.keepass.database.element.node.NodeIdUUID
|
||||
import com.kunzisoft.keepass.database.element.node.NodeKDBXInterface
|
||||
import com.kunzisoft.keepass.database.element.node.Type
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readSerializableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readSerializableCompat
|
||||
import com.kunzisoft.keepass.utils.UnsignedLong
|
||||
import java.util.*
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package com.kunzisoft.keepass.database.element.icon
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
class IconImage() : IconImageDraw() {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import android.os.ParcelUuid
|
|||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.database.element.database.DatabaseVersioned
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.UUID
|
||||
|
||||
class IconImageCustom : IconImageDraw {
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.kunzisoft.keepass.database.element.node
|
|||
import android.os.Parcel
|
||||
import android.os.ParcelUuid
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.UuidUtil
|
||||
import java.util.*
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.kunzisoft.keepass.database.element.DateInstant
|
|||
import com.kunzisoft.keepass.database.element.entry.EntryVersionedInterface
|
||||
import com.kunzisoft.keepass.database.element.group.GroupVersionedInterface
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
/**
|
||||
* Abstract class who manage Groups and Entries
|
||||
|
|
|
@ -23,8 +23,8 @@ import android.os.ParcelUuid
|
|||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.database.DatabaseVersioned
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readListCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readListCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.kunzisoft.keepass.database.element.template
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readEnum
|
||||
import com.kunzisoft.keepass.utils.writeEnum
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ package com.kunzisoft.keepass.database.element.template
|
|||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readStringStringMap
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.writeStringStringMap
|
||||
import com.kunzisoft.keepass.utils.readStringStringMap
|
||||
import com.kunzisoft.keepass.utils.writeStringStringMap
|
||||
|
||||
class TemplateAttributeOption() : Parcelable {
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.kunzisoft.keepass.database.element.template
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readListCompat
|
||||
import com.kunzisoft.keepass.utils.readListCompat
|
||||
|
||||
class TemplateSection: Parcelable {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.kunzisoft.keepass.model
|
|||
import android.net.Uri
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readEnum
|
||||
import com.kunzisoft.keepass.utils.writeEnum
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.kunzisoft.keepass.model
|
|||
import android.net.Uri
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readEnum
|
||||
import com.kunzisoft.keepass.utils.writeEnum
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.kunzisoft.keepass.model
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readSerializableCompat
|
||||
import com.kunzisoft.keepass.utils.readSerializableCompat
|
||||
import org.joda.time.DateTime
|
||||
|
||||
data class CreditCard(val cardholder: String?,
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.os.Parcel
|
|||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.Attachment
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryByte
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readEnum
|
||||
import com.kunzisoft.keepass.utils.writeEnum
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ import com.kunzisoft.keepass.database.element.template.TemplateField
|
|||
import com.kunzisoft.keepass.otp.OtpElement
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields.OTP_TOKEN_FIELD
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readListCompat
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readListCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.*
|
||||
|
||||
class EntryInfo : NodeInfo {
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.kunzisoft.keepass.model
|
|||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.database.element.Field
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
class FocusedEditField : Parcelable {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.os.Parcelable
|
|||
import com.kunzisoft.keepass.database.element.Tags
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImageStandard
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImageStandard.Companion.FOLDER_ID
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import java.util.*
|
||||
|
||||
class GroupInfo : NodeInfo {
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.os.Parcelable
|
|||
import com.kunzisoft.keepass.database.element.CustomData
|
||||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
open class NodeInfo() : Parcelable {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.kunzisoft.keepass.model
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.ParcelableUtil.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
|
||||
data class RegisterInfo(val searchInfo: SearchInfo,
|
||||
val username: String?,
|
||||
|
|
|
@ -27,180 +27,187 @@ import android.os.Parcelable
|
|||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
||||
object ParcelableUtil {
|
||||
// -------- Intent --------
|
||||
inline fun <reified T : Parcelable> Intent.getParcelableExtraCompat(key: String?): T? = when {
|
||||
key == null -> null
|
||||
SDK_INT >= 33 -> getParcelableExtra(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T
|
||||
}
|
||||
|
||||
inline fun <reified T : Parcelable> Intent.getParcelableExtraCompat(key: String?): T? = when {
|
||||
key == null -> null
|
||||
SDK_INT >= 33 -> getParcelableExtra(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T
|
||||
inline fun <reified T : Serializable> Intent.getSerializableExtraCompat(key: String?): T? = when {
|
||||
key == null -> null
|
||||
SDK_INT >= 33 -> getSerializableExtra(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getSerializableExtra(key) as? T
|
||||
}
|
||||
|
||||
inline fun <reified E : Parcelable> Intent.putParcelableList(key: String?, list: MutableList<E>) {
|
||||
putExtra(key, list.toTypedArray())
|
||||
}
|
||||
|
||||
inline fun <reified E : Parcelable> Intent.getParcelableList(key: String?): MutableList<E>? = when {
|
||||
SDK_INT >= 33 -> getParcelableArrayExtra(key, E::class.java)?.toMutableList()
|
||||
else -> @Suppress("DEPRECATION", "UNCHECKED_CAST") (getParcelableArrayExtra(key) as? Array<E>)?.toMutableList()
|
||||
}
|
||||
|
||||
inline fun <reified T : Enum<T>> Intent.getEnumExtra(key: String?) =
|
||||
getStringExtra(key)?.let { enumValueOf<T>(it) }
|
||||
|
||||
fun <T : Enum<T>> Intent.putEnumExtra(key: String?, value: T?) =
|
||||
putExtra(key, value?.name)
|
||||
|
||||
// -------- Bundle --------
|
||||
inline fun <reified T : Parcelable> Bundle.getParcelableCompat(key: String?): T? = when {
|
||||
key == null -> null
|
||||
SDK_INT >= 33 -> getParcelable(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getParcelable(key) as? T
|
||||
}
|
||||
|
||||
inline fun <reified T : Serializable> Bundle.getSerializableCompat(key: String?): T? = when {
|
||||
SDK_INT >= 33 -> getSerializable(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getSerializable(key) as? T
|
||||
}
|
||||
|
||||
inline fun <reified T : Parcelable> Bundle.getParcelableArrayCompat(key: String?): Array<out T>? {
|
||||
return when {
|
||||
SDK_INT >= 33 -> getParcelableArray(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION", "UNCHECKED_CAST") (getParcelableArray(key) as? Array<T>)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Serializable> Intent.getSerializableExtraCompat(key: String?): T? = when {
|
||||
key == null -> null
|
||||
SDK_INT >= 33 -> getSerializableExtra(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getSerializableExtra(key) as? T
|
||||
inline fun <reified E : Parcelable> Bundle.putParcelableList(key: String?, list: List<E>) {
|
||||
putParcelableArray(key, list.toTypedArray())
|
||||
}
|
||||
|
||||
inline fun <reified E : Parcelable> Bundle.getParcelableList(key: String?): MutableList<E>? = when {
|
||||
SDK_INT >= 33 -> getParcelableArray(key, E::class.java)?.toMutableList()
|
||||
else -> @Suppress("DEPRECATION", "UNCHECKED_CAST") (getParcelableArray(key) as? Array<E>)?.toMutableList()
|
||||
}
|
||||
|
||||
// -------- Parcel --------
|
||||
|
||||
inline fun <reified T : Parcelable> Parcel.readParcelableCompat(): T? = when {
|
||||
SDK_INT >= 33 -> readParcelable(T::class.java.classLoader, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(T::class.java.classLoader) as? T
|
||||
}
|
||||
|
||||
fun <T> Parcel.readParcelableCompat(clazz: Class<T>): T? = when {
|
||||
SDK_INT >= 33 -> readParcelable(clazz.classLoader, clazz)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(clazz.classLoader) as? T
|
||||
}
|
||||
|
||||
inline fun <reified T : Serializable> Parcel.readSerializableCompat(): T? = when {
|
||||
SDK_INT >= 33 -> readSerializable(T::class.java.classLoader, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") readSerializable() as? T
|
||||
}
|
||||
|
||||
inline fun <reified T> Parcel.readListCompat(outVal: MutableList<T>) {
|
||||
when {
|
||||
SDK_INT >= 33 -> readList(outVal, T::class.java.classLoader, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") readList(outVal, T::class.java.classLoader)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Parcelable> Bundle.getParcelableCompat(key: String?): T? = when {
|
||||
key == null -> null
|
||||
SDK_INT >= 33 -> getParcelable(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getParcelable(key) as? T
|
||||
// For writing to a Parcel
|
||||
fun <K : Parcelable, V : Parcelable> Parcel.writeParcelableMap(map: Map<K, V>, flags: Int) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeParcelable(key, flags)
|
||||
writeParcelable(value, flags)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Serializable> Bundle.getSerializableCompat(key: String?): T? = when {
|
||||
SDK_INT >= 33 -> getSerializable(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getSerializable(key) as? T
|
||||
// For reading from a Parcel
|
||||
inline fun <reified K : Parcelable, reified V : Parcelable> Parcel.readParcelableMap(): Map<K, V> {
|
||||
val size = readInt()
|
||||
val map = HashMap<K, V>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: K? = try {
|
||||
when {
|
||||
SDK_INT >= 33 -> readParcelable(K::class.java.classLoader, K::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(K::class.java.classLoader)
|
||||
}
|
||||
} catch (e: Exception) { null }
|
||||
val value: V? = try {
|
||||
when {
|
||||
SDK_INT >= 33 -> readParcelable(V::class.java.classLoader, V::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(V::class.java.classLoader)
|
||||
}
|
||||
} catch (e: Exception) { null }
|
||||
if (key != null && value != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
inline fun <reified T : Parcelable> Bundle.getParcelableArrayCompat(key: String?): Array<out T>? {
|
||||
return when {
|
||||
SDK_INT >= 33 -> getParcelableArray(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION", "UNCHECKED_CAST") (getParcelableArray(key) as? Array<T>)
|
||||
}
|
||||
// For writing map with string key to a Parcel
|
||||
fun <V : Parcelable> Parcel.writeStringParcelableMap(map: HashMap<String, V>, flags: Int) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeString(key)
|
||||
writeParcelable(value, flags)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified E : Parcelable> Intent.putParcelableList(key: String?, list: MutableList<E>) {
|
||||
putExtra(key, list.toTypedArray())
|
||||
// For reading map with string key from a Parcel
|
||||
inline fun <reified V : Parcelable> Parcel.readStringParcelableMap(): LinkedHashMap<String, V> {
|
||||
val size = readInt()
|
||||
val map = LinkedHashMap<String, V>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: String? = readString()
|
||||
val value: V? = try {
|
||||
when {
|
||||
SDK_INT >= 33 -> readParcelable(V::class.java.classLoader, V::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(V::class.java.classLoader)
|
||||
}
|
||||
} catch (e: Exception) { null }
|
||||
if (key != null && value != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
inline fun <reified E : Parcelable> Intent.getParcelableList(key: String?): MutableList<E>? = when {
|
||||
SDK_INT >= 33 -> getParcelableArrayExtra(key, E::class.java)?.toMutableList()
|
||||
else -> @Suppress("DEPRECATION", "UNCHECKED_CAST") (getParcelableArrayExtra(key) as? Array<E>)?.toMutableList()
|
||||
// For writing map with string key and Int value to a Parcel
|
||||
fun Parcel.writeStringIntMap(map: LinkedHashMap<String, Int>) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeString(key)
|
||||
writeInt(value)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified E : Parcelable> Bundle.putParcelableList(key: String?, list: List<E>) {
|
||||
putParcelableArray(key, list.toTypedArray())
|
||||
// For reading map with string key and Int value from a Parcel
|
||||
fun Parcel.readStringIntMap(): LinkedHashMap<String, Int> {
|
||||
val size = readInt()
|
||||
val map = LinkedHashMap<String, Int>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: String? = readString()
|
||||
val value: Int = readInt()
|
||||
if (key != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
inline fun <reified E : Parcelable> Bundle.getParcelableList(key: String?): MutableList<E>? = when {
|
||||
SDK_INT >= 33 -> getParcelableArray(key, E::class.java)?.toMutableList()
|
||||
else -> @Suppress("DEPRECATION", "UNCHECKED_CAST") (getParcelableArray(key) as? Array<E>)?.toMutableList()
|
||||
|
||||
// For writing map with string key and string value to a Parcel
|
||||
fun Parcel.writeStringStringMap(map: MutableMap<String, String>) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeString(key)
|
||||
writeString(value)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Parcelable> Parcel.readParcelableCompat(): T? = when {
|
||||
SDK_INT >= 33 -> readParcelable(T::class.java.classLoader, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(T::class.java.classLoader) as? T
|
||||
}
|
||||
|
||||
fun <T> Parcel.readParcelableCompat(clazz: Class<T>): T? = when {
|
||||
SDK_INT >= 33 -> readParcelable(clazz.classLoader, clazz)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(clazz.classLoader) as? T
|
||||
}
|
||||
|
||||
inline fun <reified T : Serializable> Parcel.readSerializableCompat(): T? = when {
|
||||
SDK_INT >= 33 -> readSerializable(T::class.java.classLoader, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") readSerializable() as? T
|
||||
}
|
||||
|
||||
inline fun <reified T> Parcel.readListCompat(outVal: MutableList<T>) {
|
||||
when {
|
||||
SDK_INT >= 33 -> readList(outVal, T::class.java.classLoader, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") readList(outVal, T::class.java.classLoader)
|
||||
}
|
||||
}
|
||||
|
||||
// For writing to a Parcel
|
||||
fun <K : Parcelable, V : Parcelable> Parcel.writeParcelableMap(map: Map<K, V>, flags: Int) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeParcelable(key, flags)
|
||||
writeParcelable(value, flags)
|
||||
}
|
||||
}
|
||||
|
||||
// For reading from a Parcel
|
||||
inline fun <reified K : Parcelable, reified V : Parcelable> Parcel.readParcelableMap(): Map<K, V> {
|
||||
val size = readInt()
|
||||
val map = HashMap<K, V>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: K? = try {
|
||||
when {
|
||||
SDK_INT >= 33 -> readParcelable(K::class.java.classLoader, K::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(K::class.java.classLoader)
|
||||
}
|
||||
} catch (e: Exception) { null }
|
||||
val value: V? = try {
|
||||
when {
|
||||
SDK_INT >= 33 -> readParcelable(V::class.java.classLoader, V::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(V::class.java.classLoader)
|
||||
}
|
||||
} catch (e: Exception) { null }
|
||||
if (key != null && value != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
// For writing map with string key to a Parcel
|
||||
fun <V : Parcelable> Parcel.writeStringParcelableMap(map: HashMap<String, V>, flags: Int) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeString(key)
|
||||
writeParcelable(value, flags)
|
||||
}
|
||||
}
|
||||
|
||||
// For reading map with string key from a Parcel
|
||||
inline fun <reified V : Parcelable> Parcel.readStringParcelableMap(): LinkedHashMap<String, V> {
|
||||
val size = readInt()
|
||||
val map = LinkedHashMap<String, V>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: String? = readString()
|
||||
val value: V? = try {
|
||||
when {
|
||||
SDK_INT >= 33 -> readParcelable(V::class.java.classLoader, V::class.java)
|
||||
else -> @Suppress("DEPRECATION") readParcelable(V::class.java.classLoader)
|
||||
}
|
||||
} catch (e: Exception) { null }
|
||||
if (key != null && value != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
// For writing map with string key and Int value to a Parcel
|
||||
fun Parcel.writeStringIntMap(map: LinkedHashMap<String, Int>) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeString(key)
|
||||
writeInt(value)
|
||||
}
|
||||
}
|
||||
|
||||
// For reading map with string key and Int value from a Parcel
|
||||
fun Parcel.readStringIntMap(): LinkedHashMap<String, Int> {
|
||||
val size = readInt()
|
||||
val map = LinkedHashMap<String, Int>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: String? = readString()
|
||||
val value: Int = readInt()
|
||||
if (key != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
|
||||
// For writing map with string key and string value to a Parcel
|
||||
fun Parcel.writeStringStringMap(map: MutableMap<String, String>) {
|
||||
writeInt(map.size)
|
||||
for ((key, value) in map) {
|
||||
writeString(key)
|
||||
writeString(value)
|
||||
}
|
||||
}
|
||||
|
||||
fun Parcel.readStringStringMap(): LinkedHashMap<String, String> {
|
||||
val size = readInt()
|
||||
val map = LinkedHashMap<String, String>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: String? = readString()
|
||||
val value: String? = readString()
|
||||
if (key != null && value != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
fun Parcel.readStringStringMap(): LinkedHashMap<String, String> {
|
||||
val size = readInt()
|
||||
val map = LinkedHashMap<String, String>(size)
|
||||
for (i in 0 until size) {
|
||||
val key: String? = readString()
|
||||
val value: String? = readString()
|
||||
if (key != null && value != null)
|
||||
map[key] = value
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
fun Parcel.readByteArrayCompat(): ByteArray? {
|
||||
|
@ -223,14 +230,8 @@ fun Parcel.writeByteArrayCompat(data: ByteArray?) {
|
|||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Enum<T>> Intent.getEnumExtra(key: String?) =
|
||||
getStringExtra(key)?.let { enumValueOf<T>(it) }
|
||||
|
||||
fun <T : Enum<T>> Intent.putEnumExtra(key: String?, value: T?) =
|
||||
putExtra(key, value?.name)
|
||||
|
||||
inline fun <reified T : Enum<T>> Parcel.readEnum() =
|
||||
readString()?.let { enumValueOf<T>(it) }
|
||||
readString()?.let { enumValueOf<T>(it) }
|
||||
|
||||
fun <T : Enum<T>> Parcel.writeEnum(value: T?) =
|
||||
writeString(value?.name)
|
||||
writeString(value?.name)
|
Loading…
Add table
Add a link
Reference in a new issue