Make conversation link available for copy and paste in the Conversation settings.

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-04-12 12:07:11 +02:00 committed by Marcel Hibbe
parent 7832f72d12
commit b6ab867280
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
7 changed files with 79 additions and 96 deletions

View file

@ -43,8 +43,8 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.bottomsheet.items.BasicListItemWithImage import com.nextcloud.talk.bottomsheet.items.BasicListItemWithImage
import com.nextcloud.talk.bottomsheet.items.listItemsWithImage import com.nextcloud.talk.bottomsheet.items.listItemsWithImage
import com.nextcloud.talk.contacts.ContactsActivity import com.nextcloud.talk.contacts.ContactsActivity
import com.nextcloud.talk.conversationinfoedit.ConversationInfoEditActivity
import com.nextcloud.talk.conversationinfo.viewmodel.ConversationInfoViewModel import com.nextcloud.talk.conversationinfo.viewmodel.ConversationInfoViewModel
import com.nextcloud.talk.conversationinfoedit.ConversationInfoEditActivity
import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ActivityConversationInfoBinding import com.nextcloud.talk.databinding.ActivityConversationInfoBinding
import com.nextcloud.talk.events.EventStatus import com.nextcloud.talk.events.EventStatus
@ -69,12 +69,13 @@ import com.nextcloud.talk.models.json.participants.ParticipantsOverall
import com.nextcloud.talk.repositories.conversations.ConversationsRepository import com.nextcloud.talk.repositories.conversations.ConversationsRepository
import com.nextcloud.talk.shareditems.activities.SharedItemsActivity import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.SpreedFeatures import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.ConversationUtils import com.nextcloud.talk.utils.ConversationUtils
import com.nextcloud.talk.utils.DateConstants import com.nextcloud.talk.utils.DateConstants
import com.nextcloud.talk.utils.DateUtils import com.nextcloud.talk.utils.DateUtils
import com.nextcloud.talk.utils.ShareUtils
import com.nextcloud.talk.utils.SpreedFeatures
import com.nextcloud.talk.utils.bundle.BundleKeys import com.nextcloud.talk.utils.bundle.BundleKeys
import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
import com.nextcloud.talk.utils.preferences.preferencestorage.DatabaseStorageModule import com.nextcloud.talk.utils.preferences.preferencestorage.DatabaseStorageModule
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
@ -161,7 +162,6 @@ class ConversationInfoActivity :
conversationToken = intent.getStringExtra(BundleKeys.KEY_ROOM_TOKEN)!! conversationToken = intent.getStringExtra(BundleKeys.KEY_ROOM_TOKEN)!!
hasAvatarSpacing = intent.getBooleanExtra(BundleKeys.KEY_ROOM_ONE_TO_ONE, false) hasAvatarSpacing = intent.getBooleanExtra(BundleKeys.KEY_ROOM_ONE_TO_ONE, false)
credentials = ApiUtils.getCredentials(conversationUser.username, conversationUser.token)!! credentials = ApiUtils.getCredentials(conversationUser.username, conversationUser.token)!!
initObservers() initObservers()
} }
@ -187,6 +187,14 @@ class ConversationInfoActivity :
binding.clearConversationHistory.setOnClickListener { showClearHistoryDialog() } binding.clearConversationHistory.setOnClickListener { showClearHistoryDialog() }
binding.addParticipantsAction.setOnClickListener { addParticipants() } binding.addParticipantsAction.setOnClickListener { addParticipants() }
binding.shareConversationButton.setOnClickListener {
ShareUtils.shareConversationLink(
this,
conversationUser.baseUrl,
conversation?.token,
conversation?.name
)
}
viewModel.getRoom(conversationUser, conversationToken) viewModel.getRoom(conversationUser, conversationToken)
themeTextViews() themeTextViews()

View file

@ -8,7 +8,6 @@
*/ */
package com.nextcloud.talk.conversationinfo package com.nextcloud.talk.conversationinfo
import android.content.Intent
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -24,8 +23,6 @@ import com.nextcloud.talk.models.domain.ConversationType
import com.nextcloud.talk.models.json.capabilities.SpreedCapability import com.nextcloud.talk.models.json.capabilities.SpreedCapability
import com.nextcloud.talk.repositories.conversations.ConversationsRepository import com.nextcloud.talk.repositories.conversations.ConversationsRepository
import com.nextcloud.talk.utils.ConversationUtils import com.nextcloud.talk.utils.ConversationUtils
import com.nextcloud.talk.utils.Mimetype
import com.nextcloud.talk.utils.ShareUtils
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
@ -82,10 +79,6 @@ class GuestAccessHelper(
} }
} }
binding.guestAccessView.shareConversationButton.setOnClickListener {
shareUrl()
}
binding.guestAccessView.resendInvitationsButton.setOnClickListener { binding.guestAccessView.resendInvitationsButton.setOnClickListener {
conversationsRepository.resendInvitations(conversation.token!!).subscribeOn(Schedulers.io()) conversationsRepository.resendInvitations(conversation.token!!).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(ResendInvitationsObserver()) .observeOn(AndroidSchedulers.mainThread()).subscribe(ResendInvitationsObserver())
@ -123,28 +116,6 @@ class GuestAccessHelper(
) )
} }
private fun shareUrl() {
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
type = Mimetype.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)
)
)
putExtra(
Intent.EXTRA_TEXT,
ShareUtils.getStringForIntent(activity, conversationUser, conversation)
)
}
val shareIntent = Intent.createChooser(sendIntent, null)
activity.startActivity(shareIntent)
}
inner class ResendInvitationsObserver : Observer<ConversationsRepository.ResendInvitationsResult> { inner class ResendInvitationsObserver : Observer<ConversationsRepository.ResendInvitationsResult> {
private lateinit var resendInvitationsResult: ConversationsRepository.ResendInvitationsResult private lateinit var resendInvitationsResult: ConversationsRepository.ResendInvitationsResult
@ -200,7 +171,6 @@ class GuestAccessHelper(
private fun showAllOptions() { private fun showAllOptions() {
binding.guestAccessView.guestAccessSettingsPasswordProtection.visibility = View.VISIBLE binding.guestAccessView.guestAccessSettingsPasswordProtection.visibility = View.VISIBLE
binding.guestAccessView.shareConversationButton.visibility = View.VISIBLE
if (conversationUser.capabilities?.spreedCapability?.features?.contains("sip-support") == true) { if (conversationUser.capabilities?.spreedCapability?.features?.contains("sip-support") == true) {
binding.guestAccessView.resendInvitationsButton.visibility = View.VISIBLE binding.guestAccessView.resendInvitationsButton.visibility = View.VISIBLE
} }
@ -208,7 +178,6 @@ class GuestAccessHelper(
private fun hideAllOptions() { private fun hideAllOptions() {
binding.guestAccessView.guestAccessSettingsPasswordProtection.visibility = View.GONE binding.guestAccessView.guestAccessSettingsPasswordProtection.visibility = View.GONE
binding.guestAccessView.shareConversationButton.visibility = View.GONE
binding.guestAccessView.resendInvitationsButton.visibility = View.GONE binding.guestAccessView.resendInvitationsButton.visibility = View.GONE
} }

View file

@ -6,8 +6,6 @@
*/ */
package com.nextcloud.talk.ui.dialog package com.nextcloud.talk.ui.dialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.view.View import android.view.View
@ -33,6 +31,7 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.users.UserManager import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.CapabilitiesUtil import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.ShareUtils
import com.nextcloud.talk.utils.SpreedFeatures 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_INTERNAL_USER_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
@ -167,7 +166,7 @@ class ConversationsListBottomDialog(
} }
binding.conversationLinkShare.setOnClickListener { binding.conversationLinkShare.setOnClickListener {
shareConversationLink() ShareUtils.shareConversationLink(activity, currentUser.baseUrl, conversation.token, conversation.name)
dismiss() dismiss()
} }
@ -184,35 +183,6 @@ 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() { private fun addConversationToFavorites() {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
ncApi.addConversationToFavorites( ncApi.addConversationToFavorites(

View file

@ -6,7 +6,10 @@
*/ */
package com.nextcloud.talk.utils package com.nextcloud.talk.utils
import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent
import android.net.Uri
import com.nextcloud.talk.R import com.nextcloud.talk.R
import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.models.domain.ConversationModel import com.nextcloud.talk.models.domain.ConversationModel
@ -20,4 +23,34 @@ object ShareUtils {
conversation?.token conversation?.token
) )
} }
fun shareConversationLink(context: Activity, baseUrl: String?, roomToken: String?, conversationName: String?) {
if (baseUrl.isNullOrBlank() || roomToken.isNullOrBlank() || conversationName.isNullOrBlank()) {
return
}
val uriToShareConversation = Uri.parse(baseUrl)
.buildUpon()
.appendPath("index.php")
.appendPath("call")
.appendPath(roomToken)
.build()
val shareConversationLink = String.format(
context.getString(
R.string.share_link_to_conversation,
conversationName,
uriToShareConversation.toString()
)
)
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, shareConversationLink)
type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, context.getString(R.string.nc_share_link))
context.startActivity(shareIntent)
}
} }

View file

@ -229,7 +229,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/standard_padding" android:padding="@dimen/standard_padding"
android:text="@string/message_expiration_title" android:text="@string/nc_conversation_settings"
android:textSize="@dimen/headline_text_size" android:textSize="@dimen/headline_text_size"
android:textStyle="bold" /> android:textStyle="bold" />
@ -261,6 +261,36 @@
android:text="@string/nc_expire_messages_explanation" android:text="@string/nc_expire_messages_explanation"
android:textColor="@color/disabled_text" android:textColor="@color/disabled_text"
android:textSize="@dimen/supporting_text_text_size" /> android:textSize="@dimen/supporting_text_text_size" />
<LinearLayout
android:id="@+id/share_conversation_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/standard_margin"
android:paddingTop="@dimen/standard_half_margin"
android:paddingEnd="@dimen/standard_margin"
android:paddingBottom="@dimen/standard_half_margin"
android:orientation="horizontal"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:layout_width="24dp"
android:layout_height="40dp"
android:layout_marginEnd="@dimen/standard_margin"
android:contentDescription="@null"
android:src="@drawable/ic_share_variant"
app:tint="@color/grey_600" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/nc_guest_access_share_link"
android:textSize="@dimen/headline_text_size" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View file

@ -108,34 +108,6 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/share_conversation_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/standard_margin"
android:paddingTop="@dimen/standard_half_margin"
android:paddingEnd="@dimen/standard_margin"
android:paddingBottom="@dimen/standard_half_margin"
android:orientation="horizontal"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:layout_width="24dp"
android:layout_height="40dp"
android:layout_marginEnd="@dimen/standard_margin"
android:contentDescription="@null"
android:src="@drawable/ic_share_variant"
app:tint="@color/grey_600" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/nc_guest_access_share_link"
android:textSize="@dimen/headline_text_size" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/resend_invitations_button" android:id="@+id/resend_invitations_button"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -788,4 +788,5 @@ How to translate with transifex:
<string name="message_last_edited_by">Edited by %1$s</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="share_link_to_conversation">Join conversation %1$s at %2$s</string>
<string name="note_to_self">Note to self</string> <string name="note_to_self">Note to self</string>
<string name="nc_conversation_settings">Conversation settings</string>
</resources> </resources>