Skip to content

Commit f2aaeb6

Browse files
committed
fixed external links and non-http protocols leading to an error (accidentally pushed all into last commit - cleaning up here)
1 parent 3b7efdd commit f2aaeb6

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

app/src/main/java/at/xtools/pwawrapper/webview/WebViewHelper.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import android.os.Build;
1313
import android.os.Handler;
1414
import android.os.Message;
15-
import android.util.Log;
1615
import android.webkit.CookieManager;
1716
import android.webkit.WebChromeClient;
1817
import android.webkit.WebResourceError;
@@ -144,31 +143,27 @@ public void onProgressChanged(WebView view, int newProgress) {
144143
@Override
145144
public void onPageStarted(WebView view, String url, Bitmap favicon) {
146145
super.onPageStarted(view, url, favicon);
147-
Log.d("TAG", "started url: "+url);
148146
handleUrlLoad(view, url);
149147
}
150148

151149
// handle loading error by showing the offline screen
152150
@Deprecated
153151
@Override
154152
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
155-
Log.d("TAG", "receivedError Old");
156153
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
157-
handleLoadError(view, failingUrl, errorCode);
154+
handleLoadError(errorCode);
158155
}
159156
}
160157

161158
@TargetApi(Build.VERSION_CODES.M)
162159
@Override
163160
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
164-
Log.d("TAG", "receivedError New");
165161
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
166162
// new API method calls this on every error for each resource.
167163
// we only want to interfere if the page itself got problems.
168164
String url = request.getUrl().toString();
169165
if (view.getUrl().equals(url)) {
170-
Log.d("TAG", "receivedError New page match " + error.getDescription().toString());
171-
handleLoadError(view, url, error.getErrorCode());
166+
handleLoadError(error.getErrorCode());
172167
}
173168
}
174169
}
@@ -192,11 +187,10 @@ private void showNoAppDialog(Activity thisActivity) {
192187
.show();
193188
}
194189
// handle load errors
195-
private void handleLoadError(WebView view, String url, int errorCode) {
190+
private void handleLoadError(int errorCode) {
196191
if (errorCode != WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
197192
uiManager.setOffline(true);
198193
} else {
199-
Log.d("TAG", "unsupported scheme!");
200194
// Unsupported Scheme, recover
201195
new Handler().postDelayed(new Runnable() {
202196
@Override
@@ -214,15 +208,6 @@ private boolean handleUrlLoad(WebView view, String url) {
214208
// stop loading
215209
view.stopLoading();
216210

217-
/*
218-
// handle non-http protocols, like mailto: or whatsapp:
219-
if (!url.startsWith("http")) {
220-
// this hit the WebView's onReceivedError callback, recover
221-
goBack();
222-
uiManager.setOffline(false);
223-
}
224-
*/
225-
226211
// open external URL in Browser/3rd party apps instead
227212
try {
228213
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

0 commit comments

Comments
 (0)