From 9e6f7237af368fe09b011822256e3bf0bcfc7686 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 12 Jul 2020 12:31:13 +0200 Subject: [PATCH] use smaller image previews on narrow screens --- .../conversations/ui/adapter/MessageAdapter.java | 4 ++-- src/main/res/values-w384dp/dimens.xml | 15 ++++++++------- src/main/res/values/dimens.xml | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 662f03c93..02e925f7d 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -555,7 +555,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.audioPlayer.setVisibility(View.GONE); viewHolder.image.setVisibility(View.VISIBLE); final FileParams params = message.getFileParams(); - final double target = metrics.density * 288; + final float target = activity.getResources().getDimension(R.dimen.image_preview_width); final int scaledW; final int scaledH; if (Math.max(params.height, params.width) * metrics.density <= target) { @@ -571,7 +571,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie scaledW = (int) target; scaledH = (int) (params.height / ((double) params.width / target)); } - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(scaledW, scaledH); + final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(scaledW, scaledH); layoutParams.setMargins(0, (int) (metrics.density * 4), 0, (int) (metrics.density * 4)); viewHolder.image.setLayoutParams(layoutParams); activity.loadBitmap(message, viewHolder.image); diff --git a/src/main/res/values-w384dp/dimens.xml b/src/main/res/values-w384dp/dimens.xml index 4a29d6f40..4f3550ab5 100644 --- a/src/main/res/values-w384dp/dimens.xml +++ b/src/main/res/values-w384dp/dimens.xml @@ -1,9 +1,10 @@ - - - 12sp - 288dp - 72dp - 64dp - 288dp + + + 12sp + 288dp + 288dp + 72dp + 64dp + 288dp diff --git a/src/main/res/values/dimens.xml b/src/main/res/values/dimens.xml index 215f11a14..069c19edc 100644 --- a/src/main/res/values/dimens.xml +++ b/src/main/res/values/dimens.xml @@ -10,6 +10,7 @@ 11sp 224dp + 224dp 16dp 80dp