aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java78
2 files changed, 68 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;