Skip to content

Commit fde0b2a

Browse files
author
Christian Schabesberger
committed
Made youtu.be links be vieweble through NewPipe, and fixed InfoBar design.
1 parent e38f907 commit fde0b2a

7 files changed

Lines changed: 69 additions & 13 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@
5555
android:host="m.youtube.com"
5656
android:scheme="https"
5757
android:pathPrefix="/watch"/>
58+
<data
59+
android:host="youtu.be"
60+
android:scheme="https"
61+
android:pathPrefix="/"/>
62+
<data
63+
android:host="youtu.be"
64+
android:scheme="http"
65+
android:pathPrefix="/"/>
5866
</intent-filter>
5967
</activity>
6068
<activity android:name=".PlayVideoActivity"

app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void onSystemUiVisibilityChange(int visibility) {
120120
}
121121
}
122122
});
123-
hideUi();
123+
showUi();
124124
}
125125

126126
@Override

app/src/main/java/org/schabi/newpipe/VideoListAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
120120
holder.itemDurationView.setText(videoList.get(position).duration);
121121

122122
if(listView.isItemChecked(position)) {
123-
convertView.setBackgroundColor(context.getResources().getColor(R.color.actionBarColorYoutube));
123+
convertView.setBackgroundColor(context.getResources().getColor(R.color.primaryColorYoutube));
124124
} else {
125125
convertView.setBackgroundColor(0);
126126
}

app/src/main/java/org/schabi/newpipe/youtube/YoutubeExtractor.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,32 @@ public static String resolveResolutionString(int itag) {
9595
@Override
9696
public String getVideoId(String videoUrl) {
9797
try {
98-
String query = (new URI(videoUrl)).getQuery();
99-
String queryElements[] = query.split("&");
100-
Map<String, String> queryArguments = new HashMap<>();
101-
for(String e : queryElements) {
102-
String[] s = e.split("=");
103-
queryArguments.put(s[0], s[1]);
98+
URI uri = new URI(videoUrl);
99+
if(uri.getHost().contains("youtube")) {
100+
String query = uri.getQuery();
101+
String queryElements[] = query.split("&");
102+
Map<String, String> queryArguments = new HashMap<>();
103+
for (String e : queryElements) {
104+
String[] s = e.split("=");
105+
queryArguments.put(s[0], s[1]);
106+
}
107+
return queryArguments.get("v");
108+
} else if(uri.getHost().contains("youtu.be")) {
109+
// uri.getRawPath() does somehow not return the last character.
110+
// so we do a workaround instead.
111+
//return uri.getRawPath();
112+
String url[] = videoUrl.split("/");
113+
return url[url.length-1];
114+
} else {
115+
Log.e(TAG, "Error could not parse url: " + videoUrl);
116+
104117
}
105-
return queryArguments.get("v");
106-
} catch(Exception e) {
118+
} catch(Exception e) {
107119
Log.e(TAG, "Error could not parse url: " + videoUrl);
108120
e.printStackTrace();
109121
return "";
110122
}
123+
return null;
111124
}
112125

113126
@Override
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light">
5+
<item name="android:actionBarStyle">@style/NewPipeActionbarTheme</item>
6+
<item name="actionBarStyle">@style/NewPipeActionbarTheme</item>
7+
<item name="android:colorPrimary">@color/primaryColorYoutube</item>
8+
<item name="android:colorPrimaryDark">@color/primaryColorDarkYoutube</item>
9+
</style>
10+
11+
<style name="NewPipeActionbarTheme" parent="Widget.AppCompat.Light.ActionBar.Solid" >
12+
<item name="android:displayOptions">showHome</item>
13+
<item name="displayOptions">showHome</item>
14+
<item name="android:background">@color/primaryColorYoutube</item>
15+
<item name="background">@color/primaryColorYoutube</item>
16+
</style>
17+
18+
<style name="FullscreenTheme" parent="Theme.AppCompat.Light.DarkActionBar">
19+
<item name="android:windowFullscreen">false</item>
20+
<item name="android:windowActionBarOverlay">true</item>
21+
<item name="windowActionBarOverlay">true</item>
22+
<item name="android:actionBarStyle">@style/NewPipePlayerActionBarTheme</item>
23+
<item name="actionBarStyle">@style/NewPipePlayerActionBarTheme</item>
24+
</style>
25+
26+
<style name="NewPipePlayerActionBarTheme" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse" >
27+
<item name="android:displayOptions">showHome</item>
28+
<item name="displayOptions">showHome</item>
29+
<item name="android:background">@color/black_overlay</item>
30+
<item name="background">@color/black_overlay</item>
31+
</style>
32+
</resources>

app/src/main/res/values/colors.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<color name="actionBarColorYoutube">#dd0000</color>
3+
<color name="primaryColorYoutube">#dd0000</color>
4+
<color name="primaryColorDarkYoutube">#bb0000</color>
45
<color name="black_overlay">#66000000</color>
56
</resources>

app/src/main/res/values/styles.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
<style name="AppTheme" parent="Theme.AppCompat.Light">
55
<item name="android:actionBarStyle">@style/NewPipeActionbarTheme</item>
66
<item name="actionBarStyle">@style/NewPipeActionbarTheme</item>
7+
<item name="colorPrimary">@color/primaryColorYoutube</item>
8+
<item name="colorPrimaryDark">@color/primaryColorDarkYoutube</item>
79
</style>
810

911
<style name="NewPipeActionbarTheme" parent="Widget.AppCompat.Light.ActionBar.Solid" >
1012
<item name="android:displayOptions">showHome</item>
1113
<item name="displayOptions">showHome</item>
12-
<item name="android:background">@color/actionBarColorYoutube</item>
13-
<item name="background">@color/actionBarColorYoutube</item>
14+
<item name="android:background">@color/primaryColorYoutube</item>
15+
<item name="background">@color/primaryColorYoutube</item>
1416
</style>
1517

1618
<style name="FullscreenTheme" parent="Theme.AppCompat.Light.DarkActionBar">

0 commit comments

Comments
 (0)