Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 22763 ]] Fix resizing mobilePickPhoto for API Level < 24 #7368

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 docs/notes/bugfix-22763.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Ensure mobilePickPhoto with width and height params works on older Android versions
15 changes: 12 additions & 3 deletions 15 engine/src/java/com/runrev/android/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -2232,9 +2232,18 @@ else if (resultCode == Activity.RESULT_OK)
float t_width = t_bitmap.getWidth();
float t_height = t_bitmap.getHeight();

InputStream t_exif_in = ((LiveCodeActivity)getContext()).getContentResolver().openInputStream(t_photo_uri);

ExifInterface t_exif = new ExifInterface(t_exif_in);
/* In API Level >= 24, you have to use an input stream to make sure that access
Copy link
Contributor Author

@livecodepanos livecodepanos Jul 7, 2020

Choose a reason for hiding this comment

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

Hmm, using the existing InputStream t_in causes the captured pic to be rotated 90 degrees. I am wondering if this was the reason @montegoulding used a new one (i.e. the t_exif_in one) in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh! Yes - the reason is that we've used the t_in stream above! Oops!

So below we should do:

if (Build.VERSION....)
{
    t_in.close();
    t_in = ((LiveCodeActivity)getContext()).getContentResolver().openInputStream(t_photo_uri);
}

This will close the (now finished) original stream, and then create a new one.

* to a photo in the library is granted. Before that you can just open the photo's
* file direct. */
ExifInterface t_exif;
if (Build.VERSION.SDK_INT >= 24)
{
t_exif = new ExifInterface(t_in);
}
else
{
t_exif = new ExifInterface(t_photo_uri.getPath());
}

int t_orientation = t_exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.