Skip to content

Commit

Permalink
deep link: "xray://import-profile/{LINK}"
Browse files Browse the repository at this point in the history
  • Loading branch information
SaeedDev94 committed Sep 5, 2024
1 parent 4307091 commit 4531c12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<intent-filter android:label="@string/appName">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="xray"
android:host="import-profile" />
</intent-filter>
</activity>
<activity
android:name=".activity.ProfileActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.content.IntentFilter
import android.content.ServiceConnection
import android.content.pm.PackageManager
import android.content.res.ColorStateList
import android.net.Uri
import android.net.VpnService
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -105,6 +106,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
it.syncState()
}
getProfiles()
val deepLink: Uri? = intent?.data
deepLink?.let {
val pathSegments = it.pathSegments
if (pathSegments.size > 0) processLink(pathSegments[0])
}
}

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
Expand Down Expand Up @@ -306,7 +312,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}

private fun processLink(link: String) {
if (link.startsWith("http")) {
if (link.startsWith("http://") || link.startsWith("https://")) {
getConfig(link)
return
}
Expand Down

0 comments on commit 4531c12

Please sign in to comment.