Compare commits

...

2 Commits

Author SHA1 Message Date
blankie e222867ec6
Handle youtu.be URLs 2022-07-28 20:57:43 +07:00
blankie 747d32dddf
Use Theme.NoDisplay 2022-07-28 20:46:35 +07:00
2 changed files with 16 additions and 8 deletions

View File

@ -11,6 +11,7 @@
android:theme="@style/Theme.Unshortify">
<activity android:name="ShareActivity"
android:theme="@android:style/Theme.NoDisplay"
android:exported="true">
<intent-filter>

View File

@ -56,7 +56,8 @@ public class ShareActivity extends Activity {
: null;
logVariable("host", host);
if (host == null || (!host.equals("youtube.com") &&
!host.endsWith(".youtube.com"))) {
!host.endsWith(".youtube.com") &&
!host.equals("youtu.be"))) {
Toast.makeText(getApplicationContext(), R.string.non_youtube_url,
Toast.LENGTH_SHORT).show();
return;
@ -69,14 +70,20 @@ public class ShareActivity extends Activity {
Toast.LENGTH_SHORT).show();
return;
}
if (!path.toLowerCase(Locale.ROOT).startsWith("/shorts/")) {
Toast.makeText(getApplicationContext(), R.string.non_shorts_url,
Toast.LENGTH_SHORT).show();
return;
}
final String[] pathSegments = urlParsed.getPath().split("/");
if (pathSegments.length != 3) {
String videoId = null;
if (host.equals("youtu.be")) {
final String[] pathSegments = urlParsed.getPath().split("/");
if (pathSegments.length == 2) {
videoId = pathSegments[1];
}
} else if (path.toLowerCase(Locale.ROOT).startsWith("/shorts/")) {
final String[] pathSegments = urlParsed.getPath().split("/");
if (pathSegments.length == 3) {
videoId = pathSegments[2];
}
}
if (videoId == null || videoId.isEmpty()) {
Toast.makeText(getApplicationContext(), R.string.non_shorts_url,
Toast.LENGTH_SHORT).show();
return;