Handle link of the same domain

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-05-03 15:37:09 +02:00
parent 1cdb491c7f
commit 65e7109d28
No known key found for this signature in database
GPG Key ID: F7AA2A8B65B50220
2 changed files with 22 additions and 3 deletions

View File

@ -154,7 +154,7 @@
<activity
android:name=".chat.ChatActivity"
android:exported="true"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
@ -163,9 +163,8 @@
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:host="*"/>
<data android:pathPrefix="/index.php/call/..*"/>
<data android:pathPattern="/index.php/call/..*"/>
</intent-filter>
</activity>
<activity

View File

@ -569,6 +569,26 @@ class ChatActivity :
}
private fun handleIntent(intent: Intent) {
val appLinkAction = intent.action
val appLinkData: Uri? = intent.data
val sharedLink = appLinkData.toString()
val roomPathPrefix1 = "${conversationUser?.baseUrl}/call"
val roomPathPrefix2 = "${conversationUser?.baseUrl}/index.php/call"
val isValidPrefix = sharedLink.contains(roomPathPrefix1, ignoreCase = true) ||
sharedLink.contains(roomPathPrefix2, ignoreCase = true)
if (appLinkAction == Intent.ACTION_VIEW && isValidPrefix) {
appLinkData?.let { linkUri ->
val host = linkUri.host
val roomToken = linkUri.lastPathSegment
val bundle = Bundle()
bundle.putString(KEY_ROOM_TOKEN, roomToken)
bundle.putString(BundleKeys.KEY_BASE_URL, host)
val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle)
startActivity(chatIntent)
}
}
val extras: Bundle? = intent.extras
roomId = extras?.getString(KEY_ROOM_ID).orEmpty()