share conversation link to other apps

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-04-04 17:52:04 +02:00 committed by Marcel Hibbe
parent c75095d67e
commit 7832f72d12
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
4 changed files with 77 additions and 4 deletions

View file

@ -6,6 +6,8 @@
*/
package com.nextcloud.talk.ui.dialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.TextUtils
import android.view.View
@ -30,10 +32,10 @@ import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.SpreedFeatures
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
@ -123,6 +125,9 @@ class ConversationsListBottomDialog(
binding.conversationOperationRename.visibility = setVisibleIf(
conversation.isNameEditable(currentUser)
)
binding.conversationLinkShare.visibility = setVisibleIf(
conversation.name != context.getString(R.string.note_to_self)
)
binding.conversationOperationDelete.visibility = setVisibleIf(
canModerate
@ -161,6 +166,11 @@ class ConversationsListBottomDialog(
markConversationAsUnread()
}
binding.conversationLinkShare.setOnClickListener {
shareConversationLink()
dismiss()
}
binding.conversationOperationRename.setOnClickListener {
renameConversation()
}
@ -174,6 +184,35 @@ class ConversationsListBottomDialog(
}
}
private fun shareConversationLink() {
val activeAccountUrl = currentUser.baseUrl
val roomToken = conversation.token
val uriToShareConversation = Uri.parse(activeAccountUrl)
.buildUpon()
.appendPath("index.php")
.appendPath("call")
.appendPath(roomToken)
.build()
val shareConversationLink = String.format(
context.getString(
R.string.share_link_to_conversation,
conversation.name,
uriToShareConversation.toString()
)
)
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, shareConversationLink)
type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, null)
context.startActivity(shareIntent)
}
private fun addConversationToFavorites() {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
ncApi.addConversationToFavorites(

View file

@ -14,7 +14,8 @@ import com.nextcloud.talk.models.domain.ConversationModel
object ShareUtils {
fun getStringForIntent(context: Context, user: User, conversation: ConversationModel?): String {
return String.format(
context.resources.getString(R.string.nc_share_text),
context.resources.getString(R.string.nc_share_link_text),
conversation?.name,
user.baseUrl,
conversation?.token
)

View file

@ -165,6 +165,36 @@
android:textSize="@dimen/bottom_sheet_text_size" />
</LinearLayout>
<LinearLayout
android:id="@+id/conversation_link_share"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/standard_padding"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="@drawable/ic_share_action"
app:tint="@color/high_emphasis_menu_icon" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:paddingStart="40dp"
android:paddingEnd="@dimen/zero"
android:text="@string/nc_share_link"
android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text"
android:textSize="@dimen/bottom_sheet_text_size" />
</LinearLayout>
<LinearLayout
android:id="@+id/conversation_operation_rename"
android:layout_width="match_parent"

View file

@ -329,9 +329,9 @@ How to translate with transifex:
<string name="nc_call_name">Conversation name</string>
<string name="create_conversation">Create conversation</string>
<string name="nc_add_emojis">Add emojis</string>
<string name="nc_share_text">Join the conversation at %1$s/index.php/call/%2$s</string>
<string name="nc_share_subject">%1$s invitation</string>
<string name="nc_share_text_pass">\nPassword: %1$s</string>
<string name="nc_share_link_text">Join the conversation %1$s at %2$s/index.php/call/%3$s</string>
<string name="nc_push_to_talk">Push-to-talk</string>
<string name="nc_push_to_talk_desc">With microphone disabled, click&amp;hold to use Push-to-talk</string>
@ -435,6 +435,7 @@ How to translate with transifex:
<string name="nc_guest_access_resend_invitations">Resend invitations</string>
<string name="nc_guest_access_resend_invitations_successful">Invitations were sent out again.</string>
<string name="nc_guest_access_resend_invitations_failed">Invitations were not send due to an error.</string>
<string name="nc_share_link">Share link</string>
<!-- Content descriptions -->
<string name="nc_description_send_message_button">Send message</string>
@ -785,4 +786,6 @@ How to translate with transifex:
<string name="nc_edit_icon">Edit Icon</string>
<string name="get_invitations_error">Failed to fetch pending invitations</string>
<string name="message_last_edited_by">Edited by %1$s</string>
<string name="share_link_to_conversation">Join conversation %1$s at %2$s</string>
<string name="note_to_self">Note to self</string>
</resources>