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

feat: Propagate the doUpdateVisitedHistory callback from WebViewClient #6857

Open
avalanchas opened this issue Sep 2, 2023 · 0 comments · May be fixed by #6858
Open

feat: Propagate the doUpdateVisitedHistory callback from WebViewClient #6857

avalanchas opened this issue Sep 2, 2023 · 0 comments · May be fixed by #6858

Comments

@avalanchas
Copy link

avalanchas commented Sep 2, 2023

Feature Request

Description

Currently, the Android com.getcapacitor.BridgeWebViewClient does not override the doUpdateVisitedHistory callback to its listeners. This knowledge should be available to the WebViewListeners, so they can (optionally) react, update their plugin functionality or act on native code

Platform(s)

This is an android platform-specific call for the WebViewClient

Preferred Solution

Add to BridgeWebViewClient:

@Override
public void doUpdateVisitedHistory [...]
    for (WebViewListener listener : bridge.getWebViewListeners()) {
        listener.onUpdateVisitedHistory(view.canGoBack());
    }

Add to WebViewListener:

/**
* Callback for page-visit changes that should lead to the user having different browsing state
* and history.
* 
* @param canGoBack Whether or not the user can go further back in the visit history
*/
public void onUpdateVisitedHistory(boolean canGoBack) {
    // Override me to add behavior to the page-visit history update
}

Alternatives

See context below, all alternatives that provide the same level of support for plugins would involve a lot of custom code with separate fields that know the state of the WebView navigation stack

Additional Context

This change will soon be required to improve the OnBackPressedDispatcher / OnBackInvokedDispatcher handling in Android. Android 13 already introduced Support for predictive back-gestures when leaving the activity, and claims this will be fleshed out in the coming years with support for predictive back in fragment transitions. The change proposed in this feature request comes from the fact that their CodeLab uses the doUpdateVisitedHistory callback, so for example the Capacitor App Plugin will sorely need this callback soon

@ionitron-bot ionitron-bot bot added the triage label Sep 2, 2023
@ionitron-bot ionitron-bot bot removed triage labels Sep 2, 2023
avalanchas pushed a commit to avalanchas/capacitor that referenced this issue Sep 2, 2023
…nic-team#6857

fix variable usage in for loops to avoid second get call
@avalanchas avalanchas linked a pull request Sep 2, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants