mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 21:43:38 +00:00
Remove ID copy interactions (#811)
* fix: remove selected session ID interactions * fix: include thread ID in home activity's creation of user details bottom sheet * refactor: use bundleOf builder instead of old bundle put value methods
This commit is contained in:
parent
44f5684b21
commit
28b97e45cc
@ -67,7 +67,7 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p
|
|||||||
menu.findItem(R.id.menu_context_copy).isVisible = !containsControlMessage && hasText
|
menu.findItem(R.id.menu_context_copy).isVisible = !containsControlMessage && hasText
|
||||||
// Copy Session ID
|
// Copy Session ID
|
||||||
menu.findItem(R.id.menu_context_copy_public_key).isVisible =
|
menu.findItem(R.id.menu_context_copy_public_key).isVisible =
|
||||||
(thread.isGroupRecipient && selectedItems.size == 1 && firstMessage.recipient.address.toString() != userPublicKey)
|
(thread.isGroupRecipient && !thread.isOpenGroupRecipient && selectedItems.size == 1 && firstMessage.recipient.address.toString() != userPublicKey)
|
||||||
// Message detail
|
// Message detail
|
||||||
menu.findItem(R.id.menu_message_details).isVisible = (selectedItems.size == 1 && firstMessage.isFailed)
|
menu.findItem(R.id.menu_message_details).isVisible = (selectedItems.size == 1 && firstMessage.isFailed)
|
||||||
// Resend
|
// Resend
|
||||||
|
@ -77,7 +77,6 @@ object ConversationMenuHelper {
|
|||||||
} else {
|
} else {
|
||||||
inflater.inflate(R.menu.menu_conversation_block, menu)
|
inflater.inflate(R.menu.menu_conversation_block, menu)
|
||||||
}
|
}
|
||||||
inflater.inflate(R.menu.menu_conversation_copy_session_id, menu)
|
|
||||||
}
|
}
|
||||||
// Closed group menu (options that should only be present in closed groups)
|
// Closed group menu (options that should only be present in closed groups)
|
||||||
if (thread.isClosedGroupRecipient) {
|
if (thread.isClosedGroupRecipient) {
|
||||||
|
@ -16,6 +16,7 @@ import android.widget.RelativeLayout
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.android.synthetic.main.view_visible_message.view.*
|
import kotlinx.android.synthetic.main.view_visible_message.view.*
|
||||||
@ -23,6 +24,7 @@ import network.loki.messenger.R
|
|||||||
import org.session.libsession.messaging.contacts.Contact.ContactContext
|
import org.session.libsession.messaging.contacts.Contact.ContactContext
|
||||||
import org.session.libsession.messaging.open_groups.OpenGroupAPIV2
|
import org.session.libsession.messaging.open_groups.OpenGroupAPIV2
|
||||||
import org.session.libsession.utilities.ViewUtil
|
import org.session.libsession.utilities.ViewUtil
|
||||||
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.ThreadUtils
|
import org.session.libsignal.utilities.ThreadUtils
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.database.*
|
import org.thoughtcrime.securesms.database.*
|
||||||
@ -103,7 +105,9 @@ class VisibleMessageView : LinearLayout {
|
|||||||
profilePictureView.publicKey = senderSessionID
|
profilePictureView.publicKey = senderSessionID
|
||||||
profilePictureView.glide = glide
|
profilePictureView.glide = glide
|
||||||
profilePictureView.update(message.individualRecipient, threadID)
|
profilePictureView.update(message.individualRecipient, threadID)
|
||||||
profilePictureView.setOnClickListener { showUserDetails(message.recipient.address.toString()) }
|
profilePictureView.setOnClickListener {
|
||||||
|
showUserDetails(senderSessionID, threadID)
|
||||||
|
}
|
||||||
if (thread.isOpenGroupRecipient) {
|
if (thread.isOpenGroupRecipient) {
|
||||||
val openGroup = lokiThreadDb.getOpenGroupChat(threadID) ?: return
|
val openGroup = lokiThreadDb.getOpenGroupChat(threadID) ?: return
|
||||||
val isModerator = OpenGroupAPIV2.isUserModerator(senderSessionID, openGroup.room, openGroup.server)
|
val isModerator = OpenGroupAPIV2.isUserModerator(senderSessionID, openGroup.room, openGroup.server)
|
||||||
@ -379,10 +383,12 @@ class VisibleMessageView : LinearLayout {
|
|||||||
pressCallback = null
|
pressCallback = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showUserDetails(publicKey: String) {
|
private fun showUserDetails(publicKey: String, threadID: Long) {
|
||||||
val userDetailsBottomSheet = UserDetailsBottomSheet()
|
val userDetailsBottomSheet = UserDetailsBottomSheet()
|
||||||
val bundle = Bundle()
|
val bundle = bundleOf(
|
||||||
bundle.putString("publicKey", publicKey)
|
UserDetailsBottomSheet.ARGUMENT_PUBLIC_KEY to publicKey,
|
||||||
|
UserDetailsBottomSheet.ARGUMENT_THREAD_ID to threadID
|
||||||
|
)
|
||||||
userDetailsBottomSheet.arguments = bundle
|
userDetailsBottomSheet.arguments = bundle
|
||||||
val activity = context as AppCompatActivity
|
val activity = context as AppCompatActivity
|
||||||
userDetailsBottomSheet.show(activity.supportFragmentManager, userDetailsBottomSheet.tag)
|
userDetailsBottomSheet.show(activity.supportFragmentManager, userDetailsBottomSheet.tag)
|
||||||
|
@ -12,6 +12,7 @@ import android.text.SpannableString
|
|||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
@ -250,8 +251,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
|||||||
bottomSheet.onViewDetailsTapped = {
|
bottomSheet.onViewDetailsTapped = {
|
||||||
bottomSheet.dismiss()
|
bottomSheet.dismiss()
|
||||||
val userDetailsBottomSheet = UserDetailsBottomSheet()
|
val userDetailsBottomSheet = UserDetailsBottomSheet()
|
||||||
val bundle = Bundle()
|
val bundle = bundleOf(
|
||||||
bundle.putString("publicKey", thread.recipient.address.toString())
|
UserDetailsBottomSheet.ARGUMENT_PUBLIC_KEY to thread.recipient.address.toString(),
|
||||||
|
UserDetailsBottomSheet.ARGUMENT_THREAD_ID to thread.threadId
|
||||||
|
)
|
||||||
userDetailsBottomSheet.arguments = bundle
|
userDetailsBottomSheet.arguments = bundle
|
||||||
userDetailsBottomSheet.show(supportFragmentManager, userDetailsBottomSheet.tag)
|
userDetailsBottomSheet.show(supportFragmentManager, userDetailsBottomSheet.tag)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,10 @@ import android.view.ViewGroup
|
|||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
import dagger.hilt.EntryPoint
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.android.synthetic.main.fragment_user_details_bottom_sheet.*
|
import kotlinx.android.synthetic.main.fragment_user_details_bottom_sheet.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
@ -20,20 +23,32 @@ import org.session.libsession.messaging.contacts.Contact
|
|||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||||
|
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp
|
import org.thoughtcrime.securesms.mms.GlideApp
|
||||||
import org.thoughtcrime.securesms.util.UiModeUtilities
|
import org.thoughtcrime.securesms.util.UiModeUtilities
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
class UserDetailsBottomSheet : BottomSheetDialogFragment() {
|
class UserDetailsBottomSheet : BottomSheetDialogFragment() {
|
||||||
|
|
||||||
|
@Inject lateinit var threadDb: ThreadDatabase
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val ARGUMENT_PUBLIC_KEY = "publicKey"
|
||||||
|
const val ARGUMENT_THREAD_ID = "threadId"
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.fragment_user_details_bottom_sheet, container, false)
|
return inflater.inflate(R.layout.fragment_user_details_bottom_sheet, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
val publicKey = arguments?.getString("publicKey") ?: return dismiss()
|
val publicKey = arguments?.getString(ARGUMENT_PUBLIC_KEY) ?: return dismiss()
|
||||||
|
val threadID = arguments?.getLong(ARGUMENT_THREAD_ID) ?: return dismiss()
|
||||||
val recipient = Recipient.from(requireContext(), Address.fromSerialized(publicKey), false)
|
val recipient = Recipient.from(requireContext(), Address.fromSerialized(publicKey), false)
|
||||||
|
val threadRecipient = threadDb.getRecipientForThreadId(threadID) ?: return dismiss()
|
||||||
profilePictureView.publicKey = publicKey
|
profilePictureView.publicKey = publicKey
|
||||||
profilePictureView.glide = GlideApp.with(this)
|
profilePictureView.glide = GlideApp.with(this)
|
||||||
profilePictureView.isLarge = true
|
profilePictureView.isLarge = true
|
||||||
@ -65,6 +80,9 @@ class UserDetailsBottomSheet : BottomSheetDialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nameTextView.text = recipient.name ?: publicKey // Uses the Contact API internally
|
nameTextView.text = recipient.name ?: publicKey // Uses the Contact API internally
|
||||||
|
|
||||||
|
publicKeyTextView.isVisible = !threadRecipient.isOpenGroupRecipient
|
||||||
|
messageButton.isVisible = !threadRecipient.isOpenGroupRecipient
|
||||||
publicKeyTextView.text = publicKey
|
publicKeyTextView.text = publicKey
|
||||||
publicKeyTextView.setOnLongClickListener {
|
publicKeyTextView.setOnLongClickListener {
|
||||||
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
Loading…
x
Reference in New Issue
Block a user