diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-08-02 21:40:46 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-08-02 21:40:46 +0200 |
commit | 7bde2bbb07eed59b56c9c57c1c81cb1e7b811404 (patch) | |
tree | 46e85b4a72139d5e7cae68b1f4e186433c2bd691 /src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | |
parent | d2a3bc74c1fc48632c72e254282324272e4e5ce2 (diff) |
add icons to files/locations in chat view
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 78 |
1 files changed, 68 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 0480ca2b4..6f9c3ee3b 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -28,6 +28,7 @@ import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; @@ -267,6 +268,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (viewHolder.download_button != null) { viewHolder.download_button.setVisibility(View.GONE); } + if (viewHolder.image_button != null) { + viewHolder.image_button.setVisibility(View.GONE); + } viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setText(text); @@ -280,6 +284,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (viewHolder.download_button != null) { viewHolder.download_button.setVisibility(View.GONE); } + if (viewHolder.image_button != null) { + viewHolder.image_button.setVisibility(View.GONE); + } viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setText(getContext().getString( @@ -294,6 +301,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (viewHolder.download_button != null) { viewHolder.download_button.setVisibility(View.GONE); } + if (viewHolder.image_button != null) { + viewHolder.image_button.setVisibility(View.GONE); + } viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setIncludeFontPadding(false); @@ -307,6 +317,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (viewHolder.download_button != null) { viewHolder.download_button.setVisibility(View.GONE); } + if (viewHolder.image_button != null) { + viewHolder.image_button.setVisibility(View.GONE); + } viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setIncludeFontPadding(true); @@ -402,13 +415,13 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.messageBody.setOnLongClickListener(openContextMenu); } - private void displayDownloadableMessage(ViewHolder viewHolder, - final Message message, String text) { + private void displayDownloadableMessage(ViewHolder viewHolder, final Message message, String text) { viewHolder.aw_player.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.VISIBLE); viewHolder.download_button.setText(text); + viewHolder.image_button.setVisibility(View.GONE); viewHolder.download_button.setOnClickListener(new OnClickListener() { @Override @@ -416,14 +429,19 @@ public class MessageAdapter extends ArrayAdapter<Message> { activity.startDownloadable(message); } }); - viewHolder.download_button.setOnLongClickListener(openContextMenu); + viewHolder.download_button.setOnLongClickListener(openContextMenu); } private void displayAudioMessage(ViewHolder viewHolder, final Message message, int position) { if (audioPlayer == null) audioPlayer = new HashMap<>(); viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE); - if (viewHolder.download_button != null) viewHolder.download_button.setVisibility(View.GONE); + if (viewHolder.download_button != null) { + viewHolder.download_button.setVisibility(View.GONE); + } + if (viewHolder.image_button != null) { + viewHolder.image_button.setVisibility(View.GONE); + } viewHolder.aw_player.setVisibility(View.VISIBLE); Uri audioFile = Uri.fromFile(activity.xmppConnectionService.getFileBackend().getFile(message)); @@ -446,8 +464,21 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.aw_player.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE); - viewHolder.download_button.setVisibility(View.VISIBLE); + viewHolder.download_button.setVisibility(View.GONE); viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); + viewHolder.image_button.setVisibility(View.VISIBLE); + String mimeType = message.getMimeType(); + if (mimeType != null) { + if (message.getMimeType().contains("pdf")) { + viewHolder.image_button.setImageResource(R.drawable.ic_file_pdf_grey600_48dp); + } else if (message.getMimeType().contains("vcard")) { + viewHolder.image_button.setImageResource(R.drawable.ic_account_card_details_grey600_48dp); + } else if (message.getMimeType().contains("calendar")) { + viewHolder.image_button.setImageResource(R.drawable.ic_calendar_grey600_48dp); + } else { + viewHolder.image_button.setImageResource(R.drawable.ic_file_grey600_48dp); + } + } viewHolder.download_button.setOnClickListener(new OnClickListener() { @Override @@ -455,15 +486,25 @@ public class MessageAdapter extends ArrayAdapter<Message> { openDownloadable(message); } }); - viewHolder.download_button.setOnLongClickListener(openContextMenu); + viewHolder.image_button.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + openDownloadable(message); + } + }); + viewHolder.download_button.setOnLongClickListener(openContextMenu); + viewHolder.image_button.setOnLongClickListener(openContextMenu); } private void displayLocationMessage(ViewHolder viewHolder, final Message message) { viewHolder.aw_player.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE); - viewHolder.download_button.setVisibility(View.VISIBLE); + viewHolder.download_button.setVisibility(View.GONE); viewHolder.download_button.setText(R.string.show_location); + viewHolder.image_button.setVisibility(View.VISIBLE); + viewHolder.image_button.setImageResource(R.drawable.ic_map_marker_grey600_48dp); viewHolder.download_button.setOnClickListener(new OnClickListener() { @Override @@ -471,7 +512,15 @@ public class MessageAdapter extends ArrayAdapter<Message> { showLocation(message); } }); - viewHolder.download_button.setOnLongClickListener(openContextMenu); + viewHolder.image_button.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + showLocation(message); + } + }); + viewHolder.download_button.setOnLongClickListener(openContextMenu); + viewHolder.image_button.setOnLongClickListener(openContextMenu); } private void displayImageMessage(ViewHolder viewHolder, @@ -479,7 +528,11 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.aw_player.setVisibility(View.GONE); if (viewHolder.download_button != null) { viewHolder.download_button.setVisibility(View.GONE); - } + + } + if (viewHolder.image_button != null) { + viewHolder.image_button.setVisibility(View.GONE); + } viewHolder.messageBody.setVisibility(View.GONE); viewHolder.image.setVisibility(View.VISIBLE); FileParams params = message.getFileParams(); @@ -541,6 +594,8 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.aw_player = (ViewGroup) view.findViewById(R.id.aw_player); viewHolder.download_button = (Button) view .findViewById(R.id.download_button); + viewHolder.image_button = (ImageButton) view + .findViewById(R.id.image_button); viewHolder.indicator = (ImageView) view .findViewById(R.id.security_indicator); viewHolder.edit_indicator = (ImageView) view.findViewById(R.id.edit_indicator); @@ -565,6 +620,8 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.aw_player = (ViewGroup) view.findViewById(R.id.aw_player); viewHolder.download_button = (Button) view .findViewById(R.id.download_button); + viewHolder.image_button = (ImageButton) view + .findViewById(R.id.image_button); viewHolder.indicator = (ImageView) view .findViewById(R.id.security_indicator); viewHolder.edit_indicator = (ImageView) view.findViewById(R.id.edit_indicator); @@ -818,7 +875,8 @@ public class MessageAdapter extends ArrayAdapter<Message> { private static class ViewHolder { protected LinearLayout message_box; - protected Button download_button; + protected ImageButton image_button; + protected Button download_button; protected ViewGroup aw_player; protected ImageView image; protected ImageView indicator; |