mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Fix group avatar issues in GroupCreateActivity
Images weren't rounded in some cases, and other times weren't updating in the group properly. Closes #4692 // FREEBIE
This commit is contained in:
parent
073be6696b
commit
7aac137fb7
@ -21,7 +21,6 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -49,7 +48,6 @@ import org.thoughtcrime.securesms.components.PushRecipientsPanel.RecipientsPanel
|
|||||||
import org.thoughtcrime.securesms.contacts.RecipientsEditor;
|
import org.thoughtcrime.securesms.contacts.RecipientsEditor;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||||
@ -325,13 +323,8 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||||||
.centerCrop().override(AVATAR_SIZE, AVATAR_SIZE)
|
.centerCrop().override(AVATAR_SIZE, AVATAR_SIZE)
|
||||||
.into(new SimpleTarget<Bitmap>() {
|
.into(new SimpleTarget<Bitmap>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(Bitmap resource,
|
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
|
||||||
GlideAnimation<? super Bitmap> glideAnimation)
|
setAvatar(Crop.getOutput(data), resource);
|
||||||
{
|
|
||||||
avatarBmp = resource;
|
|
||||||
Glide.with(GroupCreateActivity.this).load(Crop.getOutput(data)).skipMemoryCache(true)
|
|
||||||
.transform(new RoundedCorners(GroupCreateActivity.this, avatar.getWidth() / 2))
|
|
||||||
.into(avatar);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -567,6 +560,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return Optional.of(new GroupData(groupIds[0],
|
return Optional.of(new GroupData(groupIds[0],
|
||||||
existingContacts,
|
existingContacts,
|
||||||
BitmapUtil.fromByteArray(group.getAvatar()),
|
BitmapUtil.fromByteArray(group.getAvatar()),
|
||||||
|
group.getAvatar(),
|
||||||
group.getTitle()));
|
group.getTitle()));
|
||||||
} else {
|
} else {
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
@ -581,7 +575,9 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||||||
activity.groupToUpdate = group;
|
activity.groupToUpdate = group;
|
||||||
|
|
||||||
activity.groupName.setText(group.get().name);
|
activity.groupName.setText(group.get().name);
|
||||||
if (group.get().avatar != null) activity.avatar.setImageBitmap(group.get().avatar);
|
if (group.get().avatarBmp != null) {
|
||||||
|
activity.setAvatar(group.get().avatarBytes, group.get().avatarBmp);
|
||||||
|
}
|
||||||
SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(activity, group.get().recipients);
|
SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(activity, group.get().recipients);
|
||||||
adapter.setOnRecipientDeletedListener(activity);
|
adapter.setOnRecipientDeletedListener(activity);
|
||||||
activity.lv.setAdapter(adapter);
|
activity.lv.setAdapter(adapter);
|
||||||
@ -590,17 +586,28 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T> void setAvatar(T model, Bitmap bitmap) {
|
||||||
|
avatarBmp = bitmap;
|
||||||
|
Glide.with(this)
|
||||||
|
.load(model)
|
||||||
|
.skipMemoryCache(true)
|
||||||
|
.transform(new RoundedCorners(this, avatar.getWidth() / 2))
|
||||||
|
.into(avatar);
|
||||||
|
}
|
||||||
|
|
||||||
private static class GroupData {
|
private static class GroupData {
|
||||||
byte[] id;
|
byte[] id;
|
||||||
Set<Recipient> recipients;
|
Set<Recipient> recipients;
|
||||||
Bitmap avatar;
|
Bitmap avatarBmp;
|
||||||
|
byte[] avatarBytes;
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
public GroupData(byte[] id, Set<Recipient> recipients, Bitmap avatar, String name) {
|
public GroupData(byte[] id, Set<Recipient> recipients, Bitmap avatarBmp, byte[] avatarBytes, String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.recipients = recipients;
|
this.recipients = recipients;
|
||||||
this.avatar = avatar;
|
this.avatarBmp = avatarBmp;
|
||||||
this.name = name;
|
this.avatarBytes = avatarBytes;
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user