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;
|
|
|
|
import org.whispersystems.textsecure.util.Base64;
|
|
|
|
|
|
|
|
import ws.com.google.android.mms.ContentType;
|
|
|
|
import ws.com.google.android.mms.pdu.PduBody;
|
|
|
|
import ws.com.google.android.mms.pdu.PduPart;
|
|
|
|
|
|
|
|
import static org.whispersystems.textsecure.push.PushMessageProtos.PushMessageContent.GroupContext;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@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;
|
|
|
|
}
|
|
|
|
}
|