-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android): provide WebViewClient accessor (#2477)
- Loading branch information
1 parent
a05311d
commit dd3875b
Showing
2 changed files
with
57 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
32 changes: 32 additions & 0 deletions
32
android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.getcapacitor; | ||
|
||
import android.net.Uri; | ||
import android.webkit.WebResourceRequest; | ||
import android.webkit.WebResourceResponse; | ||
import android.webkit.WebView; | ||
import android.webkit.WebViewClient; | ||
|
||
public class BridgeWebViewClient extends WebViewClient { | ||
private Bridge bridge; | ||
|
||
public BridgeWebViewClient(Bridge bridge) { | ||
this.bridge = bridge; | ||
} | ||
|
||
@Override | ||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { | ||
return bridge.getLocalServer().shouldInterceptRequest(request); | ||
} | ||
|
||
@Override | ||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { | ||
Uri url = request.getUrl(); | ||
return bridge.launchIntent(url); | ||
} | ||
|
||
@Override | ||
public boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
return bridge.launchIntent(Uri.parse(url)); | ||
} | ||
|
||
} |