1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-14 16:32:08 +01:00

corrected a bit but still not able to check if app is installed

This commit is contained in:
massimiliano 2018-11-23 16:44:36 +01:00
parent 0cd0319ecc
commit 0357e65e73

View file

@ -19,6 +19,7 @@
package com.github.dfa.diaspora_android.web; package com.github.dfa.diaspora_android.web;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
@ -39,6 +40,10 @@ public class CustomWebViewClient extends WebViewClient {
private final App app; private final App app;
private String lastLoadUrl = ""; private String lastLoadUrl = "";
private boolean isAdBlockEnabled = false; private boolean isAdBlockEnabled = false;
protected Context _context;
String newpipe = "org.schabi.newpipe";//for checking if app is installed
String youtube = "com.google.android.youtube";//for checking if app is installed
public CustomWebViewClient(App app, WebView webView) { public CustomWebViewClient(App app, WebView webView) {
this.app = app; this.app = app;
@ -58,10 +63,13 @@ public class CustomWebViewClient extends WebViewClient {
|| url.startsWith("http://" + host)))) { || url.startsWith("http://" + host)))) {
return false; return false;
}//make youtube links open external-->never customtab }//make youtube links open external-->never customtab
if (url.startsWith("https://youtube")||url.startsWith("https://www.youtube")) { else if (url.startsWith("https://youtube.com/") || url.startsWith("https://www.youtube.com/") || url.startsWith("https://m.youtube.com/") || url.startsWith("https://youtu.be/")){// && checkNewpipie != null || checkYoutube != null) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent); //Intent checkNewpipie = new Intent(_context.getPackageManager().getLaunchIntentForPackage(newpipe));
return true; //Intent checkYoutube = new Intent(_context.getPackageManager().getLaunchIntentForPackage(youtube));
//if (checkNewpipie!=null || checkYoutube != null){view.getContext().startActivity(intent);}
view.getContext().startActivity(intent);
return true;
} else { } else {
Intent i = new Intent(MainActivity.ACTION_OPEN_EXTERNAL_URL); Intent i = new Intent(MainActivity.ACTION_OPEN_EXTERNAL_URL);
i.putExtra(MainActivity.EXTRA_URL, url); i.putExtra(MainActivity.EXTRA_URL, url);