Skip to content

K2GO-588 feat(privacy): with Keep offline, actions ask once, box services stay off, catalogs follow the choice - #814

Merged
luisguzman-adfa merged 16 commits into
mainfrom
feat/K2GO-588-offline-actions
Nov 22, 2026
Merged

luisguzman-adfa merged 16 commits into
mainfrom
feat/K2GO-588-offline-actions

Conversation

@luisguzman-adfa

@luisguzman-adfa luisguzman-adfa commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

With the one privacy choice off ("Keep offline", PR 1), the app and the box do not connect on their own. This PR makes the rest of that real:

  • Actions that need the internet ask first. NetworkPolicyGate shows "This needs the internet" with Keep offline (primary) and Allow only this time. Nothing is stored: the next action asks again. After an allow, the metered-data check runs as before.
  • No order is banked without an allow. ZIM, Books and Kolibri orders are banked only after an allow (or a metered "Not now"), never on Keep offline or with no network. Before, a banked order could drain later and connect for an order the user did not allow. New guardOrder(...) gives these callers a separate onKeptOffline path.
  • Grey but tappable. Controls that need the internet look grey while the app is kept offline (wizard Internet download and Continue, Get More confirms, maps, Rebuild, module update actions, Check for updates). A tap goes through the gate.
  • Catalogs refresh on their own again when the choice is on. The ADR-5094 / K2GO-390 mechanism is back: weekly + a TTL-gated check on open, Wi-Fi only, ETag, failure backoff. With Keep offline the jobs are cancelled, and the worker reads the choice when it runs. The forced check on a download 404 stays (it is part of the download the user started). The "Update catalogs" row is removed.
  • Box services stay off. KeepBoxOfflineUseCase sets off every box service that reports outbound on (Kolibri, Forgejo). It runs at app open (before the pending restarts apply) and when the Privacy screen loads. The switches are locked; a tap tells where to change the choice (Settings > About).
  • Feedback. Settings > Send feedback: Send and Test crash report look grey but stay tappable; a tap shows a snackbar with the reason and where to change the choice. The floating feedback button looks grey; a tap shows "This can connect to the internet" with Keep offline (primary) and Send anyway.
  • Snackbars show up to 5 lines (util/Snackbars), so long messages and translations are not cut at the Material default of 2.

Why

K2GO-588: "Keep offline" must mean real network silence for the app and the box, with a clear way to allow one action.

Steps to QA

  1. Fresh install, choose Keep offline in the wizard. "Internet download" looks grey. Tap it, choose an edition, tap Install: the dialog shows. Keep offline: nothing starts. Allow only this time: the install starts.
  2. Get More > Wikipedia, pick a ZIM, tap the download button: dialog. Keep offline: the picks stay in the cart and nothing is queued. Allow only this time: the download starts.
  3. Turn off Wi-Fi and mobile data, repeat step 2: "No network" snackbar, nothing is queued.
  4. Settings > Privacy (box with Kolibri/Forgejo): the switches are off and locked; a tap on a row shows the note.
  5. Settings > Send feedback: Send and Test crash report look grey; a tap shows the snackbar. The floating feedback button is grey; a tap shows the warning.
  6. Settings > About: turn the choice on. Check for updates and the feedback button are no longer grey.
  7. With the choice on and Wi-Fi: adb shell dumpsys jobscheduler | grep catalog-refresh shows the weekly jobs. With Keep offline at the next launch they are gone.

