Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 1e29cb5

Browse files
Sam1301timabbott
authored andcommitted
Fix unnecessary image rotation in PhotoSendActivity.
When a picture is clicked and sent directly (without a crop or edit), it gets rotated by 90 as most phone cameras are landscape. To solve this, it'd be better to use the displayed image and save it in the current photo path before sending.
1 parent 706aba4 commit 1e29cb5

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

app/src/main/java/com/zulip/android/activities/PhotoSendActivity.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,27 @@ public void onClick(View view) {
115115
sendPhoto.setOnClickListener(new View.OnClickListener() {
116116
@Override
117117
public void onClick(View view) {
118-
if (mIsCropped) {
119-
Bitmap bitmap;
120-
Drawable drawable = mImageView.getDrawable();
121-
if (drawable instanceof GlideBitmapDrawable) {
122-
// if imageview has drawable of type GlideBitmapDrawable
123-
bitmap = ((GlideBitmapDrawable) mImageView.getDrawable().getCurrent())
124-
.getBitmap();
125-
126-
} else {
127-
// if imageView stores cropped image drawable which is of type drawable
128-
bitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
129-
}
118+
Bitmap bitmap;
119+
Drawable drawable = mImageView.getDrawable();
120+
if (drawable instanceof GlideBitmapDrawable) {
121+
// if imageview has drawable of type GlideBitmapDrawable
122+
bitmap = ((GlideBitmapDrawable) mImageView.getDrawable().getCurrent())
123+
.getBitmap();
130124

131-
// if image was cropped, delete old file
132-
// and store new bitmap on that location
133-
mPhotoPath = PhotoHelper.saveBitmapAsFile(mPhotoPath, bitmap);
125+
} else {
126+
// if imageView stores cropped image drawable which is of type drawable
127+
bitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
134128
}
135129

130+
/* Most phone cameras are landscape, meaning if you take the photo in portrait,
131+
the resulting photos will be rotated 90 degrees. Hence used the displayed image
132+
with correct orientation and saved that in the current photo path.
133+
*/
134+
135+
// delete old file and store new bitmap on that location
136+
// used the displayed image and saved it in the mPhotoPath
137+
mPhotoPath = PhotoHelper.saveBitmapAsFile(mPhotoPath, bitmap);
138+
136139
// add the file path of cropped image
137140
sendIntent.putExtra(Intent.EXTRA_TEXT, mPhotoPath);
138141
startActivity(sendIntent);

0 commit comments

Comments
 (0)