-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add builtin Android Parcelable support
- Loading branch information
Showing
23 changed files
with
339 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
gradle/build-logic/src/main/kotlin/mySettings.settings.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
public final class kotlinx/uuid/BinarySerializer : kotlinx/serialization/KSerializer { | ||
public static final field INSTANCE Lkotlinx/uuid/BinarySerializer; | ||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; | ||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lkotlinx/uuid/UUID; | ||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; | ||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V | ||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lkotlinx/uuid/UUID;)V | ||
} | ||
|
||
public final class kotlinx/uuid/EncodingKt { | ||
public static final fun UUID ([B)Lkotlinx/uuid/UUID; | ||
public static final fun UUID ([J)Lkotlinx/uuid/UUID; | ||
public static final fun encodeToByteArray (Lkotlinx/uuid/UUID;)[B | ||
public static final fun encodeToLongArray (Lkotlinx/uuid/UUID;)[J | ||
} | ||
|
||
public abstract interface annotation class kotlinx/uuid/InternalAPI : java/lang/annotation/Annotation { | ||
} | ||
|
||
public final class kotlinx/uuid/MigrationKt { | ||
public static final fun clockSequence (Lkotlinx/uuid/UUID;)I | ||
public static final fun fromString (Lkotlinx/uuid/UUID$Companion;Ljava/lang/String;)Lkotlinx/uuid/UUID; | ||
public static final fun getLeastSignificantBits (Lkotlinx/uuid/UUID;)J | ||
public static final fun getMostSignificantBits (Lkotlinx/uuid/UUID;)J | ||
public static final fun nameUUIDFromBytes (Lkotlinx/uuid/UUID$Companion;[B)Lkotlinx/uuid/UUID; | ||
public static final fun node (Lkotlinx/uuid/UUID;)J | ||
public static final fun randomUUID (Lkotlinx/uuid/UUID$Companion;)Lkotlinx/uuid/UUID; | ||
public static final fun timestamp (Lkotlinx/uuid/UUID;)J | ||
public static final fun variant (Lkotlinx/uuid/UUID;)I | ||
public static final fun version (Lkotlinx/uuid/UUID;)I | ||
} | ||
|
||
public final class kotlinx/uuid/NameBasedGeneratorKt { | ||
public static final fun generateUUID (Lkotlinx/uuid/UUID$Companion;Lkotlinx/uuid/UUID;Ljava/lang/String;)Lkotlinx/uuid/UUID; | ||
public static final fun generateUUID (Lkotlinx/uuid/UUID$Companion;[B)Lkotlinx/uuid/UUID; | ||
} | ||
|
||
public final class kotlinx/uuid/RandomGeneratorKt { | ||
public static final fun generateUUID (Lkotlinx/uuid/UUID$Companion;Lkotlin/random/Random;)Lkotlinx/uuid/UUID; | ||
public static synthetic fun generateUUID$default (Lkotlinx/uuid/UUID$Companion;Lkotlin/random/Random;ILjava/lang/Object;)Lkotlinx/uuid/UUID; | ||
public static final fun nextUUID (Lkotlin/random/Random;)Lkotlinx/uuid/UUID; | ||
} | ||
|
||
public final class kotlinx/uuid/SecureRandom_androidKt { | ||
public static final fun getSecureRandom ()Lkotlin/random/Random; | ||
} | ||
|
||
public abstract class kotlinx/uuid/Serializer : kotlinx/serialization/KSerializer { | ||
public synthetic fun <init> (ZLkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; | ||
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lkotlinx/uuid/UUID; | ||
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; | ||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V | ||
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Lkotlinx/uuid/UUID;)V | ||
} | ||
|
||
public final class kotlinx/uuid/Serializer$Default : kotlinx/uuid/Serializer { | ||
public static final field INSTANCE Lkotlinx/uuid/Serializer$Default; | ||
} | ||
|
||
public final class kotlinx/uuid/Serializer$WrappedCurlyBrackets : kotlinx/uuid/Serializer { | ||
public static final field INSTANCE Lkotlinx/uuid/Serializer$WrappedCurlyBrackets; | ||
} | ||
|
||
public final class kotlinx/uuid/UUID : kotlinx/uuid/internal/Parcelable, java/lang/Comparable { | ||
public static final field CREATOR Landroid/os/Parcelable$Creator; | ||
public static final field Companion Lkotlinx/uuid/UUID$Companion; | ||
public fun <init> ()V | ||
public fun <init> (IJIJI)V | ||
public synthetic fun <init> (IJIJIILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public fun <init> (Ljava/lang/String;)V | ||
public fun <init> (Lkotlinx/uuid/UUID$Version;JIJI)V | ||
public synthetic fun <init> (Lkotlinx/uuid/UUID$Version;JIJIILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public synthetic fun compareTo (Ljava/lang/Object;)I | ||
public fun compareTo (Lkotlinx/uuid/UUID;)I | ||
public fun equals (Ljava/lang/Object;)Z | ||
public final fun getClockSequence ()I | ||
public final fun getNode ()J | ||
public final fun getTimeStamp ()J | ||
public final fun getVariant ()I | ||
public final fun getVersion ()Lkotlinx/uuid/UUID$Version; | ||
public final fun getVersionNumber ()I | ||
public fun hashCode ()I | ||
public final fun isRfcVariant ()Z | ||
public fun toString ()Ljava/lang/String; | ||
public final fun toString (Z)Ljava/lang/String; | ||
} | ||
|
||
public final class kotlinx/uuid/UUID$Companion { | ||
public final fun getNIL ()Lkotlinx/uuid/UUID; | ||
public final fun isValidUUIDString (Ljava/lang/String;)Z | ||
public final fun serializer ()Lkotlinx/serialization/KSerializer; | ||
} | ||
|
||
public final class kotlinx/uuid/UUID$Version : java/lang/Enum { | ||
public static final field DCE_SECURITY Lkotlinx/uuid/UUID$Version; | ||
public static final field NAME_BASED_MD5 Lkotlinx/uuid/UUID$Version; | ||
public static final field NAME_BASED_SHA1 Lkotlinx/uuid/UUID$Version; | ||
public static final field RANDOM_BASED Lkotlinx/uuid/UUID$Version; | ||
public static final field TIME_BASED Lkotlinx/uuid/UUID$Version; | ||
public static fun getEntries ()Lkotlin/enums/EnumEntries; | ||
public static fun valueOf (Ljava/lang/String;)Lkotlinx/uuid/UUID$Version; | ||
public static fun values ()[Lkotlinx/uuid/UUID$Version; | ||
} | ||
|
||
public final class kotlinx/uuid/UUID7Kt { | ||
public static final fun UUIDv7 (JLkotlin/random/Random;)Lkotlinx/uuid/UUID; | ||
public static synthetic fun UUIDv7$default (JLkotlin/random/Random;ILjava/lang/Object;)Lkotlinx/uuid/UUID; | ||
public static final fun getUnixTimeStamp (Lkotlinx/uuid/UUID;)J | ||
} | ||
|
||
public abstract interface annotation class kotlinx/uuid/UUIDExperimentalAPI : java/lang/annotation/Annotation { | ||
public abstract fun plannedVersion ()Ljava/lang/String; | ||
} | ||
|
||
public final class kotlinx/uuid/UUIDKt { | ||
public static final fun toUUID (Ljava/lang/String;)Lkotlinx/uuid/UUID; | ||
public static final fun toUUIDOrNull (Ljava/lang/String;)Lkotlinx/uuid/UUID; | ||
} | ||
|
||
public abstract class kotlinx/uuid/internal/Parcelable : android/os/Parcelable { | ||
public fun <init> (JJ)V | ||
public fun describeContents ()I | ||
public fun writeToParcel (Landroid/os/Parcel;I)V | ||
} | ||
|
||
public final class kotlinx/uuid/internal/Parcelable_androidKt { | ||
public static final fun getCreator ()Landroid/os/Parcelable$Creator; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
kotlinx-uuid-core/src/androidInstrumentedTest/kotlin/kotlinx/uuid/internal/ParcelableTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package kotlinx.uuid.internal | ||
|
||
import android.os.Parcel | ||
import androidx.test.ext.junit.runners.* | ||
import kotlinx.uuid.* | ||
import org.junit.runner.* | ||
import kotlin.test.* | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ParcelableTest { | ||
@Test | ||
fun testParcelable() { | ||
val parcel = Parcel.obtain() | ||
val uuid = UUID(SOME_UUID_STRING) | ||
uuid.writeToParcel(parcel, uuid.describeContents()) | ||
parcel.setDataPosition(0) | ||
assertEquals(uuid, UUID.CREATOR.createFromParcel(parcel)) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
kotlinx-uuid-core/src/androidMain/kotlin/kotlinx/uuid/SecureRandom.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package kotlinx.uuid | ||
|
||
import kotlin.random.* | ||
|
||
/** | ||
* Returns a platform dependent SecureRandom instance. | ||
* - On JVM, it uses `java.util.SecureRandom` | ||
* - On JS, it uses `window.crypto` or `nodejs.crypto`. | ||
* - On darwin, it uses `SecRandomCopyBytes`. | ||
* - On mingw, it uses `BCryptRandom`. | ||
* - On Linux and Android native, it uses `DevUrandom`. | ||
*/ | ||
public actual val SecureRandom: Random = java.security.SecureRandom().asKotlinRandom() |
31 changes: 31 additions & 0 deletions
31
kotlinx-uuid-core/src/androidMain/kotlin/kotlinx/uuid/internal/Parcelable.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@file:Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
|
||
package kotlinx.uuid.internal | ||
|
||
import android.os.* | ||
import kotlinx.uuid.* | ||
|
||
public actual abstract class Parcelable actual constructor( | ||
private val timeStampAndVersionRaw: Long, | ||
private val clockSequenceVariantAndNodeRaw: Long | ||
) : android.os.Parcelable { | ||
override fun describeContents(): Int = 0 | ||
override fun writeToParcel(parcel: Parcel, flags: Int) { | ||
parcel.writeLong(timeStampAndVersionRaw) | ||
parcel.writeLong(clockSequenceVariantAndNodeRaw) | ||
} | ||
} | ||
|
||
internal actual typealias ParcelableCreator<UUID> = android.os.Parcelable.Creator<UUID> | ||
|
||
public actual val creator: ParcelableCreator<UUID> = object : android.os.Parcelable.Creator<UUID> { | ||
override fun createFromParcel(parcel: Parcel): UUID { | ||
val timeStampAndVersionRaw = parcel.readLong() | ||
val clockSequenceVariantAndNodeRaw = parcel.readLong() | ||
return UUID(timeStampAndVersionRaw, clockSequenceVariantAndNodeRaw) | ||
} | ||
|
||
override fun newArray(size: Int): Array<UUID?> { | ||
return arrayOfNulls(size) | ||
} | ||
} |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
kotlinx-uuid-core/src/appleMain/kotlin/kotlinx/uuid/internal/Parcelable.apple.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package kotlinx.uuid.internal | ||
|
||
import kotlinx.uuid.* | ||
|
||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
public actual abstract class Parcelable actual constructor( | ||
timeStampAndVersionRaw: Long, | ||
clockSequenceVariantAndNodeRaw: Long | ||
) | ||
|
||
public actual interface ParcelableCreator<T : Any> | ||
|
||
internal actual val creator: ParcelableCreator<UUID> = object : ParcelableCreator<UUID> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
kotlinx-uuid-core/src/commonMain/kotlin/kotlinx/uuid/internal/Parcelable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package kotlinx.uuid.internal | ||
|
||
import kotlinx.uuid.* | ||
|
||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
public expect abstract class Parcelable( | ||
timeStampAndVersionRaw: Long, | ||
clockSequenceVariantAndNodeRaw: Long | ||
) | ||
|
||
public expect interface ParcelableCreator<T: Any> | ||
|
||
internal expect val creator: ParcelableCreator<UUID> |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
kotlinx-uuid-core/src/jsMain/kotlin/kotlinx/uuid/internal/Parcelable.js.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package kotlinx.uuid.internal | ||
|
||
import kotlinx.uuid.* | ||
|
||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
public actual abstract class Parcelable actual constructor( | ||
timeStampAndVersionRaw: Long, | ||
clockSequenceVariantAndNodeRaw: Long | ||
) | ||
|
||
public actual interface ParcelableCreator<T : Any> | ||
|
||
internal actual val creator: ParcelableCreator<UUID> = object : ParcelableCreator<UUID> {} |
Oops, something went wrong.