Split menu actions for smaller footprint

This commit is contained in:
jpirnay
2026-04-07 21:39:03 +02:00
parent abbf69649e
commit 6dd905fb5a
9 changed files with 255 additions and 50 deletions
+28 -7
View File
@@ -12,19 +12,37 @@
/**
* Activity for syncing reading progress with KOReader sync server.
*
* Flow:
* Shared pipeline:
* 1. Connect to WiFi (if not connected)
* 2. Calculate document hash
* 3. Fetch remote progress
* 4. Show comparison and options (Apply/Upload)
* 5. Apply or upload progress
* 2. Optionally sync NTP (if stale)
* 3. Calculate document hash
*
* Intent-specific behavior:
* - COMPARE: fetch remote progress, show full comparison screen, let user
* choose Apply or Upload.
* - PULL_REMOTE: fetch and map remote progress, show success feedback, then
* return applied SyncResult to reader.
* - PUSH_LOCAL: compute local mapping, warm session with GET, then upload via
* reused connection to avoid a second full TLS handshake.
*/
class KOReaderSyncActivity final : public Activity {
public:
// Intent controls UI/behavior split for the same sync pipeline.
// - COMPARE: fetch then let user choose apply/upload.
// - PULL_REMOTE: fetch and apply immediately.
// - PUSH_LOCAL: upload immediately.
// This keeps WiFi/NTP/hash/memory handling centralized while enabling a
// simpler KOReader-like reader menu UX.
enum class SyncIntent {
COMPARE,
PULL_REMOTE,
PUSH_LOCAL,
};
explicit KOReaderSyncActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
const std::shared_ptr<Epub>& epub, const std::string& epubPath, int currentSpineIndex,
int currentPage, int totalPagesInSpine, uint16_t paragraphIndex = 0,
bool hasParagraphIndex = false)
bool hasParagraphIndex = false, SyncIntent syncIntent = SyncIntent::COMPARE)
: Activity("KOReaderSync", renderer, mappedInput),
epub(epub),
epubPath(epubPath),
@@ -33,6 +51,7 @@ class KOReaderSyncActivity final : public Activity {
totalPagesInSpine(totalPagesInSpine),
localParagraphIndex(paragraphIndex),
hasLocalParagraphIndex(hasParagraphIndex),
syncIntent(syncIntent),
remoteProgress{},
remotePosition{},
localProgress{} {}
@@ -51,6 +70,7 @@ class KOReaderSyncActivity final : public Activity {
SHOWING_RESULT,
UPLOADING,
UPLOAD_COMPLETE,
APPLY_COMPLETE,
NO_REMOTE_PROGRESS,
SYNC_FAILED,
NO_CREDENTIALS
@@ -63,6 +83,7 @@ class KOReaderSyncActivity final : public Activity {
int totalPagesInSpine;
uint16_t localParagraphIndex;
bool hasLocalParagraphIndex;
SyncIntent syncIntent = SyncIntent::COMPARE;
State state = WIFI_SELECTION;
std::string statusMessage;
@@ -82,7 +103,7 @@ class KOReaderSyncActivity final : public Activity {
// Selection in result screen (0=Apply, 1=Upload)
int selectedOption = 0;
// Timestamp when UPLOAD_COMPLETE state was entered (for auto-close)
// Timestamp when completion state was entered (for auto-close)
unsigned long uploadCompleteTime = 0;
bool closeRequested = false;