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 | |
parent | d2a3bc74c1fc48632c72e254282324272e4e5ce2 (diff) |
add icons to files/locations in chat view
Diffstat (limited to '')
34 files changed, 82 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 3dc51cb98..4f12500d9 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -841,9 +841,6 @@ public class XmppConnectionService extends Service { @Override public void onTaskRemoved(final Intent rootIntent) { super.onTaskRemoved(rootIntent); -// if (!getPreferences().getBoolean("keep_foreground_service", false)) { -// this.logoutAndSave(false); -// } } private void logoutAndSave(boolean stop) { 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; diff --git a/src/main/res/drawable-hdpi/ic_account_card_details_grey600_48dp.png b/src/main/res/drawable-hdpi/ic_account_card_details_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..0a81b5b03 --- /dev/null +++ b/src/main/res/drawable-hdpi/ic_account_card_details_grey600_48dp.png diff --git a/src/main/res/drawable-hdpi/ic_calendar_grey600_48dp.png b/src/main/res/drawable-hdpi/ic_calendar_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..c9f5df52e --- /dev/null +++ b/src/main/res/drawable-hdpi/ic_calendar_grey600_48dp.png diff --git a/src/main/res/drawable-hdpi/ic_download_grey600_48dp.png b/src/main/res/drawable-hdpi/ic_download_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..58973c5d6 --- /dev/null +++ b/src/main/res/drawable-hdpi/ic_download_grey600_48dp.png diff --git a/src/main/res/drawable-hdpi/ic_file_grey600_48dp.png b/src/main/res/drawable-hdpi/ic_file_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..e9524271b --- /dev/null +++ b/src/main/res/drawable-hdpi/ic_file_grey600_48dp.png diff --git a/src/main/res/drawable-hdpi/ic_file_pdf_grey600_48dp.png b/src/main/res/drawable-hdpi/ic_file_pdf_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..821970399 --- /dev/null +++ b/src/main/res/drawable-hdpi/ic_file_pdf_grey600_48dp.png diff --git a/src/main/res/drawable-hdpi/ic_map_marker_grey600_48dp.png b/src/main/res/drawable-hdpi/ic_map_marker_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..00d32aa45 --- /dev/null +++ b/src/main/res/drawable-hdpi/ic_map_marker_grey600_48dp.png diff --git a/src/main/res/drawable-mdpi/ic_account_card_details_grey600_48dp.png b/src/main/res/drawable-mdpi/ic_account_card_details_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..c5f85936d --- /dev/null +++ b/src/main/res/drawable-mdpi/ic_account_card_details_grey600_48dp.png diff --git a/src/main/res/drawable-mdpi/ic_calendar_grey600_48dp.png b/src/main/res/drawable-mdpi/ic_calendar_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..1b6d5ca08 --- /dev/null +++ b/src/main/res/drawable-mdpi/ic_calendar_grey600_48dp.png diff --git a/src/main/res/drawable-mdpi/ic_download_grey600_48dp.png b/src/main/res/drawable-mdpi/ic_download_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..042716606 --- /dev/null +++ b/src/main/res/drawable-mdpi/ic_download_grey600_48dp.png diff --git a/src/main/res/drawable-mdpi/ic_file_grey600_48dp.png b/src/main/res/drawable-mdpi/ic_file_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..c0ca25081 --- /dev/null +++ b/src/main/res/drawable-mdpi/ic_file_grey600_48dp.png diff --git a/src/main/res/drawable-mdpi/ic_file_pdf_grey600_48dp.png b/src/main/res/drawable-mdpi/ic_file_pdf_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..0234d285f --- /dev/null +++ b/src/main/res/drawable-mdpi/ic_file_pdf_grey600_48dp.png diff --git a/src/main/res/drawable-mdpi/ic_map_marker_grey600_48dp.png b/src/main/res/drawable-mdpi/ic_map_marker_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..5d8b6ebf6 --- /dev/null +++ b/src/main/res/drawable-mdpi/ic_map_marker_grey600_48dp.png diff --git a/src/main/res/drawable-xhdpi/ic_account_card_details_grey600_48dp.png b/src/main/res/drawable-xhdpi/ic_account_card_details_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..ce59d96d3 --- /dev/null +++ b/src/main/res/drawable-xhdpi/ic_account_card_details_grey600_48dp.png diff --git a/src/main/res/drawable-xhdpi/ic_calendar_grey600_48dp.png b/src/main/res/drawable-xhdpi/ic_calendar_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..cb7a00843 --- /dev/null +++ b/src/main/res/drawable-xhdpi/ic_calendar_grey600_48dp.png diff --git a/src/main/res/drawable-xhdpi/ic_download_grey600_48dp.png b/src/main/res/drawable-xhdpi/ic_download_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..a3341c108 --- /dev/null +++ b/src/main/res/drawable-xhdpi/ic_download_grey600_48dp.png diff --git a/src/main/res/drawable-xhdpi/ic_file_grey600_48dp.png b/src/main/res/drawable-xhdpi/ic_file_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..42968200f --- /dev/null +++ b/src/main/res/drawable-xhdpi/ic_file_grey600_48dp.png diff --git a/src/main/res/drawable-xhdpi/ic_file_pdf_grey600_48dp.png b/src/main/res/drawable-xhdpi/ic_file_pdf_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..291fed0ee --- /dev/null +++ b/src/main/res/drawable-xhdpi/ic_file_pdf_grey600_48dp.png diff --git a/src/main/res/drawable-xhdpi/ic_map_marker_grey600_48dp.png b/src/main/res/drawable-xhdpi/ic_map_marker_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..f298443b3 --- /dev/null +++ b/src/main/res/drawable-xhdpi/ic_map_marker_grey600_48dp.png diff --git a/src/main/res/drawable-xxhdpi/ic_account_card_details_grey600_48dp.png b/src/main/res/drawable-xxhdpi/ic_account_card_details_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..c43ddfad7 --- /dev/null +++ b/src/main/res/drawable-xxhdpi/ic_account_card_details_grey600_48dp.png diff --git a/src/main/res/drawable-xxhdpi/ic_calendar_grey600_48dp.png b/src/main/res/drawable-xxhdpi/ic_calendar_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..1424f631f --- /dev/null +++ b/src/main/res/drawable-xxhdpi/ic_calendar_grey600_48dp.png diff --git a/src/main/res/drawable-xxhdpi/ic_download_grey600_48dp.png b/src/main/res/drawable-xxhdpi/ic_download_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..a39133662 --- /dev/null +++ b/src/main/res/drawable-xxhdpi/ic_download_grey600_48dp.png diff --git a/src/main/res/drawable-xxhdpi/ic_file_grey600_48dp.png b/src/main/res/drawable-xxhdpi/ic_file_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..b797034e2 --- /dev/null +++ b/src/main/res/drawable-xxhdpi/ic_file_grey600_48dp.png diff --git a/src/main/res/drawable-xxhdpi/ic_file_pdf_grey600_48dp.png b/src/main/res/drawable-xxhdpi/ic_file_pdf_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..f557678a7 --- /dev/null +++ b/src/main/res/drawable-xxhdpi/ic_file_pdf_grey600_48dp.png diff --git a/src/main/res/drawable-xxhdpi/ic_map_marker_grey600_48dp.png b/src/main/res/drawable-xxhdpi/ic_map_marker_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..66945c5ab --- /dev/null +++ b/src/main/res/drawable-xxhdpi/ic_map_marker_grey600_48dp.png diff --git a/src/main/res/drawable-xxxhdpi/ic_account_card_details_grey600_48dp.png b/src/main/res/drawable-xxxhdpi/ic_account_card_details_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..bf0e68746 --- /dev/null +++ b/src/main/res/drawable-xxxhdpi/ic_account_card_details_grey600_48dp.png diff --git a/src/main/res/drawable-xxxhdpi/ic_calendar_grey600_48dp.png b/src/main/res/drawable-xxxhdpi/ic_calendar_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..5cc7be147 --- /dev/null +++ b/src/main/res/drawable-xxxhdpi/ic_calendar_grey600_48dp.png diff --git a/src/main/res/drawable-xxxhdpi/ic_download_grey600_48dp.png b/src/main/res/drawable-xxxhdpi/ic_download_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..f3d934996 --- /dev/null +++ b/src/main/res/drawable-xxxhdpi/ic_download_grey600_48dp.png diff --git a/src/main/res/drawable-xxxhdpi/ic_file_grey600_48dp.png b/src/main/res/drawable-xxxhdpi/ic_file_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..877c1b8b4 --- /dev/null +++ b/src/main/res/drawable-xxxhdpi/ic_file_grey600_48dp.png diff --git a/src/main/res/drawable-xxxhdpi/ic_file_pdf_grey600_48dp.png b/src/main/res/drawable-xxxhdpi/ic_file_pdf_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..cab44b547 --- /dev/null +++ b/src/main/res/drawable-xxxhdpi/ic_file_pdf_grey600_48dp.png diff --git a/src/main/res/drawable-xxxhdpi/ic_map_marker_grey600_48dp.png b/src/main/res/drawable-xxxhdpi/ic_map_marker_grey600_48dp.png Binary files differnew file mode 100644 index 000000000..4a7d236b6 --- /dev/null +++ b/src/main/res/drawable-xxxhdpi/ic_map_marker_grey600_48dp.png diff --git a/src/main/res/layout/message_received.xml b/src/main/res/layout/message_received.xml index 19bb83206..09f00ce80 100644 --- a/src/main/res/layout/message_received.xml +++ b/src/main/res/layout/message_received.xml @@ -71,6 +71,13 @@ android:layout_height="wrap_content" android:visibility="gone" /> + <ImageButton + android:id="@+id/image_button" + android:src="@drawable/ic_file_grey600_48dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" /> + <RelativeLayout android:id="@+id/aw_player" android:layout_width="wrap_content" diff --git a/src/main/res/layout/message_sent.xml b/src/main/res/layout/message_sent.xml index ee8d38e49..e583db2c7 100644 --- a/src/main/res/layout/message_sent.xml +++ b/src/main/res/layout/message_sent.xml @@ -72,6 +72,13 @@ android:layout_height="wrap_content" android:visibility="gone" /> + <ImageButton + android:id="@+id/image_button" + android:src="@drawable/ic_file_grey600_48dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" /> + <RelativeLayout android:id="@+id/aw_player" android:layout_width="wrap_content" |