From bec19428e0065d7f8752615a35a3ce2e5c228754 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 11 Feb 2022 16:23:42 +0100 Subject: [PATCH] share conversation link Signed-off-by: Marcel Hibbe --- .../ui/dialog/ConversationOperationDialog.kt | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt index 47e43cdd4..50bb0efbb 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt @@ -33,6 +33,13 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import org.parceler.Parcels import javax.inject.Inject +import androidx.core.content.ContextCompat.startActivity + +import android.content.Intent +import androidx.core.content.ContextCompat +import com.nextcloud.talk.utils.ShareUtils +import com.nextcloud.talk.utils.database.user.UserUtils +import kotlinx.android.synthetic.main.activity_take_picture.* @AutoInjector(NextcloudTalkApplication::class) class ConversationOperationDialog( @@ -50,6 +57,10 @@ class ConversationOperationDialog( @JvmField var ncApi: NcApi? = null + @Inject + @JvmField + var userUtils: UserUtils? = null + init { NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this) } @@ -198,7 +209,27 @@ class ConversationOperationDialog( } binding.conversationOperationShareLink.setOnClickListener { - // TODO share by intent + val sendIntent: Intent = Intent().apply { + action = Intent.ACTION_SEND + type = "text/plain" + putExtra( + Intent.EXTRA_SUBJECT, + String.format( + activity.resources.getString(R.string.nc_share_subject), + activity.resources.getString(R.string.nc_app_product_name) + ) + ) + // password should not be shared!! + putExtra( + Intent.EXTRA_TEXT, + ShareUtils.getStringForIntent(activity, null, userUtils, conversation) + ) + } + + val shareIntent = Intent.createChooser(sendIntent, null) + activity.startActivity(shareIntent) + + dismiss() } }