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 handling of shared files in intent and improve error handling #6141

Conversation

Sujal-Gupta-SG
Copy link
Contributor

Changes:

  • Corrected the constant for the extra key from commons_image_exta to commons_image_extra.
  • Updated the receiveInternalSharedItems() method to improve handling of shared files:
    • Added null safety checks and proper handling of missing or malformed extras (EXTRA_FILES).
    • Added version-specific logic to handle different Android SDK versions (API 33 and above).
    • Enhanced logging for debugging shared file paths.
    • Incorporated error handling for potential exceptions when reading extras (PLACE_OBJECT and LOCATION_BEFORE_IMAGE_CAPTURE).
    • Replaced deprecated methods for API 33+ with their latest alternatives, ensuring compatibility with both older and newer versions of Android.

Benefits:

  • More robust file handling with better error logging to avoid crashes caused by missing or malformed intent extras.
  • Improved backward compatibility by ensuring that both older and newer Android versions (API 33+) can correctly retrieve intent extras.
  • Avoids deprecated method usage, replacing old API calls with modern alternatives to maintain future compatibility.
  • Clearer logging output for debugging file paths and shared items, making troubleshooting easier.

Copy link
Member

@misaochan misaochan left a comment

Choose a reason for hiding this comment

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

Hi @Sujal-Gupta-SG , could you please test this on both version 33+ and a lower version, and report your findings? Thanks!

@Sujal-Gupta-SG
Copy link
Contributor Author

Hi @Sujal-Gupta-SG , could you please test this on both version 33+ and a lower version, and report your findings? Thanks!

Hi @misaochan
I tested this on both API level 31 and API level 33 , and it's running correctly in both cases. You can test it as well if needed, but from my side, everything is working great.

@misaochan misaochan merged commit 23e1f01 into commons-app:main Jan 17, 2025
1 check passed
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.

2 participants