Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fc31458
added peertube
yausername Oct 11, 2018
cc6989b
updated extractor
yausername Oct 12, 2018
d61797f
merged dev
yausername Dec 25, 2018
c1efa78
Merge branch 'dev' into peertube
yausername Dec 25, 2018
9530af9
Merge branch 'dev' into peertube
yausername Dec 25, 2018
845663f
added themeing for peertube, change peertube instance
yausername Dec 29, 2018
d90b1ca
merged upstream/dev, changes for peertube support
yausername Mar 9, 2019
2581fa4
init services in app onCreate
yausername Mar 10, 2019
a8b5534
darker color for peertube
yausername Mar 10, 2019
039a8e0
reordered services
yausername Mar 23, 2019
b6be586
merged upstream/dev
yausername Nov 15, 2019
596005c
merged upstream/dev
yausername Nov 19, 2019
ceabfd1
updated extractor
yausername Nov 21, 2019
81658de
merged upstream/dev
yausername Nov 22, 2019
ac2543d
validate peertube instance. changed peertube color
yausername Nov 22, 2019
afef8d8
removed extra white spaces
yausername Nov 22, 2019
0fb7eab
Fix code formatting
TobiGr Nov 23, 2019
527c38a
easily switch between multiple peertube instances
yausername Nov 24, 2019
3e2dba2
merged origin/peertube-ui
yausername Nov 24, 2019
6a24dce
Merge remote-tracking branch 'upstream/dev' into peertube-ui
yausername Nov 24, 2019
309fd3f
white space changes
yausername Nov 24, 2019
4c89d1a
Merge remote-tracking branch 'upstream/dev' into peertube-ui
yausername Dec 2, 2019
890d1cb
update extractor, kiosk names and icons
yausername Dec 2, 2019
17c5e73
null check on share
yausername Dec 2, 2019
0c40a45
use plurals
yausername Dec 2, 2019
d32ad36
reorder peertube settings entry
yausername Dec 3, 2019
7a67d19
updated extractor
yausername Dec 3, 2019
d2a59ec
grammar fix
yausername Dec 4, 2019
fd5f4d9
merged upstream/dev
yausername Dec 9, 2019
a0151f2
more grammar fix
yausername Dec 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
exclude module: 'support-annotations'
})

implementation 'com.github.TeamNewPipe:NewPipeExtractor:aa4f03a'
implementation 'com.github.yausername:NewPipeExtractor:c220700'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/org/schabi/newpipe/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
if (DEBUG) Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");

ServiceHelper.initServices(this);
Comment thread
yausername marked this conversation as resolved.
Outdated

ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));

