1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-12-22 19:08:03 +01:00

Make youtube links open external, by @massimilianoLe (#220)

This commit is contained in:
massimilianoLe 2018-12-01 17:12:04 +01:00 committed by Gregor Santner
parent 04e89e516c
commit f693418d64
7 changed files with 31 additions and 4 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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);

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="48"
android:viewportWidth="48" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000"
android:pathData="M19.0447,29.8394 L32.0088,23.143 19.0447,16.3663ZM24,6.7503c10.0981,0 16.7945,0.4821 16.7945,0.4821 0.9375,0.1071 3,0.1071 4.8214,2.0357 0,0 1.4732,1.4464 1.9018,4.7678 0.5089,3.8839 0.4821,7.7678 0.4821,7.7678v3.6428c0,0 0.0268,3.8839 -0.4821,7.7678 -0.4286,3.2946 -1.9018,4.7678 -1.9018,4.7678 -1.8214,1.9018 -3.8839,1.9018 -4.8214,2.0089C40.7945,39.9911 34.0981,40.5 24,40.5 11.518,40.3929 7.6877,40.0179 7.6877,40.0179 6.6162,39.8304 4.2056,39.8839 2.3841,37.9822c0,0 -1.4732,-1.4732 -1.9018,-4.7678C-0.0265,29.3305 0.0002,25.4466 0.0002,25.4466v-3.6428c0,0 -0.0268,-3.8839 0.4821,-7.7678C0.9109,10.7146 2.3841,9.2682 2.3841,9.2682 4.2056,7.3396 6.268,7.3396 7.2055,7.2325c0,0 6.6964,-0.4821 16.7945,-0.4821z" android:strokeWidth="0.02678544"/>
</vector>

View file

@ -148,4 +148,5 @@
<string name="pref_key__show_title" translatable="false">pref_key__show_title</string>
<string name="pdf" translatable="false">PDF</string>
<string name="gsantner" translatable="false">gsantner</string>
</resources>
<string name="pref_key__open_youtube_external_enabled" translatable="false">pref_key__open_youtube_external_enabled</string>
</resources>

View file

@ -253,5 +253,7 @@
<string name="the_following_libraries_are_used">The following libraries are used:</string>
<string name="inspiration_from_leafpic__appspecific">We took some inspiration and code from LeafPic. Go check it out, it\'s free software as well!</string>
<string name="tell_me_more">Tell me more</string>
<string name="open_youtube_external_tabs_description">Enable to open Youtube links on external app</string>
<string name="pref_title__open_youtube_external">Youtube links</string>
</resources>

View file

@ -73,6 +73,13 @@
android:summary="@string/open_external_links_with_chrome_custom_tabs_description"
android:title="@string/pref_title__chrome_custom_tabs_enabled"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference
android:defaultValue="true"
android:icon="@drawable/ic_open_yt_external_black_24px"
android:key="@string/pref_key__open_youtube_external_enabled"
android:summary="@string/open_youtube_external_tabs_description"
android:title="@string/pref_title__open_youtube_external"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference
android:defaultValue="false"
android:icon="@drawable/ic_touch_app_black_24px"