Skip to content
Snippets Groups Projects
Commit c36705de authored by Pierre Nicolas's avatar Pierre Nicolas :joy:
Browse files

details: connect share and qrcode buttons

Use the new QrCodeFragment.

GitLab: #1723
Change-Id: Ie6c2bd4210a135719f6e21c5c257614ad88ac067
parent 22524754
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ package cx.ring.fragments
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Intent
import android.os.Bundle
import android.view.*
import androidx.annotation.StringRes
......@@ -40,6 +41,7 @@ import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.disposables.CompositeDisposable
import net.jami.model.Conversation
import net.jami.model.Uri
import net.jami.qrcode.QRCodePresenter
import net.jami.services.AccountService
import net.jami.services.ConversationFacade
import javax.inject.Inject
......@@ -163,12 +165,14 @@ class ConversationActionsFragment : Fragment() {
if (registeredName.isEmpty()) R.drawable.background_rounded_16_top
else R.drawable.background_clickable
)
shareButton.setOnClickListener {
shareContact(registeredName.ifEmpty { identifier.uri })
}
qrCode.setOnClickListener { showContactQRCode(identifier) }
}
)
conversationDelete.text = resources.getString(R.string.delete_conversation)
conversationDelete.setOnClickListener { }
qrCode.setOnClickListener { }
shareButton.setOnClickListener { }
descriptionPanel.isVisible = false // Disable description edit for 1-to-1 conversation
// Description being hidden, we put the rounded background on the secureP2pConnection.
......@@ -268,6 +272,28 @@ class ConversationActionsFragment : Fragment() {
Snackbar.make(binding!!.root, getString(R.string.conversation_action_copied_peer_number_clipboard, toCopy), Snackbar.LENGTH_LONG).show()
}
private fun shareContact(displayName: String) {
val sharingIntent = Intent(Intent.ACTION_SEND)
sharingIntent.type = "text/plain"
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.share_contact_intent_title))
sharingIntent.putExtra(
Intent.EXTRA_TEXT,
getString(
R.string.share_contact_intent_body,
displayName,
getText(R.string.app_website)
)
)
startActivity(Intent.createChooser(sharingIntent, getText(R.string.share_via)))
}
private fun showContactQRCode(contactUri: Uri) {
QRCodeFragment.newInstance(
QRCodePresenter.MODE_SHARE,
contactUri = contactUri
).show(parentFragmentManager, QRCodeFragment::class.java.simpleName)
}
companion object {
val TAG = ConversationActionsFragment::class.simpleName!!
fun newInstance(accountId: String, conversationId: Uri) =
......
......@@ -582,6 +582,8 @@ along with this program; if not, write to the Free Software
<string name="error_open_no_app_found">No application found to handle this file: %1$s</string>
<string name="swarm_detail_no_document">You have no documents yet.</string>
<string name="group_admin">Admin</string>
<string name="share_contact_intent_title">Add this contact on Jami!</string>
<string name="share_contact_intent_body">You can add this contact “%1$s” on the Jami distributed communication platform: %2$s</string>
<!-- JamiId -->
<string name="jami_id_copy">Copy JamiId</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment