diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt
index 3819e9c..4d284bb 100644
--- a/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt
+++ b/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt
@@ -92,7 +92,7 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback, DistributeL
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
val uri = intent.data ?: return
- if (uri.scheme == "sing-box" && uri.host != "import-remote-profile") {
+ if (uri.scheme == "sing-box" && uri.host == "import-remote-profile") {
val profile = try {
Libbox.parseRemoteProfileImportLink(uri.toString())
} catch (e: Exception) {
diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt
index f7bb253..93846a5 100644
--- a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt
+++ b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt
@@ -85,11 +85,13 @@ class EditProfileActivity : AbstractActivity() {
TypedProfile.Type.Local -> {
binding.editButton.isVisible = true
binding.remoteFields.isVisible = false
+ binding.shareURLButton.isVisible = false
}
TypedProfile.Type.Remote -> {
binding.editButton.isVisible = false
binding.remoteFields.isVisible = true
+ binding.shareURLButton.isVisible = true
binding.remoteURL.text = profile.typed.remoteURL
binding.lastUpdated.text =
DateFormat.getDateTimeInstance().format(profile.typed.lastUpdated)
@@ -105,6 +107,7 @@ class EditProfileActivity : AbstractActivity() {
binding.updateButton.setOnClickListener(this@EditProfileActivity::updateProfile)
binding.checkButton.setOnClickListener(this@EditProfileActivity::checkProfile)
binding.shareButton.setOnClickListener(this@EditProfileActivity::shareProfile)
+ binding.shareURLButton.setOnClickListener(this@EditProfileActivity::shareProfileURL)
binding.profileLayout.isVisible = true
binding.progressView.isVisible = false
}
@@ -220,4 +223,25 @@ class EditProfileActivity : AbstractActivity() {
}
}
+ private fun shareProfileURL(button: View) {
+ try {
+ startActivity(
+ Intent.createChooser(
+ Intent(Intent.ACTION_SEND).setType("application/octet-stream")
+ .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
+ .putExtra(
+ Intent.EXTRA_STREAM,
+ Libbox.generateRemoteProfileImportLink(
+ profile.name,
+ profile.typed.remoteURL
+ )
+ ),
+ getString(com.google.android.material.R.string.abc_shareactionprovider_share_with)
+ )
+ )
+ } catch (e: Exception) {
+ errorDialogBuilder(e).show()
+ }
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_profile.xml b/app/src/main/res/layout/activity_edit_profile.xml
index ece8e40..23bfa1e 100644
--- a/app/src/main/res/layout/activity_edit_profile.xml
+++ b/app/src/main/res/layout/activity_edit_profile.xml
@@ -148,6 +148,14 @@
android:layout_marginTop="8dp"
android:text="@string/profile_share" />
+
+