2014-02-20 05:06:54 +00:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
2014-02-20 05:06:54 +00:00
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
2014-02-20 05:06:54 +00:00
|
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
2015-10-24 10:58:21 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Base64;
|
2016-03-23 17:34:41 +00:00
|
|
|
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
2014-02-20 05:06:54 +00:00
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2014-02-20 05:06:54 +00:00
|
|
|
|
|
|
|
public class OutgoingGroupMediaMessage extends OutgoingSecureMediaMessage {
|
|
|
|
|
|
|
|
private final GroupContext group;
|
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
public OutgoingGroupMediaMessage(@NonNull Recipients recipients,
|
|
|
|
@NonNull String encodedGroupContext,
|
|
|
|
@NonNull List<Attachment> avatar,
|
|
|
|
long sentTimeMillis)
|
|
|
|
throws IOException
|
2014-02-20 05:06:54 +00:00
|
|
|
{
|
2015-10-13 01:25:05 +00:00
|
|
|
super(recipients, encodedGroupContext, avatar, sentTimeMillis,
|
2014-02-20 05:06:54 +00:00
|
|
|
ThreadDatabase.DistributionTypes.CONVERSATION);
|
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
this.group = GroupContext.parseFrom(Base64.decode(encodedGroupContext));
|
|
|
|
}
|
|
|
|
|
|
|
|
public OutgoingGroupMediaMessage(@NonNull Recipients recipients,
|
|
|
|
@NonNull GroupContext group,
|
2015-10-16 00:10:54 +00:00
|
|
|
@Nullable final Attachment avatar,
|
|
|
|
long sentTimeMillis)
|
2015-10-13 01:25:05 +00:00
|
|
|
{
|
|
|
|
super(recipients, Base64.encodeBytes(group.toByteArray()),
|
|
|
|
new LinkedList<Attachment>() {{if (avatar != null) add(avatar);}},
|
|
|
|
System.currentTimeMillis(),
|
|
|
|
ThreadDatabase.DistributionTypes.CONVERSATION);
|
2014-02-20 05:06:54 +00:00
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
this.group = group;
|
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;
|
|
|
|
}
|
2015-10-13 01:25:05 +00:00
|
|
|
|
|
|
|
public GroupContext getGroupContext() {
|
|
|
|
return group;
|
|
|
|
}
|
2014-02-20 05:06:54 +00:00
|
|
|
}
|