Skip to content

UI/UX: Unify feedback with Material snackbars and retain long errors - #6227

Open
eliotcougar wants to merge 16 commits into
2dust:masterfrom
eliotcougar:feat/snackbar-feedback
Open

eliotcougar wants to merge 16 commits into
2dust:masterfrom
eliotcougar:feat/snackbar-feedback

Conversation

@eliotcougar

@eliotcougar eliotcougar commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Foreground feedback now uses one process-owned Material snackbar queue, while background feedback uses permission-aware regular notifications. Long errors stay available until dismissed, addressing the unreadable or truncated error feedback described in #6053.

This carries forward the delivery work from #6204 and the maintainer's suggestion to use one foreground message mechanism; #6204 does not need to be merged first.

  • Keep upstream's rounded, centered bubble appearance and normal/success/error/info colors. Preserve safe drawing and keyboard insets. Short messages use Material's accessibility-adjusted timeout, with the existing explicit long-duration option retained.
  • Errors over 120 Unicode code points or containing a line break get a localized Close action and scrollable text, bounded to half the available height. The action stays outside the scrolling text.
  • Preserve unread queued messages across navigation and rotation. Already presented transient feedback is dismissed when another host takes over, including when an existing registered host becomes active again. Errors requiring dismissal remain available. Only one resumed host renders the queue.
  • Transfer unread work to notifications when the process backgrounds. Routine feedback replaces the preceding routine notification and expires after ten seconds on Android 8+; long errors have independent identities and no automatic expiry. Notification taps open/reuse the main screen. New foreground feedback clears stale routine notifications while retaining undismissed long errors.
  • Deliver terminal service feedback through acknowledged, package-scoped ordered broadcasts. State-only observers do not take presentation ownership; unhandled feedback falls back to notifications. Successful-stop feedback follows the native shutdown callback, excluding internal reloads and failed-start cleanup.
  • Keep existing toast, toastSuccess, toastError and toastInfo caller APIs. Resolve resource messages through the localized app context, ignore blank feedback, preserve detailed failures and classify failure callers as errors. Localize the fallback when VPN setup fails. Update completed-stop wording and the Other notifications channel title in all maintained catalogs.

The branch includes upstream v2.3.15 through 57907cf354d9769200ed4717b4430d605abe0952, using a merge commit. Current DNS ordering/finalQuery, WireGuard DNS fallback, Hysteria port, subscription RTL/infinity and HEV offload changes are retained. Native gitlinks match that upstream base.

Validation on fb614d5146c8f668007f54a30c1c0f354b778d58:

  • All 30 focused JVM tests passed for host handoff/queue ownership, message classification and service feedback policy, including the two new already-registered-host regression scenarios.
  • Both full debug JVM suites passed: 154 tests per distribution, 308 total, with zero failures, errors or skips.
  • Play Store and F-Droid Kotlin compilation, ARM64 debug assembly and full debug lint passed. Both lint reports contain zero errors; existing warnings remain.
  • Both APKs contain the three required native files and all required geodata. libgojni.so, libhev-socks5-tunnel.so and libhevsockstun.so match the official v26.10.31/HEV 2.19.3 inputs byte for byte.
  • Resource/reference checks across all ten supported catalogs, git diff --check and instruction-file boundary checks passed.

Not run on this synchronized head: device/emulator checks for navigation and activity recreation, TalkBack, touch/keyboard/D-pad operation, themes/insets/IME, notification permissions and expiry, or VPN/proxy-only/root start/stop/reload scenarios. No ADB target was available; runtime results from earlier revisions are not evidence for this head. Local APK assembly uses the official native release inputs rather than a local native rebuild; native stripping fell back to packaging those inputs unchanged. Production signing and independent binary reproducibility were not checked.

Replace the toast-shaped overlay and Android Toast fallback with standard snackbars and permission-aware background notifications. Retain the existing helper API to avoid unrelated caller churn.

Keep multiline errors and errors over 120 Unicode characters visible until Close is activated. Queue later messages, retain the queue across activity recreation, and allow long text to scroll. Routine feedback keeps the standard accessibility-adjusted timeout.

Use replaceable, expiring notifications for routine background feedback and independently dismissible notifications for long errors. A resumed host acknowledges terminal service feedback; a background state subscriber does not suppress delivery. Localize the channel and completed-stop text in all nine maintained locales.

Validation: 87 JVM tests passed; Play Store debug x86_64 assembled. Emulator checks cover timing, dismissal, rotation, foreground/background delivery, permission denial, and real lab proxy-only start/restart/stop. Lint retains four pre-existing NewApi errors outside the changed files.
Reserve the main bottom bar button width and edge inset symmetrically, retaining the existing safe-area centering and maximum snackbar width. This leaves the service control unobstructed without moving it or changing message behavior.

