Repository navigation
Conversation
The ink button is the iOS InkButtonStyle: a full-width capsule in the primary text colour, at least 52 dp tall, that dims to 30% when disabled and shrinks to 98% while pressed. The tonal button stands in for the iOS glass button style. Android has no Liquid Glass, so it is a neutral Material tonal capsule. The provider button is built on it and announces "<title>, loading" while it shows a spinner, as on iOS.
…badges Error text reads "Error: <message>" to TalkBack, the section header is marked as a heading, and the stat label reads the full number and its noun, as on iOS. The badge is the iOS GlassBadge without the glass: white text on a 55% black capsule, the same fill iOS uses for its non-glass duration pill. The stat label takes its display text from the caller for now: the compact count formatter belongs to capkit, and the app does not depend on capkit until the image pipeline brings it in. Icons are Material Symbols copied in as vector drawables (Apache 2.0), so no icon library is added. The README licence table lists them.
ToastCenter shows one toast at a time and a new one replaces the current one. A toast leaves after 2.4 s, or 4 s for errors, and a tap dismisses it. The host slides it in from the top with the iOS spring, plays a confirm or reject haptic once per toast and marks it as a polite live region so TalkBack announces it. The surface is a Material tonal capsule where iOS uses Liquid Glass. The error overloads that take an API error are left until the app depends on capkit, which holds the error model. kotlinx.coroutines 1.11.0 becomes a direct dependency, with kotlinx-coroutines-test for the timing tests, which run on virtual time. Both are Apache 2.0 and listed in the README. The app's unit tests run with ./gradlew :app:testDebugUnitTest, which the standing check line does not include yet.
…on and thumbnail Images load through Coil 3 on OkHttp with a 96 MiB memory cache and a 150 MiB disk cache. Cache keys include the pixel size, and thumbnails ask for a width rounded up to the next 160 px, as on iOS. A network interceptor applies the iOS rules on every hop, redirects included: the Bearer header goes only to the Cap origin, Authorization and X-Cap-Video-Access are removed from any request that leaves it, a request to another origin must be HTTPS, and a body over 25 MiB fails. Its tests run against loopback HTTP and HTTPS servers. They are built on ServerSocket because Android unit tests compile against android.jar, which has no com.sun.net.httpserver. The avatar, organisation icon and thumbnail follow RemoteImage.swift: initials or a person icon on CapBlue, the first letter on a neutral square, and a 16:9 thumbnail with the duration and Protected badges and the upload overlay. The thumbnail takes its duration text from the caller, as the stat label does. The last commit of this layer moves both onto capkit's formatters. Departures from iOS: the disk cache evicts least recently used entries at 150 MiB and has no 30 day age limit, because Coil's cache has none, and it stores the downloaded bytes rather than a re-encoded JPEG. The image fade becomes a duration in milliseconds because that is what Coil takes. A thumbnail whose upload has failed hides the placeholder play glyph under the overlay; on iOS the glyph stays and the warning icon is drawn over it. The app now depends on capkit for CapEnvironment and the models, and asks for the INTERNET permission. Coil 3.6.3 and OkHttp 5.5.1 are Apache 2.0; the README licence table and its artefact count are updated.
EmptyState is the one composable that stands in for every iOS ContentUnavailableView: an icon, a title marked as a heading, an optional description and optional actions. The skeleton pieces follow the iOS loading placeholder: a filled block, a text line drawn as a bar the size of its text, and a shimmer that pulses the opacity between 1 and 0.55 every 0.9 s. The shimmer is skipped when the system animation scale is zero, which is how Android expresses Reduce Motion.
The app now starts into a navigation bar in the iOS tab order: Caps, Record, Analytics, Settings. Caps, Analytics and Settings are placeholder pages. Record is never selected: it opens a placeholder page over the whole shell and closes with its Close button or Back, leaving the tab that was showing, as the iOS full screen cover does. Each tab has its own Navigation 3 back stack, saved across configuration changes, and every stack shares one set of destinations so later layers can push a Cap from any tab. Back on Analytics or Settings returns to Caps, the Android convention; iOS has no counterpart. The toast host sits over the tabs and under the recorder page, as on iOS. The shell is hidden from accessibility services while the recorder page covers it. Navigation 3 1.2.2 (runtime and ui) is Apache 2.0. The app applies the Kotlin serialization plugin because saved back stack keys are serializable. The README licence table and artefact count are updated.
GalleryActivity exists only in debug builds and shows every design system component: buttons, error text, section header, stat label, badges, toasts, avatar, organisation icon, thumbnails, empty state and skeleton. Intent extras pick one section, force light or dark and set a font scale. Its sample images come through the real image pipeline from an HTTP server the activity runs on the device's loopback address, so no network is needed. GalleryTest launches the gallery in light, in dark and at font scale 2.0 and fails if any text or labelled node is clipped by a parent, loses lines or is truncated. It also pins the accessibility labels that come from the iOS inventory. MainShellTest drives the tabs, the Record page and Back. Both run with ./gradlew :app:connectedDebugAndroidTest. The Compose rules are the v2 ones because the originals are deprecated in Compose 1.13 and warnings are errors here. Compose UI test, AndroidX Test ext JUnit 1.3.0, runner 1.7.0 and Espresso core 3.7.0 are test only and Apache 2.0; Espresso brings in Hamcrest library 1.3 (New BSD). The README documents the gallery, the tests and the licences.
… capkit The stat label and the toast centre were added before the app depended on capkit, so the label took its display text from the caller and the toast centre had no error overload. The thumbnail took its duration text the same way. The stat label now shows CapFormat.count of its value and the thumbnail shows CapFormat.duration of the Cap's duration, as the iOS components do. ToastCenter.show takes a CapApiError: it shows the error's description with the warning icon as an error toast, and shows nothing for a cancelled request, as on iOS. This is one commit more than the nine planned for this layer.
The app module now has JVM unit tests of its own (the toast timing, the image request rules and the thumbnail). The Android job and the standing check line only ran capkit's, so nothing in CI would have caught a break in them. Both now include :app:testDebugUnitTest, and the README and the plan quote the same line.
… is expanded The 25 MiB limit counted bytes inside the network interceptor. OkHttp asks for gzip on its own and expands the reply after network interceptors have run, so the count was of compressed bytes: a reply of a few kilobytes could expand to any size and reach the decoder and the disk cache. The limit now runs as an application interceptor, on the body the image loader actually reads. The rules for where credentials go stay in the network interceptor, where they are applied to every redirect hop. Two tests send gzip replies from the loopback server: one whose compressed size is under the limit and expanded size over it, which must fail, and one the other way round, which must load.
Every image loader opened a disk cache of its own on the same directory. The debug gallery builds a loader each time it is created, beside the application's, and Coil requires that only one cache is open on a directory at a time or its journal can be corrupted. The cache now belongs to AppServices, one per process, and every loader is given it.
Avatar and OrganizationIcon took the first UTF-16 unit of a name, so a name that starts outside the basic plane showed half a surrogate pair and a letter lost its combining mark. iOS takes the first Character, which is a whole grapheme. Initials are now built by initials() and firstCharacter(), which read up to the first character boundary from java.text.BreakIterator. Two of the four JVM tests failed before the change. Joined emoji and flags depend on the device's ICU data, so those two cases run as an instrumented test.
… reads ErrorText draws 13 sp text in the scheme's error colour. In the light theme that was #FF3B30 on white, a contrast of 3.55 to 1, under the 4.5 to 1 that small text needs. It is now #D70015, which measures 5.38 to 1 on the white surface and 4.83 to 1 on the grouped surface. The dark theme's #FF453A already measures 6.16 to 1 on black and is unchanged. ColorContrastTest computes the ratio for both schemes; the light case failed at 3.55 before the change.
The gallery now shows an empty state whose description is one long URL, so the test proves that text with no break opportunity wraps inside its box in both themes and at font scale 2. The test does not assert didOverflowWidth. The layout that the semantics action returns is measured at the node's widest allowed width and always wraps, so that flag is true for ordinary labels: "Buttons" measured 107 px in a 996 px layout. Text that does not wrap is caught by the existing height check instead: a temporary Text with softWrap = false failed all three gallery tests with "loses lines" (node 58 px tall, layout 156 px). A short comment in the test records why.
… drops GalleryImageServer answers on one thread and let any IOException from a connection escape it. A client that resets its connection, which an image request cancelled mid-flight does, ended the thread with an uncaught exception and took the debug app down with it. The loop now drops that connection and waits for the next one. GalleryImageServerTest resets twenty connections and then asks for the image. Before the change the run ended with "Process crashed" and a "SocketException: Connection reset" in the crash log.
The session is the API key and the user id, as on iOS. CredentialStore seals them with AES-GCM under a key that lives in the Android Keystore and writes the result to a file in the no-backup directory, so the key is not readable on disk and the file is left out of backups and device transfers. A file that cannot be opened, or that holds an implausible key or user id, reads as no session. A Keystore key can stop working, after a system update or a restore for example. Reading with such a key gives no session. Saving replaces it: when the key cannot seal the session, its entry is deleted, a new key is made and the save is tried once more, so the next sign-in works instead of failing every time. CredentialVault is the port of the iOS vault: it reads the store once, keeps the session in memory, and clear(ifMatching) only removes the session it is given, which is what lets a late 401 from an old key leave a newer session alone. Two departures from iOS. The store also records the server the session belongs to and reads nothing back for a different one, because a debug build can be pointed at another server and a saved key must not follow it there. And there is no locked state: the app is not direct-boot aware, so it never runs before the first unlock, and of the three iOS CredentialVaultTests readsAgainAfterALockedKeychain has nothing to test here. The other two are ported by name. The unit tests run on the JVM against real files with a software AES key. The instrumented tests save and read a session through the real Keystore key, check the bytes on disk, and save over a key that cannot be used for this cipher.
…guard AppModel holds the phase the root of the app will switch on: signed out, or signed in with the session. It starts from whatever the vault read at launch, so a saved session is restored without a request, and completeSignIn saves a new session before it changes the phase. A session that cannot be saved leaves the app signed out. It is a ViewModel so that it outlives a configuration change; lifecycle-viewmodel is already on the classpath through AndroidX Activity. AppServices now takes the environment, builds the vault for it, and gives the image pipeline the saved API key, which until now it had no source for. The session file is in the no-backup directory, which the platform never backs up or transfers. The two rule files and allowBackup already exclude everything, and BackupRulesTest now pins that for cloud backup, device transfer and the older rule format, so opening backup up for other data later cannot quietly take the session with it.
The root of the app now switches on the phase: the sign-in screen when signed out, the tab shell when signed in, with the 0.3 s cross fade iOS uses and the shell rebuilt whenever the API key changes. The sign-in screen is the iOS column: hero, title and subtitle, and the legal line, capped at 520 dp. The hero takes half of the height the rest leaves, between 96 and 300 dp, and once it is at its minimum the column scrolls, which is the iOS fit rule. The window resizes for the keyboard so the same rule applies with it up. The hero is the final lockup of the iOS animation, the logo beside the wordmark at the same proportions, with a short fade in. It does not animate when the system animation scale is zero. The two images are the iOS assets converted to WebP without loss. They sit in nodpi folders and are sized in dp by the layout. Terms and Privacy Policy open in a Custom Tab, the counterpart of the in-app Safari sheet. That is the first use of AndroidX Browser, pinned at 1.10.0, the newest stable release on Google Maven on 1 December 2026, Apache 2.0 by its POM. It adds one artefact to the release classpath, which the README now counts. MainShellTest saves a session before it starts the activity, since the app no longer opens on the shell without one.
SignInModel is the port of the iOS model, starting with its first step: the email field, "Continue with email", and the request for a code. An address that fails the capkit validator is refused before any request with "Enter a valid email address.", the address is normalised before it is sent, and a success moves to the code step, which for now shows where the code went and a way back. The step change slides and fades with the iOS spring. The model lives in the signed-out phase, so AppModel now takes the API client and a scope and makes a fresh model each time the app is signed out. AppServices builds the client, with the user agent "Cap-Android/<version> (<build>)" in the shape of the iOS one. The field uses the state-based text field, because the value-based one is deprecated in this Compose release and warnings are errors. It asks for an email keyboard with no capitals or correction, offers itself to password managers as a username, and carries the label "Email address". While the field has focus, it and the button under it are kept clear of the keyboard, and an error is scrolled into view when it appears and when the keyboard opens over it. Left alone, the text field keeps only its cursor line visible, which on a small screen with large text left the lower edge of the field and the whole button under the keyboard. The model tests send real requests to a loopback server. They run the model on a scheduler that only moves when the test moves it, so later timers cannot run ahead while a test waits for a reply. The loopback server now records the method and the body as well. The mail icon moves from the debug gallery to the app, which now uses it too.
The second step of the iOS sign-in screen: six boxes for the code, "Verify and sign in", "Different email" and "Resend code". The six boxes are drawn over one text field, as on iOS, so the keyboard, paste and one-time-code autofill all see a single field. It keeps digits only and stops at six. A screen reader hears "Verification code" with the digits spaced out, or "Empty". Typing the sixth digit verifies without a tap, and the button does the same. A correct code hands the session to AppModel, which saves it in the vault and moves the app to the signed-in phase. If the session cannot be saved the app stays signed out and says "Cap couldn't save your session securely. Try again." An error under the boxes is scrolled into view when it appears, so the keyboard cannot hide it. A new code can be asked for 30 seconds after the last one was sent, and the button counts down until then. A code the server refuses clears the boxes and ends the wait, so another can be requested at once. The model takes its clock as a parameter, so the tests move the countdown themselves instead of waiting for it.
"Continue with Apple" and "Continue with Google" open the server's session request page in the browser, as the iOS buttons do. The two buttons follow /api/mobile/session/config and are both shown until it answers. The page opens in an Auth Tab with ephemeral browsing asked for, the nearest match to the iOS web authentication session. A browser that supports Auth Tab hands the cap://auth redirect straight back to the app. One that does not opens a plain Custom Tab, and the redirect arrives through a new intent filter for cap://auth. MainActivity is singleTask so that intent reaches the running activity and closes the tab under it. The server's redirect cannot carry a state value, so the callback is trusted only while a provider sign-in this app started is waiting. Any other cap://auth link is dropped: with nothing pending, after the browser was closed, a second time, or when the app is already signed in. Closing a fallback tab is reported before its callback intent, so the cancel is applied in onResume, after the intent has been read. A callback with an error shows the provider's message, one without a plausible session shows "Sign in did not return a Cap session. Try again.", and a browser that cannot be opened shows "Sign in couldn't start. Check your connection and try again." The Google mark moves from the debug gallery to the app. The Apple mark is the simple-icons drawing, which is CC0, because the iOS button uses a system symbol that Android does not have. The README lists both.
The email flow now answers a failure with the wording of the iOS app instead of the general message for the status. A rate limit says "Too many attempts. Wait a few minutes and try again." on both steps. A code the server refuses with 400, 403 or 404 says "That code didn't work. Codes can be used once and expire after a few minutes, so request a new one." A refused request for a code says "This email can't sign in with a code. Try another sign in option." for 403 and "Enter a valid email address." for 400. Resending is a request, so it uses the request wording. Everything else keeps the general message.
A 401 on any signed request now ends the session, as on iOS. The API client reports the session it sent, AppServices queues it, and AppModel clears the vault only if that is still the saved session, so a late reply for an earlier session cannot sign out a newer one. The app then returns to the sign-in screen, which shows "Your session expired. Sign in again." above the email field until the next error or sign-in replaces it. The image caches, in memory and on disk, are emptied at the same time, because they may hold another account's thumbnails.
The Settings tab now holds a real page with two rows from the iOS one: Version, shown as "1.0.0 (1)", and Sign out. It is the smallest page that lets the whole sign-in flow be driven by hand. The rest of the iOS page comes with the settings layer. Sign out asks first. The question is "Sign out of Cap on this device?", the wording the plan proposes in place of "on this iPhone", and it is a dialog, the Android counterpart of the iOS confirmation sheet. Signing out asks the server to revoke the key and gives it four seconds, as iOS does. Whatever the answer, or with none, the saved session is then deleted, the image caches are emptied and the app returns to the sign-in screen with no notice. A second tap while this runs does nothing. The info and logout icons are Material Symbols, like the others.
Debug builds now read two extras from the intent that starts MainActivity, the Android form of the iOS launch variables CAP_API_BASE_URL and CAP_DEBUG_SESSION: --es capApiBaseUrl http://localhost:4310 --es capDebugSession <API key>:<user id> The first points the app at another server for the rest of the process. It goes through the same parser as every other server address, which takes https anywhere and http only on a local development host. The second saves a session before the first screen, and only when that server is a local development host, with a plausible key and a valid user id, the rules of the iOS seed. iOS reads its variables from the process environment. An Android process has no launch environment to set from adb, so the extras are read as the activity is created, by an Application subclass that exists only in the debug source set and replaces the application class in the debug manifest. To let it swap the services, CapApplication now owns the image disk cache, which must be opened once per process, and hands it to each AppServices it builds. Neither name appears in the release APK: its dex files hold no capApiBaseUrl, capDebugSession or DebugCapApplication string.
Instrumented tests for the whole flow, on the fixture server the iOS UI tests use. They start MainActivity with the debug launch arguments and type into the real screens. signIn is the port of the iOS testSignIn: an email, "Continue with email", the code 123456, then the Caps tab, with the session read back from the vault file. The others cover what the plan asks of this layer: the invalid email message, a wrong code, the code read out digit by digit, the resend countdown, "Different email", a relaunch that stays signed in, sign-out from Settings back to sign-in, and a session the server rejects, which returns to sign-in with the expired notice. Two tests hand MainActivity a cap://auth intent, one with no provider sign-in pending, which is ignored, and one after the app started one, which signs in. Nothing sleeps or polls. An idling resource tells the Compose rule the app is busy while the sign-in model has a request in flight or a sign-out is running, so each assertion waits for the reply it depends on. The countdown test waits the same way for the first tick. KeyboardSettled is a second idling resource, in its own file so later tests can use it. The keyboard slides in and out on the system's clock, which the Compose test clock does not wait for, and it moves the layout while it does. The resource is busy from the moment an inset animation for the keyboard is prepared until it ends, which it learns from a WindowInsetsAnimationCompat callback on the activity's decor view that lets the views below go on receiving the animation. It is also busy while a text field has focus and the keyboard is not yet visible, or the reverse, which covers the time between asking for the keyboard and the start of its animation. A focused field may never show a keyboard where a hardware keyboard is attached or no input method is enabled, so there only the animations count. On API 37 a hardware keyboard does not stop the keyboard from showing, so on such a device the time between asking for the keyboard and the start of its animation is not guarded. With the keyboard settled, a control in the scrolling column is scrolled to, checked with assertIsDisplayed and pressed with a pointer click, and content is checked with assertIsDisplayed, so the tests prove the controls are on screen and can be hit, on a small screen as well as a large one. After "Continue with email" the step waits on the sign-in model's own answer: a third idling resource, registered for that step only, is idle once the model is on the code step or holds an error message. The test then asserts there is no error, with the message as the failure, so a reply that never arrives as a success names itself instead of reading as a heading that is not displayed. Measured on the final file with the soft keyboard on: the whole SignInTest class ran 130 times on API 37 and 130 times on API 29, 11 tests each, with no failing run, and the whole instrumented suite ran once on each, 24 tests with 0 failures. The crash buffers were empty after every run. The fixture address defaults to http://localhost:4310 and can be set with the capFixtureUrl instrumentation argument. The README says how.
The pending Google or Apple sign-in lived only in the sign-in model, so if Android killed the app while the Auth Tab or browser was in front, the recreated model had nothing pending and dropped the returning session. AppModel now takes the activity's SavedStateHandle and keeps the provider's name and the wall-clock time it started there while a provider sign-in is pending. The sign-in model reports each change, and the marker is removed when the sign-in finishes, fails or is cancelled. A recreated AppModel restores the pending sign-in only if the marker is no more than 10 minutes old and not in the future, and removes it otherwise, so a link arriving long after the app was left is still ignored. Ten minutes covers a slow provider sign-in with a second factor; a longer wait starts again. The Auth Tab result is redelivered by the activity result registry after the activity is recreated, and the cap://auth fallback reaches the singleTask activity through onNewIntent, both after the saved state is back. MainActivity also reads a cap://auth link from its launch intent when it starts without saved state, so a recreated activity does not replay an old intent. Links nobody asked for are still ignored.
completeSignIn saved the session on the main thread, and a save goes through Android Keystore, may generate a replacement key, encrypts the payload and writes the file, so a slow Keystore or disk held up the screen. completeSignIn is now a suspend function that does vault.replace on Dispatchers.IO and changes the phase back on the caller's dispatcher, which is main in the app. The sign-in model's session callback is suspend too. A provider callback is parsed at once, then saved in a coroutine with the model busy as Verifying, so a second callback, a cancel or another sign-in is refused until the save ends. A save that fails still shows "Cap couldn't save your session securely". The vault still reads the saved session when the app starts, before the first frame, as the iOS app reads the keychain when its AppModel is created. That way a signed-in user never sees the sign-in screen first.
AppModel's SavedStateHandle was created from the activity's default creation extras, which carry the launch intent's extras as default arguments. On a start without saved state those arguments seed the handle, and MainActivity is exported, so another app could start it with a cap://auth link for its own session plus pendingProvider and pendingProviderSince extras. The forged marker restored a pending sign-in, onCreate opened the link, and the user was signed in to the other account. The handle is now created with empty default arguments, so it only ever holds state this app saved. Saved state from a recreated activity still restores, because it takes precedence over default arguments. SignInTest launches MainActivity with exactly that intent and checks that the app stays on sign-in with nothing saved. It fails without this change and passes with it.
signingOutRevokesTheSessionAndForgetsIt checked that the image caches were emptied as soon as the sign-out job finished, but the removal is started by finishSignOut as a separate coroutine. On the test's unconfined dispatcher the sign-out resumes on the HTTP client's thread after the revoke, and the removal is queued behind it on that thread, so the test could resume from join() and read the count before the removal ran. The fake removal now completes a deferred and the test awaits it before asserting. Looping the test alone 20,000 times in one JVM with every core busy, it failed 21 times before this change and 0 times after.
…to p06-finish2/playback
… p06-finish2/social
…into p06-finish2/management
|
@greptileai review |
| } | ||
| Column(modifier.fillMaxSize()) { | ||
| if (showsLibraryChrome) { | ||
| LibraryHeader(session, library, onAdd, showsDetails = !showsDesignedEmpty) |
There was a problem hiding this comment.
Empty libraries hide navigation
When the current library is empty, showsDetails = !showsDesignedEmpty hides ScopeBar along with the count. A user who selects an empty space loses both the space tabs and the organization picker, so they cannot return to their other Caps. No other screen offers these controls.
Keep ScopeBar visible when hiding the empty library’s count.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/mobile-android/app/src/main/kotlin/so/cap/mobile/features/home/LibraryContent.kt
Line: 117
Comment:
**Empty libraries hide navigation**
When the current library is empty, `showsDetails = !showsDesignedEmpty` hides `ScopeBar` along with the count. A user who selects an empty space loses both the space tabs and the organization picker, so they cannot return to their other Caps. No other screen offers these controls.
Keep `ScopeBar` visible when hiding the empty library’s count.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| } | ||
|
|
||
| private fun apply(first: CapsPage, asked: Int) { | ||
| caps = sortedCaps(edits.shown(first.caps, asked)) |
There was a problem hiding this comment.
Refresh breaks the chosen order
After a user loads all pages and chooses OLDEST, NAME, or another sort, refreshing replaces caps with only the newest server page but keeps that sort. Meanwhile, hasMore hides the sort control. The user sees a partly sorted collection and cannot change its order until they load every page again.
Reset to NEWEST when returning to a partial collection, or reload the whole collection before applying the saved sort.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/mobile-android/app/src/main/kotlin/so/cap/mobile/app/LibraryModel.kt
Line: 245
Comment:
**Refresh breaks the chosen order**
After a user loads all pages and chooses `OLDEST`, `NAME`, or another sort, refreshing replaces `caps` with only the newest server page but keeps that sort. Meanwhile, `hasMore` hides the sort control. The user sees a partly sorted collection and cannot change its order until they load every page again.
Reset to `NEWEST` when returning to a partial collection, or reload the whole collection before applying the saved sort.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
@greptileai review |
Stacked on the comments and transcript PR (#4745), which sits on the earlier Android PRs. Only the top 24 commits are new here, from
07598d584onwards. Once the PRs below merge this shows only its own diff.This PR adds sharing and managing a Cap to the Android app.
What is in it
Managing a Cap from its page, as in the iOS app: a Share button and a More menu in the top bar, with the owner's actions and, on someone else's Cap, report and block.
Fixes from review
A refused sharing change undoes only sharing. When the server refused a change of who can view, the page put back the whole Cap from before the request. Rename and password stay available while sharing saves, so a rename that had landed meanwhile was reverted on the page and no longer matched the library. Only the public setting and link access are now rolled back, on the page's current Cap. CapManagementTest holds the sharing reply, renames, then refuses sharing, and checks that the new title stays while sharing is undone.
A cancelled download leaves no file. The video file was created inside the IO block and deleted only on an I/O error. A cancellation after the copy had finished, or an interrupt during it, dropped the result, so nothing deleted the file and a whole video stayed in the cache. The file is now created before the block and deleted on any failure or cancellation. SaveToDeviceTest cancels the download once the body is written, by holding the caller's dispatcher, and checks the cache folder is empty.
Delete and block close the page whatever happens to the screen. The page waited for the reply in the menu's own scope, so a rotation while the request was out cancelled the wait: the server still deleted the Cap or blocked the owner, but the page stayed open on it. The page now closes when the Cap is recorded as gone, whoever started the request. CapManagementTest holds the delete reply and checks the page is marked gone only once the server has answered, and that a refused delete keeps it open.
Edits finish after leaving the Cap. Rename, report, block and save to device ran in the Cap page's own scope, which is cancelled when the page leaves the back stack. The dialogs close on confirm, so going back straight away cancelled the request: the library kept the old title or the blocked owner's Caps, and a save stopped silently. They now run in the session's scope, as delete and sharing already did, and only the update to the page is skipped once it has gone. CapManagementTest holds the rename and block replies, closes the page, releases them, and checks the library.
An overtaken sharing reply no longer wins. If the page changed who can view a Cap and the library changed it again before the first reply came back, the page took the first reply although a newer change had replaced it. A sharing change now reports whether it was saved, refused or overtaken, and an overtaken one shows the newest choice. CapManagementTest runs the two changes with the replies out of order and checks the page.
The password sheet keeps its saving state when the phone turns. The sheet held whether it was saving in its own composition, so a rotation while a password was being saved dropped the spinner and let Save be pressed again. Whether a password is being saved now lives with the Cap's actions, and a second save while one is out is ignored. CapManagementTest holds the password reply, checks the Cap shows as saving and that a second save is refused, then releases it and checks one request was sent.
The keyboard check in the instrumented tests works on API 29. Before API 30 a dialog that floats above the keyboard is never told about it, so the tests' keyboard check waited for ever once the rename dialog's field had focus, and CapMenuTest timed out on API 29. A keyboard shown by any window of the app now counts there. This changes only the tests.
A reply only changes what its action changed. Each action put the whole Cap from its reply on the page and in the libraries, so a sharing reply the server built before a rename finished, but that arrived after it, put the old title back, and a rename or password reply could likewise undo a newer sharing choice. A sharing reply now applies only who can view, a rename only the title and a password change only whether the Cap is protected, each onto the Cap as it is when the reply arrives. CapManagementTest holds one reply, lets the other action finish, then releases the first, in both orders, and checks the page and the library.
Passwords that cannot unlock are refused. The server saves a password of any length but refuses to unlock with one over 512 characters, which is also the most the password page sends. The sheet now says passwords can be up to 512 characters and keeps Save off until the password fits, and setting a longer one sends nothing. CapManagementTest checks that 513 characters are not sent and 512 are.
The password sheet closes after a save that outlives the screen. The sheet closed itself from a coroutine in its own composition, so if the activity was recreated during a save, the save finished but the restored sheet stayed open. Whether the last password change saved now sits next to whether one is being saved, and the menu closes the sheet when it sees a saved one. A new CapMenuTest test holds the password reply, recreates the activity, releases the reply and checks the sheet has gone; it fails without the fix.
A page read that started before a change no longer undoes it. A refresh or status poll that left before a rename, a password change or a sharing change, and answered after it, put the old title, password state or sharing back on the page and in every library. Each change to the Cap from its page is now counted with the page's comment edits, and a read that left before the latest change takes the Cap from its reply but keeps the page's title, password state and sharing, so a Cap that finished processing meanwhile still shows as finished. The libraries get only the server's fields from such a read and keep their own title, password state and sharing, so a sharing change made from the library while the read was out stays. Three new CapManagementTest cases hold the refresh's reply, rename, then release it: one checks the title on the page and in the library, one that a Cap whose reply says it has finished processing is no longer shown as processing, and one that the library keeps a Make private done while the reply was held. Each fails without its fix.
The overtaken sharing test no longer waits on a timeout. Both sharing changes for one Cap take the same lock, and the test waited for the library's change before releasing the page's held reply, so it only finished when that request timed out after 30 seconds. It now releases the held reply first, and takes under a second. This changes only the test.
Every new test except the two delete tests fails without its fix; those cover a new way of closing the page.
Screenshots
Taken on the API 37 emulator. This emulator image cannot decode video, so the player shows its "This video can't play right now." card; that is not part of this PR.
More menu for the owner, Rename, Add password and Delete
The toast after "Make private", and the Edit and Analytics placeholders
Someone else's Cap: the More menu, Report and Block owner
Where it differs from iOS, on purpose
Tests
:app:testDebugUnitTest: 364 tests, 33 of them new: CapManagementTest 28, SaveToDeviceTest 4, and 1 more in CapActionsTest.:capkit:test: 144 tests, unchanged.On the emulators, at
393a4c706: the same 17 commits, one test-only relay commit in the PR below earlier.80facf628, with the same PR 8 changes on an earlier version of the PR below.dc0759286, after the last three fixes from review: CapMenuTest once on each of API 29 and API 37, 8 tests each, 0 failures, and no crash from the app.Checked
d4fa97fae, the last commit: capkit 146 and app 393 unit tests pass, with spotlessCheck, the debug build and the androidTest sources../gradlew spotlessCheck :capkit:test :app:testDebugUnitTest :app:lintDebug :app:assembleDebug :app:assembleRelease :app:assembleDebugAndroidTestpasses on the last commit, on top of the comments and transcript PR.Not checked
Confidence Score: 4/5

The PR still needs the empty-library navigation fix before merging.
Findings
Fix with agent prompt
Summary
This PR adds sharing and Cap management to Android. The latest change adds a test that checks Download remains available to a viewer with permission.
Reviews (14) · Last reviewed commit: "test(mobile-android): cover team member ..." · Reviewed by Greptile