super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -300,6 +302,7 @@ private void showServices() {
drawerItems.getMenu()
.add(R.id.menu_services_group, s.getServiceId(), ORDER, title)
.setIcon(ServiceHelper.getIcon(s.getServiceId()));

Comment thread
yausername marked this conversation as resolved.
}
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
}
Expand Down Expand Up @@ -364,6 +367,7 @@ protected void onResume() {
String selectedServiceName = NewPipe.getService(
ServiceHelper.getSelectedServiceId(this)).getServiceInfo().getName();
headerServiceView.setText(selectedServiceName);
headerServiceView.post(() -> headerServiceView.setSelected(true));
} catch (Exception e) {
ErrorActivity.reportUiError(this, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelInfo;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
Expand Down Expand Up @@ -487,12 +488,16 @@ public void handleNextItems(ListExtractor.InfoItemsPage result) {
protected boolean onError(Throwable exception) {
if (super.onError(exception)) return true;

int errorId = exception instanceof ExtractionException ? R.string.parsing_error : R.string.general_error;
onUnrecoverableError(exception,
UserAction.REQUESTED_CHANNEL,
NewPipe.getNameOfService(serviceId),
url,
errorId);
if(exception instanceof ContentNotAvailableException){
showError(getString(R.string.content_not_available), false);
}else{
int errorId = exception instanceof ExtractionException ? R.string.parsing_error : R.string.general_error;
onUnrecoverableError(exception,
UserAction.REQUESTED_CHANNEL,
NewPipe.getNameOfService(serviceId),
url,
errorId);
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.preference.Preference;
import android.util.Log;
import android.widget.Toast;

import com.nononsenseapps.filepicker.Utils;
import com.nostra13.universalimageloader.core.ImageLoader;

import org.schabi.newpipe.App;
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.FilePickerActivityHelper;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ZipHelper;

import java.io.BufferedOutputStream;
Expand All @@ -39,6 +43,12 @@
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class ContentSettingsFragment extends BasePreferenceFragment {

private static final int REQUEST_IMPORT_PATH = 8945;
Expand All @@ -53,6 +63,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment {

private String thumbnailLoadToggleKey;

private CompositeDisposable disposables = new CompositeDisposable();

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -122,6 +134,49 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
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) -> {
Comment thread
yausername marked this conversation as resolved.
Outdated
EditTextPreference pEt = (EditTextPreference) p;
String url = (String) newInstance;
if (!url.startsWith("https://")) {
Toast.makeText(getActivity(), "instance url should start with https://",
Toast.LENGTH_SHORT).show();
return false;
} else {
pEt.setSummary("fetching instance details..");
Disposable disposable = Single.fromCallable(() -> {
ServiceList.PeerTube.setInstance(url);
return true;
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if (result) {
pEt.setSummary(url);
pEt.setText(url);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(App.getApp().getString(R.string.peertube_instance_name_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
editor.putString(App.getApp().getString(R.string.current_service_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
NavigationHelper.openMainActivity(App.getApp());
} else {
pEt.setSummary(ServiceList.PeerTube.getBaseUrl());
Toast.makeText(getActivity(), "unable to update instance",
Toast.LENGTH_SHORT).show();
}
}, error -> {
pEt.setSummary(ServiceList.PeerTube.getBaseUrl());
Toast.makeText(getActivity(), "unable to update instance",
Toast.LENGTH_SHORT).show();
});
disposables.add(disposable);
return false;
}
});
}

@Override
Expand Down Expand Up @@ -179,7 +234,7 @@ private void saveSharedPreferencesToFile(File dst) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
} finally {
try {
if (output != null) {
output.flush();
Expand All @@ -203,7 +258,8 @@ private void importDatabase(String filePath) {
} finally {
try {
zipFile.close();
} catch (Exception ignored){}
} catch (Exception ignored) {
}
}

try {
Expand All @@ -226,7 +282,7 @@ private void importDatabase(String filePath) {
}

//If settings file exist, ask if it should be imported.
if(ZipHelper.extractFileFromZip(filePath, newpipe_settings.getPath(), "newpipe.settings")) {
if (ZipHelper.extractFileFromZip(filePath, newpipe_settings.getPath(), "newpipe.settings")) {
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
alert.setTitle(R.string.import_settings);

Expand Down Expand Up @@ -281,7 +337,7 @@ else if (v instanceof String)
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}finally {
} finally {
try {
if (input != null) {
input.close();
Expand All @@ -304,4 +360,5 @@ protected void onError(Throwable e) {
ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,
"none", "", R.string.app_ui_crash));
}

Comment thread
yausername marked this conversation as resolved.
Outdated
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public static int getKioskIcons(String kioskId, Context c) {
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);
case "conferences":
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_hot);
default:
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -26,6 +27,8 @@ public static int getIcon(int serviceId) {
case 1:
return R.drawable.place_holder_cloud;
case 2:
return R.drawable.place_holder_peertube;
case 3:
return R.drawable.place_holder_gadse;
default:
return R.drawable.place_holder_circle;
Expand Down Expand Up @@ -131,4 +134,19 @@ public static boolean isBeta(final StreamingService s) {
default: return true;
}
}

public static void initService(Context context, int serviceId) {
if(serviceId == ServiceList.PeerTube.getServiceId()){
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());
}
}
}
9 changes: 8 additions & 1 deletion app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import org.schabi.newpipe.R;
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;

Expand Down Expand Up @@ -136,7 +137,13 @@ public static int getThemeForService(Context context, int serviceId) {
else if (selectedTheme.equals(blackTheme)) themeName = "BlackTheme";
else if (selectedTheme.equals(darkTheme)) themeName = "DarkTheme";

themeName += "." + service.getServiceInfo().getName();
if(serviceId == ServiceList.PeerTube.getServiceId()){
//service name for peertube depends on the instance
themeName += ".PeerTube";
}else{
themeName += "." + service.getServiceInfo().getName();
}

int resourceId = context
.getResources()
.getIdentifier(themeName, "style", context.getPackageName());
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions app/src/main/res/layout-v21/drawer_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,22 @@

<TextView
android:id="@+id/drawer_header_service_view"
android:layout_width="100dp"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_alignLeft="@id/drawer_header_np_text_view"
android:layout_alignStart="@id/drawer_header_np_text_view"
android:layout_below="@id/drawer_header_np_text_view"
android:layout_toLeftOf="@id/drawer_arrow"
android:layout_marginRight="5dp"
android:text="YouTube"
android:textSize="18sp"
android:textColor="@color/drawer_header_font_color"
android:textStyle="italic" />
android:textStyle="italic"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true" />

<ImageView
android:id="@+id/drawer_arrow"
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/res/layout/drawer_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,22 @@ android:focusable="true">

<TextView
android:id="@+id/drawer_header_service_view"
android:layout_width="100dp"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:text="YouTube"
android:layout_below="@id/drawer_header_np_text_view"
android:layout_alignLeft="@id/drawer_header_np_text_view"
android:layout_alignStart="@id/drawer_header_np_text_view"
android:layout_toLeftOf="@id/drawer_arrow"
android:layout_marginRight="5dp"
android:textSize="18sp"
android:textColor="@color/drawer_header_font_color"
android:textStyle="italic"/>
android:textStyle="italic"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true" />

<ImageView
android:id="@+id/drawer_arrow"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/drawer_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
android:layout_height="wrap_content"
app:elevation="0dp"
android:background="?attr/android:windowBackground"
app:headerLayout="@layout/drawer_header"/>
app:headerLayout="@layout/drawer_header"
android:theme="@style/NavViewTextStyle"/>
<!-- app:menu="@menu/drawer_items" -->

<LinearLayout
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/values-v21/styles_services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
<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>

<!-- Media.ccc -->
<style name="LightTheme.MediaCCC" parent="LightTheme.Switchable">
<item name="colorPrimary">@color/light_media_ccc_primary_color</item>
Expand All @@ -49,4 +68,5 @@
<item name="colorPrimaryDark">@color/dark_media_ccc_statusbar_color</item>
<item name="colorAccent">@color/dark_media_ccc_accent_color</item>
</style>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
Loading