open talk links of same baseurl inside the app

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-05-23 16:01:43 +02:00
parent 8876718677
commit 932352b785
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
2 changed files with 21 additions and 0 deletions

View file

@ -33,11 +33,13 @@ import com.nextcloud.talk.account.ServerSelectionActivity
import com.nextcloud.talk.account.SwitchAccountActivity
import com.nextcloud.talk.account.WebViewLoginActivity
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.chat.ChatActivity
import com.nextcloud.talk.events.CertificateEvent
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.FileViewerUtils
import com.nextcloud.talk.utils.UriUtils
import com.nextcloud.talk.utils.bundle.BundleKeys
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
import com.nextcloud.talk.utils.preferences.AppPreferences
import com.nextcloud.talk.utils.ssl.TrustManager
@ -248,6 +250,14 @@ open class BaseActivity : AppCompatActivity() {
// https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=41
val fileViewerUtils = FileViewerUtils(applicationContext, user)
fileViewerUtils.openFileInFilesApp(uri, UriUtils.extractInstanceInternalFileFileIdNew(uri))
} else if (UriUtils.isInstanceInternalTalkUrl(user.baseUrl!!, uri)) {
// https://cloud.nextcloud.com/call/123456789
val bundle = Bundle()
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, UriUtils.extractRoomTokenFromTalkUrl(uri))
val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle)
chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(chatIntent)
} else {
super.startActivity(intent)
}

View file

@ -27,11 +27,22 @@ class UriUtils {
Regex(".*/f/\\d*").matches(url)
}
fun isInstanceInternalTalkUrl(baseUrl: String, url: String): Boolean {
// https://cloud.nextcloud.com/call/123456789
return (url.startsWith("$baseUrl/call/") || url.startsWith("$baseUrl/index.php/call/")) &&
Regex(".*/call/\\d*").matches(url)
}
fun extractInstanceInternalFileShareFileId(url: String): String {
// https://cloud.nextcloud.com/f/41
return Uri.parse(url).lastPathSegment ?: ""
}
fun extractRoomTokenFromTalkUrl(url: String): String {
// https://cloud.nextcloud.com/call/123456789
return Uri.parse(url).lastPathSegment ?: ""
}
fun isInstanceInternalFileUrl(baseUrl: String, url: String): Boolean {
// https://cloud.nextcloud.com/apps/files/?dir=/Engineering&fileid=41
return (