Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PersistableBundle extensions #174

Merged
merged 1 commit into from
Jul 20, 2024
Merged

Conversation

arkivanov
Copy link
Owner

@arkivanov arkivanov commented Jul 20, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new methods for serialization and deserialization of objects within PersistableBundle, enhancing state management in Android applications.
    • Added unit tests to validate the functionality of the new serialization features.
  • Bug Fixes

    • Updated the version of the robolectric library, which may include various bug fixes and performance improvements.
  • Tests

    • Enhanced the testing framework for PersistableBundle to ensure accurate serialization and deserialization across multiple scenarios.

Copy link

coderabbitai bot commented Jul 20, 2024

Walkthrough

The recent changes introduce an upgrade to the robolectric library alongside significant enhancements to PersistableBundle functionality in Android. A new class and extension functions have been added to streamline serialization and deserialization processes, improving state management. Additionally, comprehensive unit tests ensure the reliability of these updates, contributing to a more robust application framework.

Changes

Files Change Summary
deps.versions.toml Updated robolectric version from 4.9.1 to 4.13.
state-keeper/api/android/state-keeper.api, state-keeper/src/androidMain/kotlin/.../PersistableBundleExt.kt Introduced PersistableBundleExtKt class with methods for serialization and deserialization.
state-keeper/src/androidUnitTest/kotlin/.../AndroidStateKeeperTest.kt, BundleExtTest.kt Updated method calls from deparcelize() to deparcelizeBundle() for enhanced clarity in state restoration.
state-keeper/src/androidUnitTest/kotlin/.../PersistableBundleExtTest.kt Added unit tests for validating PersistableBundle serialization and deserialization functionality.
state-keeper/src/androidUnitTest/kotlin/.../TestUtils.android.kt Renamed deparcelize to deparcelizeBundle; added parcelize and deparcelizePersistableBundle functions.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant PersistableBundle
    participant SerializationLibrary

    App->>PersistableBundle: putSerializable(key, value)
    PersistableBundle->>SerializationLibrary: serialize(value)
    SerializationLibrary-->>PersistableBundle: serializedValue
    PersistableBundle-->>App: success

    App->>PersistableBundle: getSerializable(key)
    PersistableBundle-->>SerializationLibrary: deserialize(serializedValue)
    SerializationLibrary-->>PersistableBundle: originalValue
    PersistableBundle-->>App: originalValue
Loading

Poem

🐰 In the garden of code, I hop with delight,
New features sprout, shining so bright.
Bundles now dance, with data in tow,
Serialization magic makes state management flow!
With tests now in place, oh what a thrill,
A rabbit rejoices, with nimble skill! 🥕


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f97f91c and c673f69.

Files selected for processing (7)
  • deps.versions.toml (1 hunks)
  • state-keeper/api/android/state-keeper.api (1 hunks)
  • state-keeper/src/androidMain/kotlin/com/arkivanov/essenty/statekeeper/PersistableBundleExt.kt (1 hunks)
  • state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/AndroidStateKeeperTest.kt (3 hunks)
  • state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/BundleExtTest.kt (2 hunks)
  • state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/PersistableBundleExtTest.kt (1 hunks)
  • state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/TestUtils.android.kt (1 hunks)
Additional comments not posted (24)
state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/TestUtils.android.kt (4)

13-19: LGTM!

The function correctly deserializes a ByteArray into a Bundle and ensures that the result is non-null.


21-25: LGTM!

The function correctly serializes a PersistableBundle into a ByteArray.


27-33: LGTM!

The function correctly deserializes a ByteArray into a PersistableBundle and ensures that the result is non-null.


7-11: LGTM!

The function correctly serializes a Bundle into a ByteArray.

state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/BundleExtTest.kt (3)

Line range hint 12-19:
LGTM!

The test correctly verifies that a Serializable object is correctly retrieved from a Bundle without serialization.


Line range hint 23-30:
LGTM!

The test correctly verifies that a Serializable object is correctly retrieved from a Bundle after serialization and deserialization.


