diff --git a/README.md b/README.md index 3ca9854..32727ee 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Android intents support incoming shared text and app links. Long-press the launc Verified connections are remembered on this device with encrypted API keys. Select a remembered connection in Connection Settings, or use the server dropdown on the main menu when more than one connection has an API key. Switching the server you browse preserves your default share destination. Use **Forget** to remove a saved connection from this device. -Search directly from the main menu. The search icon opens a mode menu with the server default, metadata, and full-text options; available modes refresh from the server. Results open in an authenticated embedded server page. +Tap **Search archive** on the main menu to open your server’s search field. Operators, suggestions and results come from the authenticated server. When you tap **Search** while browsing a filtered library view, the app focuses that view’s search field and keeps the current folder, tag, domain, and filters. Older servers open their existing Snapshot search. For Tailscale, connect your Android device to your tailnet first and enter a server’s MagicDNS name or `100.x.y.z` address as a discovery hint, or paste the output of `tailscale status --json` from a computer on your tailnet. Only reachable candidates can be discovered, and a firewall or VPN policy can block access. You can always enter a server address directly, including a different port. diff --git a/app/src/androidTest/java/io/archivebox/app/ArchiveBoxJourneyTest.kt b/app/src/androidTest/java/io/archivebox/app/ArchiveBoxJourneyTest.kt index 165be8e..75a5449 100644 --- a/app/src/androidTest/java/io/archivebox/app/ArchiveBoxJourneyTest.kt +++ b/app/src/androidTest/java/io/archivebox/app/ArchiveBoxJourneyTest.kt @@ -169,18 +169,12 @@ class ArchiveBoxJourneyTest { compose.onAllNodesWithTag("home.progress").assertCountEquals(0) shot("library") click("tab.Archive") - node("sidebar.searchField").assertIsDisplayed().performTextReplacement("cowpig.github.io") - androidx.test.espresso.Espresso.closeSoftKeyboard() - click("sidebar.searchMode") - compose.onNodeWithText("Metadata").performClick() - click("sidebar.searchSubmit") + click("sidebar.searchField") + await("browser.ready") + enterServerSearch("cowpig.github.io") + submitServerSearch() await("browser.ready") val snapshotId = snapshots("cowpig.github.io").first { it.getString("url") == "https://cowpig.github.io/about/" }.getString("id") - val inputValue = Atoms.script("function(element) { return element.value; }", Atoms.castOrDie(String::class.java)) - onWebView().withElement(findElement(Locator.CSS_SELECTOR, "input[name=q]")) - .check(webMatches(inputValue, equalTo("cowpig.github.io"))) - onWebView().withElement(findElement(Locator.CSS_SELECTOR, "select[name=search_mode]")) - .check(webMatches(inputValue, equalTo("meta"))) val resultRow = "//input[@name='_selected_action' and @value='$snapshotId']/ancestor::tr" onWebView().withElement(findElement(Locator.XPATH, resultRow)) .check(webMatches(getText(), containsString("cowpig.github.io"))) diff --git a/app/src/androidTest/java/io/archivebox/app/ClientParityTest.kt b/app/src/androidTest/java/io/archivebox/app/ClientParityTest.kt index c619711..7f8d35a 100644 --- a/app/src/androidTest/java/io/archivebox/app/ClientParityTest.kt +++ b/app/src/androidTest/java/io/archivebox/app/ClientParityTest.kt @@ -53,6 +53,11 @@ class ClientParityTest { } click("setup.skip") fill("connection.hints", first) + // An already-granted LAN permission starts discovery on entry. Wait for + // its sweep to finish so this second sweep actually receives the typed hint. + compose.waitUntil(30_000) { + compose.onAllNodes(hasTestTag("connection.discover") and isEnabled()).fetchSemanticsNodes().isNotEmpty() + } click("connection.discover", scroll = true) val device = UiDevice.getInstance(instrumentation) device.wait(Until.findObject(By.res("com.android.permissioncontroller", "permission_allow_button")), 5_000)?.click() @@ -76,20 +81,19 @@ class ClientParityTest { click("sidebar.serverSwitcher"); click("sidebar.switchServer.${firstSaved.id}") compose.waitUntil(10_000) { ArchiveRepository(context).registry.value.active_server_id == firstSaved.id } assertEquals(registry.default_server_ids, ArchiveRepository(context).registry.value.default_server_ids) - node("sidebar.searchField").assertIsDisplayed() - fill("sidebar.searchField", "a & b/日本語") - click("sidebar.searchMode"); compose.onNodeWithText("Metadata").performClick() + click("sidebar.searchField"); await("browser.ready") + val query = "title:\"a & b/日本語\"" + enterServerSearch(query) shot("menu-search") - click("sidebar.searchSubmit"); await("browser.ready") - val expression = Atoms.script("return new URL(location.href).searchParams.get('q') + '|' + new URL(location.href).searchParams.get('search_mode');", Atoms.castOrDie(String::class.java)) - onWebView().check(webMatches(expression, equalTo("a & b/日本語|meta"))) + submitServerSearch(); await("browser.ready") + val expression = Atoms.script("return new URL(location.href).searchParams.get('q');", Atoms.castOrDie(String::class.java)) + onWebView().check(webMatches(expression, equalTo(query))) shot("embedded-search") click("tab.Archive") node("sidebar.serverSwitcher").assertIsDisplayed() click("sidebar.serverSwitcher"); click("sidebar.switchServer.${secondSaved.id}") - node("sidebar.searchField").assertIsDisplayed() - assertEquals("", node("sidebar.searchField").fetchSemanticsNode().config[androidx.compose.ui.semantics.SemanticsProperties.EditableText].text) - click("sidebar.searchSubmit"); await("browser.ready") + click("sidebar.searchField"); await("browser.ready") + onWebView().check(webMatches(Atoms.script("return document.querySelector('form[role=search] input[name=q]').value;", Atoms.castOrDie(String::class.java)), equalTo(""))) onWebView().check(webMatches(Atoms.script("return location.origin;", Atoms.castOrDie(String::class.java)), equalTo(second.trimEnd('/')))) click("tab.Settings") click("history.server.${firstSaved.id}", scroll = true) diff --git a/app/src/androidTest/java/io/archivebox/app/ServerSearch.kt b/app/src/androidTest/java/io/archivebox/app/ServerSearch.kt new file mode 100644 index 0000000..410d5a7 --- /dev/null +++ b/app/src/androidTest/java/io/archivebox/app/ServerSearch.kt @@ -0,0 +1,53 @@ +package io.archivebox.app + +import android.content.ClipData +import android.content.ClipboardManager +import android.view.KeyEvent +import android.webkit.WebView +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom +import androidx.test.espresso.web.assertion.WebViewAssertions.webMatches +import androidx.test.espresso.web.model.Atoms +import androidx.test.espresso.web.sugar.Web.onWebView +import androidx.test.espresso.web.webdriver.DriverAtoms.findElement +import androidx.test.espresso.web.webdriver.DriverAtoms.webClick +import androidx.test.espresso.web.webdriver.Locator +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import kotlin.math.roundToInt +import org.hamcrest.Matchers.equalTo +import org.json.JSONArray + +/** Use the real WebView input and keyboard so non-ASCII and URL punctuation survive submission. */ +internal fun enterServerSearch(query: String) { + // Older supported servers fall back to their ordinary Snapshot search form. + val editor = "form[role=search] [role=combobox], form[role=search] input[name=q]:not(.abx-search-field input)" + val instrumentation = InstrumentationRegistry.getInstrumentation() + val device = UiDevice.getInstance(instrumentation) + // Espresso's webClick synthesizes a DOM click, so Android's actual IME may still + // target a native view. Tap the rendered field, accounting for WebView density. + val center = Atoms.script( + """function(e) { + const r = e.getBoundingClientRect(); + return JSON.stringify([(r.left + r.width/2) * devicePixelRatio, (r.top + r.height/2) * devicePixelRatio]); + }""", Atoms.castOrDie(String::class.java)) + val point = JSONArray(onWebView().withElement(findElement(Locator.CSS_SELECTOR, editor)).perform(center).get()) + val offset = IntArray(2) + onView(isAssignableFrom(WebView::class.java)).check { view, _ -> view.getLocationOnScreen(offset) } + device.click(offset[0] + point.getDouble(0).roundToInt(), offset[1] + point.getDouble(1).roundToInt()) + device.waitForIdle() + instrumentation.runOnMainSync { + instrumentation.targetContext.getSystemService(ClipboardManager::class.java) + .setPrimaryClip(ClipData.newPlainText("Search", query)) + } + device.pressKeyCode(KeyEvent.KEYCODE_V, KeyEvent.META_CTRL_ON) + device.waitForIdle() + val value = Atoms.script("function(element) { return element.value; }", Atoms.castOrDie(String::class.java)) + onWebView().withElement(findElement(Locator.CSS_SELECTOR, "form[role=search] input[name=q]")) + .check(webMatches(value, equalTo(query))) +} + +internal fun submitServerSearch() { + onWebView().withElement(findElement(Locator.CSS_SELECTOR, "form[role=search] :is(button,input)[type=submit]")) + .perform(webClick()) +} diff --git a/app/src/androidTest/java/io/archivebox/app/ServerSearchIntegrationTest.kt b/app/src/androidTest/java/io/archivebox/app/ServerSearchIntegrationTest.kt new file mode 100644 index 0000000..4f9c1c9 --- /dev/null +++ b/app/src/androidTest/java/io/archivebox/app/ServerSearchIntegrationTest.kt @@ -0,0 +1,116 @@ +package io.archivebox.app + +import android.content.Intent +import android.net.Uri +import androidx.compose.ui.test.* +import androidx.compose.ui.test.junit4.v2.createEmptyComposeRule +import androidx.test.espresso.web.assertion.WebViewAssertions.webMatches +import androidx.test.espresso.web.model.Atoms +import androidx.test.espresso.web.sugar.Web.onWebView +import androidx.test.espresso.web.webdriver.DriverAtoms.findElement +import androidx.test.espresso.web.webdriver.DriverAtoms.webClick +import androidx.test.espresso.web.webdriver.Locator +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry +import androidx.test.runner.lifecycle.Stage +import org.hamcrest.Matchers.equalTo +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +/** Exercises search against a connected server independently of LAN discovery or gallery fixtures. */ +@RunWith(AndroidJUnit4::class) +class ServerSearchIntegrationTest { + @get:Rule val compose = createEmptyComposeRule() + + private fun await(tag: String) = compose.waitUntil(30_000) { + compose.onAllNodesWithTag(tag).fetchSemanticsNodes().isNotEmpty() + } + + private fun connect() { + val args = InstrumentationRegistry.getArguments() + val context = InstrumentationRegistry.getInstrumentation().targetContext + val uri = Uri.parse("archivebox://connect").buildUpon() + .appendQueryParameter("server", requireNotNull(args.getString("serverUrl"))) + .appendQueryParameter("api_key", requireNotNull(args.getString("apiToken"))) + .build() + context.startActivity(Intent(Intent.ACTION_VIEW, uri, context, MainActivity::class.java) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) + await("connection.save") + compose.onNodeWithTag("connection.save").performScrollTo().performClick() + await("connection.status") + } + + private fun recreateActivity() { + val instrumentation = InstrumentationRegistry.getInstrumentation() + instrumentation.runOnMainSync { + ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED).single().recreate() + } + await("browser.ready") + } + + private val currentUrl = Atoms.script("return location.href;", Atoms.castOrDie(String::class.java)) + + private fun waitForSubmittedQuery(query: String): Uri { + // The admin updates history when streamed results arrive; the document + // remains ready throughout, so wait for the actual submitted URL. + compose.waitUntil(30_000) { + Uri.parse(onWebView().perform(currentUrl).get()).getQueryParameter("q") == query + } + return Uri.parse(onWebView().perform(currentUrl).get()) + } + + @Test fun submitAndReopenQuotedQuery() { + connect() + compose.onNodeWithTag("tab.Search").performClick() + await("browser.ready") + val query = "title:\"a & b/日本語\"" + enterServerSearch(query) + submitServerSearch() + await("browser.ready") + val submitted = waitForSubmittedQuery(query) + // A recreated Activity must restore results, including the encoded expression. + recreateActivity() + onWebView().check(webMatches(currentUrl, equalTo(submitted.toString()))) + compose.onNodeWithTag("tab.Archive").performClick() + compose.onNodeWithTag("sidebar.searchField").performClick() + await("browser.ready") + val input = Atoms.script("return document.querySelector('form[role=search] input[name=q]').value;", Atoms.castOrDie(String::class.java)) + onWebView().check(webMatches(input, equalTo(query))) + } + + @Test fun nativeSearchStaysInSelectedTag() { + connect() + compose.onNodeWithTag("tab.Archive").performClick() + compose.onNodeWithTag("home").performScrollToNode(hasTestTag("route.Tags")) + compose.onNodeWithTag("route.Tags").performClick() + await("browser.ready") + onWebView().withElement(findElement(Locator.CSS_SELECTOR, "a[href*='tags__id__exact=']")) + .perform(webClick()) + await("browser.ready") + val filtered = Uri.parse(onWebView().perform(currentUrl).get()) + val tag = filtered.getQueryParameter("tags__id__exact") + assertNotNull("The tag count link must open a tag-filtered Snapshot view", tag) + + compose.onNodeWithTag("tab.Search").performClick() + // The native Search tab must focus the filter's existing form. Opening a + // standalone editor here would appear functional while silently losing the tag. + val fieldFocused = Atoms.script( + "return document.activeElement.matches('[role=search] [role=combobox], [role=search] input[name=q]');", + Atoms.castOrDie(Boolean::class.javaObjectType)) + compose.waitUntil(30_000) { onWebView().perform(fieldFocused).get() } + onWebView().check(webMatches(currentUrl, equalTo(filtered.toString()))) + enterServerSearch("https") + submitServerSearch() + await("browser.ready") + val submitted = waitForSubmittedQuery("https") + assertEquals(filtered.path, submitted.path) + assertEquals(tag, submitted.getQueryParameter("tags__id__exact")) + assertEquals("https", submitted.getQueryParameter("q")) + recreateActivity() + onWebView().check(webMatches(currentUrl, equalTo(submitted.toString()))) + } +} diff --git a/app/src/main/java/io/archivebox/app/data/ArchiveApi.kt b/app/src/main/java/io/archivebox/app/data/ArchiveApi.kt index 8abf3ca..d87f4f8 100644 --- a/app/src/main/java/io/archivebox/app/data/ArchiveApi.kt +++ b/app/src/main/java/io/archivebox/app/data/ArchiveApi.kt @@ -19,7 +19,6 @@ import java.util.concurrent.TimeUnit import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException -data class ArchiveSnapshot(val id: String, val title: String, val url: String, val tags: List) data class SubmissionReceipt(val server_id: String, val crawl_id: String, val queued_urls: List) data class ServerPersona(val id: String, val name: String) data class BrowserSession(val admin_url: String, val cookie: Cookie) { @@ -178,15 +177,6 @@ class ArchiveApi(timeoutSeconds: Long = 20) { validateTokenResponse(result) } - suspend fun snapshots(connection: ServerConfiguration, query: String = "", offset: Int = 0): List { - require(offset >= 0) - val result = request(connection.server, "api/v1/core/snapshots", connection.token, - query = mapOf("search" to query, "search_mode" to "meta", "limit" to "50", "offset" to offset.toString())) - return result.getJSONArray("items").objects().map { - ArchiveSnapshot(it.getString("id"), it.optString("title").takeUnless { value -> value == "null" }.orEmpty(), it.getString("url"), it.optJSONArray("tags")?.strings().orEmpty()) - } - } - suspend fun tagSuggestions(connection: ServerConfiguration, query: String): List { val result = request(connection.server, "api/v1/core/tags/autocomplete/", connection.token, query = mapOf("q" to query)) return normalizeTags(result.getJSONArray("tags").objects().map { it.getString("name") }) diff --git a/app/src/main/java/io/archivebox/app/ui/ArchiveBoxApp.kt b/app/src/main/java/io/archivebox/app/ui/ArchiveBoxApp.kt index df570a0..8a0b478 100644 --- a/app/src/main/java/io/archivebox/app/ui/ArchiveBoxApp.kt +++ b/app/src/main/java/io/archivebox/app/ui/ArchiveBoxApp.kt @@ -3,10 +3,6 @@ package io.archivebox.app.ui import android.content.Intent import android.net.Uri import androidx.activity.compose.BackHandler -import androidx.compose.foundation.text.KeyboardActions -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.foundation.background import androidx.compose.foundation.Image import androidx.compose.foundation.clickable @@ -86,9 +82,10 @@ internal class NavigationState : ViewModel() { var browserPath by rememberSaveable { mutableStateOf(null) } var browserTitle by rememberSaveable { mutableStateOf("") } var transferMenu by rememberSaveable { mutableStateOf(null) } - var searchText by rememberSaveable { mutableStateOf("") } - var searchMode by rememberSaveable { mutableStateOf("") } - var searchModes by remember { mutableStateOf(listOf("meta", "contents", "deep")) } + var focusViewSearch by remember(connection?.id) { mutableStateOf<((Boolean) -> Unit)?>(null) } + var searchText by rememberSaveable(connection?.id) { mutableStateOf("") } + var activityPath by rememberSaveable(connection?.id) { mutableStateOf("admin/") } + var searchPath by rememberSaveable(connection?.id) { mutableStateOf(searchEditorPath("")) } var previousServerId by rememberSaveable { mutableStateOf(connection?.id) } var menuServerId by rememberSaveable { mutableStateOf(connection?.id) } LaunchedEffect(connection?.id) { @@ -96,9 +93,6 @@ internal class NavigationState : ViewModel() { previousServerId = connection?.id browserPath = null transferMenu = null - searchText = "" - searchMode = "" - searchModes = listOf("meta", "contents", "deep") } val navigation: NavigationState = viewModel() var shareRequest by navigation.shareRequest @@ -109,11 +103,14 @@ internal class NavigationState : ViewModel() { var settingsDraftVersion by rememberSaveable { mutableIntStateOf(0) } val latestIncoming by rememberUpdatedState(incoming) fun noteUserNavigation() { + focusViewSearch = null navigation.noteUserNavigation() recovery = null } fun navigateTo(destination: String, closeBrowser: Boolean = false) { noteUserNavigation() + if (destination == "Search") searchPath = searchEditorPath(searchText) + if (destination == "Activity") activityPath = "admin/" screen = destination if (closeBrowser) { browserPath = null; transferMenu = null } } @@ -159,7 +156,12 @@ internal class NavigationState : ViewModel() { repository.dismissSetup() when (incoming.action) { "add" -> { shareRequest = incoming; screen = "Add" } - "search" -> { searchText = incoming.text; searchMode = ""; screen = "Search" } + "search" -> { + searchText = incoming.text + searchPath = if (searchText.isBlank()) searchEditorPath("") else archiveSearchPath(searchText) + browserPath = null + screen = "Search" + } "connect" -> { connectionRequest = incoming; screen = "Settings" } "snapshot" -> { val c = connection @@ -198,9 +200,23 @@ internal class NavigationState : ViewModel() { } val savedServers = registry.servers.filter { it.token.isNotBlank() } val progress = rememberHomeProgress(repository, connection, phoneHome) - val submitSearch: (String, String) -> Unit = { query, mode -> - searchText = query; searchMode = mode; navigateTo("Search") + fun selectTab(destination: String) { + if (destination != "Search" || connection == null || + (browserPath == null && screen !in listOf("Search", "Activity"))) { + navigateTo(destination, closeBrowser = true) + return + } + noteUserNavigation() + val revision = navigation.userNavigationVersion + // A late WebView response must not change tabs after the user has moved on. + focusViewSearch = { found -> + if (navigation.userNavigationVersion == revision) { + focusViewSearch = null + if (!found) navigateTo("Search", closeBrowser = true) + } + } } + val openSearch = { selectTab("Search") } val switchServer: (ServerConfiguration) -> Unit = { selected -> noteUserNavigation() scope.launch { @@ -210,7 +226,7 @@ internal class NavigationState : ViewModel() { } Row(Modifier.fillMaxSize()) { if (wide) NavigationRail(Modifier.fillMaxHeight().testTag("navigation.rail"), header = { BrandMark(Modifier.padding(vertical = 24.dp)) }) { - tabs.forEach { (name, icon) -> NavigationRailItem(selected = screen == name, onClick = { navigateTo(name, closeBrowser = true) }, icon = { Icon(icon, name) }, label = { Text(name) }, modifier = Modifier.testTag("tab.$name")) } + tabs.forEach { (name, icon) -> NavigationRailItem(selected = screen == name, onClick = { selectTab(name) }, icon = { Icon(icon, name) }, label = { Text(name) }, modifier = Modifier.testTag("tab.$name")) } } Scaffold( modifier = Modifier.weight(1f), @@ -230,25 +246,30 @@ internal class NavigationState : ViewModel() { }) }, bottomBar = { - if (phoneHome) HomeActions(connection, searchText, searchMode, searchModes, submitSearch) { navigateTo("Add") } - else if (!wide) NavigationBar { tabs.forEach { (name, icon) -> NavigationBarItem(selected = screen == name && browserPath == null, onClick = { navigateTo(name, closeBrowser = true) }, icon = { Icon(icon, name) }, label = { Text(name) }, modifier = Modifier.testTag("tab.$name")) } } + if (phoneHome) HomeActions(openSearch) { navigateTo("Add") } + else if (!wide) NavigationBar { tabs.forEach { (name, icon) -> NavigationBarItem(selected = screen == name && browserPath == null, onClick = { selectTab(name) }, icon = { Icon(icon, name) }, label = { Text(name) }, modifier = Modifier.testTag("tab.$name")) } } } ) { padding -> Box(Modifier.padding(padding).consumeWindowInsets(padding).fillMaxSize()) { val c = connection when { - browserPath != null && c != null -> ServerBrowser(repository, c, browserPath!!, transferMenu = transferMenu) + browserPath != null && c != null -> ServerBrowser(repository, c, browserPath!!, transferMenu = transferMenu, + focusSearch = focusViewSearch, onSearchPage = { path, _ -> browserPath = path }) screen == "Settings" -> key(settingsDraftVersion) { ConnectionSettings(repository, connectionRequest, onRequestConsumed = { connectionRequest = null }, onGuide = { showGuide = true }, discoverOnOpen = discoverOnOpen, onDiscoveryStarted = { discoverOnOpen = false }) } screen == "Add" -> AddScreen(repository, c, "", onConnect = { navigateTo("Settings") }) - screen == "Search" && c != null -> ServerBrowser(repository, c, archiveSearchPath(searchText, searchMode), onSearchModes = { searchModes = it }) + screen == "Search" && c != null -> ServerBrowser(repository, c, searchPath, focusSearch = focusViewSearch, onSearchPage = { path, query -> + searchPath = path + if (query != null) searchText = query + }) screen == "Search" -> ConnectPrompt { navigateTo("Settings") } - screen == "Activity" && c != null -> ServerBrowser(repository, c, "admin/") + screen == "Activity" && c != null -> ServerBrowser(repository, c, activityPath, + focusSearch = focusViewSearch, onSearchPage = { path, _ -> activityPath = path }) screen == "Activity" -> ConnectPrompt { navigateTo("Settings") } - else -> HomeScreen(c, savedServers, searchText, searchMode, searchModes, + else -> HomeScreen(c, savedServers, phoneHome = phoneHome, progress = progress, listState = menuState, onSwitch = switchServer, - onAdd = { navigateTo("Add") }, onSearch = submitSearch, + onAdd = { navigateTo("Add") }, onSearch = openSearch, onActivity = { navigateTo("Activity") }, onConnect = { navigateTo("Settings") }, onTransfer = { menu -> noteUserNavigation() @@ -280,10 +301,9 @@ internal class NavigationState : ViewModel() { } @Composable private fun HomeScreen( - connection: ServerConfiguration?, servers: List, searchText: String, searchMode: String, - searchModes: List, phoneHome: Boolean, progress: HomeProgressState, + connection: ServerConfiguration?, servers: List, phoneHome: Boolean, progress: HomeProgressState, listState: androidx.compose.foundation.lazy.LazyListState, - onSwitch: (ServerConfiguration) -> Unit, onAdd: () -> Unit, onSearch: (String, String) -> Unit, + onSwitch: (ServerConfiguration) -> Unit, onAdd: () -> Unit, onSearch: () -> Unit, onActivity: () -> Unit, onConnect: () -> Unit, onTransfer: (SnapshotTransferMenu) -> Unit, onRoute: (ServerRoute) -> Unit, ) { val context = LocalContext.current @@ -307,7 +327,7 @@ internal class NavigationState : ViewModel() { } if (connection == null || !phoneHome) item { Surface(onClick = onConnect, shape = RoundedCornerShape(20.dp), color = MaterialTheme.colorScheme.surfaceContainer) { ListItem(headlineContent = { Text(if (connection == null) "Connect your server" else "Your ArchiveBox server") }, supportingContent = { Text(connection?.server ?: "Your data. Your devices. Your archive.", maxLines = 1, overflow = TextOverflow.Ellipsis) }, leadingContent = { Icon(if (connection == null) Icons.Outlined.Link else Icons.Outlined.Dns, null) }, trailingContent = { Icon(Icons.Outlined.ChevronRight, null) }) } } if (!phoneHome && servers.size > 1) item { ServerSwitcher(connection, servers, onSwitch) } - if (!phoneHome) item { key(connection?.id) { MenuSearchField(searchText, searchMode, searchModes, connection != null, onSearch) } } + if (!phoneHome) item { SearchEntry(onSearch, Modifier.fillMaxWidth()) } if (phoneHome && connection != null) item { HomeProgressStrip(progress) } item { SectionTitle("Collection") } (if (phoneHome) phoneCollectionRoutes else collectionRoutes).forEach { route -> @@ -354,42 +374,21 @@ internal class NavigationState : ViewModel() { } } -internal fun archiveSearchPath(query: String, mode: String): String = Uri.Builder() - .path("admin/core/snapshot/") - .apply { - if (query.isNotBlank()) appendQueryParameter("q", query.trim()) - if (mode.isNotBlank()) appendQueryParameter("search_mode", mode) - }.build().toString() +internal const val SEARCH_EDITOR_PATH = "public/search-field/" -@Composable private fun MenuSearchField(query: String, selectedMode: String, modes: List, enabled: Boolean, onSearch: (String, String) -> Unit, modifier: Modifier = Modifier, rounded: Boolean = false) { - var text by rememberSaveable(query) { mutableStateOf(query) } - var mode by rememberSaveable(selectedMode) { mutableStateOf(selectedMode) } - var showModes by remember { mutableStateOf(false) } - val focus = LocalFocusManager.current - OutlinedTextField( - value = text, onValueChange = { text = it }, enabled = enabled, - placeholder = { Text("Search archive") }, singleLine = true, - modifier = modifier.fillMaxWidth().testTag("sidebar.searchField"), - shape = if (rounded) RoundedCornerShape(24.dp) else OutlinedTextFieldDefaults.shape, - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), - keyboardActions = KeyboardActions(onSearch = { focus.clearFocus(); onSearch(text.trim(), mode) }), - leadingIcon = { - Box { - IconButton(onClick = { showModes = true }, enabled = enabled, modifier = Modifier.testTag("sidebar.searchMode")) { Icon(Icons.Outlined.Search, "Search mode") } - DropdownMenu(expanded = showModes, onDismissRequest = { showModes = false }) { - (listOf("") + modes).distinct().forEach { value -> - DropdownMenuItem(text = { Text(when (value) { "" -> "Server default"; "meta" -> "Metadata"; "contents" -> "Full text"; else -> value }) }, - leadingIcon = { if (mode == value) Icon(Icons.Outlined.Check, null) }, - onClick = { mode = value; showModes = false }) - } - } - } - }, - trailingIcon = { Row { - if (text.isNotEmpty()) IconButton(onClick = { text = "" }) { Icon(Icons.Outlined.Close, "Clear search") } - IconButton(onClick = { focus.clearFocus(); onSearch(text.trim(), mode) }, enabled = enabled, modifier = Modifier.testTag("sidebar.searchSubmit")) { Icon(Icons.Outlined.ArrowForward, "Search archive") } - } } - ) +internal fun searchEditorPath(query: String): String = Uri.Builder().path(SEARCH_EDITOR_PATH) + .appendQueryParameter("target", "admin") + .apply { if (query.isNotBlank()) appendQueryParameter("q", query) }.build().toString() + +internal fun archiveSearchPath(query: String): String = Uri.Builder().path("admin/core/snapshot/") + .apply { if (query.isNotBlank()) appendQueryParameter("q", query) }.build().toString() + +@Composable private fun SearchEntry(onOpen: () -> Unit, modifier: Modifier = Modifier) { + // Give the server editor the full screen for a keyboard, nested expressions and its suggestion list. + OutlinedButton(onClick = onOpen, modifier = modifier.testTag("sidebar.searchField")) { + Icon(Icons.Outlined.Search, contentDescription = null) + Text("Search archive", Modifier.padding(start = 8.dp)) + } } private val phoneCollectionRoutes = listOf( @@ -425,8 +424,7 @@ private val phoneCollectionRoutes = listOf( } @Composable private fun HomeActions( - connection: ServerConfiguration?, query: String, mode: String, modes: List, - onSearch: (String, String) -> Unit, onAdd: () -> Unit, + onSearch: () -> Unit, onAdd: () -> Unit, ) { Surface(color = MaterialTheme.colorScheme.surface, shadowElevation = 3.dp) { Row( @@ -436,12 +434,7 @@ private val phoneCollectionRoutes = listOf( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp), ) { - if (connection != null) key(connection.id) { - MenuSearchField(query, mode, modes, true, onSearch, Modifier.weight(1f), rounded = true) - } else TextButton(onClick = { onSearch("", "") }, modifier = Modifier.weight(1f).fillMaxHeight().testTag("tab.Search")) { - Icon(Icons.Outlined.Search, null) - Text("Search archive", Modifier.padding(start = 8.dp)) - } + SearchEntry(onSearch, Modifier.weight(1f)) Button(onClick = onAdd, modifier = Modifier.fillMaxHeight().testTag("tab.Add")) { Icon(Icons.Outlined.Add, null); Text("Add") } } } diff --git a/app/src/main/java/io/archivebox/app/ui/SearchScreen.kt b/app/src/main/java/io/archivebox/app/ui/SearchScreen.kt deleted file mode 100644 index ce4a1a7..0000000 --- a/app/src/main/java/io/archivebox/app/ui/SearchScreen.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.archivebox.app.ui - -import android.content.Intent -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.text.KeyboardActions -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.* -import androidx.compose.material3.* -import androidx.compose.runtime.* -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.testTag -import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.dp -import io.archivebox.app.data.* -import kotlinx.coroutines.launch - -@OptIn(ExperimentalLayoutApi::class) -@Composable internal fun SearchScreen(repository: ArchiveRepository, connection: ServerConfiguration?, initialQuery: String, onConnect: () -> Unit, onOpen: (ArchiveSnapshot) -> Unit) { - if (connection == null) { ConnectPrompt(onConnect); return } - var query by rememberSaveable(initialQuery) { mutableStateOf(initialQuery) } - var results by remember(connection) { mutableStateOf>(emptyList()) } - var busy by remember { mutableStateOf(false) } - var error by remember { mutableStateOf(null) } - var searched by remember { mutableStateOf(false) } - var more by remember { mutableStateOf(false) } - var committedQuery by remember { mutableStateOf(initialQuery) } - val scope = rememberCoroutineScope() - val context = LocalContext.current - suspend fun search(append: Boolean = false) { - busy = true; error = null - try { - if (!append) committedQuery = query - val page = repository.api.snapshots(connection, committedQuery, if (append) results.size else 0) - results = if (append) (results + page).distinctBy { it.id } else page - more = page.size == 50; searched = true - } catch (e: Exception) { error = e.message ?: "Couldn't search your archive." } - finally { busy = false } - } - LaunchedEffect(connection, initialQuery) { search() } - LazyColumn(Modifier.fillMaxSize().testTag("search"), contentPadding = PaddingValues(20.dp), verticalArrangement = Arrangement.spacedBy(14.dp)) { - item { - OutlinedTextField(query, { query = it }, label = { Text("Search titles, URLs, and tags") }, leadingIcon = { Icon(Icons.Outlined.Search, null) }, trailingIcon = { IconButton(onClick = { scope.launch { search() } }, enabled = !busy, modifier = Modifier.testTag("search.submit")) { Icon(Icons.Outlined.ArrowForward, "Search") } }, singleLine = true, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), keyboardActions = KeyboardActions(onSearch = { scope.launch { search() } }), modifier = Modifier.fillMaxWidth().testTag("search.query")) - } - if (busy) item { LinearProgressIndicator(Modifier.fillMaxWidth()) } - error?.let { message -> item { ErrorCard(message); TextButton(onClick = { scope.launch { search() } }) { Text("Try again") } } } - if (searched && results.isEmpty() && !busy && error == null) item { - Column(Modifier.padding(vertical = 48.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) { Icon(Icons.Outlined.SearchOff, null, Modifier.size(48.dp), tint = MaterialTheme.colorScheme.primary); Text("No saved pages found", style = MaterialTheme.typography.headlineSmall); Text("Try another title, URL, or tag, or save your first link from the Add tab.", color = MaterialTheme.colorScheme.onSurfaceVariant) } - } - if (results.isNotEmpty()) item { Text(if (committedQuery.isBlank()) "Your latest saved pages" else "Results for “$committedQuery”", style = MaterialTheme.typography.titleSmall, modifier = Modifier.testTag("search.results")) } - items(results, key = { it.id }) { snapshot -> - Card(onClick = { onOpen(snapshot) }, shape = RoundedCornerShape(22.dp), colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow), modifier = Modifier.fillMaxWidth().testTag("search.result.${snapshot.id}")) { - Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) { - Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { Icon(Icons.Outlined.Language, null, tint = MaterialTheme.colorScheme.primary); Text(snapshot.title.ifBlank { snapshot.url }, style = MaterialTheme.typography.titleMedium, maxLines = 3, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) } - Text(snapshot.url, maxLines = 2, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) - FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp)) { snapshot.tags.forEach { tag -> SuggestionChip(onClick = { query = tag; scope.launch { search() } }, label = { Text(tag) }, icon = { Icon(Icons.Outlined.Sell, null, Modifier.size(14.dp)) }) } } - Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - TextButton(onClick = { onOpen(snapshot) }) { Text("Open saved page"); Spacer(Modifier.width(6.dp)); Icon(Icons.Outlined.ArrowOutward, null, Modifier.size(16.dp)) } - IconButton(onClick = { - val intent = Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, snapshot.url).putExtra(Intent.EXTRA_TITLE, snapshot.title) - context.startActivity(Intent.createChooser(intent, "Share original URL")) - }) { Icon(Icons.Outlined.Share, "Share original URL") } - IconButton(onClick = { - val link = "${connection.server.trimEnd('/')}/snapshot/${snapshot.id}/index.html" - context.startActivity(Intent.createChooser(Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, link), "Share archived page")) - }) { Icon(Icons.Outlined.Link, "Share archived page") } - } - } - } - } - if (more) item { OutlinedButton(onClick = { scope.launch { search(true) } }, enabled = !busy, modifier = Modifier.fillMaxWidth().testTag("search.more")) { Text("Load more") } } - } -} diff --git a/app/src/main/java/io/archivebox/app/ui/ServerBrowser.kt b/app/src/main/java/io/archivebox/app/ui/ServerBrowser.kt index a2f9bc7..019028a 100644 --- a/app/src/main/java/io/archivebox/app/ui/ServerBrowser.kt +++ b/app/src/main/java/io/archivebox/app/ui/ServerBrowser.kt @@ -6,6 +6,7 @@ import android.graphics.Bitmap import android.net.Uri import android.os.SystemClock import android.view.ViewGroup +import android.view.inputmethod.InputMethodManager import android.webkit.* import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.* @@ -20,6 +21,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import io.archivebox.app.data.* import io.archivebox.app.BuildConfig +import kotlinx.coroutines.delay import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -41,6 +43,15 @@ internal fun allowedArchiveOrigin(url: String, server: String, adminUrl: String) internal const val SNAPSHOT_GRID_PATH = "admin/core/snapshot/grid/" +// OkHttp and Android expose encoded paths; compare the reverse proxy's prefix +// in the same representation so spaces and reserved delimiters survive rotation. +internal fun searchRoute(base: URI, encodedPath: String?): String? = when (encodedPath) { + base.resolve("core/snapshot/").rawPath -> "admin/core/snapshot/" + base.resolve("core/snapshot/grid/").rawPath -> SNAPSHOT_GRID_PATH + base.resolve("../$SEARCH_EDITOR_PATH").rawPath -> SEARCH_EDITOR_PATH + else -> null +} + internal enum class SnapshotTransferMenu(val menuID: String) { Import("library-import-menu"), Export("snapshot-export-menu"); @@ -70,10 +81,11 @@ internal enum class SnapshotTransferMenu(val menuID: String) { connection: ServerConfiguration, path: String, transferMenu: SnapshotTransferMenu? = null, - onSearchModes: ((List) -> Unit)? = null, + onSearchPage: ((String, String?) -> Unit)? = null, + focusSearch: ((Boolean) -> Unit)? = null, ) { val context = LocalContext.current - val searchModesCallback by rememberUpdatedState(onSearchModes) + val searchPageCallback by rememberUpdatedState(onSearchPage) var browser by remember { mutableStateOf(null) } var session by remember(connection) { mutableStateOf(null) } // These cells must outlive route changes: the WebView client retains their references. @@ -96,6 +108,56 @@ internal enum class SnapshotTransferMenu(val menuID: String) { session = value } catch (e: Exception) { error = e.message ?: "Couldn't open your server's browser session." } } + LaunchedEffect(focusSearch, ready, error, session, browser) { + val complete = focusSearch ?: return@LaunchedEffect + if (!ready && error == null) return@LaunchedEffect + val view = browser + val admin = session?.admin_url + if (error != null || view == null || admin == null || !sameOrigin(view.url.orEmpty(), admin)) { + complete(false) + return@LaunchedEffect + } + // Keep the server's form in place: it owns the active folder, tags, domain, + // filters and sort. The client never has to reconstruct a search scope. + val focusEditor = """ + (() => { + if (location.origin !== new URL(${JSONObject.quote(admin)}).origin) return false; + const selectors = [ + '[role="search"] [role="combobox"][contenteditable="true"]', + '[role="search"] input[name="q"]', + '#content-main input[type="search"]' + ]; + for (const selector of selectors) { + const field = [...document.querySelectorAll(selector)].find(el => + !el.disabled && el.getClientRects().length && getComputedStyle(el).visibility === 'visible'); + if (field) { + field.focus(); + field.scrollIntoView({block:'nearest'}); + return document.activeElement === field; + } + } + // Some library pages (such as Domains) load their table and its + // search form together after the top-level document finishes. + return document.readyState !== 'complete' || document.querySelector('[aria-busy="true"]') ? null : false; + })(); + """.trimIndent() + view.requestFocus() + val deadline = SystemClock.uptimeMillis() + 4_000 + var result: String + do { + result = suspendCancellableCoroutine { continuation -> + view.evaluateJavascript(focusEditor) { value -> + if (continuation.isActive) continuation.resume(value) + } + } + if (result != "null" || SystemClock.uptimeMillis() >= deadline) break + delay(120) + } while (true) + if (result == "true") context.getSystemService(InputMethodManager::class.java).showSoftInput(view, 0) + // A stalled library table still owns its search. Only a confirmed + // absence may move the user to the whole-archive editor. + complete(result != "false") + } BackHandler(canBack) { browser?.goBack() } DisposableEffect(connection) { onDispose { CookieManager.getInstance().removeAllCookies(null); WebStorage.getInstance().deleteAllData() } @@ -130,6 +192,7 @@ internal enum class SnapshotTransferMenu(val menuID: String) { settings.safeBrowsingEnabled = true CookieManager.getInstance().setAcceptThirdPartyCookies(this, false) webViewClient = object : WebViewClient() { + private var fallbackPage: String? = null private var transferOpened = false private var pageGeneration = 0 private var transferStartedOn = -1 @@ -173,20 +236,45 @@ internal enum class SnapshotTransferMenu(val menuID: String) { ready = false; error = null; canBack = view.canGoBack() } override fun onPageFinished(view: WebView, url: String) { + if (fallbackPage != null && searchRoute(base, url.toHttpUrlOrNull()?.encodedPath) == SEARCH_EDITOR_PATH) return + if (url == fallbackPage) { + // The unavailable editor was the entry page. Back must not reopen its 404. + view.clearHistory() + fallbackPage = null + } ready = error == null; canBack = view.canGoBack() openTransferMenu(view, url) - if (ready && searchModesCallback != null && sameOrigin(url, authenticated.admin_url)) { - view.evaluateJavascript("Array.from(document.querySelectorAll('select[name=search_mode] option'), option => option.value)") { result -> - val modes = runCatching { - val values = org.json.JSONArray(result) - (0 until values.length()).map { values.getString(it) }.filter { it.isNotBlank() }.distinct() - }.getOrDefault(emptyList()) - if (modes.isNotEmpty()) searchModesCallback?.invoke(modes) - } - } + if (ready) rememberSearchPage(view, url) + } + override fun doUpdateVisitedHistory(view: WebView, url: String, isReload: Boolean) { + // The results stream can replace its query URL without loading another document. + if (ready) rememberSearchPage(view, url) + } + private fun rememberSearchPage(view: WebView, url: String) { + val record = searchPageCallback ?: return + if (view !== browser || url != view.url || !sameOrigin(url, authenticated.admin_url)) return + val page = url.toHttpUrlOrNull() ?: return + val route = searchRoute(base, page.encodedPath) ?: return + // Remember the URL for rotation. Mark this navigation as already loaded + // so Compose's update block does not restart an active result stream. + view.tag = url + record(route + (page.encodedQuery?.let { "?$it" } ?: ""), if (route == SEARCH_EDITOR_PATH) null else page.queryParameter("q").orEmpty()) } override fun onReceivedError(view: WebView, request: WebResourceRequest, failure: WebResourceError) { if (request.isForMainFrame) { ready = false; error = "Couldn't load this page. ${failure.description}" } } - override fun onReceivedHttpError(view: WebView, request: WebResourceRequest, response: WebResourceResponse) { if (request.isForMainFrame) { ready = false; error = "Server returned HTTP ${response.statusCode}." } } + override fun onReceivedHttpError(view: WebView, request: WebResourceRequest, response: WebResourceResponse) { + if (!request.isForMainFrame) return + if (response.statusCode == 404 && searchRoute(base, request.url.encodedPath) == SEARCH_EDITOR_PATH && + sameOrigin(request.url.toString(), authenticated.admin_url)) { + // Older servers still expose their own supported Snapshot search. + val fallback = archiveSearchPath(request.url.getQueryParameter("q").orEmpty()) + val url = base.resolve(fallback.removePrefix("admin/")).toString() + ready = false + fallbackPage = url + view.post { view.loadUrl(url) } + return + } + ready = false; error = "Server returned HTTP ${response.statusCode}." + } // The default SSL handler cancels certificate errors; never bypass certificate validation. } tag = destination diff --git a/app/src/test/java/io/archivebox/app/data/AddressTest.kt b/app/src/test/java/io/archivebox/app/data/AddressTest.kt index 4bc5cf9..2135968 100644 --- a/app/src/test/java/io/archivebox/app/data/AddressTest.kt +++ b/app/src/test/java/io/archivebox/app/data/AddressTest.kt @@ -3,8 +3,18 @@ package io.archivebox.app.data import org.junit.Assert.* import org.junit.Test import io.archivebox.app.ui.allowedArchiveOrigin +import io.archivebox.app.ui.searchRoute +import java.net.URI class AddressTest { + @Test fun filteredSearchRoutesPreserveAnEncodedProxyPrefix() { + val base = URI("https://archive.example/Plant%20Archive/admin/") + assertEquals("admin/core/snapshot/grid/", searchRoute(base, "/Plant%20Archive/admin/core/snapshot/grid/")) + assertEquals("admin/core/snapshot/", searchRoute(base, "/Plant%20Archive/admin/core/snapshot/")) + assertEquals("public/search-field/", searchRoute(base, "/Plant%20Archive/public/search-field/")) + assertNull(searchRoute(base, "/other/admin/core/snapshot/")) + } + @Test fun bareDeviceUsesArchiveBoxPortAndExplicitUrlsRetainTheirPorts() { assertEquals("http://archivebox.local:5797/", normalizeServer("archivebox.local")) assertEquals("http://100.65.2.3:5797/", normalizeServer("100.65.2.3")) diff --git a/docs/screenshots/search-editor/after.png b/docs/screenshots/search-editor/after.png new file mode 100644 index 0000000..2241f72 Binary files /dev/null and b/docs/screenshots/search-editor/after.png differ diff --git a/docs/screenshots/search-editor/before.png b/docs/screenshots/search-editor/before.png new file mode 100644 index 0000000..e2903ce Binary files /dev/null and b/docs/screenshots/search-editor/before.png differ diff --git a/docs/screenshots/search-editor/folder.png b/docs/screenshots/search-editor/folder.png new file mode 100644 index 0000000..598a4de Binary files /dev/null and b/docs/screenshots/search-editor/folder.png differ diff --git a/docs/screenshots/search-editor/results.png b/docs/screenshots/search-editor/results.png new file mode 100644 index 0000000..d51980c Binary files /dev/null and b/docs/screenshots/search-editor/results.png differ diff --git a/scripts/capture-screenshots.sh b/scripts/capture-screenshots.sh index 5eb3adf..2decf0f 100755 --- a/scripts/capture-screenshots.sh +++ b/scripts/capture-screenshots.sh @@ -57,7 +57,7 @@ adb install --no-streaming -r "$test_apk" api_token=$(cat "$server/api-token") if [[ "${GITHUB_ACTIONS:-}" == true ]]; then printf '::add-mask::%s\n' "$api_token"; fi adb shell am instrument -w -r \ - -e class io.archivebox.app.BrowserSessionIntegrationTest,io.archivebox.app.ArchiveBoxJourneyTest,io.archivebox.app.WidgetJourneyTest,io.archivebox.app.VisualProfilesTest \ + -e class io.archivebox.app.BrowserSessionIntegrationTest,io.archivebox.app.ArchiveBoxJourneyTest,io.archivebox.app.WidgetJourneyTest,io.archivebox.app.VisualProfilesTest,io.archivebox.app.ServerSearchIntegrationTest \ -e serverUrl "$server_url" \ -e apiToken "$api_token" \ io.archivebox.app.test/androidx.test.runner.AndroidJUnitRunner | tee artifacts/instrumentation.log