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

Added option For user to choose how to open youtube links

This commit is contained in:
massimiliano 2018-11-23 19:20:59 +01:00
parent 4ccda302b1
commit e905504dff
6 changed files with 24 additions and 11 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

@ -40,10 +40,7 @@ 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
AppSettings appSettings = AppSettings.get();
public CustomWebViewClient(App app, WebView webView) {
this.app = app;
@ -63,13 +60,10 @@ public class CustomWebViewClient extends WebViewClient {
|| url.startsWith("http://" + host)))) {
return false;
}//make youtube links open external-->never customtab
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 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>
<string name="pref_key__open_youtube_external_enabled" translatable="false">pref_key__open_youtube_external_enabled</string>//make youtube open external
</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"