From caff51eaf19de795aac24b3bcc8d4dcf297894a6 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Sat, 14 Nov 2026 23:53:09 +0300 Subject: [PATCH 01/17] Update SelectionMode.kt --- .../nekohasekai/sagernet/ui/profiles/SelectionMode.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt index e2f7c7ef8..05d0c1188 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt @@ -123,6 +123,16 @@ class SelectionMode(private val host: ConfigurationFragment) { refreshPinTitle() } + private fun invertSelection() { + val shown = host.listFor(groupId)?.adapter?.displayedIds ?: return + for (id in shown) { + if (!checked.remove(id)) checked.add(id) + } + if (checked.isEmpty()) return finish() + host.onSelectionChanged(null) + refreshPinTitle() + } + /** Every checked profile is pinned, so the action unpins (refresh_pin_action). */ private fun allPinned(): Boolean { val adapter = host.listFor(groupId)?.adapter ?: return false @@ -155,6 +165,7 @@ class SelectionMode(private val host: ConfigurationFragment) { } R.id.action_selection_all -> selectAll() + R.id.action_selection_invert -> invertSelection() R.id.action_selection_delete -> delete(ids) R.id.action_selection_pin -> pin(ids) R.id.action_selection_clear_results -> clearResults(ids) From 0f4a49ed2c2fa3eb252e480bca4fdc3481bbbd78 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Sat, 14 Nov 2026 23:53:31 +0300 Subject: [PATCH 02/17] Update profile_selection_menu.xml --- app/src/main/res/menu/profile_selection_menu.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/res/menu/profile_selection_menu.xml b/app/src/main/res/menu/profile_selection_menu.xml index 74e99f3f3..16448b10c 100644 --- a/app/src/main/res/menu/profile_selection_menu.xml +++ b/app/src/main/res/menu/profile_selection_menu.xml @@ -33,6 +33,10 @@ android:id="@+id/action_selection_all" android:title="@string/profiles_select_all" app:showAsAction="never" /> + Date: Sat, 14 Nov 2026 23:53:52 +0300 Subject: [PATCH 03/17] Update strings.xml --- app/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b6872e7c..6a43e30ef 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1302,6 +1302,7 @@ %d selected Select all + Invert selection Move to group There is no other basic group to move to. From 9b722e2776c6f730471d7d1ec6512b6bdfd4ddc5 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Sat, 14 Nov 2026 23:54:14 +0300 Subject: [PATCH 04/17] Update strings.xml --- app/src/main/res/values-ru/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 9cdeb9155..0bd1fcca0 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -975,6 +975,7 @@ Разрешить домен Работающий профиль сохранён. Выбрать все + Инвертировать выбор Показать Внешний IP Скорость From 0b3f989750fe16dfb174170692231aa3d48bc878 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Sun, 15 Nov 2026 20:56:08 +0300 Subject: [PATCH 05/17] Add resolve and clearTraffic functions in SelectionMode --- .../sagernet/ui/profiles/SelectionMode.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt index 05d0c1188..3933e9735 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt @@ -10,11 +10,14 @@ import io.nekohasekai.sagernet.database.DataStore import io.nekohasekai.sagernet.database.GroupRepo import io.nekohasekai.sagernet.database.ProfileManager import io.nekohasekai.sagernet.database.ProxyEntity +import io.nekohasekai.sagernet.group.SubscriptionClient +import io.nekohasekai.sagernet.ktx.Logs import io.nekohasekai.sagernet.ktx.confirmAction import io.nekohasekai.sagernet.ktx.nameList import io.nekohasekai.sagernet.ktx.showAllowingStateLoss import io.nekohasekai.sagernet.ktx.snackbar import io.nekohasekai.sagernet.ui.ConfigurationFragment +import io.nekohasekai.sagernet.ui.MainActivity import io.nekohasekai.sagernet.widget.QRCodeDialog /** @@ -169,6 +172,8 @@ class SelectionMode(private val host: ConfigurationFragment) { R.id.action_selection_delete -> delete(ids) R.id.action_selection_pin -> pin(ids) R.id.action_selection_clear_results -> clearResults(ids) + R.id.action_selection_resolve_domain -> resolve(ids) + R.id.action_selection_clear_traffic -> clearTraffic(ids) R.id.action_selection_move -> moveToGroup(ids) R.id.action_selection_copy_links -> copyLinks(ids, throne = false) R.id.action_selection_copy_throne -> copyLinks(ids, throne = true) @@ -210,6 +215,35 @@ class SelectionMode(private val host: ConfigurationFragment) { } } + private fun resolve(ids: List) { + if (ids.isEmpty()) return + val gid = groupId + finish() + host.launchIo { + val report = SubscriptionClient.resolveProfiles(gid, ids) + if (report.isNotBlank()) host.onUi { snackbar(report).show() } + } + } + + private fun clearTraffic(ids: List) { + val gid = groupId + confirm(ids, host.getString(R.string.confirm_clear_traffic), R.string.confirm_clear) { + val service = (host.activity as? MainActivity)?.connection?.service + val adapter = host.listFor(gid)?.adapter + finish() + ids.forEach { adapter?.clearTraffic(it) } + host.launchIo { + val array = ids.toLongArray() + try { + service?.resetTraffic(array) + } catch (e: Exception) { + Logs.w(e) + } + ProfileManager.resetTraffic(array) + } + } + } + /** [title] above the names of [ids] in list order. */ private fun confirm(ids: List, title: String, @StringRes action: Int, run: () -> Unit) { host.launchIo { From 3f953e9b19c45566a39d794cbc5aa2a5440b083f Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Sun, 15 Nov 2026 20:56:38 +0300 Subject: [PATCH 06/17] Add new menu items for domain resolution and traffic clear --- app/src/main/res/menu/profile_selection_menu.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/res/menu/profile_selection_menu.xml b/app/src/main/res/menu/profile_selection_menu.xml index 16448b10c..7980aec27 100644 --- a/app/src/main/res/menu/profile_selection_menu.xml +++ b/app/src/main/res/menu/profile_selection_menu.xml @@ -45,6 +45,14 @@ android:id="@+id/action_selection_clear_results" android:title="@string/connection_test_clear_results" app:showAsAction="never" /> + + Date: Sun, 15 Nov 2026 20:57:33 +0300 Subject: [PATCH 07/17] Fix missing newline at end of SelectionMode.kt Add missing newline at the end of SelectionMode.kt From b2a3eca76c3aabbc86f21c87d3598e01eb09ee56 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Sun, 15 Nov 2026 20:57:53 +0300 Subject: [PATCH 08/17] Add newline at end of profile_selection_menu.xml Fix missing newline at the end of profile_selection_menu.xml From 8909b99dac0137c8f8f2321d9d78af6414df40bf Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Mon, 16 Nov 2026 12:03:49 +0300 Subject: [PATCH 09/17] Add exportAll function to export multiple profiles --- .../nekohasekai/sagernet/ui/profile/ProfileConfigExport.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileConfigExport.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileConfigExport.kt index 005031148..037dbbe66 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileConfigExport.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileConfigExport.kt @@ -29,4 +29,10 @@ object ProfileConfigExport { val name = if (xrayConfigs.isEmpty()) "${entity.displayName()}.json" else "${entity.displayName()}.txt" return text.toString() to name } + + fun exportAll(entities: List): Pair { + if (entities.size == 1) return export(entities.single()) + val text = entities.joinToString("\n\n") { entity -> "// ${entity.displayName()}\n" + export(entity).first } + return text to "profiles.txt" + } } From 52cd620c345619b95872f8e54d7ff72209428917 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Mon, 16 Nov 2026 12:04:14 +0300 Subject: [PATCH 10/17] Refactor exportConfiguration to use exportConfigurations --- .../nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt index c1729cc48..187ba3e70 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt @@ -218,10 +218,14 @@ class ProfileItemMenu(private val host: ConfigurationFragment) { */ private fun exportConfiguration(profile: ProxyEntity, toFile: Boolean) { // A copy parses its own outbound, so the row's cached one is only ever touched on the main thread. - val entity = profile.copy() + exportConfigurations(listOf(profile.copy()), toFile) + } + + internal fun exportConfigurations(entities: List, toFile: Boolean) { + if (entities.isEmpty()) return host.launchIo { val (config, fileName) = try { - ProfileConfigExport.export(entity) + ProfileConfigExport.exportAll(entities) } catch (e: Exception) { Logs.w(e) host.onUi { snackbar(e.readableMessage).show() } From 4dbdc108e9d0ab6a1570fbfd9203a54a6e1210a6 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Mon, 16 Nov 2026 12:04:35 +0300 Subject: [PATCH 11/17] Implement configuration export functionality Added exportConfigs function to handle configuration exports based on the selected profiles. --- .../nekohasekai/sagernet/ui/profiles/SelectionMode.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt index 3933e9735..fbf47c921 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/SelectionMode.kt @@ -179,6 +179,8 @@ class SelectionMode(private val host: ConfigurationFragment) { R.id.action_selection_copy_throne -> copyLinks(ids, throne = true) R.id.action_selection_qr_links -> showQr(ids, throne = false) R.id.action_selection_qr_throne -> showQr(ids, throne = true) + R.id.action_selection_config_clipboard -> exportConfigs(ids, toFile = false) + R.id.action_selection_config_file -> exportConfigs(ids, toFile = true) else -> return false } return true @@ -313,6 +315,15 @@ class SelectionMode(private val host: ConfigurationFragment) { } } + private fun exportConfigs(ids: List, toFile: Boolean) { + finish() + host.launchIo { + val position = ids.withIndex().associate { it.value to it.index } + val profiles = ProfileManager.getProfiles(ids).sortedBy { position[it.id] } + host.itemMenu.exportConfigurations(profiles, toFile) + } + } + /** The links of [ids] in list order with their profile names, profiles without one left out. */ private fun links(ids: List, throne: Boolean): List> { val position = ids.withIndex().associate { it.value to it.index } From 6665cc563118b42a688c8943e4c9091d81b8354c Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Mon, 16 Nov 2026 12:05:04 +0300 Subject: [PATCH 12/17] Update profile selection menu items and titles --- .../main/res/menu/profile_selection_menu.xml | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/app/src/main/res/menu/profile_selection_menu.xml b/app/src/main/res/menu/profile_selection_menu.xml index 7980aec27..069b98886 100644 --- a/app/src/main/res/menu/profile_selection_menu.xml +++ b/app/src/main/res/menu/profile_selection_menu.xml @@ -57,30 +57,43 @@ android:id="@+id/action_selection_move" android:title="@string/profiles_move_to_group" app:showAsAction="never" /> + + + + + + + android:title="@string/standard" /> + android:title="@string/throne_link" /> + android:id="@+id/action_selection_config_clipboard" + android:title="@string/action_export_clipboard" /> + android:id="@+id/action_selection_config_file" + android:title="@string/action_export_file" /> From 44d07ae936c86eb6dfbd6839b2ee20ba29288a8d Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Tue, 17 Nov 2026 20:45:57 +0300 Subject: [PATCH 13/17] Remove clipboard menu items for chain profiles --- .../io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt index 187ba3e70..94cade21d 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/profiles/ProfileItemMenu.kt @@ -187,10 +187,11 @@ class ProfileItemMenu(private val host: ConfigurationFragment) { // a chain has no link of its own, only the config it starts (bf89f273) if (profile.isChain()) { popup.menu.removeItem(R.id.action_group_qr) - popup.menu.removeItem(R.id.action_group_clipboard) + popup.menu.removeItem(R.id.action_standard_clipboard) + popup.menu.removeItem(R.id.action_universal_clipboard) } else if (profile.exportLink().isEmpty()) { 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) + popup.menu.removeItem(R.id.action_standard_clipboard) } popup.setOnMenuItemClickListener { item -> try { From 3940c7548c628702b858c58ed7f10d69a3309dce Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Tue, 17 Nov 2026 20:46:17 +0300 Subject: [PATCH 14/17] Update share menu item titles and structure --- app/src/main/res/menu/profile_share_menu.xml | 23 +++++++------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/app/src/main/res/menu/profile_share_menu.xml b/app/src/main/res/menu/profile_share_menu.xml index 3b2d4ca0f..79690a4a3 100644 --- a/app/src/main/res/menu/profile_share_menu.xml +++ b/app/src/main/res/menu/profile_share_menu.xml @@ -2,32 +2,25 @@ + android:title="@string/share_qr_link"> + android:title="@string/deep_link" /> - - - - - + android:id="@+id/action_standard_clipboard" + android:title="@string/copy_link" /> + + android:title="@string/export_config"> Date: Tue, 17 Nov 2026 20:46:41 +0300 Subject: [PATCH 15/17] Update profile selection menu item titles --- .../main/res/menu/profile_selection_menu.xml | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/app/src/main/res/menu/profile_selection_menu.xml b/app/src/main/res/menu/profile_selection_menu.xml index 069b98886..99970161f 100644 --- a/app/src/main/res/menu/profile_selection_menu.xml +++ b/app/src/main/res/menu/profile_selection_menu.xml @@ -59,7 +59,7 @@ app:showAsAction="never" /> + android:title="@string/deep_link" /> - - - - - + android:id="@+id/action_selection_copy_links" + android:title="@string/copy_link" + app:showAsAction="never" /> + Date: Tue, 17 Nov 2026 20:47:06 +0300 Subject: [PATCH 16/17] Add new strings for sharing and exporting features --- app/src/main/res/values/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a43e30ef..e29576def 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1303,6 +1303,11 @@ Select all Invert selection + QR code and link + Copy link + Copy deep link + Deep link + Export config Move to group There is no other basic group to move to. From b2ae81a053441678fe0b1a015cbfcaabc76e6812 Mon Sep 17 00:00:00 2001 From: Fasdeq13 Date: Tue, 17 Nov 2026 20:47:26 +0300 Subject: [PATCH 17/17] Add new strings for sharing and exporting configurations --- app/src/main/res/values-ru/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 0bd1fcca0..49807a668 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -976,6 +976,11 @@ Работающий профиль сохранён. Выбрать все Инвертировать выбор + QR-код и ссылка + Копировать ссылку + Копировать deep link + Deep link + Экспортировать конфиг Показать Внешний IP Скорость