Verifications

  • :app:lintStandardDebug, :app:testStandardDebugUnitTest, :app:assembleStandardDebug, :app:compileFdroidDebugJavaWithJavac: pass.
  • New unit test KeepBoxOfflineUseCaseTest (3 cases).
  • Two-pass code review done. Pass 1 found that a ZIM/Books order was banked with no network under Keep offline; fixed. Pass 2: OnlineConsent stays the one source; the box keeps its own state in each service config; the catalog jobs and the box switches have an owner that sets and clears them.
  • Device test on the OnePlus 7T (Android 16), fresh install with Keep offline:
    • Wizard: "Internet download", Continue and the feedback button look grey; Install shows the dialog; Keep offline starts nothing; Allow only this time installs (Basic, 1.5 GB).
    • No WorkManager job exists with Keep offline. Choice on + Wikipedia picker: catalog-refresh-kiwix ENQUEUED (UNMETERED, 7 days) and the check now SUCCEEDED. Choice off + picker: the weekly job is CANCELLED.
    • ZIM "dom" (14 MB): Keep offline leaves k2go_zim_wishlist empty and the pick in the selection; Allow only this time banks it and starts ZimDownloadService.
    • Settings > About: Check for updates and the feedback button turn grey/normal with the switch. Send feedback: tap shows the snackbar in full.
  • 2026-11-22, OnePlus 7T, one build of K2GO-588 feat(privacy): one choice for usage data, crash reports and automatic connections #815 + this PR + K2GO-588 fix(download): the rootfs download is HTTP only, never BitTorrent #813 on current main (lint of both flavors, unit tests, APK and F-Droid compile pass):
    • Update path: with the main build, Kolibri usage statistics and Forgejo update check were turned on (/k2go-api/system/privacy: outbound:true, pending:true). This build was installed over it without a data clear. At the first app open: outbound:false for both, pending:false.
    • Settings > Privacy: both switches off, disabled and not clickable; a row tap shows the snackbar in full. With the choice on in Settings > About, the switches are enabled again and the box stays off until the user turns one on.
    • Rebuild (dash-node) is grey; after its own confirm dialog the gate shows "This needs the internet". Keep offline: no rebuild (dash-node stays 1.6.4).
    • Light theme: About, Send feedback + snackbar, the floating button dialog, the gate dialog and Privacy (locked and unlocked) verified.

UI changes

New strings (translated to all 33 locales, machine translation for review):

  • "This needs the internet"
  • "You chose Keep offline. To do this, the app must connect to the internet. You can allow it for this action only."
  • "Allow only this time"
  • "The app is set to Keep offline, so it does not send feedback. To change it, turn on "%1$s" in Settings > About."
  • "This can connect to the internet"
  • "You chose Keep offline. Feedback is sent with another app, for example email, and that app can connect to the internet."
  • "Send anyway"
  • "The app is set to Keep offline, so these services stay off. To change it, turn on "%1$s" in Settings > About."

Removed: the "Update catalogs" row (button and status line) in Get More.
Light and dark: verified on device.

Notes

Review fixes (2026-11-22)

A code review found lifecycle gaps. Maintainer decisions and fixes (3ec3a21, 961ee56, 299645a, 04a7e52):

  • Saved orders wait for an allow (decision). OnlineAllowance: a saved order (ZIM, books, courses, maps, modules) connects only when the choice is on, or when the user allowed that kind at its commit point in this process. Every *Provisioner.hasPending and ContentAdmission read it, so a wishlist saved before Keep offline, by the wizard, or as a refused module no longer drains with no prompt. Pending downloads still lists it. Turning on Keep offline ends every allow. The allow lives in memory only, like SessionMeteredConsentStore (the precedent for this static state): a new process asks again.
  • After "Allow only this time", a metered "Not now" or no network saves nothing.
  • A change of the choice reaches the box and the catalog jobs at once. Keep offline switches every outbound service off and restarts only those; a failure of one service does not skip the others or the pending restarts at app open.
  • The locked Privacy switch shows the note on a tap on the switch itself.
  • The proot dash-node rebuild (older boxes) also goes through the gate; the dashboard Rebuild button keeps its grey look when its status loads.
  • Every hand-off of feedback to another app (floating button, disk-guard report, dash-node update failure, install failure) shows the Keep offline warning from one place, FeedbackFab.sendFeedback. Settings > Send feedback keeps its block with a snackbar (maintainer request).

Decisions recorded:

  • With Keep offline the catalogs are not refreshed by hand: the shipped catalogs plus the 404 self-heal.
  • The first open after the update applies Keep offline to the box before the user answers, so per-service ON states set before are not restored by themselves.

Known, not fixed: with held orders the progress screen ends as success while its rows say "Queued". Intermediate commit 299645a does not compile alone; the branch tip does.

