From 6028fff59c45d2f8daeeae7138d84803e9f4fb0a Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 14 Jul 2021 14:39:20 +1000 Subject: [PATCH] Make profile pictures tappable --- .../conversation/v2/messages/VisibleMessageView.kt | 13 +++++++++++++ .../home/ConversationOptionsBottomSheet.kt | 8 ++++++++ .../securesms/home/UserDetailsBottomSheet.kt | 8 ++++++++ .../layout/fragment_user_details_bottom_sheet.xml | 3 ++- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index 058054a257..b5144d4da3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -6,12 +6,14 @@ import android.graphics.Canvas import android.graphics.Rect import android.graphics.drawable.ColorDrawable import android.os.Build +import android.os.Bundle import android.os.Handler import android.os.Looper import android.util.AttributeSet import android.view.* import android.widget.LinearLayout import android.widget.RelativeLayout +import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.content.res.ResourcesCompat import androidx.core.view.isVisible @@ -24,6 +26,7 @@ import org.session.libsignal.utilities.ThreadUtils import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.model.MessageRecord +import org.thoughtcrime.securesms.home.UserDetailsBottomSheet import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.util.* import java.util.* @@ -92,6 +95,7 @@ class VisibleMessageView : LinearLayout { profilePictureView.publicKey = senderSessionID profilePictureView.glide = glide profilePictureView.update() + profilePictureView.setOnClickListener { showUserDetails(message.recipient.address.toString()) } if (thread.isOpenGroupRecipient) { val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getOpenGroupChat(threadID) ?: return val isModerator = OpenGroupAPIV2.isUserModerator(senderSessionID, openGroup.room, openGroup.server) @@ -362,5 +366,14 @@ class VisibleMessageView : LinearLayout { onPress?.invoke(event) pressCallback = null } + + private fun showUserDetails(publicKey: String) { + val userDetailsBottomSheet = UserDetailsBottomSheet() + val bundle = Bundle() + bundle.putString("publicKey", publicKey) + userDetailsBottomSheet.arguments = bundle + val activity = context as AppCompatActivity + userDetailsBottomSheet.show(activity.supportFragmentManager, userDetailsBottomSheet.tag) + } // endregion } diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt index 4664ea09c4..7b454d33c7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import kotlinx.android.synthetic.main.fragment_conversation_bottom_sheet.* import network.loki.messenger.R import org.session.libsession.utilities.recipients.Recipient +import org.thoughtcrime.securesms.util.UiModeUtilities public class ConversationOptionsBottomSheet : BottomSheetDialogFragment() { @@ -41,4 +42,11 @@ public class ConversationOptionsBottomSheet : BottomSheetDialogFragment() { } deleteTextView.setOnClickListener { onDeleteTapped?.invoke() } } + + override fun onStart() { + super.onStart() + val window = dialog?.window ?: return + val isLightMode = UiModeUtilities.isDayUiMode(requireContext()) + window.setDimAmount(if (isLightMode) 0.1f else 0.75f) + } } \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt b/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt index 147216ec6a..fec96b5de8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt @@ -19,6 +19,7 @@ import org.session.libsession.utilities.Address import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.mms.GlideApp +import org.thoughtcrime.securesms.util.UiModeUtilities class UserDetailsBottomSheet : BottomSheetDialogFragment() { @@ -70,6 +71,13 @@ class UserDetailsBottomSheet : BottomSheetDialogFragment() { } } + override fun onStart() { + super.onStart() + val window = dialog?.window ?: return + val isLightMode = UiModeUtilities.isDayUiMode(requireContext()) + window.setDimAmount(if (isLightMode) 0.1f else 0.75f) + } + fun saveNickName(recipient: Recipient) { nicknameEditText.clearFocus() hideSoftKeyboard() diff --git a/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml b/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml index 4c43adcd1e..985de78a64 100644 --- a/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml @@ -1,5 +1,6 @@ -