From 977b55e1ac3955733fc32eb849c87349375c6bcf Mon Sep 17 00:00:00 2001 From: Alexandre Ancel Date: Mon, 8 Oct 2018 22:42:38 +0200 Subject: [PATCH] Update image display - Fix images not appearing at the end of notes - Keep image aspect ratio when using fixed size --- .../java/com/orgzly/android/ui/views/TextViewWithMarkup.kt | 2 +- .../main/java/com/orgzly/android/util/AsyncImageLoader.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/orgzly/android/ui/views/TextViewWithMarkup.kt b/app/src/main/java/com/orgzly/android/ui/views/TextViewWithMarkup.kt index cf298756c..8d6472156 100644 --- a/app/src/main/java/com/orgzly/android/ui/views/TextViewWithMarkup.kt +++ b/app/src/main/java/com/orgzly/android/ui/views/TextViewWithMarkup.kt @@ -118,7 +118,7 @@ class TextViewWithMarkup : TextViewFixed { // Ensure that we are updating the correct portion of text // As this could be called during drawing - if(this.text.length > end) { + if(this.text.length >= end) { builder.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) setText(builder) diff --git a/app/src/main/java/com/orgzly/android/util/AsyncImageLoader.java b/app/src/main/java/com/orgzly/android/util/AsyncImageLoader.java index 7a4decf95..c8236b0b5 100644 --- a/app/src/main/java/com/orgzly/android/util/AsyncImageLoader.java +++ b/app/src/main/java/com/orgzly/android/util/AsyncImageLoader.java @@ -81,7 +81,9 @@ protected void onPostExecute(Drawable result) { float newPixelWidth = (int) ((float) view.getWidth()); if(fixedSize > 0) { - result.setBounds(0, 0, fixedSize, fixedSize); + // Keep aspect ratio when using fixed size + float ratio = drawableHeight / drawableWidth; + result.setBounds(0, 0, fixedSize, (int) (fixedSize * ratio)); } else { // Rescale the drawable if it is larger that the current view width