Verifications for the fixes: lint (both flavors), unit tests (new KeepBoxOfflineUseCaseTest case: a failing service does not stop the others), APK and F-Droid compile; a second review pass on the fixes (its two bugs, wizard maps and the gate-open question, are fixed in 04a7e52 and #815). Device and PCAPdroid evidence: see #815 (Keep offline: 0 B, no connection; choice on: catalogs from k2go-download.appdevforall.org at once).

…nternet asks to allow it once

The gate shows Keep offline (primary) and Allow only this time. Nothing is
stored, so the next action asks again. A ZIM, Books or Kolibri order is banked
only after an allow or a metered decline, so a later drain never connects for
an order the user kept offline. Controls that need the internet look grey but
stay tappable (wizard, Get More confirms, check for updates).
…online choice is on

Brings back the ADR-5094 / K2GO-390 refresh: weekly plus a TTL-gated check on
open, Wi-Fi only, ETag conditional GET, failure backoff. With Keep offline the
jobs are cancelled, and the worker reads the choice when it runs, so a queued
job does not connect. The forced check on a download 404 stays, because it is
part of the download the user started. The Update catalogs row is removed.
…and their switches are locked

KeepBoxOfflineUseCase sets off every installed service that reports outbound
on. It runs at app open, before the pending restarts apply, and when the
Privacy screen loads. The box keeps the state in each service config, so the
app keeps no copy. The locked switches tell where to change the choice.
…othing and the button warns first

The Settings feedback screen disables Send and Test crash report and says
where to change the choice. The feedback button looks grey; a tap tells that
the app the user picks to send the report can connect, then continues or
cancels.
…anked; more controls look grey

The gate banked a ZIM or Books order when there was no network, so a later
drain could connect for an order the user never allowed. Rebuild and the
module update actions now also look grey while the app is kept offline.
…cales

Machine translation for review. The parked strings move from
strings_untranslated.xml to strings.xml.
…edback buttons explain on tap

The feedback button warning now says that this can connect to the internet,
with Keep offline as the primary choice and Send anyway as the other. On the
Send feedback screen, Send and Test crash report look grey but stay tappable:
a tap tells why and where to change the choice. Translated to all locales.
…left unused

34 strings in all 34 strings.xml files (the old consent screen, the legacy
setup and about screens, the Update catalogs row) and 2 drawables. Found
with lint UnusedResources against main; no other reference in any flavor.
@luisguzman-adfa luisguzman-adfa added the ui change or edit to UI label Nov 21, 2026
…erated assets

The merge brings main (K2GO-552). help.db, module_sizes.csv and
rootfs_sizes.csv are generated by the build and came into an earlier
commit of this branch by mistake. They are now the same as in main.
The Settings toggle keeps both changes: OnlineChoiceEffects applies the
choice, and the controls that need the internet are marked again.
- OnlineAllowance answers "may a saved order of this kind connect now": the
  choice is on, or the user allowed that kind at its commit point in this
  process. Every hasPending (ZIM, books, courses, maps, modules) and
  ContentAdmission read it, so a wishlist saved before Keep offline, by the
  wizard, or as a refused module no longer drains with no prompt. Pending
  downloads still lists it.
- After "Allow only this time", a metered "Not now" or no network keeps the
  order offline (nothing saved), as Keep offline does.
- The commit points (ZIM, books, Kolibri, maps, modules, wizard install) record
  the allow.
…ck rule

- The proot dash-node rebuild (older boxes) goes through the gate too.
- The dashboard Rebuild button keeps its grey look when its status loads.
- Every hand-off of feedback to another app (the floating button, the disk-guard
  report, the dash-node update failure, an install failure) shows the Keep
  offline warning in one place, sendFeedback.
… catalog jobs now

- OnlineChoiceEffects.apply also re-syncs the catalog jobs (one static entry
  per catalog owner; the Kolibri one runs once per process) and, on Keep
  offline, switches every outbound box service off and restarts only those.
- KeepBoxOfflineUseCase tries every service; a failure no longer skips the
  others or the pending restarts at app open.
- The locked Privacy switch has no click listener, so a tap on it shows the note.
…s the session allows

- The wizard install also allows maps, which the wizard can bank.
- Turning on Keep offline clears every allow of the session, so a queued order
  waits instead of draining.
- At Keep offline, one failed service restart no longer stops the others.
Base automatically changed from feat/K2GO-588-one-privacy-choice to main November 22, 2026 12:17
@luisguzman-adfa
luisguzman-adfa merged commit c84da99 into main Nov 22, 2026
2 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/K2GO-588-offline-actions branch November 22, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui change or edit to UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant