aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/adapter
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/ui/adapter')
-rw-r--r--src/eu/siacs/conversations/ui/adapter/AccountAdapter.java5
-rw-r--r--src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java107
-rw-r--r--src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java8
-rw-r--r--src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java13
-rw-r--r--src/eu/siacs/conversations/ui/adapter/MessageAdapter.java224
5 files changed, 179 insertions, 178 deletions
diff --git a/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java
index 5c25bf34..e13b3204 100644
--- a/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/AccountAdapter.java
@@ -28,13 +28,14 @@ public class AccountAdapter extends ArrayAdapter<Account> {
if (view == null) {
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = (View) inflater.inflate(R.layout.account_row, parent, false);
+ view = inflater.inflate(R.layout.account_row, parent, false);
}
TextView jid = (TextView) view.findViewById(R.id.account_jid);
jid.setText(account.getJid());
TextView statusView = (TextView) view.findViewById(R.id.account_status);
ImageView imageView = (ImageView) view.findViewById(R.id.account_image);
- imageView.setImageBitmap(account.getImage(activity, 48));
+ imageView.setImageBitmap(activity.avatarService().get(account,
+ activity.getPixel(48)));
switch (account.getStatus()) {
case Account.STATUS_DISABLED:
statusView.setText(getContext().getString(
diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index f74856b0..b5c20dc5 100644
--- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
@@ -5,6 +5,7 @@ import java.util.List;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
+import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
import eu.siacs.conversations.ui.XmppActivity;
@@ -34,14 +35,14 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
if (view == null) {
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = (View) inflater.inflate(R.layout.conversation_list_row,
+ view = inflater.inflate(R.layout.conversation_list_row,
parent, false);
}
- Conversation conv = getItem(position);
+ Conversation conversation = getItem(position);
if (this.activity instanceof ConversationActivity) {
ConversationActivity activity = (ConversationActivity) this.activity;
if (!activity.isConversationsOverviewHideable()) {
- if (conv == activity.getSelectedConversation()) {
+ if (conversation == activity.getSelectedConversation()) {
view.setBackgroundColor(activity
.getSecondaryBackgroundColor());
} else {
@@ -53,65 +54,85 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
}
TextView convName = (TextView) view
.findViewById(R.id.conversation_name);
- if (conv.getMode() == Conversation.MODE_SINGLE
+ if (conversation.getMode() == Conversation.MODE_SINGLE
|| activity.useSubjectToIdentifyConference()) {
- convName.setText(conv.getName());
+ convName.setText(conversation.getName());
} else {
- convName.setText(conv.getContactJid().split("/")[0]);
+ convName.setText(conversation.getContactJid().split("/")[0]);
}
- TextView convLastMsg = (TextView) view
+ TextView mLastMessage = (TextView) view
.findViewById(R.id.conversation_lastmsg);
+ TextView mTimestamp = (TextView) view
+ .findViewById(R.id.conversation_lastupdate);
ImageView imagePreview = (ImageView) view
.findViewById(R.id.conversation_lastimage);
- Message latestMessage = conv.getLatestMessage();
+ Message message = conversation.getLatestMessage();
- if (latestMessage.getType() == Message.TYPE_TEXT
- || latestMessage.getType() == Message.TYPE_PRIVATE) {
- if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)
- && (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
- String body = Config.PARSE_EMOTICONS ? UIHelper
- .transformAsciiEmoticons(latestMessage.getBody())
- : latestMessage.getBody();
- convLastMsg.setText(body);
+ if (!conversation.isRead()) {
+ convName.setTypeface(null, Typeface.BOLD);
+ } else {
+ convName.setTypeface(null, Typeface.NORMAL);
+ }
+
+ if (message.getType() == Message.TYPE_IMAGE
+ || message.getDownloadable() != null) {
+ Downloadable d = message.getDownloadable();
+ if (conversation.isRead()) {
+ mLastMessage.setTypeface(null, Typeface.ITALIC);
} else {
- convLastMsg.setText(R.string.encrypted_message_received);
+ mLastMessage.setTypeface(null, Typeface.BOLD_ITALIC);
}
- convLastMsg.setVisibility(View.VISIBLE);
- imagePreview.setVisibility(View.GONE);
- } else if (latestMessage.getType() == Message.TYPE_IMAGE) {
- if (latestMessage.getStatus() >= Message.STATUS_RECEIVED) {
- convLastMsg.setVisibility(View.GONE);
- imagePreview.setVisibility(View.VISIBLE);
- activity.loadBitmap(latestMessage, imagePreview);
- } else {
- convLastMsg.setVisibility(View.VISIBLE);
+ if (d != null) {
+ mLastMessage.setVisibility(View.VISIBLE);
imagePreview.setVisibility(View.GONE);
- if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) {
- convLastMsg.setText(R.string.image_offered_for_download);
- } else if (latestMessage.getStatus() == Message.STATUS_RECEIVING) {
- convLastMsg.setText(R.string.receiving_image);
+ if (d.getStatus() == Downloadable.STATUS_CHECKING) {
+ mLastMessage.setText(R.string.checking_image);
+ } else if (d.getStatus() == Downloadable.STATUS_DOWNLOADING) {
+ mLastMessage.setText(R.string.receiving_image);
+ } else if (d.getStatus() == Downloadable.STATUS_OFFER) {
+ mLastMessage.setText(R.string.image_offered_for_download);
+ } else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
+ mLastMessage.setText(R.string.image_offered_for_download);
+ } else if (d.getStatus() == Downloadable.STATUS_DELETED) {
+ mLastMessage.setText(R.string.image_file_deleted);
} else {
- convLastMsg.setText("");
+ mLastMessage.setText("");
}
+ } else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
+ imagePreview.setVisibility(View.GONE);
+ mLastMessage.setVisibility(View.VISIBLE);
+ mLastMessage.setText(R.string.encrypted_message_received);
+ } else {
+ mLastMessage.setVisibility(View.GONE);
+ imagePreview.setVisibility(View.VISIBLE);
+ activity.loadBitmap(message, imagePreview);
}
- }
-
- if (!conv.isRead()) {
- convName.setTypeface(null, Typeface.BOLD);
- convLastMsg.setTypeface(null, Typeface.BOLD);
} else {
- convName.setTypeface(null, Typeface.NORMAL);
- convLastMsg.setTypeface(null, Typeface.NORMAL);
+ if ((message.getEncryption() != Message.ENCRYPTION_PGP)
+ && (message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
+ String body = Config.PARSE_EMOTICONS ? UIHelper
+ .transformAsciiEmoticons(message.getBody()) : message
+ .getBody();
+ mLastMessage.setText(body);
+ } else {
+ mLastMessage.setText(R.string.encrypted_message_received);
+ }
+ if (!conversation.isRead()) {
+ mLastMessage.setTypeface(null, Typeface.BOLD);
+ } else {
+ mLastMessage.setTypeface(null, Typeface.NORMAL);
+ }
+ mLastMessage.setVisibility(View.VISIBLE);
+ imagePreview.setVisibility(View.GONE);
}
-
- ((TextView) view.findViewById(R.id.conversation_lastupdate))
- .setText(UIHelper.readableTimeDifference(getContext(), conv
- .getLatestMessage().getTimeSent()));
+ mTimestamp.setText(UIHelper.readableTimeDifference(getContext(),
+ conversation.getLatestMessage().getTimeSent()));
ImageView profilePicture = (ImageView) view
.findViewById(R.id.conversation_image);
- profilePicture.setImageBitmap(conv.getImage(activity, 56));
+ profilePicture.setImageBitmap(activity.avatarService().get(
+ conversation, activity.getPixel(56)));
return view;
}
diff --git a/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java b/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
index 0534bc25..143dfda1 100644
--- a/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
@@ -47,11 +47,11 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
- ArrayList<String> filteredList = (ArrayList<String>) results.values;
+ ArrayList filteredList = (ArrayList) results.values;
if (results != null && results.count > 0) {
clear();
- for (String c : filteredList) {
- add(c);
+ for (Object c : filteredList) {
+ add((String) c);
}
notifyDataSetChanged();
}
@@ -71,4 +71,4 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
public Filter getFilter() {
return domainFilter;
}
-} \ No newline at end of file
+}
diff --git a/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java b/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
index df67e566..efc6b4d9 100644
--- a/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
@@ -4,6 +4,7 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.ListItem;
+import eu.siacs.conversations.ui.XmppActivity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@@ -14,8 +15,11 @@ import android.widget.TextView;
public class ListItemAdapter extends ArrayAdapter<ListItem> {
- public ListItemAdapter(Context context, List<ListItem> objects) {
- super(context, 0, objects);
+ protected XmppActivity activity;
+
+ public ListItemAdapter(XmppActivity activity, List<ListItem> objects) {
+ super(activity, 0, objects);
+ this.activity = activity;
}
@Override
@@ -24,7 +28,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ListItem item = getItem(position);
if (view == null) {
- view = (View) inflater.inflate(R.layout.contact, parent, false);
+ view = inflater.inflate(R.layout.contact, parent, false);
}
TextView name = (TextView) view.findViewById(R.id.contact_display_name);
TextView jid = (TextView) view.findViewById(R.id.contact_jid);
@@ -32,7 +36,8 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
jid.setText(item.getJid());
name.setText(item.getDisplayName());
- picture.setImageBitmap(item.getImage(48, getContext()));
+ picture.setImageBitmap(activity.avatarService().get(item,
+ activity.getPixel(48)));
return view;
}
diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 2671cf50..a24f90d7 100644
--- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -1,6 +1,5 @@
package eu.siacs.conversations.ui.adapter;
-import java.util.HashMap;
import java.util.List;
import eu.siacs.conversations.Config;
@@ -9,11 +8,10 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.Message;
+import eu.siacs.conversations.entities.Message.ImageParams;
import eu.siacs.conversations.ui.ConversationActivity;
import eu.siacs.conversations.utils.UIHelper;
-import android.content.Context;
import android.content.Intent;
-import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
@@ -40,31 +38,26 @@ public class MessageAdapter extends ArrayAdapter<Message> {
private ConversationActivity activity;
- private Bitmap accountBitmap;
-
- private BitmapCache mBitmapCache = new BitmapCache();
private DisplayMetrics metrics;
private OnContactPictureClicked mOnContactPictureClickedListener;
private OnContactPictureLongClicked mOnContactPictureLongClickedListener;
+ private OnLongClickListener openContextMenu = new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ v.showContextMenu();
+ return true;
+ }
+ };
+
public MessageAdapter(ConversationActivity activity, List<Message> messages) {
super(activity, 0, messages);
this.activity = activity;
metrics = getContext().getResources().getDisplayMetrics();
}
- private Bitmap getSelfBitmap() {
- if (this.accountBitmap == null) {
-
- if (getCount() > 0) {
- this.accountBitmap = getItem(0).getConversation().getAccount()
- .getImage(getContext(), 48);
- }
- }
- return this.accountBitmap;
- }
-
public void setOnContactPictureClicked(OnContactPictureClicked listener) {
this.mOnContactPictureClickedListener = listener;
}
@@ -101,13 +94,14 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
&& message.getMergedStatus() <= Message.STATUS_RECEIVED;
- if (message.getType() == Message.TYPE_IMAGE) {
- String[] fileParams = message.getBody().split(",");
- try {
- long size = Long.parseLong(fileParams[0]);
- filesize = size / 1024 + " KB";
- } catch (NumberFormatException e) {
- filesize = "0 KB";
+ if (message.getType() == Message.TYPE_IMAGE
+ || message.getDownloadable() != null) {
+ ImageParams params = message.getImageParams();
+ if (params.size != 0) {
+ filesize = params.size / 1024 + " KB";
+ }
+ if (message.getDownloadable() != null && message.getDownloadable().getStatus() == Downloadable.STATUS_FAILED) {
+ error = true;
}
}
switch (message.getMergedStatus()) {
@@ -134,14 +128,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
info = getContext().getString(R.string.send_failed);
error = true;
break;
- case Message.STATUS_SEND_REJECTED:
- info = getContext().getString(R.string.send_rejected);
- error = true;
- break;
- case Message.STATUS_RECEPTION_FAILED:
- info = getContext().getString(R.string.reception_failed);
- error = true;
- break;
default:
if (multiReceived) {
Contact contact = message.getContact();
@@ -268,6 +254,22 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setTextIsSelectable(true);
}
+ private void displayDownloadableMessage(ViewHolder viewHolder,
+ final Message message, int resid) {
+ viewHolder.image.setVisibility(View.GONE);
+ viewHolder.messageBody.setVisibility(View.GONE);
+ viewHolder.download_button.setVisibility(View.VISIBLE);
+ viewHolder.download_button.setText(resid);
+ viewHolder.download_button.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ startDonwloadable(message);
+ }
+ });
+ viewHolder.download_button.setOnLongClickListener(openContextMenu);
+ }
+
private void displayImageMessage(ViewHolder viewHolder,
final Message message) {
if (viewHolder.download_button != null) {
@@ -275,23 +277,19 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
viewHolder.messageBody.setVisibility(View.GONE);
viewHolder.image.setVisibility(View.VISIBLE);
- String[] fileParams = message.getBody().split(",");
- if (fileParams.length == 3) {
- double target = metrics.density * 288;
- int w = Integer.parseInt(fileParams[1]);
- int h = Integer.parseInt(fileParams[2]);
- int scalledW;
- int scalledH;
- if (w <= h) {
- scalledW = (int) (w / ((double) h / target));
- scalledH = (int) target;
- } else {
- scalledW = (int) target;
- scalledH = (int) (h / ((double) w / target));
- }
- viewHolder.image.setLayoutParams(new LinearLayout.LayoutParams(
- scalledW, scalledH));
+ ImageParams params = message.getImageParams();
+ double target = metrics.density * 288;
+ int scalledW;
+ int scalledH;
+ if (params.width <= params.height) {
+ scalledW = (int) (params.width / ((double) params.height / target));
+ scalledH = (int) target;
+ } else {
+ scalledW = (int) target;
+ scalledH = (int) (params.height / ((double) params.width / target));
}
+ viewHolder.image.setLayoutParams(new LinearLayout.LayoutParams(
+ scalledW, scalledH));
activity.loadBitmap(message, viewHolder.image);
viewHolder.image.setOnClickListener(new OnClickListener() {
@@ -303,23 +301,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
getContext().startActivity(intent);
}
});
- viewHolder.image.setOnLongClickListener(new OnLongClickListener() {
-
- @Override
- public boolean onLongClick(View v) {
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_STREAM,
- activity.xmppConnectionService.getFileBackend()
- .getJingleFileUri(message));
- shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- shareIntent.setType("image/webp");
- getContext().startActivity(
- Intent.createChooser(shareIntent,
- getContext().getText(R.string.share_with)));
- return true;
- }
- });
+ viewHolder.image.setOnLongClickListener(openContextMenu);
}
@Override
@@ -331,17 +313,22 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder = new ViewHolder();
switch (type) {
case NULL:
- view = (View) activity.getLayoutInflater().inflate(
+ view = activity.getLayoutInflater().inflate(
R.layout.message_null, parent, false);
break;
case SENT:
- view = (View) activity.getLayoutInflater().inflate(
+ view = activity.getLayoutInflater().inflate(
R.layout.message_sent, parent, false);
viewHolder.message_box = (LinearLayout) view
.findViewById(R.id.message_box);
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
- viewHolder.contact_picture.setImageBitmap(getSelfBitmap());
+ viewHolder.contact_picture.setImageBitmap(activity
+ .avatarService().get(
+ item.getConversation().getAccount(),
+ activity.getPixel(48)));
+ viewHolder.download_button = (Button) view
+ .findViewById(R.id.download_button);
viewHolder.indicator = (ImageView) view
.findViewById(R.id.security_indicator);
viewHolder.image = (ImageView) view
@@ -355,21 +342,18 @@ public class MessageAdapter extends ArrayAdapter<Message> {
view.setTag(viewHolder);
break;
case RECEIVED:
- view = (View) activity.getLayoutInflater().inflate(
+ view = activity.getLayoutInflater().inflate(
R.layout.message_received, parent, false);
viewHolder.message_box = (LinearLayout) view
.findViewById(R.id.message_box);
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
-
viewHolder.download_button = (Button) view
.findViewById(R.id.download_button);
-
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
-
- viewHolder.contact_picture.setImageBitmap(mBitmapCache.get(
- item.getConversation().getContact(), getContext()));
-
+ viewHolder.contact_picture.setImageBitmap(activity
+ .avatarService().get(item.getContact(),
+ activity.getPixel(48)));
}
viewHolder.indicator = (ImageView) view
.findViewById(R.id.security_indicator);
@@ -382,15 +366,17 @@ public class MessageAdapter extends ArrayAdapter<Message> {
view.setTag(viewHolder);
break;
case STATUS:
- view = (View) activity.getLayoutInflater().inflate(
+ view = activity.getLayoutInflater().inflate(
R.layout.message_status, parent, false);
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
- viewHolder.contact_picture.setImageBitmap(mBitmapCache.get(
- item.getConversation().getContact(), getContext()));
- viewHolder.contact_picture.setAlpha(128);
+ viewHolder.contact_picture.setImageBitmap(activity
+ .avatarService().get(
+ item.getConversation().getContact(),
+ activity.getPixel(32)));
+ viewHolder.contact_picture.setAlpha(0.5f);
viewHolder.contact_picture
.setOnClickListener(new OnClickListener() {
@@ -465,38 +451,40 @@ public class MessageAdapter extends ArrayAdapter<Message> {
if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
Contact contact = item.getContact();
if (contact != null) {
- viewHolder.contact_picture.setImageBitmap(mBitmapCache.get(
- contact, getContext()));
+ viewHolder.contact_picture.setImageBitmap(activity
+ .avatarService()
+ .get(contact, activity.getPixel(48)));
} else {
String name = item.getPresence();
if (name == null) {
name = item.getCounterpart();
}
- viewHolder.contact_picture.setImageBitmap(mBitmapCache.get(
- name, getContext()));
+ viewHolder.contact_picture.setImageBitmap(activity
+ .avatarService().get(name, activity.getPixel(48)));
}
}
}
- if (item.getType() == Message.TYPE_IMAGE) {
- if (item.getStatus() == Message.STATUS_RECEIVING) {
+ if (item.getType() == Message.TYPE_IMAGE
+ || item.getDownloadable() != null) {
+ Downloadable d = item.getDownloadable();
+ if (d != null && d.getStatus() == Downloadable.STATUS_DOWNLOADING) {
displayInfoMessage(viewHolder, R.string.receiving_image);
- } else if (item.getStatus() == Message.STATUS_RECEIVED_OFFER) {
- viewHolder.image.setVisibility(View.GONE);
- viewHolder.messageBody.setVisibility(View.GONE);
- viewHolder.download_button.setVisibility(View.VISIBLE);
- viewHolder.download_button
- .setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- Downloadable downloadable = item
- .getDownloadable();
- if (downloadable != null) {
- downloadable.start();
- }
- }
- });
+ } else if (d != null
+ && d.getStatus() == Downloadable.STATUS_CHECKING) {
+ displayInfoMessage(viewHolder, R.string.checking_image);
+ } else if (d != null
+ && d.getStatus() == Downloadable.STATUS_DELETED) {
+ displayInfoMessage(viewHolder, R.string.image_file_deleted);
+ } else if (d != null && d.getStatus() == Downloadable.STATUS_OFFER) {
+ displayDownloadableMessage(viewHolder, item,
+ R.string.download_image);
+ } else if (d != null
+ && d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
+ displayDownloadableMessage(viewHolder, item,
+ R.string.check_image_filesize);
+ } else if (d != null && d.getStatus() == Downloadable.STATUS_FAILED) {
+ displayInfoMessage(viewHolder, R.string.image_transmission_failed);
} else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)
|| (item.getEncryption() == Message.ENCRYPTION_NONE)
|| (item.getEncryption() == Message.ENCRYPTION_OTR)) {
@@ -534,6 +522,16 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return view;
}
+ public void startDonwloadable(Message message) {
+ Downloadable downloadable = message.getDownloadable();
+ if (downloadable != null) {
+ if (!downloadable.start()) {
+ Toast.makeText(activity, R.string.not_connected_try_again,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ }
+
private static class ViewHolder {
protected LinearLayout message_box;
@@ -547,30 +545,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
- private class BitmapCache {
- private HashMap<String, Bitmap> contactBitmaps = new HashMap<String, Bitmap>();
- private HashMap<String, Bitmap> unknownBitmaps = new HashMap<String, Bitmap>();
-
- public Bitmap get(Contact contact, Context context) {
- if (!contactBitmaps.containsKey(contact.getJid())) {
- contactBitmaps.put(contact.getJid(),
- contact.getImage(48, context));
- }
- return contactBitmaps.get(contact.getJid());
- }
-
- public Bitmap get(String name, Context context) {
- if (unknownBitmaps.containsKey(name)) {
- return unknownBitmaps.get(name);
- } else {
- Bitmap bm = UIHelper
- .getContactPicture(name, 48, context, false);
- unknownBitmaps.put(name, bm);
- return bm;
- }
- }
- }
-
public interface OnContactPictureClicked {
public void onContactPictureClicked(Message message);
}