use smaller image previews on narrow screens

This commit is contained in:
Daniel Gultsch 2020-07-12 12:31:13 +02:00
parent 7aeb2b2740
commit 9e6f7237af
3 changed files with 11 additions and 9 deletions

View File

@ -555,7 +555,7 @@ public class MessageAdapter extends ArrayAdapter<Message> 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<Message> 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);

View File

@ -1,9 +1,10 @@
<resources>
<!-- 384dp is the screen width of the Nexus 4. Something like a Moto G is smaller but a Nexus 5X is larger -->
<!-- https://material.io/devices/ -->
<dimen name="fineprint_size">12sp</dimen>
<dimen name="audio_player_width">288dp</dimen>
<dimen name="avatar_on_details_screen_size">72dp</dimen>
<dimen name="media_size">64dp</dimen> <!-- ideally not larger than avatar_on_details_screen -->
<dimen name="sd_label_max_width">288dp</dimen>
<!-- 384dp is the screen width of the Nexus 4. Something like a Moto G is smaller but a Nexus 5X is larger -->
<!-- https://material.io/devices/ -->
<dimen name="fineprint_size">12sp</dimen>
<dimen name="audio_player_width">288dp</dimen>
<dimen name="image_preview_width">288dp</dimen>
<dimen name="avatar_on_details_screen_size">72dp</dimen>
<dimen name="media_size">64dp</dimen> <!-- ideally not larger than avatar_on_details_screen -->
<dimen name="sd_label_max_width">288dp</dimen>
</resources>

View File

@ -10,6 +10,7 @@
</dimen> <!-- icon width (24dp) + 2 * image button padding -->
<dimen name="fineprint_size">11sp</dimen>
<dimen name="audio_player_width">224dp</dimen>
<dimen name="image_preview_width">224dp</dimen>
<dimen name="avatar_item_distance">16dp</dimen>
<dimen name="media_preview_size">80dp</dimen>