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

Fix : #5405 Feature/replace deprecated bundle calls #5611

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

TanishMoral11
Copy link
Collaborator

Explanation

Fix #5405 : This PR addresses the deprecation of certain Bundle methods in Android API level 33, as detailed in Feature Request #5405. Specifically, it replaces the usage of deprecated, type-ambiguous Bundle calls with type-safe alternatives from the BundleCompat class, which ensures compatibility with the updated Android API.

Changes Made:

  • Refactor of Bundle method calls:

    • Bundle.get() and Bundle.getSerializable() calls have been replaced with BundleCompat.get() and BundleCompat.getSerializable() respectively, using type-safe methods that are now required by API 33 and above.
  • Refactor of helper methods:

    • The getTypedSerializable() method in BundleExtensions.kt has been removed since it essentially reimplemented the BundleCompat.getSerializable() method. This reduces redundancy and ensures that the code uses the built-in methods of BundleCompat for serializable objects.

Additional Changes:

  • Replaced deprecated getSerializable() calls with BundleCompat.getSerializable().
  • Replaced get() calls with type-specific methods (e.g., getString(), getInt()).
  • Updated getTypedSerializable() helper method to use BundleCompat.
  • Modified affected files:
    • OptionsActivity.kt
    • TestFontScaleConfigurationUtilActivity.kt
    • TopicPracticeFragment.kt
    • BundleExtensions.kt
    • BundleExtensionsTest.kt

These changes were made to ensure compatibility with Android API level 33 (and later), which deprecated certain Bundle methods in favor of BundleCompat methods, specifically for better handling of type-specific data.

Testing:

  • Ensured that all affected fragments and activities were tested for correct behavior when navigating between them.
  • Validated that configuration changes (e.g., device rotation) do not break the functionality of the app.
  • Updated unit tests in BundleExtensionsTest.kt to ensure correct usage of the new type-safe methods.

This PR addresses part of issue #5405 by ensuring that all deprecated Bundle method calls are replaced and the app continues to function smoothly on API 33 and later.

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

@TanishMoral11 TanishMoral11 requested review from a team as code owners December 20, 2024 21:03
@TanishMoral11 TanishMoral11 marked this pull request as draft December 20, 2024 21:04
@TanishMoral11
Copy link
Collaborator Author

TanishMoral11 commented Dec 24, 2024

Hey @adhiamboperes ,

I'm reaching out because I encountered a couple of issues after updating the AndroidX dependencies, and I would appreciate your assistance in resolving them.

1. Duplicate Content Roots Error

After updating the dependencies, I received the following error when attempting to run the app:

Duplicate content roots detected Path: [C:/Users/Tanish/AndroidStudioProjects/0 PEN SOURCE/oppia-android/app/src/sharedTest/java] of module [oppia-android.app.unitTest] was removed from modules [oppia-android.app.androidTest]

Screenshot 2024-12-24 103110

It appears to be related to duplicate module paths, but I'm unsure about the appropriate steps to resolve this. Could you please provide some guidance on how to address this issue?

2. Gradle Duplicate Entry Error

In addition, during the Running process, I encountered the following error:
image

Caused by: org.gradle.api.InvalidUserCodeException: Entry arguments.proto is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.6/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

From my understanding, this is related to duplicate file handling in the Gradle build process. However, I’m uncertain about how to configure it correctly to resolve the issue. Any advice or recommendations would be extremely helpful.

Thanks !!

Copy link

oppiabot bot commented Dec 31, 2024

Hi @TanishMoral11, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Dec 31, 2024
@oppiabot oppiabot bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Dec 31, 2024
Copy link

oppiabot bot commented Jan 7, 2025

Hi @TanishMoral11, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jan 7, 2025
@TanishMoral11 TanishMoral11 removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jan 7, 2025
Copy link

oppiabot bot commented Jan 16, 2025

Hi @TanishMoral11, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jan 16, 2025
@TanishMoral11 TanishMoral11 removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jan 18, 2025
Copy link

oppiabot bot commented Jan 25, 2025

Hi @TanishMoral11, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jan 25, 2025
@TanishMoral11 TanishMoral11 removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jan 25, 2025
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.

[Feature Request]: Replace type-ambiguous (and now deprecated) Bundle calls
2 participants