mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-01 05:02:21 -05:00
picture notification and some drive by bug fixes
This commit is contained in:
parent
1dae59141d
commit
864f3610b3
@ -1,5 +1,6 @@
|
|||||||
package eu.siacs.conversations.services;
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -11,6 +12,7 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
@ -109,19 +111,31 @@ public class NotificationService {
|
|||||||
mBuilder.setLargeIcon(mXmppConnectionService
|
mBuilder.setLargeIcon(mXmppConnectionService
|
||||||
.getAvatarService().get(conversation, getPixel(64)));
|
.getAvatarService().get(conversation, getPixel(64)));
|
||||||
mBuilder.setContentTitle(conversation.getName());
|
mBuilder.setContentTitle(conversation.getName());
|
||||||
StringBuilder text = new StringBuilder();
|
if (messages.size() == 1 && messages.get(0).getType() == Message.TYPE_IMAGE) {
|
||||||
for (int i = 0; i < messages.size(); ++i) {
|
try {
|
||||||
text.append(getReadableBody(messages.get(i)));
|
Bitmap bitmap = mXmppConnectionService.getFileBackend().getThumbnail(messages.get(0),getPixel(288),false);
|
||||||
if (i != messages.size() - 1) {
|
mBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap));
|
||||||
text.append("\n");
|
mBuilder.setContentText(mXmppConnectionService.getString(R.string.image_file));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
for (int i = 0; i < messages.size(); ++i) {
|
||||||
|
text.append(getReadableBody(messages.get(i)));
|
||||||
|
if (i != messages.size() - 1) {
|
||||||
|
text.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mBuilder.setStyle(new NotificationCompat.BigTextStyle()
|
||||||
|
.bigText(text.toString()));
|
||||||
|
mBuilder.setContentText(getReadableBody(messages.get(0)));
|
||||||
|
if (notify) {
|
||||||
|
mBuilder.setTicker(getReadableBody(messages
|
||||||
|
.get(messages.size() - 1)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
mBuilder.setStyle(new NotificationCompat.BigTextStyle()
|
|
||||||
.bigText(text.toString()));
|
|
||||||
mBuilder.setContentText(getReadableBody(messages.get(0)));
|
|
||||||
if (notify) {
|
|
||||||
mBuilder.setTicker(getReadableBody(messages
|
|
||||||
.get(messages.size() - 1)));
|
|
||||||
}
|
}
|
||||||
mBuilder.setContentIntent(createContentIntent(conversation
|
mBuilder.setContentIntent(createContentIntent(conversation
|
||||||
.getUuid()));
|
.getUuid()));
|
||||||
|
@ -629,23 +629,11 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
if (xmppConnectionServiceBound) {
|
if (xmppConnectionServiceBound) {
|
||||||
if ((Intent.ACTION_VIEW.equals(intent.getAction()) && (VIEW_CONVERSATION
|
if (intent != null
|
||||||
.equals(intent.getType())))) {
|
&& VIEW_CONVERSATION.equals(getIntent().getType())) {
|
||||||
String convToView = (String) intent.getExtras().get(
|
handleViewConversationIntent(intent);
|
||||||
CONVERSATION);
|
|
||||||
updateConversationList();
|
|
||||||
for (int i = 0; i < conversationList.size(); ++i) {
|
|
||||||
if (conversationList.get(i).getUuid().equals(convToView)) {
|
|
||||||
setSelectedConversation(conversationList.get(i));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paneShouldBeOpen = false;
|
|
||||||
String text = intent.getExtras().getString(TEXT, null);
|
|
||||||
swapConversationFragment().setText(text);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handledViewIntent = false;
|
|
||||||
setIntent(intent);
|
setIntent(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -705,11 +693,7 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
mOpenConverstaion = null;
|
mOpenConverstaion = null;
|
||||||
} else if (getIntent() != null
|
} else if (getIntent() != null
|
||||||
&& VIEW_CONVERSATION.equals(getIntent().getType())) {
|
&& VIEW_CONVERSATION.equals(getIntent().getType())) {
|
||||||
String uuid = (String) getIntent().getExtras().get(CONVERSATION);
|
handleViewConversationIntent(getIntent());
|
||||||
String text = getIntent().getExtras().getString(TEXT, null);
|
|
||||||
selectConversationByUuid(uuid);
|
|
||||||
paneShouldBeOpen = false;
|
|
||||||
swapConversationFragment().setText(text);
|
|
||||||
setIntent(null);
|
setIntent(null);
|
||||||
} else {
|
} else {
|
||||||
showConversationsOverview();
|
showConversationsOverview();
|
||||||
@ -731,6 +715,14 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
}
|
}
|
||||||
ExceptionHelper.checkForCrash(this, this.xmppConnectionService);
|
ExceptionHelper.checkForCrash(this, this.xmppConnectionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleViewConversationIntent(Intent intent) {
|
||||||
|
String uuid = (String) intent.getExtras().get(CONVERSATION);
|
||||||
|
String text = intent.getExtras().getString(TEXT, null);
|
||||||
|
selectConversationByUuid(uuid);
|
||||||
|
paneShouldBeOpen = false;
|
||||||
|
swapConversationFragment().setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
private void selectConversationByUuid(String uuid) {
|
private void selectConversationByUuid(String uuid) {
|
||||||
for (int i = 0; i < conversationList.size(); ++i) {
|
for (int i = 0; i < conversationList.size(); ++i) {
|
||||||
|
@ -58,7 +58,6 @@ public abstract class XmppActivity extends Activity {
|
|||||||
|
|
||||||
public XmppConnectionService xmppConnectionService;
|
public XmppConnectionService xmppConnectionService;
|
||||||
public boolean xmppConnectionServiceBound = false;
|
public boolean xmppConnectionServiceBound = false;
|
||||||
protected boolean handledViewIntent = false;
|
|
||||||
|
|
||||||
protected int mPrimaryTextColor;
|
protected int mPrimaryTextColor;
|
||||||
protected int mSecondaryTextColor;
|
protected int mSecondaryTextColor;
|
||||||
|
@ -100,6 +100,8 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
|||||||
mLastMessage.setText("");
|
mLastMessage.setText("");
|
||||||
}
|
}
|
||||||
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
|
imagePreview.setVisibility(View.GONE);
|
||||||
|
mLastMessage.setVisibility(View.VISIBLE);
|
||||||
mLastMessage.setText(R.string.encrypted_message_received);
|
mLastMessage.setText(R.string.encrypted_message_received);
|
||||||
} else {
|
} else {
|
||||||
mLastMessage.setVisibility(View.GONE);
|
mLastMessage.setVisibility(View.GONE);
|
||||||
|
Loading…
Reference in New Issue
Block a user