use smaller image previews on narrow screens
This commit is contained in:
parent
7aeb2b2740
commit
9e6f7237af
|
@ -555,7 +555,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
viewHolder.audioPlayer.setVisibility(View.GONE);
|
viewHolder.audioPlayer.setVisibility(View.GONE);
|
||||||
viewHolder.image.setVisibility(View.VISIBLE);
|
viewHolder.image.setVisibility(View.VISIBLE);
|
||||||
final FileParams params = message.getFileParams();
|
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 scaledW;
|
||||||
final int scaledH;
|
final int scaledH;
|
||||||
if (Math.max(params.height, params.width) * metrics.density <= target) {
|
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;
|
scaledW = (int) target;
|
||||||
scaledH = (int) (params.height / ((double) params.width / 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));
|
layoutParams.setMargins(0, (int) (metrics.density * 4), 0, (int) (metrics.density * 4));
|
||||||
viewHolder.image.setLayoutParams(layoutParams);
|
viewHolder.image.setLayoutParams(layoutParams);
|
||||||
activity.loadBitmap(message, viewHolder.image);
|
activity.loadBitmap(message, viewHolder.image);
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<resources>
|
<resources>
|
||||||
<!-- 384dp is the screen width of the Nexus 4. Something like a Moto G is smaller but a Nexus 5X is larger -->
|
<!-- 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/ -->
|
<!-- https://material.io/devices/ -->
|
||||||
<dimen name="fineprint_size">12sp</dimen>
|
<dimen name="fineprint_size">12sp</dimen>
|
||||||
<dimen name="audio_player_width">288dp</dimen>
|
<dimen name="audio_player_width">288dp</dimen>
|
||||||
<dimen name="avatar_on_details_screen_size">72dp</dimen>
|
<dimen name="image_preview_width">288dp</dimen>
|
||||||
<dimen name="media_size">64dp</dimen> <!-- ideally not larger than avatar_on_details_screen -->
|
<dimen name="avatar_on_details_screen_size">72dp</dimen>
|
||||||
<dimen name="sd_label_max_width">288dp</dimen>
|
<dimen name="media_size">64dp</dimen> <!-- ideally not larger than avatar_on_details_screen -->
|
||||||
|
<dimen name="sd_label_max_width">288dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
</dimen> <!-- icon width (24dp) + 2 * image button padding -->
|
</dimen> <!-- icon width (24dp) + 2 * image button padding -->
|
||||||
<dimen name="fineprint_size">11sp</dimen>
|
<dimen name="fineprint_size">11sp</dimen>
|
||||||
<dimen name="audio_player_width">224dp</dimen>
|
<dimen name="audio_player_width">224dp</dimen>
|
||||||
|
<dimen name="image_preview_width">224dp</dimen>
|
||||||
<dimen name="avatar_item_distance">16dp</dimen>
|
<dimen name="avatar_item_distance">16dp</dimen>
|
||||||
|
|
||||||
<dimen name="media_preview_size">80dp</dimen>
|
<dimen name="media_preview_size">80dp</dimen>
|
||||||
|
|
Loading…
Reference in a new issue