added themeing for peertube, change peertube instance

This commit is contained in:
Ritvik Saraf 2018-12-29 23:06:39 +05:30
parent 9530af95f4
commit 845663f80f
36 changed files with 140 additions and 4 deletions

View file

@ -44,6 +44,10 @@ public class KioskTranslator {
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_hot);
case "New & hot":
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_hot);
case "Local":
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_kiosk_local);
case "Recently added":
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_kiosk_recent);
default:
return 0;
}

View file

@ -1,6 +1,7 @@
package org.schabi.newpipe.util;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
@ -10,7 +11,9 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
@ -24,9 +27,11 @@ public class ServiceHelper {
case 0:
return R.drawable.place_holder_youtube;
case 1:
return R.drawable.place_holder_circle;
return R.drawable.place_holder_cloud;
case 2:
return R.drawable.place_holder_peertube;
default:
return R.drawable.service;
return R.drawable.place_holder_circle;
}
}
@ -127,4 +132,19 @@ public class ServiceHelper {
default: return true;
}
}
public static void initService(Context context, int serviceId) {
if(serviceId == 2){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
String peerTubeInstanceUrl = sharedPreferences.getString(context.getString(R.string.peertube_instance_url_key), ServiceList.PeerTube.getBaseUrl());
String peerTubeInstanceName = sharedPreferences.getString(context.getString(R.string.peertube_instance_name_key), ServiceList.PeerTube.getServiceInfo().getName());
ServiceList.PeerTube.setInstance(peerTubeInstanceUrl, peerTubeInstanceName);
}
}
public static void initServices(Context context){
for(StreamingService s : ServiceList.all()){
initService(context, s.getServiceId());
}
}
}

View file

@ -136,7 +136,14 @@ public class ThemeHelper {
else if (selectedTheme.equals(blackTheme)) themeName = "BlackTheme";
else if (selectedTheme.equals(darkTheme)) themeName = "DarkTheme";
themeName += "." + service.getServiceInfo().getName();
switch (serviceId) {
case 2:
//service name for peertube depends on the instance
themeName += ".PeerTube";
break;
default:
themeName += "." + service.getServiceInfo().getName();
}
int resourceId = context.getResources().getIdentifier(themeName, "style", context.getPackageName());
if (resourceId > 0) {