From fec3eec0affc3fb9e13dfa9ab3d1a84d72d568ff Mon Sep 17 00:00:00 2001 From: Hocuri Date: Sun, 7 Jun 2020 13:03:52 +0200 Subject: [PATCH 1/3] Change the enlarged avatar name to the chat name --- src/org/thoughtcrime/securesms/ProfileActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ProfileActivity.java b/src/org/thoughtcrime/securesms/ProfileActivity.java index fcd948413..992b060dc 100644 --- a/src/org/thoughtcrime/securesms/ProfileActivity.java +++ b/src/org/thoughtcrime/securesms/ProfileActivity.java @@ -395,8 +395,9 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity public void onEnlargeAvatar() { String profileImagePath; Uri profileImageUri; + DcChat dcChat = dcContext.getChat(chatId); if(chatId!=0) - profileImagePath = dcContext.getChat(chatId).getProfileImage(); + profileImagePath = dcChat.getProfileImage(); else profileImagePath = dcContext.getContact(contactId).getProfileImage(); @@ -405,7 +406,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity Intent intent = new Intent(this, MediaPreviewActivity.class); intent.setDataAndType(profileImageUri, type); - intent.putExtra(MediaPreviewActivity.ACTIVITY_TITLE_EXTRA, getString(isContactProfile() ? R.string.pref_profile_photo : R.string.group_avatar)); + intent.putExtra(MediaPreviewActivity.ACTIVITY_TITLE_EXTRA, dcChat.getName()); intent.putExtra(MediaPreviewActivity.EDIT_AVATAR_CHAT_ID, chatIsGroup ? chatId : 0); // shows edit-button, might be 0 for a contact-profile startActivity(intent); } From e3f4268ca6306d5aa5f346c164b7a805c66bc67e Mon Sep 17 00:00:00 2001 From: Hocuri Date: Sun, 7 Jun 2020 13:39:46 +0200 Subject: [PATCH 2/3] Fallback to contact name if there is no chat --- .../thoughtcrime/securesms/ProfileActivity.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ProfileActivity.java b/src/org/thoughtcrime/securesms/ProfileActivity.java index 992b060dc..dc05ebfa0 100644 --- a/src/org/thoughtcrime/securesms/ProfileActivity.java +++ b/src/org/thoughtcrime/securesms/ProfileActivity.java @@ -394,19 +394,24 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity public void onEnlargeAvatar() { String profileImagePath; + String title; Uri profileImageUri; - DcChat dcChat = dcContext.getChat(chatId); - if(chatId!=0) + if(chatId!=0) { + DcChat dcChat = dcContext.getChat(chatId); profileImagePath = dcChat.getProfileImage(); - else - profileImagePath = dcContext.getContact(contactId).getProfileImage(); + title = dcChat.getName(); + } else { + DcContact dcContact = dcContext.getContact(contactId); + profileImagePath = dcContact.getProfileImage(); + title = dcContact.getDisplayName(); + } profileImageUri = Uri.fromFile(new File(profileImagePath)); String type = "image/" + profileImagePath.substring(profileImagePath.lastIndexOf(".") +1); Intent intent = new Intent(this, MediaPreviewActivity.class); intent.setDataAndType(profileImageUri, type); - intent.putExtra(MediaPreviewActivity.ACTIVITY_TITLE_EXTRA, dcChat.getName()); + intent.putExtra(MediaPreviewActivity.ACTIVITY_TITLE_EXTRA, title); intent.putExtra(MediaPreviewActivity.EDIT_AVATAR_CHAT_ID, chatIsGroup ? chatId : 0); // shows edit-button, might be 0 for a contact-profile startActivity(intent); } From ca47ec29a5ffbad108c2ca323778a65a7e21e797 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Sun, 7 Jun 2020 13:42:49 +0200 Subject: [PATCH 3/3] Do not enlarge avatar if there is none (just a big letter in a circle) --- src/org/thoughtcrime/securesms/ProfileActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/ProfileActivity.java b/src/org/thoughtcrime/securesms/ProfileActivity.java index dc05ebfa0..774a7d88e 100644 --- a/src/org/thoughtcrime/securesms/ProfileActivity.java +++ b/src/org/thoughtcrime/securesms/ProfileActivity.java @@ -406,7 +406,10 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity title = dcContact.getDisplayName(); } - profileImageUri = Uri.fromFile(new File(profileImagePath)); + File file = new File(profileImagePath); + if (!file.exists()) return; + + profileImageUri = Uri.fromFile(file); String type = "image/" + profileImagePath.substring(profileImagePath.lastIndexOf(".") +1); Intent intent = new Intent(this, MediaPreviewActivity.class);