Make profile pictures tappable

This commit is contained in:
Niels Andriesse 2021-07-14 14:39:20 +10:00
parent 073c9a9efa
commit 6028fff59c
4 changed files with 31 additions and 1 deletions

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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()

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"