From e402f77391e2c4f20321917b33e2155c51124ee2 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Fri, 14 Aug 2020 17:38:47 +0200 Subject: [PATCH 1/3] Almost fix #1544 image rotation not working sometimes --- .../securesms/components/ScaleStableImageView.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java b/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java index b817fae1a..474606b0a 100644 --- a/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java +++ b/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java @@ -112,9 +112,12 @@ public class ScaleStableImageView large = storedSizes.get(landscapeWidth + "x" + landscapeHeight); if (large == null) return; // no baseline. can't work. Bitmap original = ((BitmapDrawable) large).getBitmap(); - Bitmap cropped = Bitmap.createBitmap(original, 0, 0, width, height); - Drawable croppedDrawable = new BitmapDrawable(getResources(), cropped); - overrideDrawable(croppedDrawable); + if (height <= original.getHeight()) { + Bitmap cropped = Bitmap.createBitmap(original, 0, 0, width, height); + Drawable croppedDrawable = new BitmapDrawable(getResources(), cropped); + overrideDrawable(croppedDrawable); + } // else we do not know what to do. + // At least it does not crash anymore but only jumps a little, see https://github.com/deltachat/deltachat-android/issues/1544. } else { Util.runOnBackground(() -> { Bitmap bitmap = ((BitmapDrawable) defaultDrawable).getBitmap(); From 84c492192a0c7bde0b2382686c8790194b0e8acc Mon Sep 17 00:00:00 2001 From: Hocuri Date: Tue, 18 Aug 2020 09:48:32 +0200 Subject: [PATCH 2/3] angelo-fuchs' requests --- .../securesms/components/ScaleStableImageView.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java b/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java index 474606b0a..1f2a72901 100644 --- a/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java +++ b/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java @@ -112,12 +112,11 @@ public class ScaleStableImageView large = storedSizes.get(landscapeWidth + "x" + landscapeHeight); if (large == null) return; // no baseline. can't work. Bitmap original = ((BitmapDrawable) large).getBitmap(); - if (height <= original.getHeight()) { + if (height <= original.getHeight() && width <= original.getWidth()) { Bitmap cropped = Bitmap.createBitmap(original, 0, 0, width, height); Drawable croppedDrawable = new BitmapDrawable(getResources(), cropped); overrideDrawable(croppedDrawable); - } // else we do not know what to do. - // At least it does not crash anymore but only jumps a little, see https://github.com/deltachat/deltachat-android/issues/1544. + } } else { Util.runOnBackground(() -> { Bitmap bitmap = ((BitmapDrawable) defaultDrawable).getBitmap(); From e11252ab281df5a24b087586f7335eafdcb658a5 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Tue, 18 Aug 2020 12:37:57 +0200 Subject: [PATCH 3/3] oops, wrong operator --- .../thoughtcrime/securesms/components/ScaleStableImageView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java b/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java index 1f2a72901..7655d4130 100644 --- a/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java +++ b/src/org/thoughtcrime/securesms/components/ScaleStableImageView.java @@ -112,7 +112,7 @@ public class ScaleStableImageView large = storedSizes.get(landscapeWidth + "x" + landscapeHeight); if (large == null) return; // no baseline. can't work. Bitmap original = ((BitmapDrawable) large).getBitmap(); - if (height <= original.getHeight() && width <= original.getWidth()) { + if (height <= original.getHeight() || width <= original.getWidth()) { Bitmap cropped = Bitmap.createBitmap(original, 0, 0, width, height); Drawable croppedDrawable = new BitmapDrawable(getResources(), cropped); overrideDrawable(croppedDrawable);