Simplify nearby discovery: follow the app lifecycle and remove duplicate controls - #20
Merged
Conversation
People open Sync360 to share something, not to manage a discovery timer or choose between several buttons that restart similar operations. Replace the 60-second discovery window with discovery that follows Android app visibility. Keep it active while the app is visible, schedule cleanup after a short background grace period, and cancel the pending stop when the user returns quickly. Keep explicit Start/Stop controls beside nearby devices. Respect manual Stop across background/foreground transitions within the same process. Remove Reload, the separate Repair command, its Settings screen, and Troubleshoot shortcuts. Keep Try again for actual operation failures. Keep this implementation focused on app visibility. Remove connectivity monitoring, network-address tracking, and automatic network-change refreshes. Users can stop and restart discovery themselves when needed. Centralize discovery intent in the shared controller. Give Android scans explicit callback ownership, queue legacy Android 13 resolution, and preserve failed cleanup for retry. Keep discovery lifetime separate from transfer listeners and received content. Simplify Nearby devices into compact rows with contextual controls and a clear empty state. Desktop discovery remains active when minimized. The aim is understandable behavior and maintainable code, rather than reducing line count for its own sake. Upcoming work prioritizes code review, failure handling, and validation toward a stable 1.0. Further native discovery implementations are under consideration, without a confirmed schedule. Validation: static review and whitespace checks completed. New Android and Windows builds and lifecycle scenarios still require validation before the intended 0.5.0 preview release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this change exists
You open Sync360 because you want to send text or a file to another device. Finding that device should feel like a natural part of sharing.
Previously, discovery had a 60-second window. When that window ended, scanning stopped while device advertising could remain active.
Reload button on send screen restarted only discovery scan, while Repair button on settings screen followed another path to recreate discovery and advertising.
Those distinctions had reasons in the code, but they gave users—and the maintainer—more things to understand.
This change asks a smaller question: what behavior does nearby sharing actually need?
The thinking behind it
Earlier changes to Sync360 questioned whether every interaction needed an approval step. Text moved toward direct delivery, files adopted a receive-code flow, and navigation moved toward showing one screen at a time.
Those are earlier changes, not features newly implemented in this PR. Their lesson shaped this work: sometimes the useful improvement comes from removing a decision or process altogether.
For discovery, that meant questioning the expiring scan and overlapping recovery controls.
We also learned that a simple explanation does not automatically produce simple code. An early implementation included connectivity monitoring and automatic refreshes after network changes. That added address tracking, callbacks, timing, and coordination beyond the behavior we wanted to establish.
That machinery was removed. The current scope is deliberately focused on app visibility and explicit user control.
The new Android behavior
Discovery stays active while Sync360 is visible, without a 60-second expiry.
When the app moves into the background, a two-second grace period is scheduled after Android's process lifecycle reports backgrounding. If the user returns before the pending stop runs, it is cancelled.
This avoids repeatedly tearing down discovery when someone briefly switches apps or rapidly backgrounds and reopens Sync360.
If the user stays away, discovery and advertising stop and clean up. Returning after cleanup allows a fresh session to start.
An explicit manual Stop is respected across background/foreground transitions until Start is pressed or a fresh app process launches.
Desktop retains its existing availability while minimized. iOS visibility integration is outside this change.
Fewer controls in a clearer place
Start and Stop live inside Nearby devices.
Reload and the separate Repair action have been removed. Repair had become another way to request a discovery restart, which users can already accomplish by stopping discovery and starting it again.
Because Repair was the only Settings item, its screen and the associated Troubleshoot shortcuts were removed too.
Actual start or cleanup failures still offer Try again.
The Nearby devices section now uses compact device rows and a straightforward empty state. Device taps continue through the existing sending flow; this change does not introduce a new pairing or selection protocol.
What happens after a network change?
The app does not inspect network changes or automatically refresh discovery.
If devices disappear after changing Wi-Fi or hotspot connections, users can stop discovery, wait for it to stop, and start it again.
This is an intentional tradeoff. Automatic recovery may be revisited later, after the existing behavior is better understood and validated.
Technical changes
The app still needs careful native cleanup. Simplification does not mean deleting necessary callback, socket, or resource handling.