mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-04 05:17:36 +03:00
fix: Replace boolean parcelable
This commit is contained in:
parent
22073e4bbd
commit
5c46fdf41a
10 changed files with 45 additions and 23 deletions
|
@ -29,7 +29,9 @@ 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.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
@ -78,7 +80,7 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
|
|||
constructor(parcel: Parcel) {
|
||||
groupKDB = parcel.readParcelableCompat()
|
||||
groupKDBX = parcel.readParcelableCompat()
|
||||
isVirtual = parcel.readByte().toInt() != 0
|
||||
isVirtual = parcel.readBooleanCompat()
|
||||
}
|
||||
|
||||
enum class ChildFilter {
|
||||
|
@ -112,7 +114,7 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
|
|||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeParcelable(groupKDB, flags)
|
||||
dest.writeParcelable(groupKDBX, flags)
|
||||
dest.writeByte((if (isVirtual) 1 else 0).toByte())
|
||||
dest.writeBooleanCompat(isVirtual)
|
||||
}
|
||||
|
||||
override val nodeId: NodeId<*>
|
||||
|
|
|
@ -24,6 +24,8 @@ import android.content.Context
|
|||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.util.Base64
|
||||
import com.kunzisoft.keepass.utils.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
import org.apache.commons.io.output.CountingOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
|
@ -51,17 +53,17 @@ abstract class BinaryData : Parcelable {
|
|||
}
|
||||
|
||||
protected constructor(parcel: Parcel) {
|
||||
isCompressed = parcel.readByte().toInt() != 0
|
||||
isProtected = parcel.readByte().toInt() != 0
|
||||
isCorrupted = parcel.readByte().toInt() != 0
|
||||
isCompressed = parcel.readBooleanCompat()
|
||||
isProtected = parcel.readBooleanCompat()
|
||||
isCorrupted = parcel.readBooleanCompat()
|
||||
mLength = parcel.readLong()
|
||||
mBinaryHash = parcel.readInt()
|
||||
}
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeByte((if (isCompressed) 1 else 0).toByte())
|
||||
dest.writeByte((if (isProtected) 1 else 0).toByte())
|
||||
dest.writeByte((if (isCorrupted) 1 else 0).toByte())
|
||||
dest.writeBooleanCompat(isCompressed)
|
||||
dest.writeBooleanCompat(isProtected)
|
||||
dest.writeBooleanCompat(isCorrupted)
|
||||
dest.writeLong(mLength)
|
||||
dest.writeInt(mBinaryHash)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ package com.kunzisoft.keepass.database.element.entry
|
|||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.UnsignedInt
|
||||
import com.kunzisoft.keepass.utils.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
|
||||
class AutoType : Parcelable {
|
||||
|
||||
|
@ -41,7 +43,7 @@ class AutoType : Parcelable {
|
|||
}
|
||||
|
||||
constructor(parcel: Parcel) {
|
||||
this.enabled = parcel.readByte().toInt() != 0
|
||||
this.enabled = parcel.readBooleanCompat()
|
||||
this.obfuscationOptions = UnsignedInt(parcel.readInt())
|
||||
this.defaultSequence = parcel.readString() ?: defaultSequence
|
||||
parcel.readTypedList(this.windowSeqPairs, AutoTypeItem.CREATOR)
|
||||
|
@ -52,7 +54,7 @@ class AutoType : Parcelable {
|
|||
}
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeByte((if (enabled) 1 else 0).toByte())
|
||||
dest.writeBooleanCompat(enabled)
|
||||
dest.writeInt(obfuscationOptions.toKotlinInt())
|
||||
dest.writeString(defaultSequence)
|
||||
dest.writeTypedList(windowSeqPairs)
|
||||
|
|
|
@ -34,6 +34,8 @@ import com.kunzisoft.keepass.database.element.node.Type
|
|||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.readSerializableCompat
|
||||
import com.kunzisoft.keepass.utils.UnsignedLong
|
||||
import com.kunzisoft.keepass.utils.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
import java.util.*
|
||||
|
||||
class GroupKDBX : GroupVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInterface {
|
||||
|
@ -70,7 +72,7 @@ class GroupKDBX : GroupVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
|
|||
locationChanged = parcel.readParcelableCompat() ?: locationChanged
|
||||
customData = parcel.readParcelableCompat() ?: CustomData()
|
||||
notes = parcel.readString() ?: notes
|
||||
isExpanded = parcel.readByte().toInt() != 0
|
||||
isExpanded = parcel.readBooleanCompat()
|
||||
val isSearchingEnabled = parcel.readInt()
|
||||
enableSearching = if (isSearchingEnabled == -1) null else isSearchingEnabled == 1
|
||||
val isAutoTypeEnabled = parcel.readInt()
|
||||
|
@ -95,7 +97,7 @@ class GroupKDBX : GroupVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
|
|||
dest.writeParcelable(locationChanged, flags)
|
||||
dest.writeParcelable(customData, flags)
|
||||
dest.writeString(notes)
|
||||
dest.writeByte((if (isExpanded) 1 else 0).toByte())
|
||||
dest.writeBooleanCompat(isExpanded)
|
||||
dest.writeInt(if (enableSearching == null) -1 else if (enableSearching!!) 1 else 0)
|
||||
dest.writeInt(if (enableAutoType == null) -1 else if (enableAutoType!!) 1 else 0)
|
||||
dest.writeString(defaultAutoTypeSequence)
|
||||
|
|
|
@ -26,7 +26,9 @@ 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.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
|
||||
/**
|
||||
* Abstract class who manage Groups and Entries
|
||||
|
@ -51,7 +53,7 @@ abstract class NodeVersioned<IdType, Parent : GroupVersionedInterface<Parent, En
|
|||
this.lastModificationTime = parcel.readParcelableCompat() ?: lastModificationTime
|
||||
this.lastAccessTime = parcel.readParcelableCompat() ?: lastAccessTime
|
||||
this.expiryTime = parcel.readParcelableCompat() ?: expiryTime
|
||||
this.expires = parcel.readByte().toInt() != 0
|
||||
this.expires = parcel.readBooleanCompat()
|
||||
}
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
|
@ -62,7 +64,7 @@ abstract class NodeVersioned<IdType, Parent : GroupVersionedInterface<Parent, En
|
|||
dest.writeParcelable(lastModificationTime, flags)
|
||||
dest.writeParcelable(lastAccessTime, flags)
|
||||
dest.writeParcelable(expiryTime, flags)
|
||||
dest.writeByte((if (expires) 1 else 0).toByte())
|
||||
dest.writeBooleanCompat(expires)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
|
|
|
@ -21,6 +21,8 @@ package com.kunzisoft.keepass.database.element.security
|
|||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.utils.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
|
||||
class ProtectedString : Parcelable {
|
||||
|
||||
|
@ -39,7 +41,7 @@ class ProtectedString : Parcelable {
|
|||
}
|
||||
|
||||
constructor(parcel: Parcel) {
|
||||
isProtected = parcel.readByte().toInt() != 0
|
||||
isProtected = parcel.readBooleanCompat()
|
||||
stringValue = parcel.readString() ?: stringValue
|
||||
}
|
||||
|
||||
|
@ -48,7 +50,7 @@ class ProtectedString : Parcelable {
|
|||
}
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeByte((if (isProtected) 1 else 0).toByte())
|
||||
dest.writeBooleanCompat(isProtected)
|
||||
dest.writeString(stringValue)
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,10 @@ 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.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.readListCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
import java.util.*
|
||||
|
||||
class EntryInfo : NodeInfo {
|
||||
|
@ -66,7 +68,7 @@ class EntryInfo : NodeInfo {
|
|||
parcel.readListCompat(attachments)
|
||||
autoType = parcel.readParcelableCompat() ?: autoType
|
||||
otpModel = parcel.readParcelableCompat() ?: otpModel
|
||||
isTemplate = parcel.readByte().toInt() != 0
|
||||
isTemplate = parcel.readBooleanCompat()
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
|
@ -87,7 +89,7 @@ class EntryInfo : NodeInfo {
|
|||
parcel.writeList(attachments)
|
||||
parcel.writeParcelable(autoType, flags)
|
||||
parcel.writeParcelable(otpModel, flags)
|
||||
parcel.writeByte((if (isTemplate) 1 else 0).toByte())
|
||||
parcel.writeBooleanCompat(isTemplate)
|
||||
}
|
||||
|
||||
fun containsCustomFieldsProtected(): Boolean {
|
||||
|
|
|
@ -5,7 +5,9 @@ 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.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.readParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
|
||||
open class NodeInfo() : Parcelable {
|
||||
|
||||
|
@ -22,7 +24,7 @@ open class NodeInfo() : Parcelable {
|
|||
icon = parcel.readParcelableCompat() ?: icon
|
||||
creationTime = parcel.readParcelableCompat() ?: creationTime
|
||||
lastModificationTime = parcel.readParcelableCompat() ?: lastModificationTime
|
||||
expires = parcel.readInt() != 0
|
||||
expires = parcel.readBooleanCompat()
|
||||
expiryTime = parcel.readParcelableCompat() ?: expiryTime
|
||||
customData = parcel.readParcelableCompat() ?: customData
|
||||
}
|
||||
|
@ -32,7 +34,7 @@ open class NodeInfo() : Parcelable {
|
|||
parcel.writeParcelable(icon, flags)
|
||||
parcel.writeParcelable(creationTime, flags)
|
||||
parcel.writeParcelable(lastModificationTime, flags)
|
||||
parcel.writeInt(if (expires) 1 else 0)
|
||||
parcel.writeBooleanCompat(expires)
|
||||
parcel.writeParcelable(expiryTime, flags)
|
||||
parcel.writeParcelable(customData, flags)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.os.Parcel
|
|||
import android.os.Parcelable
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields
|
||||
import com.kunzisoft.keepass.utils.ObjectNameResource
|
||||
import com.kunzisoft.keepass.utils.readBooleanCompat
|
||||
import com.kunzisoft.keepass.utils.writeBooleanCompat
|
||||
|
||||
class SearchInfo : ObjectNameResource, Parcelable {
|
||||
var manualSelection: Boolean = false
|
||||
|
@ -44,7 +46,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
|||
}
|
||||
|
||||
private constructor(parcel: Parcel) {
|
||||
manualSelection = parcel.readByte().toInt() != 0
|
||||
manualSelection = parcel.readBooleanCompat()
|
||||
val readAppId = parcel.readString()
|
||||
applicationId = if (readAppId.isNullOrEmpty()) null else readAppId
|
||||
val readDomain = parcel.readString()
|
||||
|
@ -60,7 +62,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
|||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeByte((if (manualSelection) 1 else 0).toByte())
|
||||
parcel.writeBooleanCompat(manualSelection)
|
||||
parcel.writeString(applicationId ?: "")
|
||||
parcel.writeString(webDomain ?: "")
|
||||
parcel.writeString(webScheme ?: "")
|
||||
|
|
|
@ -234,4 +234,8 @@ inline fun <reified T : Enum<T>> Parcel.readEnum() =
|
|||
readString()?.let { enumValueOf<T>(it) }
|
||||
|
||||
fun <T : Enum<T>> Parcel.writeEnum(value: T?) =
|
||||
writeString(value?.name)
|
||||
writeString(value?.name)
|
||||
|
||||
fun Parcel.readBooleanCompat(): Boolean = readByte().toInt() != 0
|
||||
|
||||
fun Parcel.writeBooleanCompat(value: Boolean) = writeByte((if (value) 1 else 0).toByte())
|
Loading…
Add table
Add a link
Reference in a new issue