Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History management for android #453

Merged
merged 3 commits into from
Aug 16, 2023
Merged

Conversation

jonored
Copy link
Contributor

@jonored jonored commented Mar 31, 2023

Adds support for the "back" button in android, adds a function to trigger platform-dependent "back" handling (which on Android includes exiting the app if the history is empty), and extends manageHistory slightly to allow additional behavior on external history navigation such as skipping updates that would now reroute when going backwards.

… for android.

This follows the usage recommended at
https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader
to avoid an issue where assets referred to by file:// urls would receive
a permissions error and never be passed to shouldInterceptRequest in
sufficiently high API levels.

It may be appropriate to expose a method to use a different base URI,
which could simplify CORS for android apps in some use cases, and
additionally a full conversion to WebViewAssetLoader might be
reasonable.
Also exposes the external updates from manageHistory, to allow
additional behavior on "back" and "forward" such as skipping redirected
routes when going backwards.
@jonored
Copy link
Contributor Author

jonored commented Mar 31, 2023

Also includes the change to https://appassets.androidplatform.net for assets.

@@ -87,7 +86,7 @@ public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequ

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if( url != null && !url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("file://")) {
if( url != null && !url.startsWith("http://appassets.androidplatform.net") && !url.startsWith("https://appassets.androidplatform.net") && !url.startsWith("file://")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this bit be included in #452 ?

Pre-existing, but it's odd that above scheme/encodedAuthority are used but here startsWith is used. Maybe we want this de-duplicated

@@ -76,17 +83,24 @@ run jsm = do
continueWithCallbacks $ def
{ _activityCallbacks_onCreate = \_ -> do
a <- getHaskellActivity
let startPage = fromString "file:///android_asset/index.html"
let startPage = fromString "https:///appassets.androidplatform.net/index.html"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra /?

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.

4 participants