avatars for contact / new chat view #55

This commit is contained in:
daniel.boehrs
2018-11-01 16:21:43 +01:00
parent d4f1af7521
commit dd67248066
11 changed files with 145 additions and 67 deletions
@@ -63,8 +63,6 @@ import org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask;
import org.whispersystems.libsignal.util.guava.Optional;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -298,7 +296,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
dcContext.addContactToChat(chatId, contactId);
}
}
setGroupAvatar(chatId);
AvatarHelper.setGroupAvatar(this, chatId, avatarBmp);
Intent intent = new Intent(this, ConversationActivity.class);
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, chatId);
@@ -306,29 +304,6 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
finish();
}
private void setGroupAvatar(int chatId) {
if(avatarBmp == null) {
return;
}
String avatarPath = dcContext.getChat(chatId).getProfileImage();
if (avatarPath != null && !avatarPath.isEmpty()) {
File oldImage = new File(avatarPath);
if (oldImage.exists()) {
//noinspection ResultOfMethodCallIgnored
oldImage.delete();
}
}
avatarPath = AvatarHelper.getFilePathForGroupAvatar(this, chatId, System.currentTimeMillis());
FileOutputStream outStream;
try {
outStream = new FileOutputStream(avatarPath);
avatarBmp.compress(Bitmap.CompressFormat.JPEG, 85, outStream);
dcContext.setChatProfileImage(chatId, avatarPath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private boolean showGroupNameEmptyToast(String groupName) {
if(groupName == null) {
Toast.makeText(this, getString(R.string.GroupCreateActivity_please_enter_group_name), Toast.LENGTH_LONG).show();
@@ -348,7 +323,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
dcContext.setChatName(editGroupChatId, groupName);
updateGroupParticipants();
setGroupAvatar(editGroupChatId);
AvatarHelper.setGroupAvatar(this, editGroupChatId, avatarBmp);
Intent intent = new Intent();
Recipient recipient = dcContext.getRecipient(ApplicationDcContext.RECIPIENT_TYPE_CHAT, editGroupChatId);