Browse Source

Fix profile export

世界 4 years ago
parent
commit
a79087af89

+ 4 - 10
app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt

@@ -264,14 +264,8 @@ data class ProxyEntity(
     }
 
     fun haveStandardLink(): Boolean {
-        return when (requireBean()) {
-            is RelayBatonBean -> false
-            is BrookBean -> false
-            is ConfigBean -> false
-            is HysteriaBean -> false
-            is SSHBean -> false
-            is WireGuardBean -> false
-            is InternalBean -> false
+        return haveLink() && when (type) {
+            TYPE_RELAY_BATON, TYPE_BROOK, TYPE_HYSTERIA, TYPE_SSH, TYPE_WG -> false
             else -> true
         }
     }
@@ -299,7 +293,7 @@ data class ProxyEntity(
     }
 
     fun exportConfig(): Pair<String, String> {
-        var name = "profile.json"
+        var name = "${displayName()}.json"
 
         return with(requireBean()) {
             StringBuilder().apply {
@@ -307,7 +301,7 @@ data class ProxyEntity(
                 append(config.config)
 
                 if (!config.index.all { it.chain.isEmpty() }) {
-                    name = "profiles.txt"
+                    name = "${displayName()}.txt"
                 }
 
                 for ((isBalancer, chain) in config.index) {

+ 4 - 4
app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt

@@ -1521,16 +1521,16 @@ class ConfigurationFragment @JvmOverloads constructor(
                         }
 
                         when {
+                            !proxyEntity.haveLink() -> {
+                                popup.menu.removeItem(R.id.action_group_qr)
+                                popup.menu.removeItem(R.id.action_group_clipboard)
+                            }
                             !proxyEntity.haveStandardLink() -> {
                                 popup.menu.findItem(R.id.action_group_qr).subMenu.removeItem(R.id.action_standard_qr)
                                 popup.menu.findItem(R.id.action_group_clipboard).subMenu.removeItem(
                                     R.id.action_standard_clipboard
                                 )
                             }
-                            !proxyEntity.haveLink() -> {
-                                popup.menu.removeItem(R.id.action_group_qr)
-                                popup.menu.removeItem(R.id.action_group_clipboard)
-                            }
                         }
 
                         if (proxyEntity.ptBean != null || proxyEntity.brookBean != null) {