Commit graph

95 commits

Author SHA1 Message Date
Johannes Millan
7c5b58ecf6 fix(android): add WebView block recovery paths
Builds on the prior authoritative-vs-fallback fix with three layered
recovery mechanisms so users hit by a false BLOCK are never locked out
of their data:

- Last-known-good auto-recovery: persist the highest WebView version
  that has ever loaded the app on this device. A later transient
  mis-read that drops below MIN_CHROMIUM_VERSION is downgraded to WARN.
- "Try anyway" override: third button on the block screen opens an
  AlertDialog with an explicit risk acknowledgment (crashes, render
  failures, possible data loss). Confirming persists an override and
  relaunches the app. Hardened against tapjacking via
  filterTouchesWhenObscured on both the activity and dialog window.
- Override auto-clears once a healthy version is detected, so a future
  genuine block is not silently bypassed.

Also tightens the UA regex (drops the misleading Safari Version/X
fallback that always reads "4.0" and would falsely block) and adds
diagnostic logging gated by Log.isLoggable for field debugging.

Tests: 12 unit tests covering statusForVersion branches, all
applyOverrides paths, and parseMajorVersion edge cases.

Refs #7229
2026-04-29 16:17:55 +02:00
Johannes Millan
10257fc21a fix(android): avoid false WebView version lockout 2026-04-29 16:17:55 +02:00
Johannes Millan
01e30b9c7e
Feat/to me it looks like there are lots of 60dd04 (#7280)
* fix(issue): prevent crash from orphan issueProviderId (#7135)

The Jira image-headers effect in task-detail-panel subscribed to
selectIssueProviderById without an error handler, so a task with an
issueProviderId pointing at a deleted provider (e.g. after sync
convergence where taskIdsToUnlink didn't cover all local tasks)
propagated the selector throw to Zone.js as a crash dialog. Wrap the
inner selector observable in catchError that logs and falls back to
of(null); the downstream jiraCfg?.isEnabled guard handles the fallback.

Also drop IssueLog.log(issueProviderKey, issueProvider) from the
throwing variant of the selector: providers may carry credentials
(host, token, apiKey) and IssueLog history is exportable.

* fix(focus-mode): sync tray countdown with in-app timer during breaks

Tray title was rebuilt from a cached currentFocusSessionTime that only
refreshed when CURRENT_TASK_UPDATED fired. addTimeSpent is gated on an
active current task, so during focus-mode breaks or task-less focus
sessions the cache froze while the in-app timer kept ticking.

Add the tick action to taskChangeElectron$ so the cache refreshes every
second whenever the focus timer is running.

Fixes #7278

* fix(ci): restore GitHub Actions SHA pins undone by 0e9218bd68

Commit 0e9218bd68 silently reverted PR #7212 (github-actions-minor group
bump) along with its stated sync/client-id work. This restores the 15
workflow files to their pre-revert state.

Actions restored to newer pinned SHAs:
- actions/upload-artifact v7.0.0 -> v7.0.1
- step-security/harden-runner v2.16.1 -> v2.17.0
- softprops/action-gh-release v2.6.1 -> v3.0.0
- signpath/github-action-submit-signing-request v2.0 -> v2.1
- anthropics/claude-code-action v1.0.89 -> v1.0.93
- docker/build-push-action v7.0.0 -> v7.1.0
- easingthemes/ssh-deploy v5.1.1 -> v6.0.3

* fix: restore i18n, UI, and docs work undone by 0e9218bd68

Commit 0e9218bd68 silently reverted the following work alongside its stated
sync/client-id changes. Files where later master commits (fec7b25f23, etc.)
already re-applied the reverted work are intentionally left untouched.

Restored:
- #7232 docs/long-term-plans/location-based-reminders.md (513 lines)
- #7199 Romanian i18n phase 3 (ro.json + ro-md.json, ~1168 lines)
- #7049 Polish translation improvements
- #7143 planner component styling (4 scss files)
- #7211 add-task-bar preserve time estimate when typing title
- #7208 task.reducer roll-up estimates for added subtasks
- #6767 focus-mode pomodoro reset button
- #7205 plugin-dev github-issue-provider TOKEN description
- #7231 mobile-bottom-nav FAB fix
- a4fe03272 iOS keyboard accessory bar (global-theme + dialog-fullscreen-markdown)
- 309670db3 ShortSyntaxEffects undefined guard
- 667a7986f Dropbox PKCE auth comment/behavior

* fix(electron): restore electron + e2e work undone by 0e9218bd68

Commit 0e9218bd68 silently reverted the following electron/e2e work.
Files already re-fixed by later master commits are left as-is:
- e2e/tests/sync/supersync-archive-conflict.spec.ts (de33234976 + 191d129ff3)

Restored:
- e8a3e156eb fix(electron): Linux autostart IDB backing-store recovery
  (re-adds electron/clear-stale-idb-locks.ts + start-app.ts wiring)
- 5ce78a5b63 fix(electron): macOS Cmd+Q / Dock > Quit hang
  (setIsQuiting + before-quit delegate to close-handler)
- 46e0fa2d01 fix(sync): FILE_SYNC_LIST_FILES IPC contract
  (electronAPI.d.ts + local-file-sync + preload + ipc-events)
- ea1ef16307 fix(android): session-only SAF permissions on OEM devices
- 8865dc0a50 test(e2e): supersync parallel-worker stampede guard
  (SUPERSYNC_SERVER_HEALTHY env-var fallback + goto retry loop)
- af7c7687e2 test(e2e): block WS-triggered downloads in non-WS specs
- 265b44db5d test(e2e): premature waitForURL on daily-summary
  (this is literally the fix the bad commit's message claimed to add)

Conflict resolutions:
- e2e/utils/supersync-helpers.ts: kept the refined getDoneTaskElement
  checks from d64014d086 (later than c558bcab5e) while restoring the
  goto retry loop from 8865dc0a50.
- electron/start-app.ts: unioned imports (setIsQuiting +
  clearStaleLevelDbLocks from theirs, fs from ours).

* fix(sync): restore sync-core work undone by 0e9218bd68

Commit 0e9218bd68 silently reverted parts of several sync fixes. Most
sync-core reverts have already been re-addressed differently on master
by later commits (1f5184f6e7, 05cd875dd6, 09f5ced2c9, 7df43358ab,
d9158d6adb, 32dbc95ed9, 8c3b08e016, f89fe1ebc3) — those files are
intentionally left untouched to avoid reverting master's newer work.

This PR restores only the pieces that are genuinely still missing:

- e8a3e156eb fix(electron): IDB backing-store autoreload (in-app piece)
  operation-log-hydrator.service.ts + .spec.ts (the electron/clear-
  stale-idb-locks.ts piece was restored in the prior commit)

Plus three low-risk documentation/cleanup restorations:
- operation-sync.util.ts — add "Nextcloud" to isFileBasedProvider JSDoc
- dropbox.ts — restore improved _getRedirectUri JSDoc (667a7986fb)
- dialog-get-and-enter-auth-code.component.ts — restore isNativePlatform
  comment explaining why manual code entry flow is used (667a7986fb)
- file-adapter.interface.ts — remove stray "// NEW" comment (46e0fa2d01)

Intentionally NOT restored (master's newer work covers or supersedes):
- sync-trigger.service.ts / sync.effects.ts (05cd875dd6)
- sync-wrapper.service.ts (1f5184f6e7)
- sync-errors.ts (1f5184f6e7 re-added LegacySyncFormatDetectedError)
- file-based-sync-adapter.service.ts + spec (1f5184f6e7 + d9158d6adb)
- file-based-sync.types.ts (1f5184f6e7)
- operation-log.const.ts (32dbc95ed9 bumped IDB_OPEN_RETRIES to 5)
- dialog-sync-initial-cfg.component.ts (f89fe1ebc3)
2026-04-20 12:04:38 +02:00
Johannes Millan
6171a98646 refactor(android): route specialUse FGS through ServiceCompat helper
Both FocusModeForegroundService and TrackingForegroundService declare
android:foregroundServiceType="specialUse" in the manifest. The 2-arg
startForeground() overload already falls back to the manifest type on
Android 14+, but passing the type explicitly via ServiceCompat is
Google's documented best practice and removes OEM-dependent fallback
ambiguity.

Extract the Build-gated call into a Service.startForegroundSpecialUse
extension in ForegroundServiceExt.kt so a future third FGS picks up
the API-version gating automatically. Callers shrink to one-liners.
2026-04-17 19:45:20 +02:00
Johannes Millan
f81858b488 fix(android): guard broken WebView package probe
WebView.getCurrentWebViewPackage() is documented to return null on
devices without an installed provider, but in practice it can throw
AndroidRuntimeException, MissingWebViewPackageException, or NPE on
devices with a corrupt or updating provider. An unhandled throw there
short-circuits WebViewCompatibilityChecker.evaluate() before
FullscreenActivity's recovery path (added in 5a5c3bca89) has a chance
to run, re-crashing the app on launch.

Wrap the call in a narrow catch for RuntimeException so the documented
throwables fall through to the PackageManager lookup while Error
subclasses still propagate. Log at debug level so broken-provider
telemetry survives.
2026-04-17 19:45:10 +02:00
Johannes Millan
a2f45b0d69 refactor(android): narrow broad catch clauses so unknown failures surface in Play Console
The recent WebView, FGS, and JS-dialog guards each caught Exception,
which hid every thrown type behind a log line. Play Console only
surfaces uncaught throws, so a future regression inside any of these
paths would be silently swallowed.

Narrow to the known recoverable types:
- FullscreenActivity.initWebView: AndroidRuntimeException (incl.
  MissingWebViewPackageException) + IllegalStateException.
- FullscreenActivity.onJsAlert/onJsConfirm: WindowManager.BadTokenException
  + IllegalStateException; JsResult.cancel() still fires via the
  handled flag so the WebView JS thread never deadlocks.
- TrackingForegroundService / FocusModeForegroundService
  ensureForegroundNotification: IllegalArgumentException (Samsung One UI
  / Android 14 blank-title case) + SecurityException. Anything else,
  including ForegroundServiceStartNotAllowedException, now propagates.
2026-04-17 18:13:49 +02:00
Johannes Millan
5a5c3bca89 fix(android): recover from WebView init crash via WebViewBlockActivity
Observed on Play Console: AndroidRuntimeException thrown from
WebViewFactory.getProvider during FullscreenActivity.initWebView on
devices where the system WebView package itself is broken (seen with a
WebView Beta build throwing "Already registered a list of actions in
this process" from WebViewChromiumFactoryProvider.<init>). The activity
had no recovery - the constructor threw and the app died at launch.

Mirror the existing CapacitorMainActivity pattern: catch around the
WebHelper().instanceView(this) call, and on failure present the existing
WebViewBlockActivity using compatibility.copy(status = BLOCK) so the
block screen keeps the detected provider/version, then finish().

Also harden lifecycle callbacks that dereference the lateinit webView /
javaScriptInterface fields so the new failure path can't trigger an
UninitializedPropertyAccessException via OEM-specific lifecycle quirks:
::isInitialized guards in onSaveInstanceState, onRestoreInstanceState,
onBackPressed, and callJSInterfaceFunctionIfExists (the last matching
the existing guard in CapacitorMainActivity).
2026-04-17 18:13:02 +02:00
Johannes Millan
b9f91a5327 fix(android): guard FGS contract unconditionally in onStartCommand
Every Context.startForegroundService() call creates a per-call FGS token
that must be answered with startForeground() within the system timeout,
even if the service is already a foreground service. Earlier fixes closed
specific branches one at a time and left gaps — most notably ACTION_START
with null taskId while already tracking, which returned without calling
startForeground().

Satisfy the contract once at the top of onStartCommand in both
TrackingForegroundService and FocusModeForegroundService, so every branch
below (known and future) already has the token answered. Add
stopForegroundAndSelf() on the previously silent no-op branches
(ACTION_UPDATE / ACTION_STOP when idle) so the guard does not leak the
service as foreground with a placeholder notification.

The placeholder notification carries a content title — Samsung One UI can
render title-less notifications as blank and a few Android 14 builds throw
IllegalArgumentException from startForeground() without one, which would
be swallowed by the guard's try/catch and re-trigger the very timeout we
are preventing. Matches the crash's heavy Samsung/Lenovo-tablet bias.
2026-04-17 18:13:02 +02:00
Johannes Millan
367342edd6 fix(android): guard webchrome dialogs against activity teardown
Prevents WindowManager$BadTokenException in FullscreenActivity.onJsConfirm
and onJsAlert when JS fires alert()/confirm() after the activity starts
finishing. Also ensures JsResult is always released so the WebView JS
thread never deadlocks on lifecycle-driven dismissal.
2026-04-17 18:13:02 +02:00
Johannes Millan
5787437a9a
fix(reminder): restore Android alarms after app update (#7254)
Android clears all AlarmManager alarms (and may cancel WorkManager jobs)
whenever the app's APK is replaced — i.e. on every Play Store auto-update
or manual reinstall. BootReceiver already knows how to re-register
everything from ReminderAlarmStore and re-enqueue SyncReminderWorker, but
its intent-filter only listened for BOOT_COMPLETED, so after an update
reminders stayed silently unregistered until the user next opened the app.

Add MY_PACKAGE_REPLACED to the manifest and broaden the receiver's action
guard so alarm restoration runs on both events. No new permissions or
helpers required — MY_PACKAGE_REPLACED is a protected broadcast delivered
only by the system to the owning app.

Refs #6832

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-17 17:39:59 +02:00
Johannes Millan
0e9218bd68 fix(sync): handle data validation errors and improve client ID management
- Separate JsonParseError and SyncDataCorruptedError handlers in sync wrapper
- Handle corrupted remote data gracefully instead of throwing
- Add getOrGenerateClientId() as unified entry point, eliminating dual injection
  of ClientIdService + CLIENT_ID_PROVIDER in snapshot-upload, file-based-encryption,
  and sync-hydration services
- Use crypto.getRandomValues() instead of Math.random() for client ID generation
- Warn user when stored client ID is invalid and must be regenerated
- Fix flaky e2e supersync tests (premature waitForURL match on daily-summary URL)
2026-04-16 17:41:39 +02:00
Johannes Millan
ea1ef16307 fix(android): support session-only SAF permissions on OEM devices
Some OEM ROMs throw SecurityException when takePersistableUriPermission is
called, even with FLAG_GRANT_PERSISTABLE_URI_PERMISSION requested. Instead of
rejecting the call, fall through and return the URI — it remains valid for the
session. Also fix checkUriPermission to use context.checkUriPermission() which
detects both persistent grants and active session grants, so isReady() no longer
clears a working (session-only) SAF URI on those devices.
2026-04-14 22:09:02 +02:00
Johannes Millan
d32f7037a3 fix(sync): preserve own vector clock counter across full-state op resets
When a full-state op (SYNC_IMPORT/BACKUP_IMPORT) arrived from another
client, mergeRemoteOpClocks reset the local clock to a "minimal" form
but only preserved the current client's counter from the incoming op's
clock. If the current client had issued ops (e.g. GLOBAL_CONFIG) not
reflected in the incoming full-state op's clock, its counter was dropped,
causing subsequent ops to reuse the same counter value. Downstream clients
then saw these ops as EQUAL (duplicate) and skipped them silently.

Fix: take max(mergedClock[clientId], currentClock[clientId]) when
rebuilding the clock after a full-state op reset.

Also add __SP_E2E_BLOCK_WS_DOWNLOAD flag to WsTriggeredDownloadService
to allow E2E tests to block automatic WS-triggered downloads during
concurrent conflict scenarios.

Fix archive conflict test by blocking WS downloads on Client A during
the concurrent edit phase so it doesn't auto-receive B's rename via
WebSocket before archiving (restoring the intended conflict scenario).

Fix LWW singleton test to assert convergence rather than specific winner.
Fix renameTask helper to avoid Playwright/Angular re-render races.
Fix shepherd.js import paths that broke the Angular dev server build.
2026-04-01 15:41:13 +02:00
Johannes Millan
edb102534e
feat(android): improve task title from share intent using EXTRA_SUBJECT (#7052)
* feat(android): improve task title from share intent using EXTRA_SUBJECT

Browsers and many apps send the page title via Intent.EXTRA_SUBJECT, which
was previously ignored. Now the share handler uses subject > title > content
to build a meaningful task title instead of the generic "Check: Shared Content".
For links without metadata, a readable URL (domain + path) is used instead.

https://claude.ai/code/session_01LzFepWFjLKQSWKZn4iXEpS

* chore: update package-lock.json after npm install

https://claude.ai/code/session_01LzFepWFjLKQSWKZn4iXEpS

* refactor(android): simplify _buildTaskTitle and fix double spaces in URL

Deduplicate the subject/title preference logic and collapse multiple
spaces in _readableUrl output caused by leading slashes in pathnames.

https://claude.ai/code/session_01LzFepWFjLKQSWKZn4iXEpS

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-31 13:12:34 +02:00
Johannes Millan
136bb51ea0 fix(android): prevent crashes from null bridge and foreground service contract violations
Guard against null bridge/webView after onCreate by showing WebViewBlockActivity
with actionable guidance instead of crashing. Satisfy Android's foreground service
contract in TrackingForegroundService and FocusModeForegroundService by posting a
minimal notification before stopping when started without a valid action. Handle
null taskId on ACTION_START without killing an active tracking session.
2026-03-29 19:57:10 +02:00
Johannes Millan
9f8cf0a3d0 fix(oauth): use platform-specific redirect URIs and iOS client ID
Google rejects custom scheme redirect URIs that don't match the
platform's app identifier. Use the Android applicationId
(com.superproductivity.superproductivity) on Android and the iOS
bundle ID (com.super-productivity.app) on iOS, with single-slash
URI format per Google's documentation.

- Add iosClientId to OAuthFlowConfig and plugin API types
- Add iOS OAuth client ID to Google Calendar plugin
- Select client ID per platform (Android/iOS/Desktop) in bridge service
- Add Android package name intent filter in AndroidManifest
- Accept both URI schemes in OAuth callback handler
- Fix redirect handler to use IS_NATIVE_PLATFORM consistently
2026-03-27 17:33:38 +01:00
Johannes Millan
bbf3c741a7 feat(tasks): lock drag-and-drop Y-axis on small screens and throttle tree drag
Lock cdkDragLockAxis to Y on small screens (<600px) for task-list and
planner components, matching the breakpoint where planner switches to
single-column and bottom nav appears. Nav menu tree always locks Y.
Uses reactive LayoutService.isXs() so orientation changes work correctly.

Throttle tree-dnd onDragMoved with requestAnimationFrame to reduce
layout thrashing from getBoundingClientRect/elementFromPoint calls.
2026-03-24 16:25:42 +01:00
Johannes Millan
f20ebea583 fix(android): prevent ForegroundServiceDidNotStartInTimeException and bridge NPE
Add safeStopSelf() to TrackingForegroundService and FocusModeForegroundService
that calls startForeground() before stopSelf() in fallback branches (missing
task ID, stop when not running, null/unknown action). Android requires
startForeground() within 10s of startForegroundService().

Replace ambiguous NullPointerException in CapacitorMainActivity.onCreate with
a descriptive IllegalStateException when Capacitor bridge fails to initialize.
Add safe-call operators in onSaveInstanceState/onRestoreInstanceState.
2026-03-24 16:25:42 +01:00
Johannes Millan
02bc3e88e3 feat(two-way-sync): add plugin OAuth, two-way field sync, and remote issue deletion
Add OAuth support for plugins with PKCE, token persistence in local-only
IndexedDB, and Electron/web redirect handling. Extend two-way sync with
dueDay, dueWithTime, and timeEstimate field mappings including mutually
exclusive field clearing. Support remote issue deletion on task delete
and remote deletion detection during polling.

Add Google Calendar plugin (disabled from bundled builds pending legal
review) as a development reference for the plugin OAuth and two-way
sync APIs.

Additional fixes:
- Restore accidentally deleted focus-mode translation keys
- Remove full Task[] from deleteTasks action to prevent op-log bloat
- Add dueDay/deadlineDay format validation guards (#6908)
- Fix Android reminder alarm cancel intent matching
- Validate dueDay format to prevent false overdue from corrupted data
- Fix PKCE test expectation after utility consolidation
2026-03-22 13:02:41 +01:00
Johannes Millan
da41ad7603 fix(android): match cancel intent action to schedule intent for reminder alarms
cancelReminder() created a PendingIntent without setting the action,
while scheduleReminder() set ACTION_SHOW_REMINDER. Android's
Intent.filterEquals() treats null != "action" so alarmManager.cancel()
silently failed to find the scheduled alarm.
2026-03-22 10:10:19 +01:00
Johannes Millan
c13bf03d37
fix(android): prevent stale check from suppressing valid reminder notifications (#6905)
* fix(android): prevent stale check from suppressing valid reminder notifications

The isTaskStale check in ReminderAlarmReceiver was incorrectly suppressing
all locally-scheduled reminders. After 6fd0696 enhanced extractRemindersToSchedule
to detect schedule ops from actionPayload, the stale check would find the
task's own schedule op and mark it as stale — even though the alarm IS the
current schedule.

Fix by passing triggerAtMs through the alarm intent and comparing it with
schedule ops' remindAt. A task is only considered rescheduled (stale) when
the schedule op's remindAt differs from the firing alarm's trigger time.

https://claude.ai/code/session_013216HfgtetW9KKzFr5ieLQ

* fix(android): handle dual-reminder edge case and seq cursor reset

Two additional fixes found during review:

1. Dual-reminder edge case: A task can have both a standard reminder
   (remindAt) and a deadline reminder (deadlineRemindAt) with different
   times. The stale check now matches on isDueDate to prevent one
   reminder type from suppressing the other.

2. Seq cursor stuck after server reset: If the server is wiped (e.g.,
   clean sync import), latestSeq drops below the stored lastSeq. The
   worker now resets the cursor when the server's seq is lower, instead
   of being permanently stuck.

https://claude.ai/code/session_013216HfgtetW9KKzFr5ieLQ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-21 01:08:44 +01:00
Johannes Millan
6fd069658e fix(android): detect schedule/unschedule ops in background sync reminder worker
The op-log system returns empty entityChanges for most actions — only
TIME_TRACKING and addTask (CRT) ops populate it. The background sync
provider was relying on entityChanges to detect remindAt changes, so
schedule/unschedule/deadline actions were invisible to the worker.

Fix by matching on actionType strings and parsing actionPayload directly:
- unscheduleTask, removeDeadline → cancel reminders
- scheduleTaskWithTime, reScheduleTaskWithTime → parse actionPayload.remindAt
- setDeadline → parse actionPayload.deadlineRemindAt
2026-03-20 21:36:31 +01:00
Johannes Millan
a87e9ea7a9 fix(android): fix background sync reminder ordering and title extraction
Let later ops win when dismiss and reschedule are in the same batch
(previously cancellation always won, suppressing rescheduled reminders).
Also extract task title from actionPayload as fallback for UPD ops.
2026-03-20 21:36:30 +01:00
Johannes Millan
6d3006dd28 fix(android): use full server format for background sync op parsing
The SuperSync server returns operations in full format (full field names
and NgRx action strings), but the parser was using compact format codes.
This caused all background sync parsing to silently fail, preventing
reminder cancellation and scheduling.
2026-03-20 21:36:30 +01:00
Johannes Millan
167bdedec1 feat(android): check-before-show and schedule reminders from background sync
Add server-side stale check to ReminderAlarmReceiver before showing
notifications. When an alarm fires, the receiver does a quick server
fetch (5s OkHttp timeout, fail-open) to suppress notifications for
tasks that were deleted, done, dismissed, or rescheduled on another
device.

Also extend the background sync worker to schedule new/updated
reminders discovered in sync operations, not just cancel stale ones.

Key design decisions:
- Fail-open: any error or timeout still shows the notification
- Receiver only checks its own task; Worker owns all other reminder
  management and the seq cursor
- Last-writer-wins dedup via Map keyed by (taskId, isDueDate)
- Cancellation wins over scheduling in the same batch
- Independent try/catch per cancel/schedule to prevent cascading failures
- SupervisorJob on receiver's CoroutineScope
2026-03-20 21:36:30 +01:00
Johannes Millan
eb72992d3e fix(android): delay debug toast by 10 seconds 2026-03-20 21:36:30 +01:00
Johannes Millan
10a3db97ea
feat(droid): background sync notifications for android
* docs: add plan for Android background sync via WorkManager

Outlines the implementation plan for using WorkManager to periodically
sync with SuperSync server in the background, cancelling stale reminders
for tasks that were completed/deleted on other devices.

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* docs: refine plan based on multi-agent architecture review

- Pin frontend hook to SyncProviderManager.currentProviderPrivateCfg$
- Add skipWhileApplyingRemoteOps() guard for selector-based effect
- Add HRX (dismiss reminder) and deadlineRemindAt to parser
- Add batch operation ds field handling
- Add ProGuard rules step for release builds
- Add error handling note for BootReceiver WorkManager enqueue

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* docs: improve plan after second review round

Key changes:
- Remove Step 5 (ReminderAlarmStore lookup) - hash-based cancellation is
  sufficient, no store lookup needed
- Add BackgroundSyncProvider interface for extensibility to Dropbox/WebDAV
- Per-account lastServerSeq keyed by baseUrl hash
- Add SyncReminderScheduler helper to deduplicate scheduling logic
- Document edge cases: account switching, token expiry, force-kill,
  gapDetected, notification race conditions
- Add extensibility section explaining Dropbox feasibility and architecture

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* feat(android): add background sync to cancel stale reminders via WorkManager

When a task is completed/deleted on desktop, Android reminders for that task
would still fire because the mobile app didn't know about the change. This adds
a WorkManager periodic job (every 15 min) that fetches operations from the
SuperSync server and cancels AlarmManager alarms + notifications for tasks that
are done, deleted, archived, or had their reminders dismissed.

Architecture:
- BackgroundSyncProvider interface for extensibility (Dropbox/WebDAV possible later)
- SuperSyncBackgroundProvider: lightweight HTTP client + operation parser
- SyncReminderWorker: CoroutineWorker that fetches ops and cancels reminders
- SyncReminderScheduler: helper to schedule/cancel the WorkManager job
- AndroidSyncBridgeEffects: mirrors SuperSync credentials to native SharedPreferences
- Per-account lastServerSeq prevents account-switching bugs

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* chore: update package-lock.json after npm install

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* fix(android): address review issues and add tests for background sync

Fixes from code review:
- Fix distinctUntilChanged to properly handle provider switching
  (non-SuperSync emissions now treated as equal to prevent repeated clears)
- Add null-safe ops array parsing in SuperSyncBackgroundProvider
- Add write/call timeouts to OkHttpClient (30s write, 60s call)
- Remove no-op `hash and hash` line in Kotlin hash function

Tests:
- Add cross-platform parity tests for notification ID hash function
  (pinned expected values that must match Kotlin implementation)
- Add AndroidSyncBridgeEffects unit tests covering:
  - distinctUntilChanged comparator behavior
  - credential set/clear decision logic
  - observable filtering integration (dedup, null filtering)

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* fix(android): fix hash overflow and operation parser payload paths

Two critical bugs found during final review:

1. Hash function abs(Int.MIN_VALUE) bug: In Kotlin, abs(Int.MIN_VALUE)
   returns Int.MIN_VALUE (still negative) due to 32-bit overflow.
   Fixed by converting to Long before abs(), matching JS behavior where
   Math.abs works on 64-bit floats.

2. Operation parser payload structure: The parser was looking at
   p.isDone and p.task.changes directly, but the actual compact
   operation format wraps everything in p.entityChanges[] and
   p.actionPayload. Rewrote to use p.entityChanges as primary source
   (consistent structure with entityType, entityId, changes fields)
   and p.actionPayload.task.changes as secondary source.

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* docs: add long-term plan for Android background sync improvements

Covers three phases: fast app startup via cached sync seq,
push-based notification cancellation via FCM, and extending
background sync to Dropbox/WebDAV providers.

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

* fix(android): address review feedback for background reminder sync

- Remove PLAN.md from repo root (C1)
- Use EncryptedSharedPreferences for access token storage with
  fallback to standard SharedPreferences on broken KeyStore (C2)
- Reset lastServerSeq when access token changes to prevent stale
  seq on account switch with same server URL (I1)
- Add max iteration guard (100) to pagination loop to prevent
  infinite loops from server bugs (I2)
- Use type predicate filter instead of non-null assertions (I3)
- Add exponential backoff (5min) to WorkManager schedule (S1)
- Add comments linking action type codes to frontend source (S2)
- Extract distinctUntilChanged comparator to named function with
  JSDoc explaining the suppression semantics (S3)

https://claude.ai/code/session_01RkrVBB492k8RBA8zt5swwe

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-20 10:24:02 +01:00
Johannes Millan
06b8831948
fix(android): match navigation bar color to system theme on startup (#6872)
Add values-night/colors.xml with dark theme colors (#131314) so the
navigation bar and status bar match the system dark theme before the
Angular app boots. Also fix light-mode status bar initial color to
#f8f8f7 to match what the app sets dynamically.

https://claude.ai/code/session_017CVEn9yTUqcPiRzoafP24R

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-19 01:43:14 +01:00
Johannes Millan
945b8ed15c fix(android): improve startup overlay to webapp add task bar transition
- Match webapp styling: replace colored border stroke with 12dp
  elevation shadow matching the webapp's global bar variant
- Show webapp add task bar when native overlay bar is open but empty,
  not just when it contains text
- Target global add task bar specifically (add-task-bar.global) to
  avoid focusing an inline bar that may already exist on the page
2026-03-18 13:14:10 +01:00
Johannes Millan
49952c5c6a feat(android): add native startup overlay for quick task entry
Show a native FAB button during app startup so users can add tasks
while Angular bootstraps. Tapping the FAB expands a themed input bar
with keyboard tracking. Submitted tasks queue in SharedPreferences
via WidgetTaskQueue and are processed by AndroidEffects after
hydration. Partial (unsubmitted) text transfers to the web AddTaskBar
via sessionStorage.

Design:
- Two-phase dismiss keeps native overlay visible until web input mounts
- MutationObserver with resolved guard detects AddTaskBar readiness
- Day/night theme support with primary-colored border
- FAB color (#6495ED) matches the loading spinner
- Overlay cleaned up in onDestroy to prevent listener leaks

Also removes the old Quick Add Widget (QuickAddActivity,
QuickAddWidgetProvider, and all associated resources).

Also modernizes the loading spinner from double-bounce to a subtle
pulse animation.
2026-03-18 13:14:10 +01:00
Johannes Millan
8a4473541e fix(android): set navigation bar color to match app theme
Add NavigationBarPlugin Capacitor plugin to dynamically update the
Android system navigation bar color and icon style when the app theme
changes. Set initial color in native XML styles for all themes
including the launch theme. Reduce bottom nav and FAB shadows to
prevent visual cutoff at the system navigation bar boundary.
2026-03-18 13:14:10 +01:00
Johannes Millan
42dc92b10d fix(sync): prevent empty-upload to WebDAV on Android
Add defense-in-depth guards to prevent the Capacitor bridge from
silently uploading zero-byte files to WebDAV, which corrupts sync
state for all clients.

- Add empty-data guard in WebdavApi.upload() with tests
- Reject empty PUT body in Android WebDavHttpPlugin (Kotlin)
- Validate compressAndEncryptData() output for all providers
- Add payload size diagnostic logging in WebDavHttpAdapter
- Use android.util.Log instead of println for proper logcat filtering

Closes #6855
2026-03-17 13:59:40 +01:00
Johannes Millan
6768eaeb22 fix(android): show correct notification text for due date reminders
The notification body incorrectly showed "Note reminder" for all
non-TASK reminder types, including DUE_DATE reminders. Replace the
if/else with a when expression that handles each type explicitly.
2026-03-10 15:58:22 +01:00
Johannes Millan
fd28c04cce feat(reminder): overhaul mobile notification UX for Android and iOS
- Add notification actions: Done, Snooze 10m, Snooze 1h (Android + iOS)
- Add BootReceiver to re-register alarms after device reboot
- Add SharedPreferences queues for background-to-frontend communication
  (ReminderDoneQueue, ReminderSnoozeQueue, ReminderTapQueue)
- Add "fire and verify" pattern: sync before acting on stale notifications
- Add due-date notification scheduling (configurable hour, default 9 AM)
- Add exact alarm permission warning for Android 12+
- Add notification grouping (Android groups, iOS thread identifiers)
- Add isOngoing flag for persistent alarm-style notifications
- Sanitize REMINDER_TASK_ID to prevent JS injection
2026-03-06 21:19:55 +01:00
Johannes Millan
de03a2d11e fix(android): prevent crash on SAF folder selection (#6545)
Wrap takePersistableUriPermission() in try/catch to handle SecurityException
thrown on certain Samsung/Android 13 devices. Reject the Capacitor call on
failure so the error propagates cleanly. Add .catch() to FormlyBtnComponent
promise chain to prevent unhandled rejections.
2026-02-16 18:44:27 +01:00
Johannes Millan
02fe1a5ff2 fix(android): persist share intent to SharedPreferences for cold-start reliability
Share-to-app via Android SEND intent was unreliable on cold start because
share data was stored only in memory (pendingShareIntent). If the process
died before Angular loaded, the data was lost. Now share data is persisted
to SharedPreferences immediately and pulled synchronously by the frontend.
2026-02-13 14:06:43 +01:00
Johannes Millan
40b18c4693 fix(sync): implement OAuth redirect for Dropbox on mobile
- Add redirect_uri parameter to OAuth flow for mobile platforms
- Create OAuthCallbackHandlerService to handle deep link callbacks
- Register custom URI scheme (com.super-productivity.app://) in Android/iOS
- Add platform-specific UI for OAuth flow (automatic vs manual)
- Implement proper error handling for OAuth callback errors
- Add comprehensive unit tests for callback handler
- Fix memory leak by properly cleaning up event listeners
- Use IS_NATIVE_PLATFORM constant for consistent platform detection

Web/Electron continue using manual code entry (no regression).
Mobile (iOS/Android) now use automatic redirect with deep linking.

Fixes Dropbox OAuth authentication on iOS and Android platforms.
2026-01-21 14:30:24 +01:00
Johannes Millan
2844560ef8 refactor(tasks): remove isEnableUrl config, always enable URL parsing 2026-01-20 17:07:24 +01:00
Johannes Millan
566760bd4a feat(android): add optional alarm-style notifications and fix reminder cancellation
- Fix bug where native Android alarms weren't cancelled when reminders were removed
- Add cancelNativeReminderOnUnschedule$ effect to cancel alarms on unschedule/dismiss
- Add useAlarmStyleReminders setting (default: false) for regular vs alarm notifications
- Create separate notification channels for alarm-style and regular reminders
- Add IS_ANDROID_WEB_VIEW_TOKEN injection token for testability
- Pass useAlarmStyle parameter through JS bridge to native Kotlin layer
2026-01-15 17:49:56 +01:00
Johannes Millan
dfa6a94a4b fix(android): show notification with sound when focus mode timer completes in background
When the app is backgrounded on Android, the focus mode countdown timer
now triggers a high-priority notification with alarm sound and vibration
when it completes. Previously, only the silent foreground service
notification was shown, causing users to miss timer completion.

Changes:
- Add completion notification channel with IMPORTANCE_HIGH
- Detect timer completion in FocusModeForegroundService
- Broadcast completion event to activity via LocalBroadcastManager
- Forward event to Angular via onFocusModeTimerComplete$ subject
- Handle native completion in effects to sync app state

Fixes #5923
2026-01-09 15:01:06 +01:00
Johannes Millan
1a79592aca build: update links to match our new organization 2026-01-05 14:45:06 +01:00
Johannes Millan
b7cbef2f79 feat(android): add alarm sound and vibration to task reminders
Use default alarm ringtone with USAGE_ALARM audio attributes so
reminders play even when phone is on silent. Add vibration pattern
and change notification category from REMINDER to ALARM.

Fixes #5603
2026-01-04 12:45:00 +01:00
Johannes Millan
a14c95093d fix(android): add error handling for native service calls
Wrap all androidInterface native method calls in try-catch blocks to
prevent app crashes when Java exceptions are raised during method
invocation. Users are now notified via snackbar when service start
fails, while update/stop failures are logged silently.

Changes:
- Add _safeNativeCall helper to TypeScript effects for DRY error handling
- Add safeCall inline helper to Kotlin JavaScriptInterface
- Wrap focus mode and tracking service calls with error handling
- Show user-friendly error notification on service start failures
- Add unit tests for error handling logic

Fixes #5819
2026-01-02 17:09:08 +01:00
Johannes Millan
00fdb29db9 fix(android): resolve race condition and improve widget reliability
- Add @Synchronized to WidgetTaskQueue methods to prevent task loss
- Use apply() instead of commit() in addTask() to avoid UI blocking
- Change QuickAddActivity to extend AppCompatActivity for consistency
- Add unit tests for setCounter() plugin API method
2026-01-01 12:34:39 +01:00
Johannes Millan
4a89c05d32 feat(android): add quick add widget 2025-12-31 12:45:17 +01:00
Johannes Millan
25edb4ff1e perf(android): prewarm WebView during idle time to speed up startup
Load WebView native libraries during main thread idle time using
IdleHandler and WebSettings.getDefaultUserAgent(). This reduces
the 200-300ms freeze on first WebView creation.
2025-12-31 11:45:52 +01:00
Johannes Millan
d11435808e fix(focus-mode): address critical focus mode and Android notification issues
- Fix pausedTaskId race condition: pass pausedTaskId in action payload
  instead of reading from state (reducer clears before effect reads)
- Fix Android focus notification: update title/isBreak on transitions,
  restart timer runnable on resume from paused state
- Fix Android reminder cancellation: track scheduled IDs and cancel
  alarms when reminders are removed
- Fix banner Start button: dispatch skipBreak first when isBreakTimeUp
  to properly resume task tracking
- Fix WebDAV validation: use translation key instead of hardcoded string

Addresses code review feedback for sync issues identified in focus mode,
Android notifications, and reminder scheduling.
2025-12-22 19:00:02 +01:00
Johannes Millan
2c910f6753 fix(android): sync notification timer when time spent is manually changed
Add updateTrackingService method to reset the notification timer when
the user manually edits time spent on a task. Previously, the Android
foreground service maintained its own timer that was only set at
tracking start, causing desync when users manually reset time.

Fixes #5772
2025-12-22 14:40:40 +01:00
Johannes Millan
f7901ba47f feat(android): add better notifications and permanent notification for focus mode 2025-12-19 15:52:11 +01:00
Johannes Millan
ffa7122aea feat(android): add background time tracking via foreground service
When a task is being tracked and the app goes to the background on Android,
JavaScript execution is paused/throttled, causing time tracking to stop.

This adds a native Foreground Service that:
- Shows a persistent notification with task title and elapsed time
- Tracks time independently using timestamps (not JS ticks)
- Provides Pause and Done action buttons on the notification
- Syncs elapsed time back to Angular when the app resumes or task changes

Architecture:
- Native service stores startTimestamp + accumulatedMs
- Calculates elapsed = (now - startTimestamp) + accumulated
- Angular effects sync time on resume, task switch, and notification actions
2025-12-19 13:38:52 +01:00