@@ -75,8 +75,6 @@ public class MainActivity extends AppCompatActivity {
75
75
76
76
GoService goService ;
77
77
78
- private String location = "" ;
79
-
80
78
// This is for the file picker dialog invoked by file upload forms in the WebView.
81
79
// Used by e.g. MoonPay's KYC forms.
82
80
private ValueCallback <Uri []> filePathCallback ;
@@ -222,12 +220,6 @@ public void run() {
222
220
vw .getSettings ().setMediaPlaybackRequiresUserGesture (false );
223
221
224
222
vw .setWebViewClient (new WebViewClient () {
225
- @ Override
226
- public void onPageFinished (WebView view , String url ) {
227
- // The url is not correctly updated when navigating to a new page. This allows to
228
- // know the current location and to block external requests on that base.
229
- view .evaluateJavascript ("window.location.pathname" , path -> location = path );
230
- }
231
223
@ Override
232
224
public WebResourceResponse shouldInterceptRequest (final WebView view , WebResourceRequest request ) {
233
225
if (request != null && request .getUrl () != null ) {
@@ -246,30 +238,10 @@ public WebResourceResponse shouldInterceptRequest(final WebView view, WebResourc
246
238
}
247
239
} else {
248
240
// external request
249
- // allow if location is listed
250
- List <Pattern > patterns = new ArrayList <>();
251
- patterns .add (Pattern .compile ("^\" /buy/pocket/.*\" $" ));
252
- patterns .add (Pattern .compile ("^\" /buy/moonpay/.*\" $" ));
253
- patterns .add (Pattern .compile ("^\" /bitsurance/.*\" $" ));
254
- patterns .add (Pattern .compile ("^\" /account/[^\\ /]+/wallet-connect/.*\" $" ));
255
- for (Pattern pattern : patterns ) {
256
- if (pattern .matcher (location ).matches ()) {
257
- return super .shouldInterceptRequest (view , request );
258
- }
259
- }
260
-
261
- String domain = request .getUrl ().getHost ();
262
- if (domain != null ) {
263
- // allow if domain is listed
264
- patterns = new ArrayList <>();
265
- patterns .add (Pattern .compile ("^verify\\ .walletconnect\\ .com$" ));
266
- for (Pattern pattern : patterns ) {
267
- if (pattern .matcher (domain ).matches ()) {
268
- return super .shouldInterceptRequest (view , request );
269
- }
270
- }
271
- }
272
- Util .log ("Blocked: " + url );
241
+ // Unlike the Qt app, we don't allow requests based on which URL we are in
242
+ // currently within the React app, as it's very hard to figure what the
243
+ // current app URL is without having the frontend itself inform us.
244
+ return super .shouldInterceptRequest (view , request );
273
245
}
274
246
} else {
275
247
Util .log ("Null request!" );
@@ -365,12 +337,7 @@ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathC
365
337
final String javascriptVariableName = "android" ;
366
338
vw .addJavascriptInterface (new JavascriptBridge (this ), javascriptVariableName );
367
339
368
- try {
369
- String data = readRawText (getAssets ().open ("web/index.html" ));
370
- vw .loadDataWithBaseURL (BASE_URL , data , null , null , null );
371
- } catch (IOException e ) {
372
- e .printStackTrace ();
373
- }
340
+ vw .loadUrl (BASE_URL + "index.html" );
374
341
375
342
// We call updateDevice() here in case the app was started while the device was already connected.
376
343
// In that case, handleIntent() is not called with ACTION_USB_DEVICE_ATTACHED.
0 commit comments