added themeing for peertube, change peertube instance
@ -54,7 +54,7 @@ dependencies {
|
||||
exclude module: 'support-annotations'
|
||||
})
|
||||
|
||||
implementation 'com.github.yausername:NewPipeExtractor:df0db84'
|
||||
implementation 'com.github.yausername:NewPipeExtractor:b1a77fa'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.23.0'
|
||||
|
@ -50,6 +50,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
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.fragments.BackPressable;
|
||||
@ -95,6 +96,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (DEBUG) Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
|
||||
|
||||
ServiceHelper.initServices(this);
|
||||
|
||||
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -18,9 +18,11 @@ import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.report.ErrorActivity;
|
||||
import org.schabi.newpipe.report.UserAction;
|
||||
import org.schabi.newpipe.util.Constants;
|
||||
import org.schabi.newpipe.util.FilePickerActivityHelper;
|
||||
import org.schabi.newpipe.util.ZipHelper;
|
||||
|
||||
@ -39,6 +41,9 @@ import java.util.Map;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class ContentSettingsFragment extends BasePreferenceFragment {
|
||||
|
||||
private static final int REQUEST_IMPORT_PATH = 8945;
|
||||
@ -122,6 +127,40 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
||||
NewPipe.setLocalization(new Localization((String) newCountry, oldLocal.getLanguage()));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
Preference peerTubeInstance = findPreference(getString(R.string.peertube_instance_url_key));
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
peerTubeInstance.setDefaultValue(sharedPreferences.getString(getString(R.string.peertube_instance_url_key), ServiceList.PeerTube.getBaseUrl()));
|
||||
peerTubeInstance.setSummary(sharedPreferences.getString(getString(R.string.peertube_instance_url_key), ServiceList.PeerTube.getBaseUrl()));
|
||||
|
||||
peerTubeInstance.setOnPreferenceChangeListener((Preference p, Object newInstance) -> {
|
||||
String url = (String) newInstance;
|
||||
if(!url.startsWith("https://")){
|
||||
Toast.makeText(getActivity(), "instance url should start with https://",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}else{
|
||||
boolean shouldUpdate = Single.fromCallable(() -> {
|
||||
ServiceList.PeerTube.setInstance(url);
|
||||
return true;
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.onErrorReturnItem(false)
|
||||
.blockingGet();
|
||||
|
||||
if (shouldUpdate) {
|
||||
p.setSummary(url);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(getString(R.string.peertube_instance_name_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
|
||||
editor.putString(getString(R.string.current_service_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
|
||||
editor.putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, true).apply();
|
||||
}else{
|
||||
Toast.makeText(getActivity(), "unable to update instance",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return shouldUpdate;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
BIN
app/src/main/res/drawable-hdpi/ic_kiosklocal_black_24dp.png
Executable file
After Width: | Height: | Size: 208 B |
BIN
app/src/main/res/drawable-hdpi/ic_kiosklocal_white_24dp.png
Executable file
After Width: | Height: | Size: 206 B |
BIN
app/src/main/res/drawable-hdpi/ic_kioskrecent_black_24dp.png
Executable file
After Width: | Height: | Size: 475 B |
BIN
app/src/main/res/drawable-hdpi/ic_kioskrecent_white_24dp.png
Executable file
After Width: | Height: | Size: 460 B |
BIN
app/src/main/res/drawable-mdpi/ic_kiosklocal_black_24dp.png
Executable file
After Width: | Height: | Size: 166 B |
BIN
app/src/main/res/drawable-mdpi/ic_kiosklocal_white_24dp.png
Executable file
After Width: | Height: | Size: 166 B |
BIN
app/src/main/res/drawable-mdpi/ic_kioskrecent_black_24dp.png
Executable file
After Width: | Height: | Size: 311 B |
BIN
app/src/main/res/drawable-mdpi/ic_kioskrecent_white_24dp.png
Executable file
After Width: | Height: | Size: 312 B |
BIN
app/src/main/res/drawable-nodpi/place_holder_cloud.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
app/src/main/res/drawable-nodpi/place_holder_peertube.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_kiosklocal_black_24dp.png
Executable file
After Width: | Height: | Size: 235 B |
BIN
app/src/main/res/drawable-xhdpi/ic_kiosklocal_white_24dp.png
Executable file
After Width: | Height: | Size: 226 B |
BIN
app/src/main/res/drawable-xhdpi/ic_kioskrecent_black_24dp.png
Executable file
After Width: | Height: | Size: 597 B |
BIN
app/src/main/res/drawable-xhdpi/ic_kioskrecent_white_24dp.png
Executable file
After Width: | Height: | Size: 588 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_kiosklocal_black_24dp.png
Executable file
After Width: | Height: | Size: 291 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_kiosklocal_white_24dp.png
Executable file
After Width: | Height: | Size: 284 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_kioskrecent_black_24dp.png
Executable file
After Width: | Height: | Size: 856 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_kioskrecent_white_24dp.png
Executable file
After Width: | Height: | Size: 835 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_kiosklocal_black_24dp.png
Executable file
After Width: | Height: | Size: 344 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_kiosklocal_white_24dp.png
Executable file
After Width: | Height: | Size: 345 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_kioskrecent_black_24dp.png
Executable file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_kioskrecent_white_24dp.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
@ -31,4 +31,23 @@
|
||||
<item name="colorAccent">@color/dark_soundcloud_accent_color</item>
|
||||
</style>
|
||||
|
||||
<!-- PeerTube -->
|
||||
<style name="LightTheme.PeerTube" parent="LightTheme.Switchable">
|
||||
<item name="colorPrimary">@color/light_peertube_primary_color</item>
|
||||
<item name="colorPrimaryDark">@color/light_peertube_dark_color</item>
|
||||
<item name="colorAccent">@color/light_peertube_accent_color</item>
|
||||
</style>
|
||||
|
||||
<style name="DarkTheme.PeerTube" parent="DarkTheme.Switchable">
|
||||
<item name="colorPrimary">@color/dark_peertube_primary_color</item>
|
||||
<item name="colorPrimaryDark">@color/dark_peertube_dark_color</item>
|
||||
<item name="colorAccent">@color/dark_peertube_accent_color</item>
|
||||
</style>
|
||||
|
||||
<style name="BlackTheme.PeerTube" parent="BlackTheme.Switchable">
|
||||
<item name="colorPrimary">@color/dark_peertube_primary_color</item>
|
||||
<item name="colorPrimaryDark">@color/dark_peertube_dark_color</item>
|
||||
<item name="colorAccent">@color/dark_peertube_accent_color</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -28,6 +28,8 @@
|
||||
<attr name="bug" format="reference"/>
|
||||
<attr name="settings" format="reference"/>
|
||||
<attr name="ic_hot" format="reference"/>
|
||||
<attr name="ic_kiosk_local" format="reference"/>
|
||||
<attr name="ic_kiosk_recent" format="reference"/>
|
||||
<attr name="ic_channel" format="reference"/>
|
||||
<attr name="ic_bookmark" format="reference"/>
|
||||
<attr name="ic_playlist_add" format="reference"/>
|
||||
|
@ -22,4 +22,15 @@
|
||||
<color name="dark_soundcloud_accent_color">#FFFFFF</color>
|
||||
<color name="dark_soundcloud_statusbar_color">#ff9100</color>
|
||||
|
||||
<!-- PeerTube -->
|
||||
<color name="light_peertube_primary_color">#f97d46</color>
|
||||
<color name="light_peertube_dark_color">#c04e19</color>
|
||||
<color name="light_peertube_accent_color">#000000</color>
|
||||
<color name="light_peertube_statusbar_color">#f97d46</color>
|
||||
|
||||
<color name="dark_peertube_primary_color">#f97d46</color>
|
||||
<color name="dark_peertube_dark_color">#c04e19</color>
|
||||
<color name="dark_peertube_accent_color">#FFFFFF</color>
|
||||
<color name="dark_peertube_statusbar_color">#f97d46</color>
|
||||
|
||||
</resources>
|
@ -143,6 +143,8 @@
|
||||
<string name="default_language_value">en</string>
|
||||
<string name="default_country_value">GB</string>
|
||||
<string name="content_language_key" translatable="false">content_language</string>
|
||||
<string name="peertube_instance_url_key" translatable="false">peertube_instance_url</string>
|
||||
<string name="peertube_instance_name_key" translatable="false">peertube_instance_name</string>
|
||||
<string name="content_country_key" translatable="false">content_country</string>
|
||||
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
|
||||
<string name="use_tor_key" translatable="false">use_tor</string>
|
||||
|
@ -107,6 +107,7 @@
|
||||
<string name="default_content_country_title">Default content country</string>
|
||||
<string name="service_title">Service</string>
|
||||
<string name="content_language_title">Default content language</string>
|
||||
<string name="peertube_instance_url_title">PeerTube instance</string>
|
||||
<string name="settings_category_player_title">Player</string>
|
||||
<string name="settings_category_player_behavior_title">Behavior</string>
|
||||
<string name="settings_category_video_audio_title">Video & audio</string>
|
||||
|
@ -44,6 +44,8 @@
|
||||
<item name="play">@drawable/ic_play_arrow_black_24dp</item>
|
||||
<item name="settings">@drawable/ic_settings_black_24dp</item>
|
||||
<item name="ic_hot">@drawable/ic_whatshot_black_24dp</item>
|
||||
<item name="ic_kiosk_local">@drawable/ic_kiosklocal_black_24dp</item>
|
||||
<item name="ic_kiosk_recent">@drawable/ic_kioskrecent_black_24dp</item>
|
||||
<item name="ic_channel">@drawable/ic_channel_black_24dp</item>
|
||||
<item name="ic_bookmark">@drawable/ic_bookmark_black_24dp</item>
|
||||
<item name="ic_playlist_add">@drawable/ic_playlist_add_black_24dp</item>
|
||||
@ -104,6 +106,8 @@
|
||||
<item name="play">@drawable/ic_play_arrow_white_24dp</item>
|
||||
<item name="settings">@drawable/ic_settings_white_24dp</item>
|
||||
<item name="ic_hot">@drawable/ic_whatshot_white_24dp</item>
|
||||
<item name="ic_kiosk_local">@drawable/ic_kiosklocal_white_24dp</item>
|
||||
<item name="ic_kiosk_recent">@drawable/ic_kioskrecent_white_24dp</item>
|
||||
<item name="ic_channel">@drawable/ic_channel_white_24dp</item>
|
||||
<item name="ic_bookmark">@drawable/ic_bookmark_white_24dp</item>
|
||||
<item name="ic_playlist_add">@drawable/ic_playlist_add_white_24dp</item>
|
||||
|
@ -28,4 +28,23 @@
|
||||
<item name="colorAccent">@color/dark_soundcloud_accent_color</item>
|
||||
</style>
|
||||
|
||||
<!-- PeerTube -->
|
||||
<style name="LightTheme.PeerTube" parent="LightTheme.Switchable">
|
||||
<item name="colorPrimary">@color/light_peertube_primary_color</item>
|
||||
<item name="colorPrimaryDark">@color/light_peertube_dark_color</item>
|
||||
<item name="colorAccent">@color/light_peertube_accent_color</item>
|
||||
</style>
|
||||
|
||||
<style name="DarkTheme.PeerTube" parent="DarkTheme.Switchable">
|
||||
<item name="colorPrimary">@color/dark_peertube_primary_color</item>
|
||||
<item name="colorPrimaryDark">@color/dark_peertube_dark_color</item>
|
||||
<item name="colorAccent">@color/dark_peertube_accent_color</item>
|
||||
</style>
|
||||
|
||||
<style name="BlackTheme.PeerTube" parent="BlackTheme.Switchable">
|
||||
<item name="colorPrimary">@color/dark_peertube_primary_color</item>
|
||||
<item name="colorPrimaryDark">@color/dark_peertube_dark_color</item>
|
||||
<item name="colorAccent">@color/dark_peertube_accent_color</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -18,6 +18,11 @@
|
||||
android:summary="%s"
|
||||
android:title="@string/content_language_title"/>
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/peertube_instance_url_key"
|
||||
android:title="@string/peertube_instance_url_title"
|
||||
android:inputType="textUri" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/show_age_restricted_content"
|
||||
|