mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Fix crash when creating group with no avatar icon
Fixes #4320 // FREEBIE
This commit is contained in:
parent
4271732b10
commit
a086a2471c
@ -26,6 +26,7 @@ import android.net.Uri;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -460,10 +461,12 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity {
|
|||||||
return handlePushOperation(groupId, groupName, avatar, memberE164Numbers);
|
return handlePushOperation(groupId, groupName, avatar, memberE164Numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<Long, Recipients> handlePushOperation(byte[] groupId, String groupName, byte[] avatar,
|
private Pair<Long, Recipients> handlePushOperation(byte[] groupId, String groupName,
|
||||||
|
@Nullable byte[] avatar,
|
||||||
Set<String> e164numbers)
|
Set<String> e164numbers)
|
||||||
throws InvalidNumberException
|
throws InvalidNumberException
|
||||||
{
|
{
|
||||||
|
Attachment avatarAttachment = null;
|
||||||
String groupRecipientId = GroupUtil.getEncodedId(groupId);
|
String groupRecipientId = GroupUtil.getEncodedId(groupId);
|
||||||
Recipients groupRecipient = RecipientFactory.getRecipientsFromString(this, groupRecipientId, false);
|
Recipients groupRecipient = RecipientFactory.getRecipientsFromString(this, groupRecipientId, false);
|
||||||
|
|
||||||
@ -474,8 +477,11 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity {
|
|||||||
.addAllMembers(e164numbers)
|
.addAllMembers(e164numbers)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Uri avatarUri = SingleUseBlobProvider.getInstance().createUri(avatar);
|
if (avatar != null) {
|
||||||
Attachment avatarAttachment = new UriAttachment(avatarUri, ContentType.IMAGE_JPEG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length);
|
Uri avatarUri = SingleUseBlobProvider.getInstance().createUri(avatar);
|
||||||
|
avatarAttachment = new UriAttachment(avatarUri, ContentType.IMAGE_JPEG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length);
|
||||||
|
}
|
||||||
|
|
||||||
OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, context, avatarAttachment, System.currentTimeMillis());
|
OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, context, avatarAttachment, System.currentTimeMillis());
|
||||||
long threadId = MessageSender.send(this, masterSecret, outgoingMessage, -1, false);
|
long threadId = MessageSender.send(this, masterSecret, outgoingMessage, -1, false);
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ public class Recipient {
|
|||||||
|
|
||||||
private final long recipientId;
|
private final long recipientId;
|
||||||
|
|
||||||
private String number;
|
private @NonNull String number;
|
||||||
private String name;
|
private @Nullable String name;
|
||||||
private boolean stale;
|
private boolean stale;
|
||||||
|
|
||||||
private ContactPhoto contactPhoto;
|
private ContactPhoto contactPhoto;
|
||||||
@ -123,7 +123,7 @@ public class Recipient {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNumber() {
|
public @NonNull String getNumber() {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ public class RecipientFactory {
|
|||||||
return provider.getRecipients(context, ids, asynchronous);
|
return provider.getRecipients(context, ids, asynchronous);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Recipient getRecipientForId(Context context, long recipientId, boolean asynchronous) {
|
public @NonNull static Recipient getRecipientForId(Context context, long recipientId, boolean asynchronous) {
|
||||||
return provider.getRecipient(context, recipientId, asynchronous);
|
return provider.getRecipient(context, recipientId, asynchronous);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Recipients getRecipientsForIds(Context context, long[] recipientIds, boolean asynchronous) {
|
public @NonNull static Recipients getRecipientsForIds(Context context, long[] recipientIds, boolean asynchronous) {
|
||||||
return provider.getRecipients(context, recipientIds, asynchronous);
|
return provider.getRecipients(context, recipientIds, asynchronous);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class RecipientProvider {
|
|||||||
ContactColors.UNKNOWN_COLOR));
|
ContactColors.UNKNOWN_COLOR));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
Recipient getRecipient(Context context, long recipientId, boolean asynchronous) {
|
@NonNull Recipient getRecipient(Context context, long recipientId, boolean asynchronous) {
|
||||||
Recipient cachedRecipient = recipientCache.get(recipientId);
|
Recipient cachedRecipient = recipientCache.get(recipientId);
|
||||||
if (cachedRecipient != null && !cachedRecipient.isStale()) return cachedRecipient;
|
if (cachedRecipient != null && !cachedRecipient.isStale()) return cachedRecipient;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class RecipientProvider {
|
|||||||
return cachedRecipient;
|
return cachedRecipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
Recipients getRecipients(Context context, long[] recipientIds, boolean asynchronous) {
|
@NonNull Recipients getRecipients(Context context, long[] recipientIds, boolean asynchronous) {
|
||||||
Recipients cachedRecipients = recipientsCache.get(new RecipientIds(recipientIds));
|
Recipients cachedRecipients = recipientsCache.get(new RecipientIds(recipientIds));
|
||||||
if (cachedRecipients != null && !cachedRecipients.isStale()) return cachedRecipients;
|
if (cachedRecipients != null && !cachedRecipients.isStale()) return cachedRecipients;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user