From 3f208383f3cfa2147f54ffdf7075c25e9acc5bbc Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 7 Sep 2020 15:20:32 +1000 Subject: [PATCH] Hook everything up --- .../fragment_user_details_bottom_sheet.xml | 5 +++-- .../securesms/loki/activities/HomeActivity.kt | 3 +++ .../loki/dialogs/UserDetailsBottomSheet.kt | 21 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/res/layout/fragment_user_details_bottom_sheet.xml b/res/layout/fragment_user_details_bottom_sheet.xml index cb87ca86e3..705317e32d 100644 --- a/res/layout/fragment_user_details_bottom_sheet.xml +++ b/res/layout/fragment_user_details_bottom_sheet.xml @@ -19,10 +19,11 @@ android:layout_marginTop="@dimen/large_spacing" /> diff --git a/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt index 4dd163af49..90a9ffe9eb 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt @@ -275,6 +275,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe bottomSheet.onViewDetailsTapped = { bottomSheet.dismiss() val userDetailsBottomSheet = UserDetailsBottomSheet() + val bundle = Bundle() + bundle.putString("publicKey", thread.recipient.address.toPhoneString()) + userDetailsBottomSheet.arguments = bundle userDetailsBottomSheet.show(supportFragmentManager, userDetailsBottomSheet.tag) } bottomSheet.onBlockTapped = { diff --git a/src/org/thoughtcrime/securesms/loki/dialogs/UserDetailsBottomSheet.kt b/src/org/thoughtcrime/securesms/loki/dialogs/UserDetailsBottomSheet.kt index aef13c98b2..ca1fabcec9 100644 --- a/src/org/thoughtcrime/securesms/loki/dialogs/UserDetailsBottomSheet.kt +++ b/src/org/thoughtcrime/securesms/loki/dialogs/UserDetailsBottomSheet.kt @@ -1,11 +1,19 @@ package org.thoughtcrime.securesms.loki.dialogs +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context import android.os.Bundle import com.google.android.material.bottomsheet.BottomSheetDialogFragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast +import kotlinx.android.synthetic.main.fragment_user_details_bottom_sheet.* +import kotlinx.android.synthetic.main.view_conversation.view.* import network.loki.messenger.R +import org.thoughtcrime.securesms.database.DatabaseFactory +import org.thoughtcrime.securesms.mms.GlideApp public class UserDetailsBottomSheet : BottomSheetDialogFragment() { @@ -15,5 +23,18 @@ public class UserDetailsBottomSheet : BottomSheetDialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + val publicKey = arguments?.getString("publicKey") ?: return dismiss() + profilePictureView.publicKey = publicKey + profilePictureView.glide = GlideApp.with(this) + profilePictureView.isLarge = true + profilePictureView.update() + nameTextView.text = DatabaseFactory.getLokiUserDatabase(requireContext()).getDisplayName(publicKey) ?: publicKey + publicKeyTextView.text = publicKey + copyButton.setOnClickListener { + val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clip = ClipData.newPlainText("Session ID", publicKey) + clipboard.setPrimaryClip(clip) + Toast.makeText(requireContext(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show() + } } } \ No newline at end of file