From a6cfe5817dbaa5ecabad1e0223165a93388a16d3 Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 5 Jun 2023 14:58:56 +0930 Subject: [PATCH] Change unset profile pic in dialog --- .../securesms/preferences/SettingsActivity.kt | 24 ++++++++++++++---- app/src/main/res/drawable/ic_pictures.xml | 18 +++++++++++++ .../main/res/layout/dialog_change_avatar.xml | 25 +++++++++++++++++++ 3 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/ic_pictures.xml diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt index 6b6497982d..5a03cebc37 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt @@ -26,8 +26,10 @@ import nl.komponents.kovenant.all import nl.komponents.kovenant.ui.alwaysUi import nl.komponents.kovenant.ui.successUi import org.session.libsession.avatars.AvatarHelper +import org.session.libsession.avatars.ProfileContactPhoto import org.session.libsession.utilities.* import org.session.libsession.utilities.SSKEnvironment.ProfileManagerProtocol +import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.avatar.AvatarSelection import org.thoughtcrime.securesms.components.ProfilePictureView @@ -100,10 +102,12 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { private fun setupProfilePictureView(view: ProfilePictureView) { view.glide = glide - view.publicKey = hexEncodedPublicKey - view.displayName = getDisplayName() - view.isLarge = true - view.update() + view.apply { + publicKey = hexEncodedPublicKey + displayName = getDisplayName() + isLarge = true + update() + } } override fun onSaveInstanceState(outState: Bundle) { @@ -273,7 +277,17 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { } } .show().apply { - findViewById(R.id.profile_picture_view)?.let(::setupProfilePictureView) + val profilePic = findViewById(R.id.profile_picture_view) + ?.also(::setupProfilePictureView) + + val pictureIcon = findViewById(R.id.ic_pictures) + + val recipient = Recipient.from(context, Address.fromSerialized(hexEncodedPublicKey), false) + + val photoSet = (recipient.contactPhoto as ProfileContactPhoto).avatarObject !in setOf("0", "") + + profilePic?.isVisible = photoSet + pictureIcon?.isVisible = !photoSet } } diff --git a/app/src/main/res/drawable/ic_pictures.xml b/app/src/main/res/drawable/ic_pictures.xml new file mode 100644 index 0000000000..967d0a65b0 --- /dev/null +++ b/app/src/main/res/drawable/ic_pictures.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/layout/dialog_change_avatar.xml b/app/src/main/res/layout/dialog_change_avatar.xml index afe3672f15..60705698f1 100644 --- a/app/src/main/res/layout/dialog_change_avatar.xml +++ b/app/src/main/res/layout/dialog_change_avatar.xml @@ -5,6 +5,31 @@ android:layout_height="wrap_content" android:layout_width="match_parent"> + + + + + + + +