Skip to content

Commit 7bace94

Browse files
committed
Added invidious icon + Show it when instance is selected
1 parent 8343edb commit 7bace94

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
import java.util.ArrayList;
9797
import java.util.List;
9898
import java.util.Objects;
99+
import java.util.OptionalInt;
99100

100101
public class MainActivity extends AppCompatActivity {
101102
private static final String TAG = "MainActivity";
@@ -481,19 +482,26 @@ protected void onResume() {
481482
try {
482483
final int selectedServiceId = ServiceHelper.getSelectedServiceId(this);
483484
final StreamingService service = NewPipe.getService(selectedServiceId);
485+
484486
String selectedServiceName = service.getServiceInfo().getName();
487+
int icon = ServiceHelper.getIcon(selectedServiceId);
488+
485489
if (service instanceof InstanceBasedStreamingService) {
486490
final Instance instance =
487-
((InstanceBasedStreamingService) service).getInstance();
491+
((InstanceBasedStreamingService<?>) service).getInstance();
488492
selectedServiceName =
489493
(instance.getServiceName() != null
490494
? instance.getServiceName() + " / "
491495
: "") + instance.getName();
496+
497+
final OptionalInt overrideIcon = ServiceHelper.getOverrideIconForInstance(instance);
498+
if (overrideIcon.isPresent()) {
499+
icon = overrideIcon.getAsInt();
500+
}
492501
}
493502

494503
drawerHeaderBinding.drawerHeaderServiceView.setText(selectedServiceName);
495-
drawerHeaderBinding.drawerHeaderServiceIcon.setImageResource(ServiceHelper
496-
.getIcon(selectedServiceId));
504+
drawerHeaderBinding.drawerHeaderServiceIcon.setImageResource(icon);
497505

498506
drawerHeaderBinding.drawerHeaderServiceView.post(() -> drawerHeaderBinding
499507
.drawerHeaderServiceView.setSelected(true));

app/src/main/java/org/schabi/newpipe/settings/serviceinstances/youtubelike/YouTubeLikeInstanceListFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static class InvidiousInstanceTypeCreator
6363
public InvidiousInstanceTypeCreator() {
6464
super(
6565
InvidiousInstance.SERVICE_NAME,
66-
R.drawable.ic_placeholder_circle, // TODO
66+
R.drawable.ic_placeholder_invidious,
6767
InvidiousInstance.class,
6868
InvidiousInstance::new,
6969
R.string.invidious_instance_list_url);

app/src/main/java/org/schabi/newpipe/util/services/ServiceHelper.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
import org.schabi.newpipe.extractor.ServiceList;
1919
import org.schabi.newpipe.extractor.StreamingService;
2020
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
21+
import org.schabi.newpipe.extractor.instance.Instance;
2122
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
23+
import org.schabi.newpipe.extractor.services.youtube.invidious.InvidiousInstance;
2224

25+
import java.util.OptionalInt;
2326
import java.util.concurrent.TimeUnit;
2427

2528
public final class ServiceHelper {
@@ -45,6 +48,13 @@ public static int getIcon(final int serviceId) {
4548
}
4649
}
4750

51+
public static OptionalInt getOverrideIconForInstance(final Instance instance) {
52+
if (instance instanceof InvidiousInstance) {
53+
return OptionalInt.of(R.drawable.ic_placeholder_invidious);
54+
}
55+
return OptionalInt.empty();
56+
}
57+
4858
public static String getTranslatedFilterString(final String filter, final Context c) {
4959
switch (filter) {
5060
case "all":
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:height="24dp"
3+
android:width="24dp"
4+
android:viewportHeight="607"
5+
android:viewportWidth="607"
6+
android:tint="@color/defaultIconTint">
7+
<path android:pathData="M277,12.1c-77.5,6.8 -152.3,43.6 -202,99.4 -49.1,55.1 -74.3,120 -74.3,191.5 -0.1,46.6 10,88.4 31.2,129.6 14.6,28.4 30.7,50.2 54,73.4 17.2,17.1 26.4,24.7 46.1,37.8 41.5,27.7 90.5,45.2 140.4,50.1 16.1,1.6 50.8,1.4 66.6,-0.4 91.4,-10.5 171.5,-59 221.3,-134.2 30.6,-46.2 46.7,-99.5 46.7,-155.3 0,-26.8 -2.2,-44.8 -8.5,-69.9 -9.4,-37.8 -29.3,-77.8 -54.1,-109.1 -15.6,-19.6 -44.9,-46.5 -66.5,-61.1 -40.5,-27.2 -89.4,-45.3 -137.9,-50.9 -13,-1.5 -50.2,-2.1 -63,-0.9zM324.5,26c52.7,3.9 101.2,20.3 143.5,48.5 17.6,11.7 27.4,19.8 43.6,36 31.5,31.3 51.8,63.3 66.4,104.5 5.2,14.8 11.2,39.9 13.1,55.5 1.9,15 1.7,53.3 -0.4,68.4 -10.2,73 -48.9,138.2 -109.2,183.6 -33.2,25 -71.6,42.5 -113.5,51.9 -34.8,7.7 -78.4,8.7 -115,2.5 -121.4,-20.5 -217.7,-115.7 -235,-232.4 -5.6,-37.7 -3,-80.1 7,-114.8 15.1,-52 42.7,-95 85,-132.6 56.6,-50.2 136.8,-76.8 214.5,-71.1z"
8+
android:fillColor="#FF000000" />
9+
<path android:pathData="M278.7,140.1c-12.4,6.5 -12.3,25.5 0.3,31.9 8.6,4.4 19.6,1.6 24.7,-6.2 5.8,-8.7 2.6,-21.1 -6.7,-25.8 -5.1,-2.6 -13.2,-2.6 -18.3,0.1z"
10+
android:fillColor="#FF000000" />
11+
<path android:pathData="M288.2,196.2c-1.2,1.6 -6.3,16.6 -10.2,30.3 -3,10.4 -10.1,35 -16.5,56.5 -2,6.9 -5.8,19.9 -8.5,29 -2.6,9.1 -6.4,22.1 -8.5,29 -2,6.9 -5.8,19.9 -8.5,29 -2.6,9.1 -6.4,22.1 -8.5,29 -2,6.9 -5.7,19.5 -8.1,28 -5.9,20.7 -9.3,29.9 -11.5,31 -1,0.6 -3.5,1 -5.6,1 -7.3,-0 -8.4,0.8 -8.1,5.4l0.3,4.1 22.8,0.3 22.8,0.2 -0.3,-4.7 -0.3,-4.8 -7.3,-0.3c-6.6,-0.3 -7.4,-0.5 -8.4,-2.7 -1.3,-2.8 0,-10.4 3.7,-22.5 1.3,-4.1 4.7,-15.6 7.5,-25.5 2.8,-9.9 6.6,-23 8.5,-29 1.8,-6.1 5.6,-19.1 8.5,-29 2.8,-9.9 6.6,-23 8.5,-29 1.8,-6.1 5.6,-19.1 8.5,-29 8.5,-29.7 12.3,-41.9 13.1,-42.9 0.5,-0.5 1.7,1.1 2.8,3.5 1,2.4 19.2,39.3 40.3,81.9 21.1,42.6 44.7,90.2 52.3,105.8l13.9,28.2 16.8,-0c9.2,-0 16.8,-0.4 16.8,-0.8 0,-0.4 -7.5,-15.8 -16.6,-34.2 -58.8,-118.3 -96.9,-195.8 -103.3,-210 -2.9,-6.3 -6.9,-15.1 -8.9,-19.5 -4.4,-9.5 -5.8,-11 -8,-8.3z"
12+
android:fillColor="#FF000000" />
13+
</vector>

0 commit comments

Comments
 (0)