Line range hint 33-43:
LGTM!

The test correctly verifies that a Serializable object is correctly retrieved from a Bundle after double serialization and deserialization.

state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/PersistableBundleExtTest.kt (4)

13-21: LGTM!

The test correctly verifies that a Serializable object is correctly retrieved from a PersistableBundle without serialization.


23-31: LGTM!

The test correctly verifies that a Serializable object is correctly retrieved from a PersistableBundle after serialization and deserialization.


33-44: LGTM!

The test correctly verifies that a Serializable object is correctly retrieved from a PersistableBundle after double serialization and deserialization.


46-47: LGTM!

The data class is correctly defined and used in the tests.

state-keeper/src/androidMain/kotlin/com/arkivanov/essenty/statekeeper/PersistableBundleExt.kt (4)

17-20: LGTM!

The putSerializable function correctly inserts a serializable value into a PersistableBundle using the provided SerializationStrategy.


27-29: LGTM!

The getSerializable function correctly retrieves a serializable value from a PersistableBundle using the provided DeserializationStrategy.


35-38: LGTM!

The putSerializableContainer function correctly inserts a SerializableContainer into a PersistableBundle using the SerializableContainer.serializer().


45-47: LGTM!

The getSerializableContainer function correctly retrieves a SerializableContainer from a PersistableBundle using the SerializableContainer.serializer().

deps.versions.toml (1)

14-14: Upgrade approved! Verify compatibility.

The robolectric version has been updated from 4.9.1 to 4.13. Ensure compatibility with the rest of the codebase.

state-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/statekeeper/AndroidStateKeeperTest.kt (4)

Line range hint 13-27:
LGTM!

The saves_and_restores_state_without_parcelling test function correctly verifies state saving and restoring without parcelling.


47-47: LGTM!

The saves_and_restores_state_with_parcelling test function correctly verifies state saving and restoring with parcelling. The change to deparcelizeBundle() improves clarity and specificity.


Line range hint 49-61:
LGTM!

The GIVEN_isSavingAllowed_is_false_on_save_THEN_state_not_saved test function correctly verifies that state is not saved when saving is not allowed.


75-75: LGTM!

The GIVEN_discardSavedState_is_true_on_restore_THEN_discards_saved_state test function correctly verifies that saved state is discarded when discardSavedState is true. The change to deparcelizeBundle() improves clarity and specificity.

state-keeper/api/android/state-keeper.api (4)

18-19: Ensure proper error handling in getSerializable.

The method getSerializable retrieves a serializable object from a PersistableBundle. Ensure that the method handles cases where the key does not exist or the deserialization fails.


20-20: Ensure proper error handling in getSerializableContainer.

The method getSerializableContainer retrieves a SerializableContainer from a PersistableBundle. Ensure that the method handles cases where the key does not exist.


21-21: Ensure proper error handling in putSerializable.

The method putSerializable inserts a serializable object into a PersistableBundle. Ensure that the method handles cases where the serialization fails.


22-22: Ensure proper error handling in putSerializableContainer.

The method putSerializableContainer inserts a SerializableContainer into a PersistableBundle. Ensure that the method handles cases where the container is null or invalid.

@arkivanov arkivanov force-pushed the persistable-bundle-extensions branch from c673f69 to 195b1fe Compare July 20, 2024 14:51
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c673f69 and 195b1fe.

Files selected for processing (2)
  • state-keeper/api/android/state-keeper.api (1 hunks)
  • state-keeper/src/androidMain/kotlin/com/arkivanov/essenty/statekeeper/PersistableBundleExt.kt (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • state-keeper/api/android/state-keeper.api
  • state-keeper/src/androidMain/kotlin/com/arkivanov/essenty/statekeeper/PersistableBundleExt.kt

@arkivanov arkivanov merged commit f6d2dfb into master Jul 20, 2024
2 checks passed
@arkivanov arkivanov deleted the persistable-bundle-extensions branch July 20, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant