aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ConversationFragment.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index a4259f27..d42b33c4 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -297,27 +297,38 @@ public class ConversationFragment extends Fragment {
}
});
} else {
- try {
- Bitmap thumbnail = activity.xmppConnectionService.getFileBackend().getThumbnailFromMessage(item,(int) (metrics.density * 288));
- viewHolder.image.setImageBitmap(thumbnail);
- viewHolder.messageBody.setVisibility(View.GONE);
- viewHolder.image.setVisibility(View.VISIBLE);
- viewHolder.image.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- Uri uri = Uri.parse("content://eu.siacs.conversations.images/"+item.getConversationUuid()+"/"+item.getUuid());
- Log.d("xmppService","staring intent with uri:"+uri.toString());
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(uri, "image/*");
- startActivity(intent);
- }
- });
- } catch (FileNotFoundException e) {
- viewHolder.image.setVisibility(View.GONE);
- viewHolder.messageBody.setText("error loading image file");
- viewHolder.messageBody.setVisibility(View.VISIBLE);
- }
+ viewHolder.messageBody.setVisibility(View.GONE);
+ viewHolder.image.setVisibility(View.VISIBLE);
+ String[] params = item.getBody().split(",");
+ if (params.length==3) {
+ int target = (int) (metrics.density * 288);
+ int w = Integer.parseInt(params[1]);
+ int h = Integer.parseInt(params[2]);
+ int scalledW;
+ int scalledH;
+ if (w <= h) {
+ scalledW = (int) (w / ((double) h / target));
+ scalledH = target;
+ } else {
+ scalledW = target;
+ scalledH = (int) (h / ((double) w / target));
+ }
+ viewHolder.image.setLayoutParams(new LinearLayout.LayoutParams(scalledW, scalledH));
+ } else {
+ Log.d("xmppService","message body has less than 3 params");
+ }
+ activity.loadBitmap(item, viewHolder.image);
+ viewHolder.image.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Uri uri = Uri.parse("content://eu.siacs.conversations.images/"+item.getConversationUuid()+"/"+item.getUuid());
+ Log.d("xmppService","staring intent with uri:"+uri.toString());
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setDataAndType(uri, "image/*");
+ startActivity(intent);
+ }
+ });
}
} else {
viewHolder.image.setVisibility(View.GONE);
@@ -686,13 +697,6 @@ public class ConversationFragment extends Fragment {
return bm;
}
}
-
- public Bitmap getError() {
- if (error == null) {
- error = UIHelper.getErrorPicture(200);
- }
- return error;
- }
}
class DecryptMessage extends AsyncTask<Message, Void, Boolean> {