Validation: 87 Play Store debug unit tests, Kotlin compilation and x86_64 debug assembly passed. Emulator checks confirmed centering and non-overlap in portrait and landscape, plus Close activation across light/dark themes, dynamic colors and both column layouts.
Own the Material snackbar queue at process lifetime. Only the resumed host renders it; activity replacement preserves unread messages, and actual backgrounding transfers them to permission-aware notifications. All foreground delivery paths now use the same coordinator instead of an activity ViewModel and separate teardown fallback.

Give persistent error notifications distinct immutable intents to a private, scrollable full-text destination. Preserve the complete message through SavedStateHandle and provide Close and normal back navigation without introducing new translation keys.

Emit Service stopped from the existing native completion callback, not when asynchronous shutdown is requested. Keep internal reloads and failed-start cleanup silent through a small daemon-side feedback state. Remove the now-unused reload parameter without changing native shutdown or connection-test cancellation ownership.

Validation: focused and complete JVM tests, Kotlin compilation and x86_64 debug assembly passed. Emulator reproductions now pass for editor completion, background queue delivery, rotation, persistent errors and distinct notification targets. Real lab-profile proxy and VPN start/stop feedback also passed. Full lint retains four pre-existing NewApi errors outside these changes.
Open retained error notifications in an isolated notification-only task, using direct immutable PendingIntents instead of rebuilding the main activity stack. Routine notifications reuse Main; error identities, full-text restoration and explicit dismissal remain intact.

Classify malformed custom-config diagnostics and invalid proxy-chain member lists as errors so long messages require dismissal while short messages retain their timeout. Simplify nullable-tag posting, compute immutable dismissal policy once, and avoid redundant blank checks and unused Close-label lookups.

Make successful startup or reload arm feedback only from the empty state, preserving an outstanding stop request. Add focused regressions for stop/reload interleaving and recovery after a failed reload without expanding the service lifecycle model.

Validation: 96 JVM tests, Kotlin compilation and x86_64 debug assembly passed. Emulator checks cover unsaved-editor preservation, distinct error targets, normal Main reuse, real validation callers, rotation/scrolling/dismissal, message handoff, background policy, and normal VPN/proxy-only start-stop feedback. Full lint retains four pre-existing NewApi errors outside this patch; native handover/stop race injection and root-mode runtime were not run.
Route all feedback notification taps to MainActivity. Remove UserMessageActivity, its ViewModel and manifest registration, and the per-error navigation payload and task setup. Notification text may be truncated by Android, as requested.

Keep expanded notification text, independent retained-error identities, existing expiry and permission policy, and foreground snackbar behavior unchanged.

Validation: all 96 JVM tests, Kotlin compilation and x86_64 debug assembly passed. Emulator checks confirmed the activity is absent, retained error and routine notification taps reuse Main, and tapped notifications dismiss correctly. Native inputs were unchanged; no Android test directory was introduced.
Replace stale toast comments and parser-log wording, and remove the commented-out stop message without changing completed-stop delivery. Remove the obsolete ToastCompat license listing after confirming no resolved runtime dependency remains; retain the shared Apache license text.

Delete seven unreferenced resource keys from all nine locale catalogs, leaving every surviving resource unchanged. Route nine permission, file-picker, QR-decoding, certificate-fetch, asset-download and subscription-import failure sites through toastError. Preserve informational prompts, progress, summaries and the existing compatibility API.

Validation: focused message/delivery tests and all 96 JVM tests passed, along with Kotlin compilation and x86_64 debug assembly. Foreground/background emulator smoke checks passed for timeout, dismissal, rotation, queued feedback, notification retention and terminal delivery. Catalog/reference checks passed; no native inputs or Android test sources changed. Individual operation-failure scenarios and TalkBack speech were not rerun.
@eliotcougar

Copy link
Copy Markdown
Contributor Author

I didn't rename toast, toastError, and toastSuccess.
toast and toastSuccess are currently identical and don't have a distinct style.

These issues can be addressed if you want.

@2dust

2dust commented Sep 21, 2026

Copy link
Copy Markdown
Owner

感谢 pr
测试发现一个 bug,在其他页面弹出的信息后,切换到主页面后消息会重复弹出一次。复现如下:

  1. 打开检查更新页面,等弹出消息
  2. 回退到主页面

@2dust

2dust commented Sep 21, 2026

Copy link
Copy Markdown
Owner

提交功能最好是分开 多个 PR:

  1. toast 的重构
  2. MessageHelper 的重构
  3. 调用处的新增或修改

@2dust

2dust commented Sep 21, 2026

Copy link
Copy Markdown
Owner

先不急着修改,需要点时间考虑下整体的方案。

@eliotcougar

Copy link
Copy Markdown
Contributor Author

I agree completely. We will continue to refine this PR as necessary. Splitting is also possible.
The main point is that addressing feedback architecture is necessary before finalizing TalkBack part 1 PR that builds on it.

The process-owned snackbar queue outlives individual screens. Previously a still-visible message was rendered again by the next activity, restarting its appearance and timeout when returning from Check for updates to Main.

