diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8c94bce2ac..725ad40d3d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -87,7 +87,7 @@
@@ -100,6 +100,17 @@
+
+
+
+
+
+
+
+
+
https://matrix.to/#/#element-android:matrix.org
* - https://app.element.io/#/room/#element-android:matrix.org -> https://matrix.to/#/#element-android:matrix.org
* - https://www.example.org/#/room/#element-android:matrix.org -> https://matrix.to/#/#element-android:matrix.org
+ * Also convert links coming from the matrix.to website:
+ * - element://room/#element-android:matrix.org -> https://matrix.to/#/#element-android:matrix.org
+ * - element://user/@alice:matrix.org -> https://matrix.to/#/@alice:matrix.org
*/
override fun convert(uri: Uri): Uri? {
val uriString = uri.toString()
+ // Handle links coming from the matrix.to website.
+ .replacePrefix(MATRIX_TO_CUSTOM_SCHEME_BASE_URL, "https://app.element.io/#/")
val baseUrl = MatrixConfiguration.MATRIX_TO_PERMALINK_BASE_URL
return when {
@@ -54,7 +60,8 @@ class DefaultMatrixToConverter @Inject constructor() : MatrixToConverter {
}
companion object {
- val SUPPORTED_PATHS = listOf(
+ private const val MATRIX_TO_CUSTOM_SCHEME_BASE_URL = "element://"
+ private val SUPPORTED_PATHS = listOf(
"/#/room/",
"/#/user/",
"/#/group/"
diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/permalink/DefaultMatrixToConverterTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/permalink/DefaultMatrixToConverterTest.kt
index 7401ac7c2e..2b4933e5ac 100644
--- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/permalink/DefaultMatrixToConverterTest.kt
+++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/permalink/DefaultMatrixToConverterTest.kt
@@ -53,4 +53,16 @@ class DefaultMatrixToConverterTest {
val url = Uri.parse("https://element.io/")
assertThat(DefaultMatrixToConverter().convert(url)).isNull()
}
+
+ @Test
+ fun `converting url coming from the matrix-to website returns a matrix-to url for room case`() {
+ val url = Uri.parse("element://room/#element-android:matrix.org")
+ assertThat(DefaultMatrixToConverter().convert(url)).isEqualTo(Uri.parse("https://matrix.to/#/#element-android:matrix.org"))
+ }
+
+ @Test
+ fun `converting url coming from the matrix-to website returns a matrix-to url for user case`() {
+ val url = Uri.parse("element://user/@alice:matrix.org")
+ assertThat(DefaultMatrixToConverter().convert(url)).isEqualTo(Uri.parse("https://matrix.to/#/@alice:matrix.org"))
+ }
}
diff --git a/tools/adb/deeplink_matrixto.sh b/tools/adb/deeplink_matrixto.sh
new file mode 100755
index 0000000000..2153937288
--- /dev/null
+++ b/tools/adb/deeplink_matrixto.sh
@@ -0,0 +1,19 @@
+#! /bin/bash
+#
+# Copyright (c) 2024 New Vector Ltd
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+adb shell am start -a android.intent.action.VIEW \
+ -d "element://room/%23element-android%3Amatrix.org"