mirror of
https://github.com/gsantner/dandelion
synced 2025-09-10 10:49:42 +02:00
Make youtube links open external, by @massimilianoLe (#220)
This commit is contained in:
parent
04e89e516c
commit
f693418d64
7 changed files with 31 additions and 4 deletions
|
@ -359,6 +359,10 @@ public class AppSettings extends SharedPreferencesPropertyBackend {
|
|||
return getBool(R.string.pref_key__topbar_stream_shortcut, false);
|
||||
}
|
||||
|
||||
public boolean isOpenYoutubeExternalEnabled() {
|
||||
return getBool(R.string.pref_key__open_youtube_external_enabled, true);
|
||||
}
|
||||
|
||||
public String getScreenRotation() {
|
||||
return getString(R.string.pref_key__screen_rotation, R.string.rotation_val_system);
|
||||
}
|
||||
|
|
|
@ -94,9 +94,9 @@ public class BrowserFragment extends ThemedFragment {
|
|||
this.setRetainInstance(true);
|
||||
|
||||
//pull to refresh
|
||||
swipe = view.findViewById(R.id.swipe);
|
||||
swipe.setOnRefreshListener(() -> reloadUrl());
|
||||
swipe.setDistanceToTriggerSync(20000);
|
||||
swipe = view.findViewById(R.id.swipe);
|
||||
swipe.setOnRefreshListener(() -> reloadUrl());
|
||||
swipe.setDistanceToTriggerSync(2000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
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;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.webkit.CookieManager;
|
||||
|
@ -38,6 +40,7 @@ public class CustomWebViewClient extends WebViewClient {
|
|||
private final App app;
|
||||
private String lastLoadUrl = "";
|
||||
private boolean isAdBlockEnabled = false;
|
||||
AppSettings appSettings = AppSettings.get();
|
||||
|
||||
public CustomWebViewClient(App app, WebView webView) {
|
||||
this.app = app;
|
||||
|
@ -56,6 +59,11 @@ public class CustomWebViewClient extends WebViewClient {
|
|||
|| (host != null && (url.startsWith("https://" + host)
|
||||
|| url.startsWith("http://" + host)))) {
|
||||
return false;
|
||||
}//make youtube links open external-->never customtab
|
||||
else if (appSettings.isOpenYoutubeExternalEnabled()&&(url.startsWith("https://youtube.com/") || url.startsWith("https://www.youtube.com/") || url.startsWith("https://m.youtube.com/") || url.startsWith("https://youtu.be/"))){
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
view.getContext().startActivity(intent);
|
||||
return true;
|
||||
} else {
|
||||
Intent i = new Intent(MainActivity.ACTION_OPEN_EXTERNAL_URL);
|
||||
i.putExtra(MainActivity.EXTRA_URL, url);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue