mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-25 22:45:41 +03:00
Pretty URL for conversation link
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
9f356a67aa
commit
acd0b92b6c
5 changed files with 38 additions and 10 deletions
|
@ -206,12 +206,14 @@ class ConversationInfoActivity :
|
||||||
if (ConversationUtils.isNoteToSelfConversation(conversation)) {
|
if (ConversationUtils.isNoteToSelfConversation(conversation)) {
|
||||||
binding.shareConversationButton.visibility = GONE
|
binding.shareConversationButton.visibility = GONE
|
||||||
}
|
}
|
||||||
|
val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(conversationUser)
|
||||||
binding.shareConversationButton.setOnClickListener {
|
binding.shareConversationButton.setOnClickListener {
|
||||||
ShareUtils.shareConversationLink(
|
ShareUtils.shareConversationLink(
|
||||||
this,
|
this,
|
||||||
conversationUser.baseUrl,
|
conversationUser.baseUrl,
|
||||||
conversation?.token,
|
conversation?.token,
|
||||||
conversation?.name
|
conversation?.name,
|
||||||
|
canGeneratePrettyURL
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,10 @@ data class CoreCapability(
|
||||||
@JsonField(name = ["reference-api"])
|
@JsonField(name = ["reference-api"])
|
||||||
var referenceApi: String?,
|
var referenceApi: String?,
|
||||||
@JsonField(name = ["reference-regex"])
|
@JsonField(name = ["reference-regex"])
|
||||||
var referenceRegex: String?
|
var referenceRegex: String?,
|
||||||
|
@JsonField(name = ["mod-rewrite-working"])
|
||||||
|
var modRewriteWorking: Boolean?
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() : this(null, null, null, null)
|
constructor() : this(null, null, null, null, null)
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,14 @@ class ConversationsListBottomDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.conversationLinkShare.setOnClickListener {
|
binding.conversationLinkShare.setOnClickListener {
|
||||||
ShareUtils.shareConversationLink(activity, currentUser.baseUrl, conversation.token, conversation.name)
|
val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(currentUser)
|
||||||
|
ShareUtils.shareConversationLink(
|
||||||
|
activity,
|
||||||
|
currentUser.baseUrl,
|
||||||
|
conversation.token,
|
||||||
|
conversation.name,
|
||||||
|
canGeneratePrettyURL
|
||||||
|
)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,10 @@ object CapabilitiesUtil {
|
||||||
user.capabilities?.coreCapability?.referenceApi == "true"
|
user.capabilities?.coreCapability?.referenceApi == "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun canGeneratePrettyURL(user: User): Boolean {
|
||||||
|
return user.capabilities?.coreCapability?.modRewriteWorking == true
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
//region SpreedCapabilities
|
//region SpreedCapabilities
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.utils
|
package com.nextcloud.talk.utils
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
@ -13,17 +14,29 @@ import com.nextcloud.talk.R
|
||||||
|
|
||||||
object ShareUtils {
|
object ShareUtils {
|
||||||
|
|
||||||
fun shareConversationLink(context: Activity, baseUrl: String?, roomToken: String?, conversationName: String?) {
|
@SuppressLint("StringFormatMatches")
|
||||||
|
fun shareConversationLink(
|
||||||
|
context: Activity,
|
||||||
|
baseUrl: String?,
|
||||||
|
roomToken: String?,
|
||||||
|
conversationName: String?,
|
||||||
|
canGeneratePrettyURL: Boolean
|
||||||
|
) {
|
||||||
if (baseUrl.isNullOrBlank() || roomToken.isNullOrBlank() || conversationName.isNullOrBlank()) {
|
if (baseUrl.isNullOrBlank() || roomToken.isNullOrBlank() || conversationName.isNullOrBlank()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val uriToShareConversation = Uri.parse(baseUrl)
|
val uriBuilder = Uri.parse(baseUrl)
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
.appendPath("index.php")
|
|
||||||
.appendPath("call")
|
if (!canGeneratePrettyURL) {
|
||||||
.appendPath(roomToken)
|
uriBuilder.appendPath("index.php")
|
||||||
.build()
|
}
|
||||||
|
|
||||||
|
uriBuilder.appendPath("call")
|
||||||
|
uriBuilder.appendPath(roomToken)
|
||||||
|
|
||||||
|
val uriToShareConversation = uriBuilder.build()
|
||||||
|
|
||||||
val shareConversationLink = String.format(
|
val shareConversationLink = String.format(
|
||||||
context.getString(
|
context.getString(
|
||||||
|
|
Loading…
Reference in a new issue