Simplifying shouldOverrideUrlLoading
This commit is contained in:
parent
b8bbd8f6e0
commit
f89829735d
@ -301,45 +301,35 @@ public class LightningWebClient extends WebViewClient {
|
|||||||
|
|
||||||
Map<String, String> headers = mLightningView.getRequestHeaders();
|
Map<String, String> headers = mLightningView.getRequestHeaders();
|
||||||
|
|
||||||
// If the headers are empty, the user has not expressed the desire
|
if (mLightningView.isIncognito()) {
|
||||||
// to use them and therefore we can revert back to the old way of loading
|
// If we are in incognito, immediately load, we don't want the url to leave the app
|
||||||
if (headers.isEmpty()) {
|
return continueLoadingUrl(view, url, headers);
|
||||||
if (mLightningView.isIncognito()) {
|
}
|
||||||
// If we are in incognito, immediately load, we don't want the url to leave the app
|
if (url.startsWith(Constants.ABOUT)) {
|
||||||
return false;
|
// If this is an about page, immediately load, we don't need to leave the app
|
||||||
}
|
return continueLoadingUrl(view, url, headers);
|
||||||
if (url.startsWith(Constants.ABOUT)) {
|
}
|
||||||
// If this is an about page, immediately load, we don't need to leave the app
|
|
||||||
return false;
|
if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) {
|
||||||
}
|
// If it was a mailto: link, or an intent, or could be launched elsewhere, do that
|
||||||
|
return true;
|
||||||
if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) {
|
}
|
||||||
// If it was a mailto: link, or an intent, or could be launched elsewhere, do that
|
|
||||||
return true;
|
// If none of the special conditions was met, continue with loading the url
|
||||||
}
|
return continueLoadingUrl(view, url, headers);
|
||||||
} else {
|
}
|
||||||
if (mLightningView.isIncognito() && Utils.doesSupportHeaders()) {
|
|
||||||
// If we are in incognito, immediately load, we don't want the url to leave the app
|
private boolean continueLoadingUrl(@NonNull WebView webView,
|
||||||
view.loadUrl(url, headers);
|
@NonNull String url,
|
||||||
return true;
|
@NonNull Map<String, String> headers) {
|
||||||
}
|
if (headers.isEmpty()) {
|
||||||
if (url.startsWith(Constants.ABOUT) && Utils.doesSupportHeaders()) {
|
return false;
|
||||||
// If this is an about page, immediately load, we don't need to leave the app
|
} else if (Utils.doesSupportHeaders()) {
|
||||||
view.loadUrl(url, headers);
|
webView.loadUrl(url, headers);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
|
return false;
|
||||||
if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) {
|
|
||||||
// If it was a mailto: link, or an intent, or could be launched elsewhere, do that
|
|
||||||
return true;
|
|
||||||
} else if (Utils.doesSupportHeaders()) {
|
|
||||||
// Otherwise, load the headers.
|
|
||||||
view.loadUrl(url, headers);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If none of those instances was true, revert back to the old way of loading
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMailOrIntent(@NonNull String url, @NonNull WebView view) {
|
private boolean isMailOrIntent(@NonNull String url, @NonNull WebView view) {
|
||||||
|
Loading…
Reference in New Issue
Block a user