android: go home instead of closing when back is pressed with no webview history - #249
Open
gabparrot wants to merge 1 commit into
Open
android: go home instead of closing when back is pressed with no webview history#249gabparrot wants to merge 1 commit into
gabparrot wants to merge 1 commit into
Conversation
gabparrot
force-pushed
the
fix-back-press-home
branch
from
June 27, 2026 13:59
9b6630b to
d575c79
Compare
gabparrot
force-pushed
the
fix-back-press-home
branch
from
June 27, 2026 14:10
d575c79 to
4feb286
Compare
rnons
reviewed
Jun 28, 2026
| } | ||
|
|
||
| fun requestGoHome() { | ||
| val home = Uri.parse(webView.url ?: "").buildUpon()?.path("/")?.clearQuery()?.fragment(null)?.build()?.toString() |
Contributor
There was a problem hiding this comment.
instead of depending on current url, should we map to either https://m.youtube.com/ or https://music.youtube.com/
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.
When the app was opened directly on a video (e.g. via a YouTube deep link, or via "Restore last playing on start" resuming a watch URL), there was no WebView back history to return to, so pressing the hardware back button called
Activity.finish()and closed the app instead of landing on the home page (#250).NouTubeView.goBackonly had two outcomes: navigate back ifcanGoBack()is true, otherwise finish the activity. There was no path that landed the user on the home page first.When
canGoBack()is false, check the current path. If we're already on a home root (/or empty), finish the activity as before so the user can still close the app from home. Otherwise navigate the WebView to the current host's root (e.g.https://m.youtube.com/orhttps://music.youtube.com/) and clear the WebView history once the load completes (via apendingClearHistoryflag consumed inonPageFinished), so the next back press from home closes the app cleanly instead of bouncing back to the video.canGoBack()paths, share-intent handling, and the "Restore last playing on start" setting are unchanged.Closes #250