From a68823491c4195cd26ed73da61882ba0379ef7f0 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Thu, 28 Jun 2018 20:37:05 +0200 Subject: [PATCH 01/40] Delete on long press --- .../holder/ChannelMiniInfoItemHolder.java | 7 ++ .../subscription/SubscriptionFragment.java | 88 ++++++++++++++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java index 643886da8..ca783833a 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java @@ -47,6 +47,13 @@ public class ChannelMiniInfoItemHolder extends InfoItemHolder { itemBuilder.getOnChannelSelectedListener().selected(item); } }); + + itemView.setOnLongClickListener(view -> { + if (itemBuilder.getOnChannelSelectedListener() != null) { + itemBuilder.getOnChannelSelectedListener().held(item); + } + return true; + }); } protected String getDetailLine(final ChannelInfoItem item) { diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index 5f6ea42ee..f31e0a7c3 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -1,8 +1,11 @@ package org.schabi.newpipe.local.subscription; +import android.annotation.SuppressLint; import android.app.Activity; +import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Color; @@ -17,6 +20,7 @@ import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.ActionBar; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -30,18 +34,24 @@ import com.nononsenseapps.filepicker.Utils; import org.schabi.newpipe.R; import org.schabi.newpipe.database.subscription.SubscriptionEntity; +import org.schabi.newpipe.download.DownloadDialog; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; +import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.stream.StreamInfo; +import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.info_list.InfoListAdapter; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.local.subscription.services.SubscriptionsExportService; import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService; +import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; +import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.OnClickGesture; import org.schabi.newpipe.util.ServiceHelper; @@ -55,12 +65,17 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.concurrent.TimeUnit; import icepick.State; +import io.reactivex.Observable; import io.reactivex.Observer; +import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Consumer; +import io.reactivex.functions.Function; import io.reactivex.schedulers.Schedulers; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_MODE; @@ -316,12 +331,17 @@ public class SubscriptionFragment extends BaseStateFragment() { - @Override + public void selected(ChannelInfoItem selectedItem) { // Requires the parent fragment to find holder for fragment replacement NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(), selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName()); } + + public void held(ChannelInfoItem selectedItem) { + showLongTapDialog(selectedItem); + } + }); //noinspection ConstantConditions @@ -330,6 +350,72 @@ public class SubscriptionFragment extends BaseStateFragment importExportOptions.switchState()); } + private void showLongTapDialog(ChannelInfoItem selectedItem) { + final Context context = getContext(); + final Activity activity = getActivity(); + if (context == null || context.getResources() == null || getActivity() == null) return; + + final String[] commands = new String[]{ + context.getResources().getString(R.string.share), + context.getResources().getString(R.string.unsubscribe) + }; + + final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { + switch (i) { + case 0: + shareChannel(selectedItem); + break; + case 1: + deleteChannel(selectedItem); + break; + default: + break; + } + }; + + final View bannerView = View.inflate(activity, R.layout.dialog_title, null); + bannerView.setSelected(true); + + TextView titleView = bannerView.findViewById(R.id.itemTitleView); + titleView.setText(selectedItem.getName()); + + TextView detailsView = bannerView.findViewById(R.id.itemAdditionalDetails); + detailsView.setVisibility(View.GONE); + + new AlertDialog.Builder(activity) + .setCustomTitle(bannerView) + .setItems(commands, actions) + .create() + .show(); + + } + + private void shareChannel (ChannelInfoItem selectedItem) { + shareUrl(selectedItem.getName(), selectedItem.getUrl()); + } + + @SuppressLint("CheckResult") + private void deleteChannel (ChannelInfoItem selectedItem) { + ExtractorHelper.getChannelInfo(selectedItem.getServiceId(), selectedItem.getUrl(), true) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe((@NonNull ChannelInfo result) -> { + mapOnUnsubscribe(SubscriptionEntity.from(result)); + }, (@NonNull Throwable throwable) -> { + + }); + } + + private Function mapOnUnsubscribe(final SubscriptionEntity subscription) { + return new Function() { + @Override + public Object apply(@NonNull Object o) throws Exception { + subscriptionService.subscriptionTable().delete(subscription); + return o; + } + }; + } + private void resetFragment() { if (disposables != null) disposables.clear(); if (infoListAdapter != null) infoListAdapter.clearStreamItemList(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5ca88bd6f..2faae0175 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -27,6 +27,7 @@ RSS Subscribe Subscribed + Unsubscribe Channel unsubscribed Unable to change subscription Unable to update subscription From 0b7593ad28a1d04d67ef85e6157eca4c83579cc0 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Thu, 28 Jun 2018 20:43:46 +0200 Subject: [PATCH 02/40] Delete on long press --- .../subscription/SubscriptionFragment.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index f31e0a7c3..4b311a852 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -8,8 +8,12 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; +import android.content.pm.ResolveInfo; +import android.content.res.Resources; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.os.Parcelable; @@ -21,6 +25,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -78,6 +83,7 @@ import io.reactivex.functions.Consumer; import io.reactivex.functions.Function; import io.reactivex.schedulers.Schedulers; +import static android.content.ContentValues.TAG; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_MODE; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_VALUE; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE; @@ -400,20 +406,20 @@ public class SubscriptionFragment extends BaseStateFragment { - mapOnUnsubscribe(SubscriptionEntity.from(result)); + new LongOperation().execute(SubscriptionEntity.from(result)); }, (@NonNull Throwable throwable) -> { }); } - private Function mapOnUnsubscribe(final SubscriptionEntity subscription) { - return new Function() { - @Override - public Object apply(@NonNull Object o) throws Exception { - subscriptionService.subscriptionTable().delete(subscription); - return o; - } - }; + + private class LongOperation extends AsyncTask { + + @Override + protected Void doInBackground(SubscriptionEntity... params) { + subscriptionService.subscriptionTable().delete(params[0]); + return null; + } } private void resetFragment() { From 5150c2ee62dba57e954a8ef436118218e0ff50cb Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Thu, 28 Jun 2018 23:56:39 +0200 Subject: [PATCH 03/40] This thing actually works lol --- .../local/subscription/SubscriptionFragment.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index 4b311a852..8f02158bc 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -73,6 +73,7 @@ import java.util.Locale; import java.util.concurrent.TimeUnit; import icepick.State; +import io.reactivex.Flowable; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.Single; @@ -406,18 +407,20 @@ public class SubscriptionFragment extends BaseStateFragment { - new LongOperation().execute(SubscriptionEntity.from(result)); + new LongOperation().execute(result); }, (@NonNull Throwable throwable) -> { }); } - private class LongOperation extends AsyncTask { + private class LongOperation extends AsyncTask { @Override - protected Void doInBackground(SubscriptionEntity... params) { - subscriptionService.subscriptionTable().delete(params[0]); + protected Void doInBackground(ChannelInfo... params) { + ChannelInfo info = params[0]; + Flowable> subscription = subscriptionService.subscriptionTable().getSubscription(info.getServiceId(), info.getUrl()); + subscriptionService.subscriptionTable().delete(subscription.blockingFirst()); return null; } } From f2f275512d4ef276e473ffb08b24202fef340c18 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Fri, 29 Jun 2018 00:39:16 +0200 Subject: [PATCH 04/40] It looks good now --- .../subscription/SubscriptionFragment.java | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index 8f02158bc..16f203923 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -6,6 +6,7 @@ import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; +import android.content.Entity; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ResolveInfo; @@ -76,6 +77,7 @@ import icepick.State; import io.reactivex.Flowable; import io.reactivex.Observable; import io.reactivex.Observer; +import io.reactivex.Scheduler; import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; @@ -405,26 +407,13 @@ public class SubscriptionFragment extends BaseStateFragment { - new LongOperation().execute(result); - }, (@NonNull Throwable throwable) -> { - + List toDelete = subscriptionService.subscriptionTable().getSubscription(result.getServiceId(), result.getUrl()).blockingFirst(); + subscriptionService.subscriptionTable().delete(toDelete); }); } - - private class LongOperation extends AsyncTask { - - @Override - protected Void doInBackground(ChannelInfo... params) { - ChannelInfo info = params[0]; - Flowable> subscription = subscriptionService.subscriptionTable().getSubscription(info.getServiceId(), info.getUrl()); - subscriptionService.subscriptionTable().delete(subscription.blockingFirst()); - return null; - } - } - private void resetFragment() { if (disposables != null) disposables.clear(); if (infoListAdapter != null) infoListAdapter.clearStreamItemList(); From b9ea7ce066189b21b94268ed9ae33b9c222f4385 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Fri, 29 Jun 2018 00:39:44 +0200 Subject: [PATCH 05/40] Code looking nicer --- .../newpipe/local/subscription/SubscriptionFragment.java | 4 +++- .../main/java/org/schabi/newpipe/util/ExtractorHelper.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index 16f203923..4c4242055 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -409,7 +409,9 @@ public class SubscriptionFragment extends BaseStateFragment { - List toDelete = subscriptionService.subscriptionTable().getSubscription(result.getServiceId(), result.getUrl()).blockingFirst(); + List toDelete = subscriptionService.subscriptionTable() + .getSubscription(result.getServiceId(), result.getUrl()) + .blockingFirst(); subscriptionService.subscriptionTable().delete(toDelete); }); } 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 1897589c6..e248ed993 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -32,6 +32,7 @@ import org.schabi.newpipe.extractor.Info; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfo; +import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; From 181a14ce5958149af308872dfc66a826caea2da1 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Sat, 30 Jun 2018 02:20:01 +0200 Subject: [PATCH 06/40] Disposable now is cleaned properly --- .../newpipe/local/subscription/SubscriptionFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index 4c4242055..c0e24b53f 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -405,6 +405,7 @@ public class SubscriptionFragment extends BaseStateFragment Date: Sat, 30 Jun 2018 02:42:47 +0200 Subject: [PATCH 07/40] Added unsubscription toast Added error handling Corrected threads --- .../subscription/SubscriptionFragment.java | 63 +++++++++++-------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index c0e24b53f..5a9f34cd9 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -6,15 +6,10 @@ import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; -import android.content.Entity; import android.content.Intent; import android.content.IntentFilter; -import android.content.pm.ResolveInfo; -import android.content.res.Resources; import android.graphics.Color; import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; -import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.os.Parcelable; @@ -26,7 +21,6 @@ import android.support.v7.app.ActionBar; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; -import android.util.TypedValue; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -40,24 +34,20 @@ import com.nononsenseapps.filepicker.Utils; import org.schabi.newpipe.R; import org.schabi.newpipe.database.subscription.SubscriptionEntity; -import org.schabi.newpipe.download.DownloadDialog; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.stream.StreamInfo; -import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.info_list.InfoListAdapter; -import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.local.subscription.services.SubscriptionsExportService; import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService; +import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; -import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.OnClickGesture; import org.schabi.newpipe.util.ServiceHelper; @@ -71,22 +61,15 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Locale; -import java.util.concurrent.TimeUnit; import icepick.State; -import io.reactivex.Flowable; -import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.Scheduler; -import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.Disposable; -import io.reactivex.functions.Consumer; -import io.reactivex.functions.Function; import io.reactivex.schedulers.Schedulers; -import static android.content.ContentValues.TAG; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_MODE; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_VALUE; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE; @@ -405,16 +388,42 @@ public class SubscriptionFragment extends BaseStateFragment { - List toDelete = subscriptionService.subscriptionTable() - .getSubscription(result.getServiceId(), result.getUrl()) - .blockingFirst(); - subscriptionService.subscriptionTable().delete(toDelete); - })); + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(getUnsubscribeObserver()); + } + + + + private Observer getUnsubscribeObserver() { + return new Observer() { + @Override + public void onSubscribe(Disposable d) { + disposables.add(d); + } + + @Override + public void onNext(ChannelInfo info) { + List toDelete = subscriptionService.subscriptionTable() + .getSubscription(info.getServiceId(), info.getUrl()) + .blockingFirst(); + Log.d(TAG, "onNext: test"); + + Scheduler io = Schedulers.io(); + io.scheduleDirect(() -> subscriptionService.subscriptionTable().delete(toDelete)); + } + + @Override + public void onError(Throwable exception) { + SubscriptionFragment.this.onError(exception); + } + + @Override + public void onComplete() { + Toast.makeText(activity, getString(R.string.channel_unsubscribed), Toast.LENGTH_SHORT).show(); + } + }; } private void resetFragment() { From 510591ef0f33bad0d72a0901c64bee33f29f58c8 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Thu, 16 Aug 2018 00:45:37 +0200 Subject: [PATCH 08/40] Removed use of blockingFirst() and scheduleDirect() --- .../subscription/SubscriptionFragment.java | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index a8603960b..c0a96da32 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -21,7 +21,6 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -44,9 +43,9 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.info_list.InfoListAdapter; -import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.local.subscription.services.SubscriptionsExportService; import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService; +import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -66,7 +65,6 @@ import java.util.Locale; import icepick.State; import io.reactivex.Observer; -import io.reactivex.Scheduler; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.Disposable; @@ -413,13 +411,12 @@ public class SubscriptionFragment extends BaseStateFragment toDelete = subscriptionService.subscriptionTable() + final io.reactivex.Observable> observable = subscriptionService.subscriptionTable() .getSubscription(info.getServiceId(), info.getUrl()) - .blockingFirst(); - Log.d(TAG, "onNext: test"); + .toObservable(); - Scheduler io = Schedulers.io(); - io.scheduleDirect(() -> subscriptionService.subscriptionTable().delete(toDelete)); + observable.observeOn(Schedulers.io()) + .subscribe(getDeleteObserver()); } @Override @@ -434,6 +431,28 @@ public class SubscriptionFragment extends BaseStateFragment> getDeleteObserver(){ + return new Observer>() { + @Override + public void onSubscribe(Disposable d) { + disposables.add(d); + } + + @Override + public void onNext(List subscriptionEntities) { + subscriptionService.subscriptionTable().delete(subscriptionEntities); + } + + @Override + public void onError(Throwable exception) { + SubscriptionFragment.this.onError(exception); + } + + @Override + public void onComplete() { } + }; + } + private void resetFragment() { if (disposables != null) disposables.clear(); if (infoListAdapter != null) infoListAdapter.clearStreamItemList(); From f4416fe007c90f0da6b890c30f5f5ad404e34722 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Thu, 16 Aug 2018 01:04:37 +0200 Subject: [PATCH 09/40] Doesn't use getChannelInfo() anymore. --- .../subscription/SubscriptionFragment.java | 43 ++++--------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index c0a96da32..e39047bd3 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -37,7 +37,6 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; -import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; @@ -47,7 +46,6 @@ import org.schabi.newpipe.local.subscription.services.SubscriptionsExportService import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; -import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.FilePickerActivityHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.OnClickGesture; @@ -394,43 +392,18 @@ public class SubscriptionFragment extends BaseStateFragment> observable = subscriptionService.subscriptionTable() + .getSubscription(selectedItem.getServiceId(), selectedItem.getUrl()) + .toObservable(); - - - private Observer getUnsubscribeObserver() { - return new Observer() { - @Override - public void onSubscribe(Disposable d) { - disposables.add(d); - } - - @Override - public void onNext(ChannelInfo info) { - final io.reactivex.Observable> observable = subscriptionService.subscriptionTable() - .getSubscription(info.getServiceId(), info.getUrl()) - .toObservable(); - - observable.observeOn(Schedulers.io()) + observable.observeOn(Schedulers.io()) .subscribe(getDeleteObserver()); - } - @Override - public void onError(Throwable exception) { - SubscriptionFragment.this.onError(exception); - } - - @Override - public void onComplete() { - Toast.makeText(activity, getString(R.string.channel_unsubscribed), Toast.LENGTH_SHORT).show(); - } - }; + Toast.makeText(activity, getString(R.string.channel_unsubscribed), Toast.LENGTH_SHORT).show(); } + + private Observer> getDeleteObserver(){ return new Observer>() { @Override @@ -449,7 +422,7 @@ public class SubscriptionFragment extends BaseStateFragment Date: Wed, 22 Aug 2018 08:32:58 +0300 Subject: [PATCH 10/40] Video details tablet layout --- .../fragments/detail/VideoDetailFragment.java | 7 +- .../fragment_video_detail.xml | 505 ++++++++++++++++++ 2 files changed, 510 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/layout-large-land/fragment_video_detail.xml 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..bb642cefa 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 @@ -179,7 +179,7 @@ public class VideoDetailFragment private TextView thumbsDisabledTextView; private TextView nextStreamTitle; - private LinearLayout relatedStreamRootLayout; + private View relatedStreamRootLayout; private LinearLayout relatedStreamsView; private ImageButton relatedStreamExpandButton; @@ -623,7 +623,10 @@ public class VideoDetailFragment infoItemBuilder.buildView(relatedStreamsView, info.getNextVideo())); relatedStreamsView.addView(getSeparatorView()); relatedStreamRootLayout.setVisibility(View.VISIBLE); - } else nextStreamTitle.setVisibility(View.GONE); + } else { + nextStreamTitle.setVisibility(View.GONE); + relatedStreamRootLayout.setVisibility(View.GONE); + } if (info.getRelatedStreams() != null && !info.getRelatedStreams().isEmpty() && showRelatedStreams) { diff --git a/app/src/main/res/layout-large-land/fragment_video_detail.xml b/app/src/main/res/layout-large-land/fragment_video_detail.xml new file mode 100644 index 000000000..4d3914947 --- /dev/null +++ b/app/src/main/res/layout-large-land/fragment_video_detail.xml @@ -0,0 +1,505 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1e0f6f9e41e5d7c22fec18788615059e9f19c5af Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 22 Aug 2018 10:14:01 +0300 Subject: [PATCH 11/40] Grid view --- .../fragments/list/BaseListFragment.java | 56 +++++++++++++-- .../newpipe/info_list/InfoListAdapter.java | 34 ++++++++- .../holder/ChannelGridInfoItemHolder.java | 13 ++++ .../holder/PlaylistGridInfoItemHolder.java | 13 ++++ .../holder/StreamGridInfoItemHolder.java | 13 ++++ .../res/layout/list_channel_grid_item.xml | 48 +++++++++++++ .../res/layout/list_playlist_grid_item.xml | 72 +++++++++++++++++++ .../main/res/layout/list_stream_grid_item.xml | 69 ++++++++++++++++++ app/src/main/res/values/dimens.xml | 2 + app/src/main/res/values/settings_keys.xml | 11 +++ app/src/main/res/values/strings.xml | 3 + app/src/main/res/xml/appearance_settings.xml | 8 +++ 12 files changed, 335 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelGridInfoItemHolder.java create mode 100644 app/src/main/java/org/schabi/newpipe/info_list/holder/PlaylistGridInfoItemHolder.java create mode 100644 app/src/main/java/org/schabi/newpipe/info_list/holder/StreamGridInfoItemHolder.java create mode 100644 app/src/main/res/layout/list_channel_grid_item.xml create mode 100644 app/src/main/res/layout/list_playlist_grid_item.xml create mode 100644 app/src/main/res/layout/list_stream_grid_item.xml diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index 1db12bba9..bfa16fb08 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -3,10 +3,14 @@ package org.schabi.newpipe.fragments.list; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.res.Resources; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; @@ -21,9 +25,9 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.fragments.OnScrollBelowItemsListener; -import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.info_list.InfoItemDialog; import org.schabi.newpipe.info_list.InfoListAdapter; +import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.player.playqueue.SinglePlayQueue; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.util.NavigationHelper; @@ -36,7 +40,7 @@ import java.util.Queue; import static org.schabi.newpipe.util.AnimationUtils.animateView; -public abstract class BaseListFragment extends BaseStateFragment implements ListViewContract, StateSaver.WriteRead { +public abstract class BaseListFragment extends BaseStateFragment implements ListViewContract, StateSaver.WriteRead, SharedPreferences.OnSharedPreferenceChangeListener { /*////////////////////////////////////////////////////////////////////////// // Views @@ -44,6 +48,9 @@ public abstract class BaseListFragment extends BaseStateFragment implem protected InfoListAdapter infoListAdapter; protected RecyclerView itemsList; + private int updateFlags = 0; + + private static final int LIST_MODE_UPDATE_FLAG = 0x32; /*////////////////////////////////////////////////////////////////////////// // LifeCycle @@ -59,12 +66,32 @@ public abstract class BaseListFragment extends BaseStateFragment implem public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); + PreferenceManager.getDefaultSharedPreferences(activity) + .registerOnSharedPreferenceChangeListener(this); } @Override public void onDestroy() { super.onDestroy(); StateSaver.onDestroy(savedState); + PreferenceManager.getDefaultSharedPreferences(activity) + .unregisterOnSharedPreferenceChangeListener(this); + } + + @Override + public void onResume() { + super.onResume(); + + if (updateFlags != 0) { + if ((updateFlags & LIST_MODE_UPDATE_FLAG) != 0) { + final String list_key = getString(R.string.list_view_mode_value); + final boolean useGrid = !list_key.equals(PreferenceManager.getDefaultSharedPreferences(activity).getString(getString(R.string.list_view_mode_key), list_key)); + itemsList.setLayoutManager(useGrid ? getGridLayoutManager() : getListLayoutManager()); + infoListAdapter.setGridItemVariants(useGrid); + infoListAdapter.notifyDataSetChanged(); + } + updateFlags = 0; + } } /*////////////////////////////////////////////////////////////////////////// @@ -119,13 +146,27 @@ public abstract class BaseListFragment extends BaseStateFragment implem return new LinearLayoutManager(activity); } + protected RecyclerView.LayoutManager getGridLayoutManager() { + final Resources resources = activity.getResources(); + int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width); + width += (24 * resources.getDisplayMetrics().density); + final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width); + final GridLayoutManager lm = new GridLayoutManager(activity, spanCount); + lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount)); + return lm; + } + @Override protected void initViews(View rootView, Bundle savedInstanceState) { super.initViews(rootView, savedInstanceState); - itemsList = rootView.findViewById(R.id.items_list); - itemsList.setLayoutManager(getListLayoutManager()); + final String list_key = getString(R.string.list_view_mode_value); + final boolean useGrid = !list_key.equals(PreferenceManager.getDefaultSharedPreferences(activity).getString(getString(R.string.list_view_mode_key), list_key)); + itemsList = rootView.findViewById(R.id.items_list); + itemsList.setLayoutManager(useGrid ? getGridLayoutManager() : getListLayoutManager()); + + infoListAdapter.setGridItemVariants(useGrid); infoListAdapter.setFooter(getListFooter()); infoListAdapter.setHeader(getListHeader()); @@ -315,4 +356,11 @@ public abstract class BaseListFragment extends BaseStateFragment implem public void handleNextItems(N result) { isLoading.set(false); } + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (key.equals(getString(R.string.list_view_mode_key))) { + updateFlags |= LIST_MODE_UPDATE_FLAG; + } + } } diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java index cf12deb6f..15fdcad05 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.info_list; import android.app.Activity; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.View; @@ -12,9 +13,12 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.info_list.holder.ChannelInfoItemHolder; import org.schabi.newpipe.info_list.holder.ChannelMiniInfoItemHolder; +import org.schabi.newpipe.info_list.holder.ChannelGridInfoItemHolder; import org.schabi.newpipe.info_list.holder.InfoItemHolder; +import org.schabi.newpipe.info_list.holder.PlaylistGridInfoItemHolder; import org.schabi.newpipe.info_list.holder.PlaylistInfoItemHolder; import org.schabi.newpipe.info_list.holder.PlaylistMiniInfoItemHolder; +import org.schabi.newpipe.info_list.holder.StreamGridInfoItemHolder; import org.schabi.newpipe.info_list.holder.StreamInfoItemHolder; import org.schabi.newpipe.info_list.holder.StreamMiniInfoItemHolder; import org.schabi.newpipe.util.FallbackViewHolder; @@ -52,14 +56,18 @@ public class InfoListAdapter extends RecyclerView.Adapter infoItemList; private boolean useMiniVariant = false; + private boolean useGridVariant = false; private boolean showFooter = false; private View header = null; private View footer = null; @@ -94,6 +102,10 @@ public class InfoListAdapter extends RecyclerView.Adapter data) { if (data != null) { if (DEBUG) { @@ -206,11 +218,11 @@ public class InfoListAdapter extends RecyclerView.Adapter + + + + + + + + + diff --git a/app/src/main/res/layout/list_playlist_grid_item.xml b/app/src/main/res/layout/list_playlist_grid_item.xml new file mode 100644 index 000000000..949b1159b --- /dev/null +++ b/app/src/main/res/layout/list_playlist_grid_item.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/list_stream_grid_item.xml b/app/src/main/res/layout/list_stream_grid_item.xml new file mode 100644 index 000000000..cf73bf9b1 --- /dev/null +++ b/app/src/main/res/layout/list_stream_grid_item.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index e7af3231e..229c00533 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -12,6 +12,8 @@ 124dp 70dp + 164dp + 92dp 94dp diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 02f065285..941f033d8 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -891,5 +891,16 @@ 144p + list_view_mode + list + + + list + grid + + + @string/list + @string/grid + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 240fef3dc..f3976c6a4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -514,5 +514,8 @@ None Minimize to background player Minimize to popup player + List view mode + List + Grid diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml index 239f5f3b3..490310c91 100644 --- a/app/src/main/res/xml/appearance_settings.xml +++ b/app/src/main/res/xml/appearance_settings.xml @@ -22,6 +22,14 @@ android:title="@string/show_hold_to_append_title" android:summary="@string/show_hold_to_append_summary"/> + + Date: Wed, 22 Aug 2018 10:29:37 +0300 Subject: [PATCH 12/40] Fix crash on screen rotation --- .../fragments/detail/VideoDetailFragment.java | 31 +++++++++++++------ .../fragment_video_detail.xml | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) 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 bb642cefa..ad3dacf6b 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 @@ -33,12 +33,14 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewParent; import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; +import android.widget.ScrollView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -64,19 +66,17 @@ import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.fragments.BackPressable; import org.schabi.newpipe.fragments.BaseStateFragment; -import org.schabi.newpipe.local.history.HistoryRecordManager; -import org.schabi.newpipe.report.ErrorActivity; -import org.schabi.newpipe.util.StreamItemAdapter; -import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper; -import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.info_list.InfoItemDialog; +import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; +import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.player.MainVideoPlayer; import org.schabi.newpipe.player.PopupVideoPlayer; import org.schabi.newpipe.player.helper.PlayerHelper; import org.schabi.newpipe.player.old.PlayVideoActivity; import org.schabi.newpipe.player.playqueue.PlayQueue; import org.schabi.newpipe.player.playqueue.SinglePlayQueue; +import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ExtractorHelper; @@ -87,6 +87,8 @@ import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.OnClickGesture; import org.schabi.newpipe.util.PermissionHelper; +import org.schabi.newpipe.util.StreamItemAdapter; +import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper; import org.schabi.newpipe.util.ThemeHelper; import java.io.Serializable; @@ -179,7 +181,7 @@ public class VideoDetailFragment private TextView thumbsDisabledTextView; private TextView nextStreamTitle; - private View relatedStreamRootLayout; + private LinearLayout relatedStreamRootLayout; private LinearLayout relatedStreamsView; private ImageButton relatedStreamExpandButton; @@ -622,10 +624,10 @@ public class VideoDetailFragment relatedStreamsView.addView( infoItemBuilder.buildView(relatedStreamsView, info.getNextVideo())); relatedStreamsView.addView(getSeparatorView()); - relatedStreamRootLayout.setVisibility(View.VISIBLE); + setRelatedStreamsVisibility(View.VISIBLE); } else { nextStreamTitle.setVisibility(View.GONE); - relatedStreamRootLayout.setVisibility(View.GONE); + setRelatedStreamsVisibility(View.GONE); } if (info.getRelatedStreams() != null @@ -642,13 +644,13 @@ public class VideoDetailFragment } //if (DEBUG) Log.d(TAG, "Total time " + ((System.nanoTime() - first) / 1000000L) + "ms"); - relatedStreamRootLayout.setVisibility(View.VISIBLE); + setRelatedStreamsVisibility(View.VISIBLE); relatedStreamExpandButton.setVisibility(View.VISIBLE); relatedStreamExpandButton.setImageDrawable(ContextCompat.getDrawable( activity, ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.expand))); } else { - if (info.getNextVideo() == null) relatedStreamRootLayout.setVisibility(View.GONE); + if (info.getNextVideo() == null) setRelatedStreamsVisibility(View.GONE); relatedStreamExpandButton.setVisibility(View.GONE); } } @@ -1302,4 +1304,13 @@ public class VideoDetailFragment showError(getString(R.string.blocked_by_gema), false, R.drawable.gruese_die_gema); } + + private void setRelatedStreamsVisibility(int visibility) { + final ViewParent parent = relatedStreamRootLayout.getParent(); + if (parent instanceof ScrollView) { + ((ScrollView) parent).setVisibility(visibility); + } else { + relatedStreamRootLayout.setVisibility(visibility); + } + } } \ No newline at end of file diff --git a/app/src/main/res/layout-large-land/fragment_video_detail.xml b/app/src/main/res/layout-large-land/fragment_video_detail.xml index 4d3914947..bf49a01a6 100644 --- a/app/src/main/res/layout-large-land/fragment_video_detail.xml +++ b/app/src/main/res/layout-large-land/fragment_video_detail.xml @@ -456,13 +456,13 @@ Date: Wed, 22 Aug 2018 10:33:10 +0300 Subject: [PATCH 13/40] Update translations --- app/src/main/res/values-ru/strings.xml | 5 +++++ app/src/main/res/values-uk/strings.xml | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 3cacc83e8..e2198f240 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -485,6 +485,7 @@ Предел разрешения в мобильной сети Каналы Плейлисты + Видео Дорожки Пользователи Пропускать тишину @@ -497,4 +498,8 @@ Фоновый плеер Плеер в окне + Вид списка + Список + Сетка + diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 78eb45590..e4d4106d4 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -481,8 +481,12 @@ Зменшити до фонового програвачу Зменшити до віконного програвачу -Канали + Канали Плейлисти Стежки Користувачі - + + Вигляд списку + Список + Сiтка + From 4326354ca65a6b00b6ef693a9f0064824a28d509 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Wed, 22 Aug 2018 13:59:12 +0200 Subject: [PATCH 14/40] Code cleanup --- .../newpipe/local/subscription/SubscriptionFragment.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index e39047bd3..7b7f43047 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -392,11 +392,10 @@ public class SubscriptionFragment extends BaseStateFragment> observable = subscriptionService.subscriptionTable() + subscriptionService.subscriptionTable() .getSubscription(selectedItem.getServiceId(), selectedItem.getUrl()) - .toObservable(); - - observable.observeOn(Schedulers.io()) + .toObservable() + .observeOn(Schedulers.io()) .subscribe(getDeleteObserver()); Toast.makeText(activity, getString(R.string.channel_unsubscribed), Toast.LENGTH_SHORT).show(); From ce21fe208738ea6f27936df4314b78d76a80074b Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 29 Aug 2018 07:53:58 +0300 Subject: [PATCH 15/40] Always show description on tablets --- .../fragments/detail/VideoDetailFragment.java | 37 ++++++++++++------- .../fragment_video_detail.xml | 16 +------- 2 files changed, 24 insertions(+), 29 deletions(-) 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 ad3dacf6b..8f46ec7c6 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 @@ -156,6 +156,7 @@ public class VideoDetailFragment private View videoTitleRoot; private TextView videoTitleTextView; + @Nullable private ImageView videoTitleToggleArrow; private TextView videoCountView; @@ -417,14 +418,16 @@ public class VideoDetailFragment } private void toggleTitleAndDescription() { - if (videoDescriptionRootLayout.getVisibility() == View.VISIBLE) { - videoTitleTextView.setMaxLines(1); - videoDescriptionRootLayout.setVisibility(View.GONE); - videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); - } else { - videoTitleTextView.setMaxLines(10); - videoDescriptionRootLayout.setVisibility(View.VISIBLE); - videoTitleToggleArrow.setImageResource(R.drawable.arrow_up); + if (videoTitleToggleArrow != null) { //it is null for tablets + if (videoDescriptionRootLayout.getVisibility() == View.VISIBLE) { + videoTitleTextView.setMaxLines(1); + videoDescriptionRootLayout.setVisibility(View.GONE); + videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); + } else { + videoTitleTextView.setMaxLines(10); + videoDescriptionRootLayout.setVisibility(View.VISIBLE); + videoTitleToggleArrow.setImageResource(R.drawable.arrow_up); + } } } @@ -1119,8 +1122,10 @@ public class VideoDetailFragment animateView(videoTitleTextView, true, 0); videoDescriptionRootLayout.setVisibility(View.GONE); - videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); - videoTitleToggleArrow.setVisibility(View.GONE); + if (videoTitleToggleArrow != null) { + videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); + videoTitleToggleArrow.setVisibility(View.GONE); + } videoTitleRoot.setClickable(false); imageLoader.cancelDisplayTask(thumbnailImageView); @@ -1195,11 +1200,15 @@ public class VideoDetailFragment detailDurationView.setVisibility(View.GONE); } - videoTitleRoot.setClickable(true); - videoTitleToggleArrow.setVisibility(View.VISIBLE); - videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); videoDescriptionView.setVisibility(View.GONE); - videoDescriptionRootLayout.setVisibility(View.GONE); + if (videoTitleToggleArrow != null) { + videoTitleRoot.setClickable(true); + videoTitleToggleArrow.setVisibility(View.VISIBLE); + videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); + videoDescriptionRootLayout.setVisibility(View.GONE); + } else { + videoDescriptionRootLayout.setVisibility(View.VISIBLE); + } if (!TextUtils.isEmpty(info.getUploadDate())) { videoUploadDateView.setText(Localization.localizeDate(activity, info.getUploadDate())); } diff --git a/app/src/main/res/layout-large-land/fragment_video_detail.xml b/app/src/main/res/layout-large-land/fragment_video_detail.xml index bf49a01a6..73939d60a 100644 --- a/app/src/main/res/layout-large-land/fragment_video_detail.xml +++ b/app/src/main/res/layout-large-land/fragment_video_detail.xml @@ -109,9 +109,6 @@ android:id="@+id/detail_title_root_layout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackground" - android:clickable="true" - android:focusable="true" android:paddingLeft="12dp" android:paddingRight="12dp"> @@ -129,15 +126,6 @@ tools:ignore="RtlHardcoded" tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a ultricies ex. Integer sit amet sodales risus. Duis non mi et urna pretium bibendum. Nunc eleifend est quis ipsum porttitor egestas. Sed facilisis, nisl quis eleifend pellentesque, orci metus egestas dolor, at accumsan eros metus quis libero." /> - - @@ -413,9 +401,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" - android:orientation="vertical" - android:visibility="gone" - tools:visibility="visible"> + android:orientation="vertical"> Date: Wed, 29 Aug 2018 08:08:19 +0300 Subject: [PATCH 16/40] Hide related streams while loading --- .../newpipe/fragments/detail/VideoDetailFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 8f46ec7c6..77583f2e5 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 @@ -1122,9 +1122,15 @@ public class VideoDetailFragment animateView(videoTitleTextView, true, 0); videoDescriptionRootLayout.setVisibility(View.GONE); - if (videoTitleToggleArrow != null) { + if (videoTitleToggleArrow != null) { //phone videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); videoTitleToggleArrow.setVisibility(View.GONE); + } else { //tablet + final View related = (View) relatedStreamRootLayout.getParent(); + //don`t need to hide it if related streams are disabled + if (related.getVisibility() == View.VISIBLE) { + related.setVisibility(View.INVISIBLE); + } } videoTitleRoot.setClickable(false); From fb25f6c7ac9ff8e24241e79e94f7ac046f836ad0 Mon Sep 17 00:00:00 2001 From: Vasily Date: Wed, 29 Aug 2018 08:19:15 +0300 Subject: [PATCH 17/40] Automatic list layout --- .../fragments/list/BaseListFragment.java | 19 ++++++++++++++----- app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values/settings_keys.xml | 4 +++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index bfa16fb08..21abf40ad 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.preference.PreferenceManager; @@ -84,8 +85,7 @@ public abstract class BaseListFragment extends BaseStateFragment implem if (updateFlags != 0) { if ((updateFlags & LIST_MODE_UPDATE_FLAG) != 0) { - final String list_key = getString(R.string.list_view_mode_value); - final boolean useGrid = !list_key.equals(PreferenceManager.getDefaultSharedPreferences(activity).getString(getString(R.string.list_view_mode_key), list_key)); + final boolean useGrid = isGridLayout(); itemsList.setLayoutManager(useGrid ? getGridLayoutManager() : getListLayoutManager()); infoListAdapter.setGridItemVariants(useGrid); infoListAdapter.notifyDataSetChanged(); @@ -160,9 +160,7 @@ public abstract class BaseListFragment extends BaseStateFragment implem protected void initViews(View rootView, Bundle savedInstanceState) { super.initViews(rootView, savedInstanceState); - final String list_key = getString(R.string.list_view_mode_value); - final boolean useGrid = !list_key.equals(PreferenceManager.getDefaultSharedPreferences(activity).getString(getString(R.string.list_view_mode_key), list_key)); - + final boolean useGrid = isGridLayout(); itemsList = rootView.findViewById(R.id.items_list); itemsList.setLayoutManager(useGrid ? getGridLayoutManager() : getListLayoutManager()); @@ -363,4 +361,15 @@ public abstract class BaseListFragment extends BaseStateFragment implem updateFlags |= LIST_MODE_UPDATE_FLAG; } } + + protected boolean isGridLayout() { + final String list_mode = PreferenceManager.getDefaultSharedPreferences(activity).getString(getString(R.string.list_view_mode_key), getString(R.string.list_view_mode_value)); + if ("auto".equals(list_mode)) { + final Configuration configuration = getResources().getConfiguration(); + return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE + && configuration.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE); + } else { + return "grid".equals(list_mode); + } + } } diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index e2198f240..a053cafb3 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -501,5 +501,6 @@ Вид списка Список Сетка + Автоматически diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 941f033d8..0c71944c3 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -892,13 +892,15 @@ list_view_mode - list + auto + auto list grid + @string/auto @string/list @string/grid diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f3976c6a4..b63de7dbd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -517,5 +517,6 @@ List view mode List Grid + Auto From ee4942dfd70a980192c8b4e604c94a412553b2a8 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 31 Aug 2018 14:34:32 +0300 Subject: [PATCH 18/40] Grid layout for local lists --- .../newpipe/local/BaseLocalListFragment.java | 70 +++++++++++++++- .../newpipe/local/LocalItemListAdapter.java | 42 ++++++++-- .../holder/LocalPlaylistGridItemHolder.java | 13 +++ .../local/holder/LocalPlaylistItemHolder.java | 4 + .../LocalPlaylistStreamGridItemHolder.java | 13 +++ .../LocalStatisticStreamGridItemHolder.java | 13 +++ .../LocalStatisticStreamItemHolder.java | 14 +++- .../holder/RemotePlaylistGridItemHolder.java | 13 +++ .../holder/RemotePlaylistItemHolder.java | 4 + .../layout/list_stream_playlist_grid_item.xml | 84 +++++++++++++++++++ 10 files changed, 257 insertions(+), 13 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistGridItemHolder.java create mode 100644 app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamGridItemHolder.java create mode 100644 app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamGridItemHolder.java create mode 100644 app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistGridItemHolder.java create mode 100644 app/src/main/res/layout/list_stream_playlist_grid_item.xml diff --git a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java index 5192aa2ab..abdf82353 100644 --- a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java @@ -1,8 +1,13 @@ package org.schabi.newpipe.local; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.content.res.Resources; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; @@ -25,7 +30,7 @@ import static org.schabi.newpipe.util.AnimationUtils.animateView; * called and is memory efficient when in backstack. * */ public abstract class BaseLocalListFragment extends BaseStateFragment - implements ListViewContract { + implements ListViewContract, SharedPreferences.OnSharedPreferenceChangeListener { /*////////////////////////////////////////////////////////////////////////// // Views @@ -36,6 +41,9 @@ public abstract class BaseLocalListFragment extends BaseStateFragment protected LocalItemListAdapter itemListAdapter; protected RecyclerView itemsList; + private int updateFlags = 0; + + private static final int LIST_MODE_UPDATE_FLAG = 0x32; /*////////////////////////////////////////////////////////////////////////// // Lifecycle - Creation @@ -45,6 +53,29 @@ public abstract class BaseLocalListFragment extends BaseStateFragment public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); + PreferenceManager.getDefaultSharedPreferences(activity) + .registerOnSharedPreferenceChangeListener(this); + } + + @Override + public void onDestroy() { + super.onDestroy(); + PreferenceManager.getDefaultSharedPreferences(activity) + .unregisterOnSharedPreferenceChangeListener(this); + } + + @Override + public void onResume() { + super.onResume(); + if (updateFlags != 0) { + if ((updateFlags & LIST_MODE_UPDATE_FLAG) != 0) { + final boolean useGrid = isGridLayout(); + itemsList.setLayoutManager(useGrid ? getGridLayoutManager() : getListLayoutManager()); + itemListAdapter.setGridItemVariants(useGrid); + itemListAdapter.notifyDataSetChanged(); + } + updateFlags = 0; + } } /*////////////////////////////////////////////////////////////////////////// @@ -59,6 +90,16 @@ public abstract class BaseLocalListFragment extends BaseStateFragment return activity.getLayoutInflater().inflate(R.layout.pignate_footer, itemsList, false); } + protected RecyclerView.LayoutManager getGridLayoutManager() { + final Resources resources = activity.getResources(); + int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width); + width += (24 * resources.getDisplayMetrics().density); + final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width); + final GridLayoutManager lm = new GridLayoutManager(activity, spanCount); + lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount)); + return lm; + } + protected RecyclerView.LayoutManager getListLayoutManager() { return new LinearLayoutManager(activity); } @@ -67,10 +108,13 @@ public abstract class BaseLocalListFragment extends BaseStateFragment protected void initViews(View rootView, Bundle savedInstanceState) { super.initViews(rootView, savedInstanceState); - itemsList = rootView.findViewById(R.id.items_list); - itemsList.setLayoutManager(getListLayoutManager()); - itemListAdapter = new LocalItemListAdapter(activity); + + final boolean useGrid = isGridLayout(); + itemsList = rootView.findViewById(R.id.items_list); + itemsList.setLayoutManager(useGrid ? getGridLayoutManager() : getListLayoutManager()); + + itemListAdapter.setGridItemVariants(useGrid); itemListAdapter.setHeader(headerRootView = getListHeader()); itemListAdapter.setFooter(footerRootView = getListFooter()); @@ -174,4 +218,22 @@ public abstract class BaseLocalListFragment extends BaseStateFragment resetFragment(); return super.onError(exception); } + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (key.equals(getString(R.string.list_view_mode_key))) { + updateFlags |= LIST_MODE_UPDATE_FLAG; + } + } + + protected boolean isGridLayout() { + final String list_mode = PreferenceManager.getDefaultSharedPreferences(activity).getString(getString(R.string.list_view_mode_key), getString(R.string.list_view_mode_value)); + if ("auto".equals(list_mode)) { + final Configuration configuration = getResources().getConfiguration(); + return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE + && configuration.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE); + } else { + return "grid".equals(list_mode); + } + } } diff --git a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java index 99937b58c..e298dedd3 100644 --- a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java @@ -1,18 +1,21 @@ package org.schabi.newpipe.local; import android.app.Activity; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.View; import android.view.ViewGroup; import org.schabi.newpipe.database.LocalItem; -import org.schabi.newpipe.local.HeaderFooterHolder; -import org.schabi.newpipe.local.LocalItemBuilder; import org.schabi.newpipe.local.holder.LocalItemHolder; +import org.schabi.newpipe.local.holder.LocalPlaylistGridItemHolder; import org.schabi.newpipe.local.holder.LocalPlaylistItemHolder; +import org.schabi.newpipe.local.holder.LocalPlaylistStreamGridItemHolder; import org.schabi.newpipe.local.holder.LocalPlaylistStreamItemHolder; +import org.schabi.newpipe.local.holder.LocalStatisticStreamGridItemHolder; import org.schabi.newpipe.local.holder.LocalStatisticStreamItemHolder; +import org.schabi.newpipe.local.holder.RemotePlaylistGridItemHolder; import org.schabi.newpipe.local.holder.RemotePlaylistItemHolder; import org.schabi.newpipe.util.FallbackViewHolder; import org.schabi.newpipe.util.Localization; @@ -52,14 +55,19 @@ public class LocalItemListAdapter extends RecyclerView.Adapter localItems; private final DateFormat dateFormat; private boolean showFooter = false; + private boolean useGridVariant = false; private View header = null; private View footer = null; @@ -134,6 +142,10 @@ public class LocalItemListAdapter extends RecyclerView.Adapter + + + + + + + + + + + + + \ No newline at end of file From b1a5547de2357046e5d605cfd52af11b63b4b81b Mon Sep 17 00:00:00 2001 From: u1 Date: Fri, 31 Aug 2018 16:34:35 +0300 Subject: [PATCH 19/40] Fix reordering playlist items on grid layout --- .../newpipe/local/playlist/LocalPlaylistFragment.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index 35a1530c9..f400061e1 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -459,7 +459,11 @@ public class LocalPlaylistFragment extends BaseLocalListFragment Date: Fri, 31 Aug 2018 16:49:25 +0300 Subject: [PATCH 20/40] Grid layout for subscriptions --- .../subscription/SubscriptionFragment.java | 59 ++++++++++++++++++- .../main/res/layout/fragment_subscription.xml | 1 - 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index d8a26f0eb..584acfaf8 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -5,11 +5,15 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; import android.os.Environment; import android.os.Parcelable; +import android.preference.PreferenceManager; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -17,6 +21,7 @@ import android.support.v4.app.FragmentManager; import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -72,7 +77,7 @@ import static org.schabi.newpipe.local.subscription.services.SubscriptionsImport import static org.schabi.newpipe.util.AnimationUtils.animateRotation; import static org.schabi.newpipe.util.AnimationUtils.animateView; -public class SubscriptionFragment extends BaseStateFragment> { +public class SubscriptionFragment extends BaseStateFragment> implements SharedPreferences.OnSharedPreferenceChangeListener { private static final int REQUEST_EXPORT_CODE = 666; private static final int REQUEST_IMPORT_CODE = 667; @@ -80,6 +85,9 @@ public class SubscriptionFragment extends BaseStateFragment From 1e53d6bfab9a2832e087029303c40b16ac0404f1 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 31 Aug 2018 17:08:13 +0300 Subject: [PATCH 21/40] Scroll top related streams when loading --- .../schabi/newpipe/fragments/detail/VideoDetailFragment.java | 5 +++++ 1 file changed, 5 insertions(+) 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 65a423084..7e0a013ca 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 @@ -1262,6 +1262,11 @@ public class VideoDetailFragment // Only auto play in the first open autoPlayEnabled = false; } + + final ViewParent related = relatedStreamRootLayout.getParent(); + if (related instanceof ScrollView) { + ((ScrollView) related).scrollTo(0, 0); + } } From d4c1b8d32139ca33fdefe4ad1ca0e155ca8c1a01 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 31 Aug 2018 17:12:56 +0300 Subject: [PATCH 22/40] Fix: remove title from PlaylistDialog --- .../newpipe/local/dialog/PlaylistDialog.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java index 4b8e391c7..15ba5d184 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java @@ -1,9 +1,11 @@ package org.schabi.newpipe.local.dialog; +import android.app.Dialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; +import android.view.Window; import org.schabi.newpipe.database.stream.model.StreamEntity; import org.schabi.newpipe.util.StateSaver; @@ -41,6 +43,18 @@ public abstract class PlaylistDialog extends DialogFragment implements StateSave StateSaver.onDestroy(savedState); } + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final Dialog dialog = super.onCreateDialog(savedInstanceState); + //remove title + final Window window = dialog.getWindow(); + if (window != null) { + window.requestFeature(Window.FEATURE_NO_TITLE); + } + return dialog; + } + /*////////////////////////////////////////////////////////////////////////// // State Saving //////////////////////////////////////////////////////////////////////////*/ From b24baa68ba36f8d54fe111e1efe7f3881c023e39 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 31 Aug 2018 17:30:06 +0300 Subject: [PATCH 23/40] Tablet UI in player --- .../activity_main_player.xml | 581 ++++++++++++++++++ 1 file changed, 581 insertions(+) create mode 100644 app/src/main/res/layout-large-land/activity_main_player.xml diff --git a/app/src/main/res/layout-large-land/activity_main_player.xml b/app/src/main/res/layout-large-land/activity_main_player.xml new file mode 100644 index 000000000..7d7e1230e --- /dev/null +++ b/app/src/main/res/layout-large-land/activity_main_player.xml @@ -0,0 +1,581 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 0cd153ab61ab546d67a92f486d0c57db1fb5fa0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Mon, 3 Sep 2018 13:07:10 +0200 Subject: [PATCH 24/40] Spelling: Language rework --- app/src/main/res/values/strings.xml | 130 ++++++++++++++-------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eaeeb2685..9edc14198 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,7 +5,7 @@ %1$s views Published on %1$s No stream player found. Do you want to install VLC? - No stream player found (you can install VLC to play it) + No stream player found (you can install VLC to play it). Install Cancel https://f-droid.org/repository/browse/?fdfilter=vlc&fdid=org.videolan.vlc @@ -13,23 +13,23 @@ Open in popup mode Share Download - Download stream file. + Download stream file Search Settings - Did you mean: %1$s ? + Did you mean: %1$s? Share with Choose browser rotation Use external video player - Some resolutions will NOT have audio when this option is enabled + Removes audio at SOME resolutions Use external audio player NewPipe popup mode RSS Subscribe Subscribed Channel unsubscribed - Unable to change subscription - Unable to update subscription + Could not change subscription + Could not update subscription Show info Main @@ -48,8 +48,8 @@ Path to store downloaded videos in Enter download path for videos - Audio download path - Path to store downloaded audio in + Audio download folder + Downloaded audio is stored here Enter download path for audio files Autoplay @@ -75,7 +75,7 @@ Use fast inexact seek Inexact seek allows the player to seek to positions faster with reduced precision Load thumbnails - Disable to stop all thumbnails from loading and save on data and memory usage. Changing this will clear both in-memory and on-disk image cache. + When off no thumbnails load, saving data and memory usage. Changes clear both in-memory and on-disk image cache. Image cache wiped Wipe cached metadata Remove all cached webpage data @@ -93,18 +93,18 @@ Resume on focus gain Continue playing after interruptions (e.g. phone calls) Download - Next video - Show \'next\' and \'similar\' videos - Show \"hold to append\" tip + Next + Show \'Next\' and \'Similar\' videos + Show \"Hold to append\" tip Show tip when background or popup button is pressed on video details page - URL not supported + Unsupported URL Default content country Service Default content language Player Behavior - Video & Audio - History & Cache + Video & audio + History & cache Popup Appearance Other @@ -116,8 +116,8 @@ https://www.c3s.cc/ Play Content - Show age restricted content - Age Restricted Video. Allowing such material is possible from Settings. + Age restricted content + Show age Restricted Video. Allowing such material is possible from \"Settings\". live LIVE Downloads @@ -147,7 +147,7 @@ newpipe NewPipe Notification - Notifications for NewPipe Background and Popup Players + Notifications for NewPipe background and popup players [Unknown] @@ -158,29 +158,29 @@ Import database Export database - Will override your current history and subscriptions - Export history, subscriptions and playlists. + Overrides your current history and subscriptions + Export history, subscriptions and playlists Clear watch history - Deletes the history of played streams. - Delete whole watch history. + Deletes the history of played streams + Delete entire watch history? Watch history deleted. Clear search history - Deletes history of search keywords. - Delete whole search history. + Deletes history of search keywords + Delete entire search history? Search history deleted. Error - External storage not available. - Download to external SD Card is not possible yet. Should the download place be reset? + External storage unavailable + Download to external SD card is not possible yet. Reset download folder location? Network error Could not load all thumbnails Could not decrypt video URL signature Could not parse website Could not parse website completely - Content not available + Content unavailable Blocked by GEMA Could not set up download menu - This is a LIVE STREAM, which is not yet supported. + Live streams are not supported yet Could not get any stream Could not load image App/UI crashed @@ -191,10 +191,10 @@ Invalid URL No video streams found No audio streams found - Invalid directory - Invalid file/content source - File doesn\'t exist or insufficient permission to read or write to it - File name cannot be empty + No such folder + No such file/content source + The file doesn\'t exist or permission to read or write to it is lacking + Filename cannot be empty An error occurred: %1$s No streams available to download @@ -223,7 +223,7 @@ User report No results @string/no_videos - Nothing Here But Crickets + Nothing here but crickets Drag to reorder Cannot create download directory \'%1$s\' @@ -279,7 +279,7 @@ Filename Threads Error - Server unsupported + Unsupported server File already exists Malformed URL or Internet not available NewPipe Downloading @@ -294,8 +294,8 @@ MD5 SHA-1 reCAPTCHA - reCAPTCHA Challenge - reCAPTCHA Challenge requested + reCAPTCHA challenge + reCAPTCHA challenge requested @@ -340,7 +340,7 @@ https://newpipe.schabi.org/legal/privacy/ Read privacy policy NewPipe\'s License - NewPipe is copyleft libre software: You can use, study share and improve it at your will. Specifically you can redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + NewPipe is copyleft libre software: You can use, study share and improve it at will. Specifically you can redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Read license @@ -348,7 +348,7 @@ History Searched Watched - History is disabled + History is turned off History The history is empty History cleared @@ -364,11 +364,11 @@ What tabs are shown on the main page Selection Your tabs - Blank Page - Kiosk Page - Subscription Page - Feed Page - Channel Page + Nothing + Kiosk + Subscriptions + Feed + Channel @string/blank_page_summary @string/kiosk_page_summary @@ -377,10 +377,10 @@ @string/channel_page_summary Select a channel - No channel subscribed yet + No channel subscriptions yet Select a kiosk - Export complete - Import complete + Exported + Imported No valid ZIP file Warning: Could not import all files. This will override your current setup. @@ -394,17 +394,17 @@ %1$s/%2$s - Background Player - Popup Player + Background player + Popup player Remove Details Audio Settings - Hold To Enqueue - Enqueue on Background - Enqueue on Popup - Start Playing Here - Start Here on Background - Start Here on Popup + Hold To enqueue + Enqueue when backgrounded + Enqueue on new popup + Start playing here + Start here when backgrounded + Start here on new popup Open Drawer @@ -428,9 +428,9 @@ "Loading requested content" - Create New Playlist - Delete Playlist - Rename Playlist + New Playlist + Delete + Rename Name Add To Playlist Set as Playlist Thumbnail @@ -438,11 +438,11 @@ Bookmark Playlist Remove Bookmark - Do you want to delete this playlist? + Delete this playlist? Playlist created - Added to playlist - Playlist thumbnail changed - Could not delete playlist + Playlisted + Playlist thumbnail changed. + Could not delete playlist. No Captions @@ -461,11 +461,11 @@ Enable LeakCanary Memory leak monitoring may cause the app to become unresponsive when heap dumping - Report Out-of-lifecycle Errors + Report out-of-lifecycle errors Force reporting of undeliverable Rx exceptions outside of fragment or activity lifecycle after disposal - Import/Export + Import/export Import Import from Export to @@ -516,8 +516,8 @@ - Minimize on application switch - Action when switching to other application from main video player — %s + Minimize on app switch + Action when switching to other app from main video player — %s None Minimize to background player Minimize to popup player From 27fbe690333f460f44841559c5b2d8926085ca50 Mon Sep 17 00:00:00 2001 From: BO41 Date: Tue, 28 Aug 2018 19:17:14 +0200 Subject: [PATCH 25/40] code cleanup mainly removes throw statements automated using Android Studio, staged by hand BUILD SUCCESSFUL in 52s 39 actionable tasks: 37 executed, 2 up-to-date --- app/src/main/java/org/schabi/newpipe/App.java | 2 +- .../newpipe/local/dialog/PlaylistDialog.java | 2 +- .../subscription/SubscriptionService.java | 2 +- .../mediasession/PlayQueueNavigator.java | 2 +- .../player/playback/CustomTrackSelector.java | 2 +- .../playqueue/AbstractInfoPlayQueue.java | 2 +- .../newpipe/report/AcraReportSender.java | 2 +- .../settings/SelectChannelFragment.java | 2 +- .../newpipe/settings/SelectKioskFragment.java | 2 +- .../schabi/newpipe/util/ExtractorHelper.java | 2 +- .../services/ImportExportJsonHelperTest.java | 2 +- .../newpipe/report/ErrorActivityTest.java | 2 +- .../schabi/newpipe/util/ListHelperTest.java | 20 +++++++++---------- .../util/QuadraticSliderStrategyTest.java | 18 ++++++++--------- .../giga/get/DownloadManagerImplTest.java | 12 +++++------ 15 files changed, 37 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index f436a26b8..dfce8f100 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -106,7 +106,7 @@ public class App extends Application { // https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling RxJavaPlugins.setErrorHandler(new Consumer() { @Override - public void accept(@NonNull Throwable throwable) throws Exception { + public void accept(@NonNull Throwable throwable) { Log.e(TAG, "RxJavaPlugins.ErrorHandler called with -> : " + "throwable = [" + throwable.getClass().getName() + "]"); diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java index 4b8e391c7..96d628683 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java @@ -58,7 +58,7 @@ public abstract class PlaylistDialog extends DialogFragment implements StateSave @Override @SuppressWarnings("unchecked") - public void readFrom(@NonNull Queue savedObjects) throws Exception { + public void readFrom(@NonNull Queue savedObjects) { streamEntities = (List) savedObjects.poll(); } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionService.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionService.java index fc4230711..b4545a2dd 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionService.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionService.java @@ -116,7 +116,7 @@ public class SubscriptionService { public Completable updateChannelInfo(final ChannelInfo info) { final Function, CompletableSource> update = new Function, CompletableSource>() { @Override - public CompletableSource apply(@NonNull List subscriptionEntities) throws Exception { + public CompletableSource apply(@NonNull List subscriptionEntities) { if (DEBUG) Log.d(TAG, "updateChannelInfo() called with: subscriptionEntities = [" + subscriptionEntities + "]"); if (subscriptionEntities.size() == 1) { SubscriptionEntity subscription = subscriptionEntities.get(0); diff --git a/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java b/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java index 429c26fd9..3d1fd171f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java +++ b/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java @@ -79,7 +79,7 @@ public class PlayQueueNavigator implements MediaSessionConnector.QueueNavigator private void publishFloatingQueueWindow() { if (callback.getQueueSize() == 0) { - mediaSession.setQueue(Collections.emptyList()); + mediaSession.setQueue(Collections.emptyList()); activeQueueItemId = MediaSessionCompat.QueueItem.UNKNOWN_ID; return; } diff --git a/app/src/main/java/org/schabi/newpipe/player/playback/CustomTrackSelector.java b/app/src/main/java/org/schabi/newpipe/player/playback/CustomTrackSelector.java index d80ea5bae..45cf545ce 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playback/CustomTrackSelector.java +++ b/app/src/main/java/org/schabi/newpipe/player/playback/CustomTrackSelector.java @@ -55,7 +55,7 @@ public class CustomTrackSelector extends DefaultTrackSelector { /** @see DefaultTrackSelector#selectTextTrack(TrackGroupArray, int[][], Parameters) */ @Override protected TrackSelection selectTextTrack(TrackGroupArray groups, int[][] formatSupport, - Parameters params) throws ExoPlaybackException { + Parameters params) { TrackGroup selectedGroup = null; int selectedTrackIndex = 0; int selectedTrackScore = 0; diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java index 2c08f4f92..5ff766313 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java @@ -26,7 +26,7 @@ abstract class AbstractInfoPlayQueue ext transient Disposable fetchReactor; AbstractInfoPlayQueue(final U item) { - this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0); + this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0); } AbstractInfoPlayQueue(final int serviceId, diff --git a/app/src/main/java/org/schabi/newpipe/report/AcraReportSender.java b/app/src/main/java/org/schabi/newpipe/report/AcraReportSender.java index 2d3226ab6..4ef075353 100644 --- a/app/src/main/java/org/schabi/newpipe/report/AcraReportSender.java +++ b/app/src/main/java/org/schabi/newpipe/report/AcraReportSender.java @@ -31,7 +31,7 @@ import org.schabi.newpipe.R; public class AcraReportSender implements ReportSender { @Override - public void send(@NonNull Context context, @NonNull CrashReportData report) throws ReportSenderException { + public void send(@NonNull Context context, @NonNull CrashReportData report) { ErrorActivity.reportError(context, report, ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,"none", "App crash, UI failure", R.string.app_ui_crash)); diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java index 0ebdbefe0..6d85d5967 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java @@ -89,7 +89,7 @@ public class SelectChannelFragment extends DialogFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.select_channel_fragment, container, false); - recyclerView = (RecyclerView) v.findViewById(R.id.items_list); + recyclerView = v.findViewById(R.id.items_list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); channelAdapter = new SelectChannelAdapter(); recyclerView.setAdapter(channelAdapter); diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java index 44cb16682..16ba6fec6 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java @@ -75,7 +75,7 @@ public class SelectKioskFragment extends DialogFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.select_kiosk_fragment, container, false); - recyclerView = (RecyclerView) v.findViewById(R.id.items_list); + recyclerView = v.findViewById(R.id.items_list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); try { selectKioskAdapter = new SelectKioskAdapter(); 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 e445233c3..fb9579802 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -183,7 +183,7 @@ public final class ExtractorHelper { cache.removeInfo(serviceId, url); load = loadFromNetwork; } else { - load = Maybe.concat(ExtractorHelper.loadFromCache(serviceId, url), + load = Maybe.concat(ExtractorHelper.loadFromCache(serviceId, url), loadFromNetwork.toMaybe()) .firstElement() //Take the first valid .toSingle(); diff --git a/app/src/test/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelperTest.java b/app/src/test/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelperTest.java index 4a8b3d8c8..7f5f818be 100644 --- a/app/src/test/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelperTest.java +++ b/app/src/test/java/org/schabi/newpipe/local/subscription/services/ImportExportJsonHelperTest.java @@ -27,7 +27,7 @@ public class ImportExportJsonHelperTest { } @Test - public void testInvalidSource() throws Exception { + public void testInvalidSource() { List invalidList = Arrays.asList( "{}", "", diff --git a/app/src/test/java/org/schabi/newpipe/report/ErrorActivityTest.java b/app/src/test/java/org/schabi/newpipe/report/ErrorActivityTest.java index 44a2f7cd0..ca6c76ff3 100644 --- a/app/src/test/java/org/schabi/newpipe/report/ErrorActivityTest.java +++ b/app/src/test/java/org/schabi/newpipe/report/ErrorActivityTest.java @@ -15,7 +15,7 @@ import static org.junit.Assert.assertNull; */ public class ErrorActivityTest { @Test - public void getReturnActivity() throws Exception { + public void getReturnActivity() { Class returnActivity; returnActivity = ErrorActivity.getReturnActivity(MainActivity.class); assertEquals(MainActivity.class, returnActivity); diff --git a/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java b/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java index 278ea81e1..abc09dc98 100644 --- a/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java +++ b/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java @@ -45,7 +45,7 @@ public class ListHelperTest { new VideoStream("", MediaFormat.MPEG_4, /**/ "1080p60", true)); @Test - public void getSortedStreamVideosListTest() throws Exception { + public void getSortedStreamVideosListTest() { List result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4, true, videoStreamsTestList, videoOnlyStreamsTestList, true); List expected = Arrays.asList("144p", "240p", "360p", "480p", "720p", "720p60", "1080p", "1080p60", "1440p60", "2160p", "2160p60"); @@ -67,7 +67,7 @@ public class ListHelperTest { } @Test - public void getSortedStreamVideosExceptHighResolutionsTest() throws Exception { + public void getSortedStreamVideosExceptHighResolutionsTest() { //////////////////////////////////// // Don't show Higher resolutions // ////////////////////////////////// @@ -79,7 +79,7 @@ public class ListHelperTest { } @Test - public void getDefaultResolutionTest() throws Exception { + public void getDefaultResolutionTest() { List testList = Arrays.asList( new VideoStream("", MediaFormat.MPEG_4, /**/ "720p"), new VideoStream("", MediaFormat.v3GPP, /**/ "240p"), @@ -130,7 +130,7 @@ public class ListHelperTest { } @Test - public void getHighestQualityAudioFormatTest() throws Exception { + public void getHighestQualityAudioFormatTest() { AudioStream stream = audioStreamsTestList.get(ListHelper.getHighestQualityAudioIndex(MediaFormat.M4A, audioStreamsTestList)); assertEquals(320, stream.average_bitrate); assertEquals(MediaFormat.M4A, stream.getFormat()); @@ -145,7 +145,7 @@ public class ListHelperTest { } @Test - public void getHighestQualityAudioFormatPreferredAbsent() throws Exception { + public void getHighestQualityAudioFormatPreferredAbsent() { ////////////////////////////////////////// // Doesn't contain the preferred format // @@ -186,13 +186,13 @@ public class ListHelperTest { } @Test - public void getHighestQualityAudioNull() throws Exception { + public void getHighestQualityAudioNull() { assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, null)); assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, new ArrayList())); } @Test - public void getLowestQualityAudioFormatTest() throws Exception { + public void getLowestQualityAudioFormatTest() { AudioStream stream = audioStreamsTestList.get(ListHelper.getMostCompactAudioIndex(MediaFormat.M4A, audioStreamsTestList)); assertEquals(128, stream.average_bitrate); assertEquals(MediaFormat.M4A, stream.getFormat()); @@ -207,7 +207,7 @@ public class ListHelperTest { } @Test - public void getLowestQualityAudioFormatPreferredAbsent() throws Exception { + public void getLowestQualityAudioFormatPreferredAbsent() { ////////////////////////////////////////// // Doesn't contain the preferred format // @@ -250,13 +250,13 @@ public class ListHelperTest { } @Test - public void getLowestQualityAudioNull() throws Exception { + public void getLowestQualityAudioNull() { assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, null)); assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, new ArrayList())); } @Test - public void getVideoDefaultStreamIndexCombinations() throws Exception { + public void getVideoDefaultStreamIndexCombinations() { List testList = Arrays.asList( new VideoStream("", MediaFormat.MPEG_4, /**/ "1080p"), new VideoStream("", MediaFormat.MPEG_4, /**/ "720p60"), diff --git a/app/src/test/java/org/schabi/newpipe/util/QuadraticSliderStrategyTest.java b/app/src/test/java/org/schabi/newpipe/util/QuadraticSliderStrategyTest.java index 8c8d52043..c652472d1 100644 --- a/app/src/test/java/org/schabi/newpipe/util/QuadraticSliderStrategyTest.java +++ b/app/src/test/java/org/schabi/newpipe/util/QuadraticSliderStrategyTest.java @@ -11,25 +11,25 @@ public class QuadraticSliderStrategyTest { private final SliderStrategy.Quadratic standard = new SliderStrategy.Quadratic(0f, 100f, 50f, STEP); @Test - public void testLeftBound() throws Exception { + public void testLeftBound() { assertEquals(standard.progressOf(0), 0); assertEquals(standard.valueOf(0), 0f, DELTA); } @Test - public void testCenter() throws Exception { + public void testCenter() { assertEquals(standard.progressOf(50), 50); assertEquals(standard.valueOf(50), 50f, DELTA); } @Test - public void testRightBound() throws Exception { + public void testRightBound() { assertEquals(standard.progressOf(100), 100); assertEquals(standard.valueOf(100), 100f, DELTA); } @Test - public void testLeftRegion() throws Exception { + public void testLeftRegion() { final int leftProgress = standard.progressOf(25); final double leftValue = standard.valueOf(25); assertTrue(leftProgress > 0 && leftProgress < 50); @@ -37,7 +37,7 @@ public class QuadraticSliderStrategyTest { } @Test - public void testRightRegion() throws Exception { + public void testRightRegion() { final int leftProgress = standard.progressOf(75); final double leftValue = standard.valueOf(75); assertTrue(leftProgress > 50 && leftProgress < 100); @@ -45,7 +45,7 @@ public class QuadraticSliderStrategyTest { } @Test - public void testConversion() throws Exception { + public void testConversion() { assertEquals(standard.progressOf(standard.valueOf(0)), 0); assertEquals(standard.progressOf(standard.valueOf(25)), 25); assertEquals(standard.progressOf(standard.valueOf(50)), 50); @@ -54,7 +54,7 @@ public class QuadraticSliderStrategyTest { } @Test - public void testReverseConversion() throws Exception { + public void testReverseConversion() { // Need a larger delta since step size / granularity is too small and causes // floating point round-off errors during conversion final float largeDelta = 1f; @@ -67,7 +67,7 @@ public class QuadraticSliderStrategyTest { } @Test - public void testQuadraticPropertyLeftRegion() throws Exception { + public void testQuadraticPropertyLeftRegion() { final double differenceCloserToCenter = Math.abs(standard.valueOf(40) - standard.valueOf(45)); final double differenceFurtherFromCenter = @@ -76,7 +76,7 @@ public class QuadraticSliderStrategyTest { } @Test - public void testQuadraticPropertyRightRegion() throws Exception { + public void testQuadraticPropertyRightRegion() { final double differenceCloserToCenter = Math.abs(standard.valueOf(75) - standard.valueOf(70)); final double differenceFurtherFromCenter = diff --git a/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java b/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java index 6ff702273..49bfd4840 100644 --- a/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java +++ b/app/src/test/java/us/shandian/giga/get/DownloadManagerImplTest.java @@ -110,7 +110,7 @@ public class DownloadManagerImplTest { } @Test - public void resumeMission() throws Exception { + public void resumeMission() { DownloadMission mission = missions.get(0); mission.running = true; verify(mission, never()).start(); @@ -122,7 +122,7 @@ public class DownloadManagerImplTest { } @Test - public void pauseMission() throws Exception { + public void pauseMission() { DownloadMission mission = missions.get(0); mission.running = false; downloadManager.pauseMission(0); @@ -133,7 +133,7 @@ public class DownloadManagerImplTest { } @Test - public void deleteMission() throws Exception { + public void deleteMission() { DownloadMission mission = missions.get(0); assertEquals(mission, downloadManager.getMission(0)); downloadManager.deleteMission(0); @@ -143,18 +143,18 @@ public class DownloadManagerImplTest { } @Test(expected = RuntimeException.class) - public void getMissionWithNegativeIndex() throws Exception { + public void getMissionWithNegativeIndex() { downloadManager.getMission(-1); } @Test - public void getMission() throws Exception { + public void getMission() { assertSame(missions.get(0), downloadManager.getMission(0)); assertSame(missions.get(1), downloadManager.getMission(1)); } @Test - public void sortByTimestamp() throws Exception { + public void sortByTimestamp() { ArrayList downloadMissions = new ArrayList<>(); DownloadMission mission = new DownloadMission(); mission.timestamp = 0; From 5660b5ddc6d90299710896a796570d58c563517a Mon Sep 17 00:00:00 2001 From: BO41 Date: Tue, 28 Aug 2018 19:25:56 +0200 Subject: [PATCH 26/40] accessibility image without contentDescription Keyboard inaccessible widget BUILD SUCCESSFUL in 6s 39 actionable tasks: 4 executed, 35 up-to-date --- app/src/main/res/layout-v21/drawer_header.xml | 9 ++++++--- app/src/main/res/layout/drawer_header.xml | 9 ++++++--- app/src/main/res/layout/fragment_about.xml | 3 ++- app/src/main/res/layout/item_search_history.xml | 3 ++- app/src/main/res/layout/item_software_component.xml | 3 ++- app/src/main/res/layout/mission_item.xml | 6 ++++-- app/src/main/res/layout/mission_item_linear.xml | 6 ++++-- app/src/main/res/layout/select_channel_item.xml | 3 ++- app/src/main/res/layout/select_kiosk_item.xml | 6 ++++-- 9 files changed, 32 insertions(+), 16 deletions(-) diff --git a/app/src/main/res/layout-v21/drawer_header.xml b/app/src/main/res/layout-v21/drawer_header.xml index 4cdc2b30e..9336c8d9c 100644 --- a/app/src/main/res/layout-v21/drawer_header.xml +++ b/app/src/main/res/layout-v21/drawer_header.xml @@ -16,7 +16,8 @@ android:layout_height="match_parent" android:background="?attr/colorPrimary" android:scaleType="centerCrop" - android:src="@drawable/background_header" /> + android:src="@drawable/background_header" + android:contentDescription="TODO" /> + android:src="@drawable/np_logo_nude_shadow" + android:contentDescription="TODO" /> + android:src="@drawable/ic_arrow_down_white" + android:contentDescription="TODO" /> \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml index c119c302a..833abe1c6 100644 --- a/app/src/main/res/layout/drawer_header.xml +++ b/app/src/main/res/layout/drawer_header.xml @@ -16,7 +16,8 @@ android:focusable="true"> android:layout_height="match_parent" android:background="?attr/colorPrimary" android:src="@drawable/background_header" - android:scaleType="centerCrop"/> + android:scaleType="centerCrop" + android:contentDescription="TODO" /> android:layout_width="70dp" android:layout_height="70dp" - android:src="@drawable/np_logo_nude_shadow"/> + android:src="@drawable/np_logo_nude_shadow" + android:contentDescription="TODO" /> android:paddingBottom="20dp" android:paddingRight="20dp" android:src="@drawable/ic_arrow_down_white" - android:paddingEnd="20dp" /> + android:paddingEnd="20dp" + android:contentDescription="TODO" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 320f72ab9..e8537cad3 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -21,7 +21,8 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginBottom="8dp" - app:srcCompat="@mipmap/ic_launcher" /> + app:srcCompat="@mipmap/ic_launcher" + android:contentDescription="TODO" /> + android:paddingTop="8dp" + android:focusable="true"> + android:clickable="true" + android:focusable="true"> + android:scaleType="centerInside" + android:contentDescription="TODO" /> @@ -50,7 +51,8 @@ android:layout_centerHorizontal="true" android:scaleType="fitXY" android:gravity="center" - android:padding="10dp"/> + android:padding="10dp" + android:contentDescription="TODO" /> + android:padding="15dp" + android:contentDescription="TODO" /> + android:scaleType="centerInside" + android:contentDescription="TODO" /> diff --git a/app/src/main/res/layout/select_channel_item.xml b/app/src/main/res/layout/select_channel_item.xml index 09602a371..5d00c1b01 100644 --- a/app/src/main/res/layout/select_channel_item.xml +++ b/app/src/main/res/layout/select_channel_item.xml @@ -6,7 +6,8 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:clickable="true" - android:padding="5dp"> + android:padding="5dp" + android:focusable="true"> + android:padding="5dp" + android:focusable="true"> + tools:ignore="RtlHardcoded" + android:contentDescription="TODO" /> Date: Tue, 28 Aug 2018 19:30:44 +0200 Subject: [PATCH 27/40] correctness use apply() on SharedPreferences use dp instead of sp for text sizes BUILD SUCCESSFUL in 22s 39 actionable tasks: 10 executed, 29 up-to-date --- .../org/schabi/newpipe/settings/ContentSettingsFragment.java | 2 +- app/src/main/res/layout-v21/drawer_header.xml | 4 ++-- app/src/main/res/layout/drawer_header.xml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 0ca78b34a..ca48ed8b5 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -264,7 +264,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { else if (v instanceof String) prefEdit.putString(key, ((String) v)); } - prefEdit.commit(); + prefEdit.apply(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { diff --git a/app/src/main/res/layout-v21/drawer_header.xml b/app/src/main/res/layout-v21/drawer_header.xml index 9336c8d9c..4474ee4ed 100644 --- a/app/src/main/res/layout-v21/drawer_header.xml +++ b/app/src/main/res/layout-v21/drawer_header.xml @@ -40,7 +40,7 @@ android:layout_toRightOf="@id/drawer_header_np_nude_view" android:gravity="center" android:text="@string/app_name" - android:textSize="30dp" + android:textSize="30sp" android:textColor="@color/drawer_header_font_color" android:textStyle="bold|italic" /> @@ -52,7 +52,7 @@ android:layout_alignStart="@id/drawer_header_np_text_view" android:layout_below="@id/drawer_header_np_text_view" android:text="YouTube" - android:textSize="18dp" + android:textSize="18sp" android:textColor="@color/drawer_header_font_color" android:textStyle="italic" /> diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml index 833abe1c6..0458773d7 100644 --- a/app/src/main/res/layout/drawer_header.xml +++ b/app/src/main/res/layout/drawer_header.xml @@ -40,7 +40,7 @@ android:focusable="true"> android:layout_alignTop="@id/drawer_header_np_nude_view" android:layout_alignBottom="@id/drawer_header_np_nude_view" android:gravity="center" - android:textSize="30dp" + android:textSize="30sp" android:textColor="@color/drawer_header_font_color" android:textStyle="bold|italic"/> @@ -52,7 +52,7 @@ android:focusable="true"> 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:textSize="18dp" + android:textSize="18sp" android:textColor="@color/drawer_header_font_color" android:textStyle="italic"/> From 5db0cc524174dfda56d19cc7e1bd61d91fa8ec06 Mon Sep 17 00:00:00 2001 From: BO41 Date: Tue, 28 Aug 2018 19:40:05 +0200 Subject: [PATCH 28/40] performance + usability obsolete layout params Ellipsis string can be replaced with ellipsis character Missing inputType Usage of showAsAction=always BUILD SUCCESSFUL in 5s 39 actionable tasks: 4 executed, 35 up-to-date --- app/src/main/res/layout/activity_error.xml | 3 ++- app/src/main/res/layout/mission_item_linear.xml | 3 +-- app/src/main/res/menu/menu_videooptions.xml | 6 +++--- app/src/main/res/values-hu/strings.xml | 2 +- app/src/main/res/values-ko/strings.xml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/res/layout/activity_error.xml b/app/src/main/res/layout/activity_error.xml index 7752dc7cb..c47077c73 100644 --- a/app/src/main/res/layout/activity_error.xml +++ b/app/src/main/res/layout/activity_error.xml @@ -114,7 +114,8 @@ + android:layout_height="wrap_content" + android:inputType="" />