Skip to content

Commit 6048b10

Browse files
authored
Merge pull request #2798 from element-hq/feature/bma/externalPermalinkFix
Feature/bma/external permalink fix
2 parents 86838e7 + 19a97c6 commit 6048b10

File tree

4 files changed

+33
-50
lines changed

4 files changed

+33
-50
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@
8484
<category android:name="android.intent.category.BROWSABLE" />
8585

8686
<data android:scheme="https" />
87-
<data android:host="*.element.io" />
87+
<!-- Note: we can't use "*.element.io" here because it'll intercept the "mas.element.io" domain too. -->
88+
<!-- Matching asset file: https://app.element.io/.well-known/assetlinks.json -->
89+
<data android:host="app.element.io" />
90+
<!-- Matching asset file: https://develop.element.io/.well-known/assetlinks.json -->
91+
<data android:host="develop.element.io" />
92+
<!-- Matching asset file: https://staging.element.io/.well-known/assetlinks.json -->
93+
<data android:host="staging.element.io" />
8894
</intent-filter>
8995
<!--
9096
matrix.to links

app/src/main/kotlin/io/element/android/x/MainActivity.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import io.element.android.compound.theme.ElementTheme
3939
import io.element.android.compound.theme.Theme
4040
import io.element.android.compound.theme.isDark
4141
import io.element.android.compound.theme.mapToTheme
42-
import io.element.android.features.call.ui.ElementCallActivity
4342
import io.element.android.features.lockscreen.api.handleSecureFlag
4443
import io.element.android.features.lockscreen.api.isLocked
4544
import io.element.android.libraries.architecture.bindings
@@ -59,13 +58,6 @@ class MainActivity : NodeActivity() {
5958
Timber.tag(loggerTag.value).w("onCreate, with savedInstanceState: ${savedInstanceState != null}")
6059
installSplashScreen()
6160
super.onCreate(savedInstanceState)
62-
if (ElementCallActivity.maybeStart(this, intent)) {
63-
Timber.tag(loggerTag.value).w("Starting Element Call Activity")
64-
if (savedInstanceState == null) {
65-
finish()
66-
return
67-
}
68-
}
6961
appBindings = bindings()
7062
appBindings.lockScreenService().handleSecureFlag(this)
7163
enableEdgeToEdge()
@@ -149,12 +141,6 @@ class MainActivity : NodeActivity() {
149141
override fun onNewIntent(intent: Intent) {
150142
super.onNewIntent(intent)
151143
Timber.tag(loggerTag.value).w("onNewIntent")
152-
153-
if (ElementCallActivity.maybeStart(this, intent)) {
154-
Timber.tag(loggerTag.value).w("Starting Element Call Activity")
155-
return
156-
}
157-
158144
// If the mainNode is not init yet, keep the intent for later.
159145
// It can happen when the activity is killed by the system. The methods are called in this order :
160146
// onCreate(savedInstanceState=true) -> onNewIntent -> onResume -> onMainNodeInit

features/call/src/main/AndroidManifest.xml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616

1717
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
1818

19-
<uses-feature android:name="android.hardware.camera" android:required="false" />
20-
<uses-feature android:name="android.hardware.microphone" android:required="false" />
19+
<uses-feature
20+
android:name="android.hardware.camera"
21+
android:required="false" />
22+
<uses-feature
23+
android:name="android.hardware.microphone"
24+
android:required="false" />
2125

2226
<uses-permission android:name="android.permission.RECORD_AUDIO" />
2327
<uses-permission android:name="android.permission.CAMERA" />
@@ -28,19 +32,27 @@
2832
<application>
2933
<activity
3034
android:name=".ui.ElementCallActivity"
31-
android:label="@string/element_call"
32-
android:exported="true"
33-
android:taskAffinity="io.element.android.features.call"
3435
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"
35-
android:launchMode="singleTask">
36+
android:exported="true"
37+
android:label="@string/element_call"
38+
android:launchMode="singleTask"
39+
android:taskAffinity="io.element.android.features.call">
40+
41+
<intent-filter android:autoVerify="true">
42+
<action android:name="android.intent.action.VIEW" />
3643

37-
<!--
38-
Note: intent-filter for https://call.element.io link is now managed by the MainActivity.
39-
-->
44+
<category android:name="android.intent.category.DEFAULT" />
45+
<category android:name="android.intent.category.BROWSABLE" />
46+
47+
<data android:scheme="https" />
4048

49+
<!-- Matching asset file: https://call.element.io/.well-known/assetlinks.json -->
50+
<data android:host="call.element.io" />
51+
</intent-filter>
4152
<!-- Custom scheme to handle urls from other domains in the format: element://call?url=https%3A%2F%2Felement.io -->
4253
<intent-filter>
4354
<action android:name="android.intent.action.VIEW" />
55+
4456
<category android:name="android.intent.category.DEFAULT" />
4557
<category android:name="android.intent.category.BROWSABLE" />
4658

@@ -50,14 +62,18 @@
5062
<!-- Custom scheme to handle urls from other domains in the format: io.element.call:/?url=https%3A%2F%2Felement.io -->
5163
<intent-filter>
5264
<action android:name="android.intent.action.VIEW" />
65+
5366
<category android:name="android.intent.category.DEFAULT" />
5467
<category android:name="android.intent.category.BROWSABLE" />
5568

5669
<data android:scheme="io.element.call" />
5770
</intent-filter>
5871

5972
</activity>
60-
<service android:name=".CallForegroundService" android:enabled="true" android:foregroundServiceType="mediaPlayback" />
73+
<service
74+
android:name=".CallForegroundService"
75+
android:enabled="true"
76+
android:foregroundServiceType="mediaPlayback" />
6177
</application>
6278

6379
</manifest>

features/call/src/main/kotlin/io/element/android/features/call/ui/ElementCallActivity.kt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.element.android.features.call.ui
1818

1919
import android.Manifest
20-
import android.app.Activity
2120
import android.content.Context
2221
import android.content.Intent
2322
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
@@ -36,7 +35,6 @@ import androidx.compose.runtime.collectAsState
3635
import androidx.compose.runtime.getValue
3736
import androidx.compose.runtime.mutableStateOf
3837
import androidx.compose.runtime.remember
39-
import androidx.core.app.ActivityOptionsCompat
4038
import androidx.core.content.IntentCompat
4139
import com.bumble.appyx.core.integrationpoint.NodeComponentActivity
4240
import io.element.android.compound.theme.ElementTheme
@@ -49,7 +47,6 @@ import io.element.android.features.call.di.CallBindings
4947
import io.element.android.features.call.utils.CallIntentDataParser
5048
import io.element.android.features.preferences.api.store.AppPreferencesStore
5149
import io.element.android.libraries.architecture.bindings
52-
import io.element.android.libraries.core.bool.orFalse
5350
import javax.inject.Inject
5451

5552
class ElementCallActivity : NodeComponentActivity(), CallScreenNavigator {
@@ -66,28 +63,6 @@ class ElementCallActivity : NodeComponentActivity(), CallScreenNavigator {
6663
}
6764
context.startActivity(intent)
6865
}
69-
70-
/**
71-
* Starts the [ElementCallActivity] if the intent contains a valid URL,
72-
* and returns true if it's the case.
73-
*/
74-
fun maybeStart(
75-
activity: Activity,
76-
intent: Intent?,
77-
): Boolean {
78-
return intent?.data
79-
?.takeIf { uri -> uri.scheme == "https" && uri.host == "call.element.io" }
80-
?.let { uri ->
81-
val callIntent = Intent(activity, ElementCallActivity::class.java).apply {
82-
data = uri
83-
}
84-
// Disable animation since MainActivity has already been animated.
85-
val options = ActivityOptionsCompat.makeCustomAnimation(activity, 0, 0)
86-
activity.startActivity(callIntent, options.toBundle())
87-
true
88-
}
89-
.orFalse()
90-
}
9166
}
9267

9368
@Inject lateinit var callIntentDataParser: CallIntentDataParser

0 commit comments

Comments
 (0)