| commit | 57162ea74b646ef7ae43397251fd4cd32e2d80c3 | [log] [tgz] |
|---|---|---|
| author | Kuan-Ying Chou <[email protected]> | Thu Oct 17 19:10:05 2024 +0100 |
| committer | Kuan-Ying Chou <[email protected]> | Thu Oct 31 13:39:11 2024 +0000 |
| tree | 407745a89b0b1f8a2364376bbc06dde6a0371c1b | |
| parent | 73305d3cf9d9bfff42b1836ac0127032b7721496 [diff] |
Add functions to encode serializable objects to and decode serializable objects from `SavedState`. We do this by implementing an `Encoder` and a `Decoder` that writes and reads a `SavedState` output format for Kotlin Serialization (https://github.com/Kotlin/kotlinx.serialization). The format represents a Kotlin Serialization "primitive" as their corresponding `SavedState` supported type, and represents a "composite" in a `SavedState` with its property names as keys. Nested composites are represented by nested `SavedState`s. Here are some other design choices we made: 1. We don't record size for collections and rely on the size of the `SavedState` in decoding so that collections and non-collections are treated the same. 2. To save space, we don't encode default values by default (it can be tweaked with `@EncodeDefault` with plugin-generated serializers). 3. To support nullable parameters with default arguments (e.g. `val a: String? = "foo"`) and for `SavedState` size to be correct for collections, we encode `null`s. 4. To keep things simple we don't support specifying custom `SerializersModule`s for now. Please note that when using Kotlin Serialization and these functions as a `Parcelable` alternative on Android there's a performance overhead because of the extra serialization needed. Also note that on Android we don't have built-in support for Android or Java specific types supported by `Bundle` or `Parcel` yet (e.g. `Exception`, `java.io.Serializable`, or `IBinder`). We may consider adding these types in the future. Relnote: Add encodeToSavedState() and decodeFromSavedState() functions Test: SavedStateCodecTest.kt Bug: 374102924 Change-Id: I6f59faffaa3777bf56132a67f41b867d7a9663e5
Jetpack is a suite of libraries, tools, and guidance to help developers write high-quality apps easier. These components help you follow best practices, free you from writing boilerplate code, and simplify complex tasks, so you can focus on the code you care about.
Jetpack comprises the androidx.* package libraries, unbundled from the platform APIs. This means that it offers backward compatibility and is updated more frequently than the Android platform, making sure you always have access to the latest and greatest versions of the Jetpack components.
Our official AARs and JARs binaries are distributed through Google Maven.
You can learn more about using it from Android Jetpack landing page.
For contributions via GitHub, see the GitHub Contribution Guide.
Note: The contributions workflow via GitHub is currently experimental - only contributions to the following projects are being accepted at this time:
When contributing to Jetpack, follow the code review etiquette.
We are not currently accepting new modules.
Head over to the onboarding docs to learn more about getting set up and the development workflow!
Our continuous integration system builds all in progress (and potentially unstable) libraries as new changes are merged. You can manually download these AARs and JARs for your experimentation.
Before uploading your first contribution, you will need setup a password and agree to the contribution agreement:
Generate a HTTPS password: https://android-review.googlesource.com/new-password
Agree to the Google Contributor Licenses Agreement: https://android-review.googlesource.com/settings/new-agreement
AndroidX uses git to store all the binary Gradle dependencies. They are stored in prebuilts/androidx/internal and prebuilts/androidx/external directories in your checkout. All the dependencies in these directories are also available from google(), or mavenCentral(). We store copies of these dependencies to have hermetic builds. You can pull in a new dependency using our importMaven tool.