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
1 changed files with 12 additions and 4 deletions

View File

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