Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty URL for conversation link #3895

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ class ConversationInfoActivity :
if (ConversationUtils.isNoteToSelfConversation(conversation)) {
binding.shareConversationButton.visibility = GONE
}
val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(conversationUser)
binding.shareConversationButton.setOnClickListener {
ShareUtils.shareConversationLink(
this,
conversationUser.baseUrl,
conversation?.token,
conversation?.name
conversation?.name,
canGeneratePrettyURL
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ data class CoreCapability(
@JsonField(name = ["reference-api"])
var referenceApi: String?,
@JsonField(name = ["reference-regex"])
var referenceRegex: String?
var referenceRegex: String?,
@JsonField(name = ["mod-rewrite-working"])
var modRewriteWorking: Boolean?
) : Parcelable {
// 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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,14 @@ class ConversationsListBottomDialog(
}

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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ object CapabilitiesUtil {
user.capabilities?.coreCapability?.referenceApi == "true"
}

fun canGeneratePrettyURL(user: User): Boolean {
return user.capabilities?.coreCapability?.modRewriteWorking == true
}

// endregion

//region SpreedCapabilities
Expand Down
25 changes: 19 additions & 6 deletions app/src/main/java/com/nextcloud/talk/utils/ShareUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,37 @@
*/
package com.nextcloud.talk.utils

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.net.Uri
import com.nextcloud.talk.R

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()) {
return
}

val uriToShareConversation = Uri.parse(baseUrl)
val uriBuilder = Uri.parse(baseUrl)
.buildUpon()
.appendPath("index.php")
.appendPath("call")
.appendPath(roomToken)
.build()

if (!canGeneratePrettyURL) {
uriBuilder.appendPath("index.php")
}

uriBuilder.appendPath("call")
uriBuilder.appendPath(roomToken)

val uriToShareConversation = uriBuilder.build()

val shareConversationLink = String.format(
context.getString(
Expand Down
2 changes: 1 addition & 1 deletion scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 126 errors and 81 warnings</span>
<span class="mdl-layout-title">Lint Report: 119 errors and 81 warnings</span>
Loading