From aa25a77d5f3f7731e0dc1b81c3a36e80e4f0bc36 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Wed, 19 May 2021 09:03:57 +0200 Subject: [PATCH] handle youtube.com in app --- app/app/build.gradle | 4 ++-- .../main/java/it/purser/stream/ShareActivity.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/app/build.gradle b/app/app/build.gradle index eea89dc..ebc5c70 100644 --- a/app/app/build.gradle +++ b/app/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "it.purser.stream" minSdkVersion 25 targetSdkVersion 29 - versionCode 104 - versionName "104.0" + versionCode 106 + versionName "106.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/app/src/main/java/it/purser/stream/ShareActivity.java b/app/app/src/main/java/it/purser/stream/ShareActivity.java index 7008d4b..6a65694 100644 --- a/app/app/src/main/java/it/purser/stream/ShareActivity.java +++ b/app/app/src/main/java/it/purser/stream/ShareActivity.java @@ -11,6 +11,9 @@ public class ShareActivity extends Activity { private Uri getSharedLink() { HashSet domains = new HashSet<>(); domains.add("youtu.be"); + domains.add("youtube.com"); + domains.add("www.youtube.com"); + domains.add("tv.nrk.no"); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); @@ -20,6 +23,16 @@ public class ShareActivity extends Activity { Uri uri = Uri.parse(txt); String host = uri.getHost().toLowerCase(Locale.ROOT); if(domains.contains(host)) { + if(host.contains("youtube.com")) { + Uri.Builder builder = new Uri.Builder(); + builder.authority(host); + builder.scheme("https"); + String path = uri.getQueryParameter("v"); + if(path != null) { + builder.path(path); + return builder.build(); + } + } return uri; } } catch(Exception e) {}