2014-02-20 05:06:54 +00:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
2014-11-12 19:15:05 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Base64;
|
2015-05-29 23:23:47 +00:00
|
|
|
import org.whispersystems.textsecure.internal.push.TextSecureProtos.GroupContext;
|
2014-02-20 05:06:54 +00:00
|
|
|
|
|
|
|
import ws.com.google.android.mms.ContentType;
|
|
|
|
import ws.com.google.android.mms.pdu.PduBody;
|
|
|
|
import ws.com.google.android.mms.pdu.PduPart;
|
|
|
|
|
|
|
|
public class OutgoingGroupMediaMessage extends OutgoingSecureMediaMessage {
|
|
|
|
|
|
|
|
private final GroupContext group;
|
|
|
|
|
|
|
|
public OutgoingGroupMediaMessage(Context context, Recipients recipients,
|
|
|
|
GroupContext group, byte[] avatar)
|
|
|
|
{
|
|
|
|
super(context, recipients, new PduBody(), Base64.encodeBytes(group.toByteArray()),
|
|
|
|
ThreadDatabase.DistributionTypes.CONVERSATION);
|
|
|
|
|
|
|
|
this.group = group;
|
|
|
|
|
2014-02-22 18:54:43 +00:00
|
|
|
if (avatar != null) {
|
|
|
|
PduPart part = new PduPart();
|
|
|
|
part.setData(avatar);
|
|
|
|
part.setContentType(ContentType.IMAGE_PNG.getBytes());
|
|
|
|
part.setContentId((System.currentTimeMillis()+"").getBytes());
|
|
|
|
part.setName(("Image" + System.currentTimeMillis()).getBytes());
|
|
|
|
body.addPart(part);
|
|
|
|
}
|
2014-02-20 05:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isGroup() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-22 01:51:25 +00:00
|
|
|
public boolean isGroupUpdate() {
|
|
|
|
return group.getType().getNumber() == GroupContext.Type.UPDATE_VALUE;
|
2014-02-20 05:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isGroupQuit() {
|
|
|
|
return group.getType().getNumber() == GroupContext.Type.QUIT_VALUE;
|
|
|
|
}
|
|
|
|
}
|