Skip to content

refactor(parcel): migrate to type-safe Parcel read methods#16488

Open
joshtrichards wants to merge 7 commits intomasterfrom
jtr/refactor-type-safer-readSerializable-readParcelable
Open

refactor(parcel): migrate to type-safe Parcel read methods#16488
joshtrichards wants to merge 7 commits intomasterfrom
jtr/refactor-type-safer-readSerializable-readParcelable

Conversation

@joshtrichards
Copy link
Member

Summary

Migrates deprecated readSerializable() and readParcelable() calls to their type-safe variants using AndroidX ParcelCompat for backward compatibility with Android 9+.

Addresses lint warnings such as these:

w: file:///home/runner/work/android/android/app/src/main/java/com/nextcloud/client/account/RegisteredUser.kt:33:16 'fun <T : Parcelable!> readParcelable(p0: ClassLoader?): T?' is deprecated. Deprecated in Java.
w: file:///home/runner/work/android/android/app/src/main/java/com/nextcloud/client/account/RegisteredUser.kt:34:16 'fun <T : Parcelable!> readParcelable(p0: ClassLoader?): T?' is deprecated. Deprecated in Java.
w: file:///home/runner/work/android/android/app/src/main/java/com/nextcloud/client/account/RegisteredUser.kt:35:16 'fun <T : Parcelable!> readParcelable(p0: ClassLoader?): T?' is deprecated. Deprecated in Java.
w: file:///home/runner/work/android/android/app/src/main/java/com/nextcloud/client/account/Server.kt:22:16 'fun readSerializable(): Serializable?' is deprecated. Deprecated in Java.
w: file:///home/runner/work/android/android/app/src/main/java/com/nextcloud/client/account/Server.kt:23:16 'fun <T : Parcelable!> readParcelable(p0: ClassLoader?): T?' is deprecated. Deprecated in Java.

Changes

  • Add readSerializableCompat extension function to existing ParcableExtensions.kt
  • Update Server.kt to use extension functions
  • Update Request.kt (DownloadRequest & UploadRequest) to use extension functions
  • Update RegisteredUser.kt to use extension functions
  • Update OCFile.java to use ParcelCompat directly
  • Update ConflictDialogData.kt for consistency with type parameters

Why

  • Removes deprecation warnings on Android 13+ (API 33+)
  • Maintains backward compatibility with minSdk 28 (Android 9)
  • Provides type safety at compile time
  • Establishes consistent pattern across the codebase

Testing

  • Existing Parcelable tests pass
  • Account switching works correctly
  • File operations (upload/download) work correctly
  • No runtime errors on Android 9-14

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🏁 Checklist

  • Tests written, or not not needed

Signed-off-by: Josh <josh.t.richards@gmail.com>
Add readSerializableCompat to ParcableExtensions.kt for type-safe
Serializable deserialization using AndroidX ParcelCompat, maintaining consistency with existing readParcelableCompat function.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Codacy

SpotBugs

CategoryBaseNew
Bad practice4242
Correctness7474
Dodgy code257257
Experimental11
Internationalization77
Malicious code vulnerability22
Multithreaded correctness3434
Performance4443
Security1818
Total479478

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16488.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@joshtrichards joshtrichards marked this pull request as ready for review February 9, 2026 14:22
Copy link
Collaborator

@alperozturk96 alperozturk96 left a comment

Choose a reason for hiding this comment

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

Hello

Thank you for the PR, this is a valuable addition and much appreciated.

Given the scope of the changes, I would suggest splitting this into smaller, more focused PRs. For example:

  • One PR for Request.kt
  • One PR for Server.kt
  • Additional PRs for other affected components as needed

Breaking the changes down this way will make the review process more manageable, allow us to test each part thoroughly, and help identify any unforeseen edge cases early. It will also reduce risk and make merging safer and more incremental.

Thank you again for your effort and contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants