From 2d029b9f761b5a4f684a12621c6bb260616f4b4e Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 5 Aug 2018 13:13:04 +0200 Subject: [PATCH 01/11] fix exception when loading premium videos --- app/build.gradle | 2 +- .../schabi/newpipe/fragments/list/search/SearchFragment.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ad3404b9f..1a7029c4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:1eff8c5708' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:701666f4982514' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.8.9' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 411379963..fbea95ec0 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -575,8 +575,7 @@ public class SearchFragment .onNext(searchEditText.getText().toString()), throwable -> showSnackBarError(throwable, UserAction.DELETE_FROM_HISTORY, "none", - "Deleting item failed", R.string.general_error) - ); + "Deleting item failed", R.string.general_error)); disposables.add(onDelete); }) .show(); From b0efe49e29995a75f4472355ae010fe74e9dbfec Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 5 Aug 2018 13:29:19 +0200 Subject: [PATCH 02/11] fix cycling search results --- .../org/schabi/newpipe/fragments/list/search/SearchFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index fbea95ec0..6e51c0baf 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -863,6 +863,7 @@ public class SearchFragment showListFooter(false); currentPageUrl = result.getNextPageUrl(); infoListAdapter.addInfoItemList(result.getItems()); + nextPageUrl = result.getNextPageUrl(); if (!result.getErrors().isEmpty()) { showSnackBarError(result.getErrors(), UserAction.SEARCHED, From c2d11e786fae4d51e354dca6cc38b4f59b1b6051 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 5 Aug 2018 14:20:25 +0200 Subject: [PATCH 03/11] rename Search Query handler --- app/build.gradle | 2 +- .../schabi/newpipe/fragments/list/search/SearchFragment.java | 2 +- .../main/java/org/schabi/newpipe/util/ExtractorHelper.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1a7029c4e..dca11d3c6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:701666f4982514' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:aeb813840d6' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.8.9' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 6e51c0baf..2a564f0a8 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -365,7 +365,7 @@ public class SearchFragment int itemId = 0; boolean isFirstItem = true; final Context c = getContext(); - for(String filter : service.getSearchQIHFactory().getAvailableContentFilter()) { + for(String filter : service.getSearchQHFactory().getAvailableContentFilter()) { menuItemToFilterName.put(itemId, filter); MenuItem item = menu.add(1, itemId++, diff --git a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java index 74e2d4cd5..e445233c3 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -73,7 +73,7 @@ public final class ExtractorHelper { return Single.fromCallable(() -> SearchInfo.getInfo(NewPipe.getService(serviceId), NewPipe.getService(serviceId) - .getSearchQIHFactory() + .getSearchQHFactory() .fromQuery(searchString, contentFilter, sortFilter), contentCountry)); } @@ -88,7 +88,7 @@ public final class ExtractorHelper { return Single.fromCallable(() -> SearchInfo.getMoreItems(NewPipe.getService(serviceId), NewPipe.getService(serviceId) - .getSearchQIHFactory() + .getSearchQHFactory() .fromQuery(searchString, contentFilter, sortFilter), contentCountry, pageUrl)); From 0f517b803bb437ceda7c73443d80088e1a689570 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Wed, 15 Aug 2018 20:59:06 +0200 Subject: [PATCH 04/11] fix layout width of currentPlayTime --- .../schabi/newpipe/player/ServicePlayerActivity.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index b57a710ed..0d08c47b2 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -1,8 +1,10 @@ package org.schabi.newpipe.player; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; +import android.graphics.Point; import android.os.Build; import android.os.Bundle; import android.os.IBinder; @@ -13,9 +15,12 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.support.v7.widget.helper.ItemTouchHelper; import android.util.Log; +import android.view.Display; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.PopupMenu; @@ -562,6 +567,12 @@ public abstract class ServicePlayerActivity extends AppCompatActivity if (player != null) { progressLiveSync.setClickable(!player.isLiveEdge()); } + + // this will make shure progressCurrentTime has the same width as progressEndTime + final ViewGroup.LayoutParams endTimeParams = progressEndTime.getLayoutParams(); + final ViewGroup.LayoutParams currentTimeParams = progressCurrentTime.getLayoutParams(); + currentTimeParams.width = progressEndTime.getWidth(); + progressCurrentTime.setLayoutParams(currentTimeParams); } @Override From badd4d3207f29b159139bf2dc9efb51b3a8f77d5 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 17 Aug 2018 17:03:26 +0200 Subject: [PATCH 05/11] fix linkhandling in description bla --- app/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index dca11d3c6..d669a82e4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,12 +49,13 @@ ext { icepickLibVersion = '3.2.0' stethoLibVersion = '1.5.0' } + dependencies { androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2') { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:aeb813840d6' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:c4e16c7337' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.8.9' From 44a71d85659e512ad12d19fb96507d42aca15a8e Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 17 Aug 2018 18:50:35 +0200 Subject: [PATCH 06/11] add reset extSD card folder dialog --- app/src/main/AndroidManifest.xml | 5 +-- .../download/ExtSDDownloadFailedActivity.java | 40 +++++++++++++++++++ .../newpipe/settings/NewPipeSettings.java | 13 ++++++ .../giga/get/DownloadManagerImpl.java | 33 ++++++++++++++- .../giga/service/DownloadManagerService.java | 2 +- app/src/main/res/values/strings.xml | 2 + 6 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/download/ExtSDDownloadFailedActivity.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 33e0651e5..e4d448184 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -76,10 +76,6 @@ android:name=".about.AboutActivity" android:label="@string/title_activity_about"/> - - @@ -122,6 +118,7 @@ + { + + NewPipeSettings.resetDownloadFolders(this); + finish(); + }) + .setNegativeButton(R.string.cancel, (DialogInterface dialogInterface, int i) -> { + + dialogInterface.dismiss(); + finish(); + }) + .create() + .show(); + } +} diff --git a/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java b/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java index 92f98a9a2..08ec74d17 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java +++ b/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java @@ -107,4 +107,17 @@ public class NewPipeSettings { private static File getFolder(String defaultDirectoryName) { return new File(Environment.getExternalStorageDirectory(), defaultDirectoryName); } + + public static void resetDownloadFolders(Context context) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + resetDownloadFolder(prefs, context.getString(R.string.download_path_audio_key), Environment.DIRECTORY_MUSIC); + resetDownloadFolder(prefs, context.getString(R.string.download_path_key), Environment.DIRECTORY_MOVIES); + } + + private static void resetDownloadFolder(SharedPreferences prefs, String key, String defaultDirectoryName) { + final File folder = getFolder(defaultDirectoryName); + SharedPreferences.Editor spEditor = prefs.edit(); + spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath()); + spEditor.apply(); + } } diff --git a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java index ecd3ce562..550bd420d 100755 --- a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java @@ -1,10 +1,22 @@ package us.shandian.giga.get; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Handler; +import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.util.Log; +import org.schabi.newpipe.R; +import org.schabi.newpipe.download.ExtSDDownloadFailedActivity; +import org.schabi.newpipe.settings.NewPipeSettings; + import java.io.File; import java.io.FilenameFilter; +import java.io.IOException; import java.io.RandomAccessFile; import java.net.HttpURLConnection; import java.net.URL; @@ -23,7 +35,8 @@ public class DownloadManagerImpl implements DownloadManager { private static final String TAG = DownloadManagerImpl.class.getSimpleName(); private final DownloadDataSource mDownloadDataSource; - private final ArrayList mMissions = new ArrayList(); + private final ArrayList mMissions = new ArrayList<>(); + private final Context context; /** * Create a new instance @@ -33,6 +46,13 @@ public class DownloadManagerImpl implements DownloadManager { */ public DownloadManagerImpl(Collection searchLocations, DownloadDataSource downloadDataSource) { mDownloadDataSource = downloadDataSource; + this.context = null; + loadMissions(searchLocations); + } + + public DownloadManagerImpl(Collection searchLocations, DownloadDataSource downloadDataSource, Context context) { + mDownloadDataSource = downloadDataSource; + this.context = context; loadMissions(searchLocations); } @@ -277,10 +297,12 @@ public class DownloadManagerImpl implements DownloadManager { } private class Initializer extends Thread { - private DownloadMission mission; + private final DownloadMission mission; + private final Handler handler; public Initializer(DownloadMission mission) { this.mission = mission; + this.handler = new Handler(); } @Override @@ -335,6 +357,13 @@ public class DownloadManagerImpl implements DownloadManager { af.close(); mission.start(); + } catch (IOException ie) { + if(context == null) throw new RuntimeException(ie); + + if(ie.getMessage().contains("Permission denied")) { + handler.post(() -> + context.startActivity(new Intent(context, ExtSDDownloadFailedActivity.class))); + } else throw new RuntimeException(ie); } catch (Exception e) { // TODO Notify throw new RuntimeException(e); diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index 50975728f..59f5e2225 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -81,7 +81,7 @@ public class DownloadManagerService extends Service { ArrayList paths = new ArrayList<>(2); paths.add(NewPipeSettings.getVideoDownloadPath(this)); paths.add(NewPipeSettings.getAudioDownloadPath(this)); - mManager = new DownloadManagerImpl(paths, mDataSource); + mManager = new DownloadManagerImpl(paths, mDataSource, this); if (DEBUG) { Log.d(TAG, "mManager == null"); Log.d(TAG, "Download directory: " + paths); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 344ef2198..0e72ecd35 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -170,6 +170,8 @@ Search history deleted. Error + External storage not available. + Download to external SD Card is not possible yet. Should the download place be reseted? Network error Could not load all thumbnails Could not decrypt video URL signature From 98c65fb9b73d94a85c53c928cf019dfab8231eda Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 18 Aug 2018 14:11:41 +0200 Subject: [PATCH 07/11] add more debug statements to BasePlayer --- .../download/ExtSDDownloadFailedActivity.java | 2 -- .../java/org/schabi/newpipe/player/BasePlayer.java | 12 +++++++++++- .../java/org/schabi/newpipe/report/UserAction.java | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/download/ExtSDDownloadFailedActivity.java b/app/src/main/java/org/schabi/newpipe/download/ExtSDDownloadFailedActivity.java index 2d98f4665..c02ef92eb 100644 --- a/app/src/main/java/org/schabi/newpipe/download/ExtSDDownloadFailedActivity.java +++ b/app/src/main/java/org/schabi/newpipe/download/ExtSDDownloadFailedActivity.java @@ -25,12 +25,10 @@ public class ExtSDDownloadFailedActivity extends AppCompatActivity { .setTitle(R.string.download_to_sdcard_error_title) .setMessage(R.string.download_to_sdcard_error_message) .setPositiveButton(R.string.yes, (DialogInterface dialogInterface, int i) -> { - NewPipeSettings.resetDownloadFolders(this); finish(); }) .setNegativeButton(R.string.cancel, (DialogInterface dialogInterface, int i) -> { - dialogInterface.dismiss(); finish(); }) diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 7339dd50f..db8c3fd5b 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -69,6 +69,7 @@ import org.schabi.newpipe.player.playqueue.PlayQueue; import org.schabi.newpipe.player.playqueue.PlayQueueAdapter; import org.schabi.newpipe.player.playqueue.PlayQueueItem; import org.schabi.newpipe.player.resolver.MediaSourceTag; +import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.util.ImageDisplayConstants; import org.schabi.newpipe.util.SerializedCache; @@ -86,6 +87,7 @@ import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_INTERNAL import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_PERIOD_TRANSITION; import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK; import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT; +import static org.schabi.newpipe.report.UserAction.PLAY_STREAM; /** * Base for the players, joining the common properties @@ -363,7 +365,10 @@ public abstract class BasePlayer implements try { context.unregisterReceiver(broadcastReceiver); } catch (final IllegalArgumentException unregisteredException) { - Log.e(TAG, "Broadcast receiver already unregistered.", unregisteredException); + ErrorActivity.reportError(context, unregisteredException, null, null, + ErrorActivity.ErrorInfo.make(PLAY_STREAM, + "none", + "play stream", R.string.general_error)); } } @@ -1001,6 +1006,8 @@ public abstract class BasePlayer implements try { metadata = (MediaSourceTag) simpleExoPlayer.getCurrentTag(); } catch (IndexOutOfBoundsException | ClassCastException error) { + if(DEBUG) Log.d(TAG, "Could not update metadata: " + error.getMessage()); + if(DEBUG) error.printStackTrace(); return; } @@ -1087,6 +1094,9 @@ public abstract class BasePlayer implements return simpleExoPlayer.isCurrentWindowDynamic(); } catch (@NonNull IndexOutOfBoundsException ignored) { // Why would this even happen =( + // But lets log it anyway. Save is save + if(DEBUG) Log.d(TAG, "Could not update metadata: " + ignored.getMessage()); + if(DEBUG) ignored.printStackTrace(); return false; } } diff --git a/app/src/main/java/org/schabi/newpipe/report/UserAction.java b/app/src/main/java/org/schabi/newpipe/report/UserAction.java index 93a3ce16c..00a25ed8d 100644 --- a/app/src/main/java/org/schabi/newpipe/report/UserAction.java +++ b/app/src/main/java/org/schabi/newpipe/report/UserAction.java @@ -15,7 +15,8 @@ public enum UserAction { REQUESTED_CHANNEL("requested channel"), REQUESTED_PLAYLIST("requested playlist"), REQUESTED_KIOSK("requested kiosk"), - DELETE_FROM_HISTORY("delete from history"); + DELETE_FROM_HISTORY("delete from history"), + PLAY_STREAM("Play stream"); private final String message; From eacbaa3680bf4b72bb398a1459c9fc68a649f582 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 18 Aug 2018 14:20:36 +0200 Subject: [PATCH 08/11] fix exception on nothing found --- .../schabi/newpipe/fragments/list/search/SearchFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 2a564f0a8..a699e28bc 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -836,7 +836,10 @@ public class SearchFragment @Override public void handleResult(@NonNull SearchInfo result) { - if (!result.getErrors().isEmpty()) { + final List exceptions = result.getErrors(); + if (!exceptions.isEmpty() + && !(exceptions.size() == 1 + && exceptions.get(0) instanceof SearchExtractor.NothingFoundException)){ showSnackBarError(result.getErrors(), UserAction.SEARCHED, NewPipe.getNameOfService(serviceId), searchString, 0); } From ce83fd9a107e3d6fac8837ba20b8380eb5ac3a69 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 21 Aug 2018 17:43:39 +0200 Subject: [PATCH 09/11] make dash parser ignore segmented streams --- app/build.gradle | 2 +- .../schabi/newpipe/fragments/detail/VideoDetailFragment.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d669a82e4..8170869d1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,7 +55,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:c4e16c7337' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:e662c97433c950' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.8.9' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index d91502cdd..c726f8cee 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1227,10 +1227,10 @@ public class VideoDetailFragment spinnerToolbar.setVisibility(View.GONE); break; default: + if(info.getAudioStreams().isEmpty()) detailControlsBackground.setVisibility(View.GONE); if (!info.getVideoStreams().isEmpty() || !info.getVideoOnlyStreams().isEmpty()) break; - detailControlsBackground.setVisibility(View.GONE); detailControlsPopup.setVisibility(View.GONE); spinnerToolbar.setVisibility(View.GONE); thumbnailPlayButton.setImageResource(R.drawable.ic_headset_white_24dp); From 2003f51d49cb695539b3f28fd7f361bc024accbe Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Wed, 22 Aug 2018 16:04:32 +0200 Subject: [PATCH 10/11] fix thumbnail not shown in background player --- .../newpipe/fragments/BaseStateFragment.java | 7 +- .../list/channel/ChannelFragment.java | 175 ++++++++---------- .../newpipe/player/BackgroundPlayer.java | 4 - .../org/schabi/newpipe/player/BasePlayer.java | 3 +- .../newpipe/player/playqueue/PlayQueue.java | 3 +- .../schabi/newpipe/util/NavigationHelper.java | 2 - 6 files changed, 85 insertions(+), 109 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java index af16ff062..589d15bd4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java @@ -87,12 +87,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC RxView.clicks(errorButtonRetry) .debounce(300, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Consumer() { - @Override - public void accept(Object o) throws Exception { - onRetryButtonClicked(); - } - }); + .subscribe(o -> onRetryButtonClicked()); } protected void onRetryButtonClicked() { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 01922a4f3..4df5982f7 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -169,38 +169,35 @@ public class ChannelFragment extends BaseListInfoFragment { context.getResources().getString(R.string.share) }; - final DialogInterface.OnClickListener actions = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - final int index = Math.max(infoListAdapter.getItemsList().indexOf(item), 0); - switch (i) { - case 0: - NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item)); - break; - case 1: - NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item)); - break; - case 2: - NavigationHelper.playOnMainPlayer(context, getPlayQueue(index)); - break; - case 3: - NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index)); - break; - case 4: - NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index)); - break; - case 5: - if (getFragmentManager() != null) { - PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)) - .show(getFragmentManager(), TAG); - } - break; - case 6: - shareUrl(item.getName(), item.getUrl()); - break; - default: - break; - } + final DialogInterface.OnClickListener actions = (DialogInterface dialogInterface, int i) -> { + final int index = Math.max(infoListAdapter.getItemsList().indexOf(item), 0); + switch (i) { + case 0: + NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item)); + break; + case 1: + NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item)); + break; + case 2: + NavigationHelper.playOnMainPlayer(context, getPlayQueue(index)); + break; + case 3: + NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index)); + break; + case 4: + NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index)); + break; + case 5: + if (getFragmentManager() != null) { + PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)) + .show(getFragmentManager(), TAG); + } + break; + case 6: + shareUrl(item.getName(), item.getUrl()); + break; + default: + break; } }; @@ -258,12 +255,12 @@ public class ChannelFragment extends BaseListInfoFragment { private static final int BUTTON_DEBOUNCE_INTERVAL = 100; private void monitorSubscription(final ChannelInfo info) { - final Consumer onError = new Consumer() { - @Override - public void accept(Throwable throwable) throws Exception { + final Consumer onError = (Throwable throwable) -> { animateView(headerSubscribeButton, false, 100); - showSnackBarError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(currentInfo.getServiceId()), "Get subscription status", 0); - } + showSnackBarError(throwable, UserAction.SUBSCRIPTION, + NewPipe.getNameOfService(currentInfo.getServiceId()), + "Get subscription status", + 0); }; final Observable> observable = subscriptionService.subscriptionTable() @@ -279,50 +276,38 @@ public class ChannelFragment extends BaseListInfoFragment { // so only update the UI for the latest emission ("sync" the subscribe button's state) .debounce(100, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Consumer>() { - @Override - public void accept(List subscriptionEntities) throws Exception { - updateSubscribeButton(!subscriptionEntities.isEmpty()); - } - }, onError)); + .subscribe((List subscriptionEntities) -> + updateSubscribeButton(!subscriptionEntities.isEmpty()) + , onError)); } private Function mapOnSubscribe(final SubscriptionEntity subscription) { - return new Function() { - @Override - public Object apply(@NonNull Object o) throws Exception { - subscriptionService.subscriptionTable().insert(subscription); - return o; - } + return (@NonNull Object o) -> { + subscriptionService.subscriptionTable().insert(subscription); + return o; }; } private Function mapOnUnsubscribe(final SubscriptionEntity subscription) { - return new Function() { - @Override - public Object apply(@NonNull Object o) throws Exception { - subscriptionService.subscriptionTable().delete(subscription); - return o; - } + return (@NonNull Object o) -> { + subscriptionService.subscriptionTable().delete(subscription); + return o; }; } private void updateSubscription(final ChannelInfo info) { if (DEBUG) Log.d(TAG, "updateSubscription() called with: info = [" + info + "]"); - final Action onComplete = new Action() { - @Override - public void run() throws Exception { + final Action onComplete = () -> { if (DEBUG) Log.d(TAG, "Updated subscription: " + info.getUrl()); - } }; - final Consumer onError = new Consumer() { - @Override - public void accept(@NonNull Throwable throwable) throws Exception { - onUnrecoverableError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(info.getServiceId()), "Updating Subscription for " + info.getUrl(), R.string.subscription_update_failed); - } - }; + final Consumer onError = (@NonNull Throwable throwable) -> + onUnrecoverableError(throwable, + UserAction.SUBSCRIPTION, + NewPipe.getNameOfService(info.getServiceId()), + "Updating Subscription for " + info.getUrl(), + R.string.subscription_update_failed); disposables.add(subscriptionService.updateChannelInfo(info) .subscribeOn(Schedulers.io()) @@ -331,19 +316,16 @@ public class ChannelFragment extends BaseListInfoFragment { } private Disposable monitorSubscribeButton(final Button subscribeButton, final Function action) { - final Consumer onNext = new Consumer() { - @Override - public void accept(@NonNull Object o) throws Exception { + final Consumer onNext = (@NonNull Object o) -> { if (DEBUG) Log.d(TAG, "Changed subscription status to this channel!"); - } }; - final Consumer onError = new Consumer() { - @Override - public void accept(@NonNull Throwable throwable) throws Exception { - onUnrecoverableError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(currentInfo.getServiceId()), "Subscription Change", R.string.subscription_change_failed); - } - }; + final Consumer onError = (@NonNull Throwable throwable) -> + onUnrecoverableError(throwable, + UserAction.SUBSCRIPTION, + NewPipe.getNameOfService(currentInfo.getServiceId()), + "Subscription Change", + R.string.subscription_change_failed); /* Emit clicks from main thread unto io thread */ return RxView.clicks(subscribeButton) @@ -355,25 +337,25 @@ public class ChannelFragment extends BaseListInfoFragment { } private Consumer> getSubscribeUpdateMonitor(final ChannelInfo info) { - return new Consumer>() { - @Override - public void accept(List subscriptionEntities) throws Exception { - if (DEBUG) - Log.d(TAG, "subscriptionService.subscriptionTable.doOnNext() called with: subscriptionEntities = [" + subscriptionEntities + "]"); - if (subscribeButtonMonitor != null) subscribeButtonMonitor.dispose(); + return (List subscriptionEntities) -> { + if (DEBUG) + Log.d(TAG, "subscriptionService.subscriptionTable.doOnNext() called with: subscriptionEntities = [" + subscriptionEntities + "]"); + if (subscribeButtonMonitor != null) subscribeButtonMonitor.dispose(); - if (subscriptionEntities.isEmpty()) { - if (DEBUG) Log.d(TAG, "No subscription to this channel!"); - SubscriptionEntity channel = new SubscriptionEntity(); - channel.setServiceId(info.getServiceId()); - channel.setUrl(info.getUrl()); - channel.setData(info.getName(), info.getAvatarUrl(), info.getDescription(), info.getSubscriberCount()); - subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnSubscribe(channel)); - } else { - if (DEBUG) Log.d(TAG, "Found subscription to this channel!"); - final SubscriptionEntity subscription = subscriptionEntities.get(0); - subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnUnsubscribe(subscription)); - } + if (subscriptionEntities.isEmpty()) { + if (DEBUG) Log.d(TAG, "No subscription to this channel!"); + SubscriptionEntity channel = new SubscriptionEntity(); + channel.setServiceId(info.getServiceId()); + channel.setUrl(info.getUrl()); + channel.setData(info.getName(), + info.getAvatarUrl(), + info.getDescription(), + info.getSubscriberCount()); + subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnSubscribe(channel)); + } else { + if (DEBUG) Log.d(TAG, "Found subscription to this channel!"); + final SubscriptionEntity subscription = subscriptionEntities.get(0); + subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnUnsubscribe(subscription)); } }; } @@ -491,8 +473,11 @@ public class ChannelFragment extends BaseListInfoFragment { super.handleNextItems(result); if (!result.getErrors().isEmpty()) { - showSnackBarError(result.getErrors(), UserAction.REQUESTED_CHANNEL, NewPipe.getNameOfService(serviceId), - "Get next page of: " + url, R.string.general_error); + showSnackBarError(result.getErrors(), + UserAction.REQUESTED_CHANNEL, + NewPipe.getNameOfService(serviceId), + "Get next page of: " + url, + R.string.general_error); } } diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index 8594ca395..de981f283 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -309,7 +309,6 @@ public final class BackgroundPlayer extends Service { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); - resetNotification(); updateNotificationThumbnail(); updateNotification(-1); } @@ -342,7 +341,6 @@ public final class BackgroundPlayer extends Service { updateProgress(currentProgress, duration, bufferPercent); if (!shouldUpdateOnProgress) return; - resetNotification(); if (bigNotRemoteView != null) { bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, duration, currentProgress, false); bigNotRemoteView.setTextViewText(R.id.notificationTime, getTimeString(currentProgress) + " / " + getTimeString(duration)); @@ -531,8 +529,6 @@ public final class BackgroundPlayer extends Service { @Override public void onPlaying() { super.onPlaying(); - resetNotification(); - updateNotificationThumbnail(); updateNotification(R.drawable.ic_pause_white); lockManager.acquireWifiAndCpu(); } diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index db8c3fd5b..d87df3666 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -51,6 +51,7 @@ import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; +import org.schabi.newpipe.BuildConfig; import org.schabi.newpipe.Downloader; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.stream.StreamInfo; @@ -98,7 +99,7 @@ import static org.schabi.newpipe.report.UserAction.PLAY_STREAM; public abstract class BasePlayer implements Player.EventListener, PlaybackListener, ImageLoadingListener { - public static final boolean DEBUG = true; + public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release"); @NonNull public static final String TAG = "BasePlayer"; @NonNull final protected Context context; diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java index a21560abd..c9e07c96a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java @@ -6,6 +6,7 @@ import android.util.Log; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; +import org.schabi.newpipe.BuildConfig; import org.schabi.newpipe.player.playqueue.events.AppendEvent; import org.schabi.newpipe.player.playqueue.events.ErrorEvent; import org.schabi.newpipe.player.playqueue.events.InitEvent; @@ -41,7 +42,7 @@ import io.reactivex.subjects.BehaviorSubject; public abstract class PlayQueue implements Serializable { private final String TAG = "PlayQueue@" + Integer.toHexString(hashCode()); - public static final boolean DEBUG = true; + public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release"); private ArrayList backup; private ArrayList streams; diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 4556cfd7d..13767125d 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -31,8 +31,6 @@ import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.stream.Stream; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.VideoStream; -import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; -import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; import org.schabi.newpipe.fragments.MainFragment; import org.schabi.newpipe.fragments.detail.VideoDetailFragment; import org.schabi.newpipe.fragments.list.channel.ChannelFragment; From b1429366da3b89487c7f842f2a14ae46052005ab Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 24 Aug 2018 17:42:35 +0200 Subject: [PATCH 11/11] fixes acording to code review fixes moreacording to code review fixed link handling once more --- app/build.gradle | 2 +- .../newpipe/player/BackgroundPlayer.java | 6 ++++++ .../newpipe/player/ServicePlayerActivity.java | 4 ---- .../newpipe/settings/NewPipeSettings.java | 21 +++++++++++-------- .../giga/get/DownloadManagerImpl.java | 8 ++----- app/src/main/res/values/strings.xml | 2 +- build.gradle | 2 +- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8170869d1..354dbaa0e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,7 +55,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:e662c97433c950' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:fef71aeccc37' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.8.9' diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index de981f283..91faa1014 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -26,6 +26,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Bitmap; +import android.os.Build; import android.os.IBinder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -309,6 +310,7 @@ public final class BackgroundPlayer extends Service { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); + resetNotification(); updateNotificationThumbnail(); updateNotification(-1); } @@ -341,6 +343,8 @@ public final class BackgroundPlayer extends Service { updateProgress(currentProgress, duration, bufferPercent); if (!shouldUpdateOnProgress) return; + resetNotification(); + if(Build.VERSION.SDK_INT >= 26 /*Oreo*/) updateNotificationThumbnail(); if (bigNotRemoteView != null) { bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, duration, currentProgress, false); bigNotRemoteView.setTextViewText(R.id.notificationTime, getTimeString(currentProgress) + " / " + getTimeString(duration)); @@ -529,6 +533,8 @@ public final class BackgroundPlayer extends Service { @Override public void onPlaying() { super.onPlaying(); + resetNotification(); + updateNotificationThumbnail(); updateNotification(R.drawable.ic_pause_white); lockManager.acquireWifiAndCpu(); } diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 0d08c47b2..94305e6c4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -1,10 +1,8 @@ package org.schabi.newpipe.player; import android.content.ComponentName; -import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.graphics.Point; import android.os.Build; import android.os.Bundle; import android.os.IBinder; @@ -15,12 +13,10 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.support.v7.widget.helper.ItemTouchHelper; import android.util.Log; -import android.view.Display; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.PopupMenu; diff --git a/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java b/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java index 08ec74d17..2a0e2645b 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java +++ b/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java @@ -71,7 +71,7 @@ public class NewPipeSettings { } public static File getVideoDownloadFolder(Context context) { - return getFolder(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES); + return getDir(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES); } public static String getVideoDownloadPath(Context context) { @@ -81,7 +81,7 @@ public class NewPipeSettings { } public static File getAudioDownloadFolder(Context context) { - return getFolder(context, R.string.download_path_audio_key, Environment.DIRECTORY_MUSIC); + return getDir(context, R.string.download_path_audio_key, Environment.DIRECTORY_MUSIC); } public static String getAudioDownloadPath(Context context) { @@ -90,21 +90,21 @@ public class NewPipeSettings { return prefs.getString(key, Environment.DIRECTORY_MUSIC); } - private static File getFolder(Context context, int keyID, String defaultDirectoryName) { + private static File getDir(Context context, int keyID, String defaultDirectoryName) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final String key = context.getString(keyID); String downloadPath = prefs.getString(key, null); if ((downloadPath != null) && (!downloadPath.isEmpty())) return new File(downloadPath.trim()); - final File folder = getFolder(defaultDirectoryName); + final File dir = getDir(defaultDirectoryName); SharedPreferences.Editor spEditor = prefs.edit(); - spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath()); + spEditor.putString(key, getNewPipeChildFolderPathForDir(dir)); spEditor.apply(); - return folder; + return dir; } @NonNull - private static File getFolder(String defaultDirectoryName) { + private static File getDir(String defaultDirectoryName) { return new File(Environment.getExternalStorageDirectory(), defaultDirectoryName); } @@ -115,9 +115,12 @@ public class NewPipeSettings { } private static void resetDownloadFolder(SharedPreferences prefs, String key, String defaultDirectoryName) { - final File folder = getFolder(defaultDirectoryName); SharedPreferences.Editor spEditor = prefs.edit(); - spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath()); + spEditor.putString(key, getNewPipeChildFolderPathForDir(getDir(defaultDirectoryName))); spEditor.apply(); } + + private static String getNewPipeChildFolderPathForDir(File dir) { + return new File(dir, "NewPipe").getAbsolutePath(); + } } diff --git a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java index 550bd420d..3294f5164 100755 --- a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java @@ -1,18 +1,13 @@ package us.shandian.giga.get; -import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Handler; -import android.preference.PreferenceManager; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; -import org.schabi.newpipe.R; import org.schabi.newpipe.download.ExtSDDownloadFailedActivity; -import org.schabi.newpipe.settings.NewPipeSettings; import java.io.File; import java.io.FilenameFilter; @@ -36,6 +31,7 @@ public class DownloadManagerImpl implements DownloadManager { private final DownloadDataSource mDownloadDataSource; private final ArrayList mMissions = new ArrayList<>(); + @NonNull private final Context context; /** diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0e72ecd35..eaeeb2685 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -171,7 +171,7 @@ Error External storage not available. - Download to external SD Card is not possible yet. Should the download place be reseted? + Download to external SD Card is not possible yet. Should the download place be reset? Network error Could not load all thumbnails Could not decrypt video URL signature diff --git a/build.gradle b/build.gradle index 0448ed61e..20c8a0dfc 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files