Skip to content

Commit a028df8

Browse files
feat: added bulk parser for ids on android (#257)
1 parent b963851 commit a028df8

3 files changed

Lines changed: 35 additions & 11 deletions

File tree

‎android/app/src/main/java/com/therealaleph/mhrv/ui/HomeScreen.kt‎

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,15 @@ private fun ConnectionModeDropdown(
718718
}
719719

720720
// =========================================================================
721-
// Deployment IDs editor — one row per ID, with add/remove buttons.
721+
// Deployment IDs editor — one row per ID, with add/remove buttons. The
722+
// "+ Add" field accepts a single ID OR a bulk paste of many separated by
723+
// whitespace / newline / comma / semicolon — useful when migrating from
724+
// the desktop config or pasting a freshly-deployed batch (issue: bulk add).
722725
// =========================================================================
723726

727+
/** Split a bulk-pasted blob into individual entries. */
728+
private val ID_SEPARATORS = Regex("[\\s,;]+")
729+
724730
@Composable
725731
private fun DeploymentIdsField(
726732
urls: List<String>,
@@ -736,6 +742,8 @@ private fun DeploymentIdsField(
736742
)
737743

738744
// Existing entries — each with its own row and a remove button.
745+
// A bulk paste into an existing row also expands into multiple
746+
// entries, so users don't have to find the "+ Add" field to do it.
739747
urls.forEachIndexed { index, url ->
740748
Row(
741749
verticalAlignment = Alignment.CenterVertically,
@@ -744,8 +752,18 @@ private fun DeploymentIdsField(
744752
OutlinedTextField(
745753
value = url,
746754
onValueChange = { edited ->
755+
val parts = edited.split(ID_SEPARATORS).filter { it.isNotBlank() }
747756
val updated = urls.toMutableList()
748-
updated[index] = edited
757+
if (parts.size > 1) {
758+
// Bulk paste into this row: expand in place.
759+
updated.removeAt(index)
760+
updated.addAll(index, parts)
761+
} else {
762+
// Normal typing — preserve raw input so the
763+
// caret/whitespace doesn't get reformatted on
764+
// every keystroke.
765+
updated[index] = edited
766+
}
749767
onChange(updated)
750768
},
751769
enabled = enabled,
@@ -765,25 +783,29 @@ private fun DeploymentIdsField(
765783
}
766784
}
767785

768-
// "Add" row: text field + button.
786+
// "Add" row: multi-line text field + button. Multi-line so a user
787+
// can paste a long list at once (newline-separated is the natural
788+
// form when copying out of the desktop UI's textarea).
769789
Row(
770-
verticalAlignment = Alignment.CenterVertically,
790+
verticalAlignment = Alignment.Top,
771791
modifier = Modifier.fillMaxWidth(),
772792
) {
773793
OutlinedTextField(
774794
value = newEntry,
775795
onValueChange = { newEntry = it },
776796
enabled = enabled,
777797
modifier = Modifier.weight(1f),
778-
singleLine = true,
779-
placeholder = { Text("Paste URL or ID") },
798+
singleLine = false,
799+
minLines = 1,
800+
maxLines = 6,
801+
placeholder = { Text(stringResource(R.string.placeholder_paste_ids)) },
780802
)
781803
Spacer(Modifier.width(8.dp))
782804
Button(
783805
onClick = {
784-
val trimmed = newEntry.trim()
785-
if (trimmed.isNotBlank()) {
786-
onChange(urls + trimmed)
806+
val parts = newEntry.split(ID_SEPARATORS).filter { it.isNotBlank() }
807+
if (parts.isNotEmpty()) {
808+
onChange(urls + parts)
787809
newEntry = ""
788810
}
789811
},

‎android/app/src/main/res/values-fa/strings.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
<!-- Field labels -->
3232
<string name="field_deployment_urls">آدرس‌(های) Deployment یا Script ID</string>
33+
<string name="placeholder_paste_ids">یک URL/ID، یا چند مورد با خط جدید/فاصله/ویرگول/نقطه‌ویرگول جدا کنید</string>
3334
<string name="field_auth_key">کلید احراز (auth_key)</string>
3435
<string name="field_google_ip">google_ip</string>
3536
<string name="field_front_domain">دامنهٔ فرانت</string>
@@ -53,7 +54,7 @@
5354
<string name="lang_toggle_cd">تغییر زبان</string>
5455

5556
<!-- Supporting / helper text -->
56-
<string name="help_deployment_urls">URL کامل (https://script.google.com/macros/s/.../exec) یا فقط ID خام. چند ID به‌صورت چرخشی استفاده می‌شوند — بیشتر ID = سرعت بیشتر در حالت تونل کامل.</string>
57+
<string name="help_deployment_urls">URL کامل (https://script.google.com/macros/s/.../exec) یا فقط ID خام. می‌توانید چند مورد را یک‌جا در فیلد افزودن جای‌گذاری کنید — با خط جدید/فاصله/ویرگول/نقطه‌ویرگول جدا می‌شوند. چند ID به‌صورت چرخشی استفاده می‌شوند — بیشتر ID = سرعت بیشتر در حالت تونل کامل.</string>
5758
<string name="help_auth_key">همان رمز مشترکی که داخل Apps Script گذاشتید.</string>
5859
<string name="help_mode_vpn_tun">هنگام اتصال، مجوز VPN سیستم درخواست می‌شود. تمام ترافیک دستگاه به‌صورت خودکار رد می‌شود.</string>
5960
<string name="help_mode_proxy_only">بدون VPN سیستم. بعد از اتصال، پروکسی Wi-Fi را روی 127.0.0.1:%1$d (HTTP) یا %2$d (SOCKS5) تنظیم کنید. فقط برنامه‌هایی که تنظیمات پروکسی را رعایت می‌کنند رد می‌شوند.</string>

‎android/app/src/main/res/values/strings.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
<!-- Field labels -->
3232
<string name="field_deployment_urls">Deployment URL(s) or script ID(s)</string>
33+
<string name="placeholder_paste_ids">Paste one URL/ID, or many separated by newline / space / comma / semicolon</string>
3334
<string name="field_auth_key">auth_key</string>
3435
<string name="field_google_ip">google_ip</string>
3536
<string name="field_front_domain">front_domain</string>
@@ -53,7 +54,7 @@
5354
<string name="lang_toggle_cd">Switch language</string>
5455

5556
<!-- Supporting / helper text -->
56-
<string name="help_deployment_urls">Full URLs (https://script.google.com/macros/s/.../exec) or bare IDs. Multiple IDs are rotated round-robin — more IDs = more pipeline throughput in full mode.</string>
57+
<string name="help_deployment_urls">Full URLs (https://script.google.com/macros/s/.../exec) or bare IDs. Paste many at once into the Add field — they\'ll be split on newline / space / comma / semicolon. Multiple IDs are rotated round-robin — more IDs = more pipeline throughput in full mode.</string>
5758
<string name="help_auth_key">The shared secret you set in the Apps Script.</string>
5859
<string name="help_mode_vpn_tun">Requests the OS VPN grant on Connect. All device traffic is routed automatically.</string>
5960
<string name="help_mode_proxy_only">No OS VPN. Set your Wi-Fi proxy to 127.0.0.1:%1$d (HTTP) or %2$d (SOCKS5) after Connect. Only apps that honour the proxy settings will tunnel.</string>

0 commit comments

Comments
 (0)