Record which saved screen identity actually presented each snackbar and dismiss shown transient feedback when another screen takes over. Keep unseen messages queued, including confirmations emitted immediately before an editor finishes, and retain long errors until explicitly dismissed. Preserve the host identity across recreation so rotation does not discard feedback.

Add regression coverage for navigation, queued messages, recreation, repeated text, and stale presentation callbacks. Validated with 101 JVM tests and API 37 emulator checks for navigation, rotation, editor completion, foreground timing, and background fallback delivery.
Resolve the Coil dependency conflict by keeping upstream Coil 3 and the process-lifecycle dependency required by snackbar ownership. Retain upstream Gradle, AGP, Kotlin, form-validation, deletion-dialog and translation updates.

Route the background feedback channel through upstream ensureNotificationChannel so all channels share the same localized-name update behavior while preserving user preferences. Remove the now-duplicate channel-creation block.

Keep the snackbar navigation replay fix, queued save confirmations, long-error dismissal and service-feedback handling intact. Validated the merged sources with 118 JVM tests, Play Store debug compilation and assembly, plus emulator navigation, recreation and inline-validation checks.
Retain upstream's single-dispatcher approach and reuse one lazy main-thread
handler. Preserve both resource and text overloads of toast, toastSuccess,
toastError and toastInfo, including the new optional long argument. Normal,
success and info feedback share the same delivery path and presentation.

Carry explicit long duration through UserMessage to Material's timed Long
duration. Lengthy or multiline errors continue to require dismissal regardless
of that option. Keep notification fallback, localized resource lookup, queued
save confirmations and the navigation-replay fix; do not restore Android Toasts.

Keep upstream inline password/subscription validation and its deletion of the
obsolete ServerActivity. Preserve error classification in the current editors
without reintroducing removed validation messages or changing service behavior.

Validation: 121 JVM tests passed, including three duration/navigation regressions;
Play Store debug Kotlin compilation and x86_64 assembly passed. API 37 emulator
checks passed for all 16 helper overload/duration combinations, main/worker
dispatch, actual Long timeout, indefinite errors, navigation, rotation, queued
feedback, acknowledged service events, background replacement/expiry and inline
form validation. No native inputs or Android test sources changed.
Use the upstream 85%-opacity normal, success, error and info palette, compact 14sp text, rounded shape and centered 75%-width placement above the service controls. Carry the message category through the shared foreground/background model instead of discarding success and info styling.

Keep Material host serialization, timing and native accessibility semantics. Retain complete scrollable error text and a separate Close button for long errors; reserve the button height and reduce the bottom offset while the IME is visible so landscape editing does not collapse the message.

Resolve the upstream startup-error change through acknowledged process-owned feedback. Preserve nonblank error details in both the foreground snackbar and notification fallback without duplicating MainViewModel presentation. Retain all other upstream changes unchanged.

Validation: 123 JVM tests, Play Store debug compilation and x86_64 assembly passed. API 37 emulator checks cover message categories, light/dark and dynamic colors, single/double columns, portrait/landscape and IME, full error scrolling, touch/Enter/Space/D-pad dismissal, rotation/navigation retention, terminal-event delivery and background replacement/expiry. Recorded TalkBack speech and physical-device validation were not run.
Resolve shared-resource conflicts without dropping feature-specific semantics or current upstream translations. Retain upstream service and UI updates, and migrate feature regression tests to the upstream JUnit Platform setup.

Validation: PlaystoreDebug JVM suite, Kotlin compilation and APK assembly passed. All declared ABIs contain the current Xray library and both HEV libraries. Full device and OEM lifecycle regression coverage was not run.
Disarm successful-stop feedback before an explicit restart tears down the old core. Preserve an already pending user stop and re-arm feedback only after the replacement starts. Cover repeated cleanup and failed restarts without introducing a second service lifecycle state machine.
Integrate upstream/master 01b4630, including subscription response-header
usage metadata, the subscription information card, pill group navigation,
current Kotlin/Gradle versions, and the upstream native dependency gitlinks.

Preserve process-owned snackbar delivery, permission-aware background
notifications, and the restart/stop feedback fix: intermediate restart and
reload shutdowns stay silent, while an explicit stop reports native completion
only once. Extend the new Azerbaijani catalog with completed-stop wording and
the notification channel, removing the same obsolete toast keys as the other
maintained catalogs.

Validation: all 141 Play Store debug JVM tests passed; Kotlin compilation and
x86_64 debug assembly passed. The three required packaged native libraries
hash-match the official upstream inputs. Locale XML, feature-key coverage,
placeholders, whitespace, and instruction-file staging gates passed.
Not run: device feedback, notification-permission, navigation, and service
lifecycle scenarios in VPN, proxy-only, and root modes; VM/adb use was excluded.
Keep current DNS, WireGuard, Hysteria, subscription display and native dependency changes alongside the foreground and background feedback paths.
Apply the existing transient-message dismissal policy when unregistering the active host reveals another registered host. Preserve unread queued messages and errors that require dismissal, with regression coverage for both cases.

Use the existing localized startup-failure feedback when VPN setup fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants