From 273390ee001f4db10b52daf5b8ff009fb3f01a41 Mon Sep 17 00:00:00 2001 From: friendlyanon <1736896+friendlyanon@users.noreply.github.com> Date: Sat, 6 Jun 2020 22:26:11 +0200 Subject: [PATCH] Merge from upstream and apply legacy patches --- app/build.gradle | 6 ++--- .../CheckForNewAppVersionTask.java | 3 ++- .../schabi/newpipelegacy/MainActivity.java | 3 ++- .../newpipelegacy/about/AboutActivity.java | 4 +-- .../database/playlist/PlaylistStreamEntry.kt | 2 +- .../database/stream/StreamStatisticsEntry.kt | 2 +- .../database/stream/dao/StreamDAO.kt | 6 ++--- .../database/stream/model/StreamEntity.kt | 6 ++--- .../fragments/list/BaseListInfoFragment.java | 3 ++- .../local/feed/FeedDatabaseManager.kt | 4 +-- .../newpipelegacy/local/feed/FeedViewModel.kt | 2 +- .../local/feed/service/FeedLoadService.kt | 6 ++--- .../subscription/SubscriptionFragment.kt | 2 +- .../local/subscription/SubscriptionManager.kt | 6 ++--- .../local/subscription/item/ChannelItem.kt | 2 +- .../subscription/item/FeedImportExportItem.kt | 2 +- .../settings/DownloadSettingsFragment.java | 1 - .../streams/SrtFromTtmlWriter.java | 3 +-- .../newpipelegacy/streams/WebMReader.java | 4 +-- .../newpipelegacy/streams/WebMWriter.java | 3 ++- checkstyle-suppressions.xml | 27 ++++++++++++++++++- 21 files changed, 62 insertions(+), 35 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 528fc377f..66a758b82 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,9 +9,9 @@ android { buildToolsVersion '29.0.3' defaultConfig { - applicationId "org.schabi.newpipe" - resValue "string", "app_name", "NewPipe" - minSdkVersion 19 + applicationId 'org.schabi.newpipelegacy' + resValue "string", "app_name", "NewPipe Legacy" + minSdkVersion 16 targetSdkVersion 29 versionCode 80 versionName "0.19.5" diff --git a/app/src/main/java/org/schabi/newpipelegacy/CheckForNewAppVersionTask.java b/app/src/main/java/org/schabi/newpipelegacy/CheckForNewAppVersionTask.java index 3d8524ccb..6ec46c87c 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/CheckForNewAppVersionTask.java +++ b/app/src/main/java/org/schabi/newpipelegacy/CheckForNewAppVersionTask.java @@ -48,6 +48,7 @@ public class CheckForNewAppVersionTask extends AsyncTask { private static final String GITHUB_APK_SHA1 = "C7:A4:55:67:6C:34:97:42:10:CE:3B:02:8F:D4:11:E5:10:FB:01:17"; private static final String NEWPIPE_API_URL = "https://newpipe.schabi.org/api/data.json"; + private static final String FLAVOR = "github_legacy"; /** * Method to get the apk's SHA1 key. See https://stackoverflow.com/questions/9293019/#22506133. @@ -159,7 +160,7 @@ protected void onPostExecute(final String response) { try { final JsonObject githubStableObject = JsonParser.object().from(response) - .getObject("flavors").getObject("github").getObject("stable"); + .getObject("flavors").getObject(FLAVOR).getObject("stable"); final String versionName = githubStableObject.getString("version"); final int versionCode = githubStableObject.getInt("version_code"); diff --git a/app/src/main/java/org/schabi/newpipelegacy/MainActivity.java b/app/src/main/java/org/schabi/newpipelegacy/MainActivity.java index 7f6abe742..e3c91cbab 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipelegacy/MainActivity.java @@ -117,7 +117,8 @@ protected void onCreate(final Bundle savedInstanceState) { + "savedInstanceState = [" + savedInstanceState + "]"); } - // enable TLS1.1/1.2 for jelly bean and kitkat devices, to fix download and play for mediaCCC sources + // enable TLS1.1/1.2 for jelly bean and kitkat devices, to fix download and play for + // mediaCCC sources if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { TLSSocketFactoryCompat.setAsDefault(); } diff --git a/app/src/main/java/org/schabi/newpipelegacy/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipelegacy/about/AboutActivity.java index 38110a827..0fe60c53c 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipelegacy/about/AboutActivity.java @@ -23,8 +23,8 @@ import org.schabi.newpipelegacy.R; import org.schabi.newpipelegacy.util.ThemeHelper; -import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; -import static org.schabi.newpipe.util.ShareUtils.openUrlInBrowser; +import static org.schabi.newpipelegacy.util.Localization.assureCorrectAppLanguage; +import static org.schabi.newpipelegacy.util.ShareUtils.openUrlInBrowser; public class AboutActivity extends AppCompatActivity { /** diff --git a/app/src/main/java/org/schabi/newpipelegacy/database/playlist/PlaylistStreamEntry.kt b/app/src/main/java/org/schabi/newpipelegacy/database/playlist/PlaylistStreamEntry.kt index 0c2eee205..506012cfe 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/database/playlist/PlaylistStreamEntry.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/database/playlist/PlaylistStreamEntry.kt @@ -2,10 +2,10 @@ package org.schabi.newpipelegacy.database.playlist import androidx.room.ColumnInfo import androidx.room.Embedded +import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipelegacy.database.LocalItem import org.schabi.newpipelegacy.database.playlist.model.PlaylistStreamEntity import org.schabi.newpipelegacy.database.stream.model.StreamEntity -import org.schabi.newpipe.extractor.stream.StreamInfoItem class PlaylistStreamEntry( @Embedded diff --git a/app/src/main/java/org/schabi/newpipelegacy/database/stream/StreamStatisticsEntry.kt b/app/src/main/java/org/schabi/newpipelegacy/database/stream/StreamStatisticsEntry.kt index 8ba90c0e4..4c5427b68 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/database/stream/StreamStatisticsEntry.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/database/stream/StreamStatisticsEntry.kt @@ -3,10 +3,10 @@ package org.schabi.newpipelegacy.database.stream import androidx.room.ColumnInfo import androidx.room.Embedded import java.util.Date +import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipelegacy.database.LocalItem import org.schabi.newpipelegacy.database.history.model.StreamHistoryEntity import org.schabi.newpipelegacy.database.stream.model.StreamEntity -import org.schabi.newpipe.extractor.stream.StreamInfoItem class StreamStatisticsEntry( @Embedded diff --git a/app/src/main/java/org/schabi/newpipelegacy/database/stream/dao/StreamDAO.kt b/app/src/main/java/org/schabi/newpipelegacy/database/stream/dao/StreamDAO.kt index 3fdf1044f..9224cd548 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/database/stream/dao/StreamDAO.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/database/stream/dao/StreamDAO.kt @@ -8,12 +8,12 @@ import androidx.room.Query import androidx.room.Transaction import io.reactivex.Flowable import java.util.Date -import org.schabi.newpipelegacy.database.BasicDAO -import org.schabi.newpipelegacy.database.stream.model.StreamEntity -import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_ID import org.schabi.newpipe.extractor.stream.StreamType import org.schabi.newpipe.extractor.stream.StreamType.AUDIO_LIVE_STREAM import org.schabi.newpipe.extractor.stream.StreamType.LIVE_STREAM +import org.schabi.newpipelegacy.database.BasicDAO +import org.schabi.newpipelegacy.database.stream.model.StreamEntity +import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_ID @Dao abstract class StreamDAO : BasicDAO { diff --git a/app/src/main/java/org/schabi/newpipelegacy/database/stream/model/StreamEntity.kt b/app/src/main/java/org/schabi/newpipelegacy/database/stream/model/StreamEntity.kt index 0fbd6ef4d..62c4f5659 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/database/stream/model/StreamEntity.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/database/stream/model/StreamEntity.kt @@ -8,13 +8,13 @@ import androidx.room.PrimaryKey import java.io.Serializable import java.util.Calendar import java.util.Date -import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_SERVICE_ID -import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_TABLE -import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_URL import org.schabi.newpipe.extractor.localization.DateWrapper import org.schabi.newpipe.extractor.stream.StreamInfo import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.extractor.stream.StreamType +import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_SERVICE_ID +import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_TABLE +import org.schabi.newpipelegacy.database.stream.model.StreamEntity.Companion.STREAM_URL import org.schabi.newpipelegacy.player.playqueue.PlayQueueItem @Entity(tableName = STREAM_TABLE, diff --git a/app/src/main/java/org/schabi/newpipelegacy/fragments/list/BaseListInfoFragment.java b/app/src/main/java/org/schabi/newpipelegacy/fragments/list/BaseListInfoFragment.java index c2b436e38..6241858c3 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/fragments/list/BaseListInfoFragment.java +++ b/app/src/main/java/org/schabi/newpipelegacy/fragments/list/BaseListInfoFragment.java @@ -106,7 +106,8 @@ protected void doInitialLoadLogic() { /** * Implement the logic to load the info from the network.
- * You can use the default implementations from {@link org.schabi.newpipelegacy.util.ExtractorHelper}. + * You can use the default implementations from + * {@link org.schabi.newpipelegacy.util.ExtractorHelper}. * * @param forceLoad allow or disallow the result to come from the cache * @return Rx {@link Single} containing the {@link ListInfo} diff --git a/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedDatabaseManager.kt b/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedDatabaseManager.kt index a15f65617..7d41a4134 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedDatabaseManager.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedDatabaseManager.kt @@ -9,14 +9,14 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import java.util.Calendar import java.util.Date +import org.schabi.newpipe.extractor.stream.StreamInfoItem +import org.schabi.newpipe.extractor.stream.StreamType import org.schabi.newpipelegacy.MainActivity.DEBUG import org.schabi.newpipelegacy.NewPipeDatabase import org.schabi.newpipelegacy.database.feed.model.FeedEntity import org.schabi.newpipelegacy.database.feed.model.FeedGroupEntity import org.schabi.newpipelegacy.database.feed.model.FeedLastUpdatedEntity import org.schabi.newpipelegacy.database.stream.model.StreamEntity -import org.schabi.newpipe.extractor.stream.StreamInfoItem -import org.schabi.newpipe.extractor.stream.StreamType import org.schabi.newpipelegacy.local.subscription.FeedGroupIcon class FeedDatabaseManager(context: Context) { diff --git a/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedViewModel.kt b/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedViewModel.kt index 3517e0638..79736c5ec 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedViewModel.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/local/feed/FeedViewModel.kt @@ -12,8 +12,8 @@ import io.reactivex.schedulers.Schedulers import java.util.Calendar import java.util.Date import java.util.concurrent.TimeUnit -import org.schabi.newpipelegacy.database.feed.model.FeedGroupEntity import org.schabi.newpipe.extractor.stream.StreamInfoItem +import org.schabi.newpipelegacy.database.feed.model.FeedGroupEntity import org.schabi.newpipelegacy.local.feed.service.FeedEventManager import org.schabi.newpipelegacy.local.feed.service.FeedEventManager.Event.ErrorResultEvent import org.schabi.newpipelegacy.local.feed.service.FeedEventManager.Event.IdleEvent diff --git a/app/src/main/java/org/schabi/newpipelegacy/local/feed/service/FeedLoadService.kt b/app/src/main/java/org/schabi/newpipelegacy/local/feed/service/FeedLoadService.kt index 2b0900ff8..72e601be8 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/local/feed/service/FeedLoadService.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/local/feed/service/FeedLoadService.kt @@ -47,12 +47,12 @@ import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicInteger import org.reactivestreams.Subscriber import org.reactivestreams.Subscription -import org.schabi.newpipelegacy.MainActivity.DEBUG -import org.schabi.newpipelegacy.R -import org.schabi.newpipelegacy.database.feed.model.FeedGroupEntity import org.schabi.newpipe.extractor.ListInfo import org.schabi.newpipe.extractor.exceptions.ReCaptchaException import org.schabi.newpipe.extractor.stream.StreamInfoItem +import org.schabi.newpipelegacy.MainActivity.DEBUG +import org.schabi.newpipelegacy.R +import org.schabi.newpipelegacy.database.feed.model.FeedGroupEntity import org.schabi.newpipelegacy.local.feed.FeedDatabaseManager import org.schabi.newpipelegacy.local.feed.service.FeedEventManager.Event.ErrorResultEvent import org.schabi.newpipelegacy.local.feed.service.FeedEventManager.Event.IdleEvent diff --git a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionFragment.kt index 4c47b3528..74d8e5de9 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionFragment.kt @@ -38,9 +38,9 @@ import kotlin.math.max import kotlinx.android.synthetic.main.dialog_title.view.itemAdditionalDetails import kotlinx.android.synthetic.main.dialog_title.view.itemTitleView import kotlinx.android.synthetic.main.fragment_subscription.items_list +import org.schabi.newpipe.extractor.channel.ChannelInfoItem import org.schabi.newpipelegacy.R import org.schabi.newpipelegacy.database.feed.model.FeedGroupEntity -import org.schabi.newpipe.extractor.channel.ChannelInfoItem import org.schabi.newpipelegacy.fragments.BaseStateFragment import org.schabi.newpipelegacy.local.subscription.SubscriptionViewModel.SubscriptionState import org.schabi.newpipelegacy.local.subscription.dialog.FeedGroupDialog diff --git a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionManager.kt b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionManager.kt index 8373c0eee..0416713f9 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionManager.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/SubscriptionManager.kt @@ -4,13 +4,13 @@ import android.content.Context import io.reactivex.Completable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -import org.schabi.newpipelegacy.NewPipeDatabase -import org.schabi.newpipelegacy.database.subscription.SubscriptionDAO -import org.schabi.newpipelegacy.database.subscription.SubscriptionEntity import org.schabi.newpipe.extractor.ListInfo import org.schabi.newpipe.extractor.channel.ChannelInfo import org.schabi.newpipe.extractor.feed.FeedInfo import org.schabi.newpipe.extractor.stream.StreamInfoItem +import org.schabi.newpipelegacy.NewPipeDatabase +import org.schabi.newpipelegacy.database.subscription.SubscriptionDAO +import org.schabi.newpipelegacy.database.subscription.SubscriptionEntity import org.schabi.newpipelegacy.local.feed.FeedDatabaseManager class SubscriptionManager(context: Context) { diff --git a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/ChannelItem.kt b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/ChannelItem.kt index 880973bb0..d9d4c21f5 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/ChannelItem.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/ChannelItem.kt @@ -8,8 +8,8 @@ import kotlinx.android.synthetic.main.list_channel_item.itemAdditionalDetails import kotlinx.android.synthetic.main.list_channel_item.itemChannelDescriptionView import kotlinx.android.synthetic.main.list_channel_item.itemThumbnailView import kotlinx.android.synthetic.main.list_channel_item.itemTitleView -import org.schabi.newpipelegacy.R import org.schabi.newpipe.extractor.channel.ChannelInfoItem +import org.schabi.newpipelegacy.R import org.schabi.newpipelegacy.util.ImageDisplayConstants import org.schabi.newpipelegacy.util.Localization import org.schabi.newpipelegacy.util.OnClickGesture diff --git a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/FeedImportExportItem.kt b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/FeedImportExportItem.kt index b7eb219a6..e55ed05a4 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/FeedImportExportItem.kt +++ b/app/src/main/java/org/schabi/newpipelegacy/local/subscription/item/FeedImportExportItem.kt @@ -14,9 +14,9 @@ import kotlinx.android.synthetic.main.feed_import_export_group.import_export import kotlinx.android.synthetic.main.feed_import_export_group.import_export_expand_icon import kotlinx.android.synthetic.main.feed_import_export_group.import_export_options import kotlinx.android.synthetic.main.feed_import_export_group.import_from_options -import org.schabi.newpipelegacy.R import org.schabi.newpipe.extractor.NewPipe import org.schabi.newpipe.extractor.exceptions.ExtractionException +import org.schabi.newpipelegacy.R import org.schabi.newpipelegacy.util.AnimationUtils import org.schabi.newpipelegacy.util.ServiceHelper import org.schabi.newpipelegacy.util.ThemeHelper diff --git a/app/src/main/java/org/schabi/newpipelegacy/settings/DownloadSettingsFragment.java b/app/src/main/java/org/schabi/newpipelegacy/settings/DownloadSettingsFragment.java index 4d02db10f..1518a6a2c 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/settings/DownloadSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipelegacy/settings/DownloadSettingsFragment.java @@ -26,7 +26,6 @@ import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import us.shandian.giga.io.StoredDirectoryHelper; diff --git a/app/src/main/java/org/schabi/newpipelegacy/streams/SrtFromTtmlWriter.java b/app/src/main/java/org/schabi/newpipelegacy/streams/SrtFromTtmlWriter.java index a3a421f97..016ce6228 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/streams/SrtFromTtmlWriter.java +++ b/app/src/main/java/org/schabi/newpipelegacy/streams/SrtFromTtmlWriter.java @@ -11,8 +11,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; /** * @author kapodamy @@ -49,6 +47,7 @@ private void writeFrame(final String begin, final String end, final StringBuilde writeString(NEW_LINE); } + @SuppressWarnings("CharsetObjectCanBeUsed") private void writeString(final String text) throws IOException { out.write(text.getBytes("utf-8")); } diff --git a/app/src/main/java/org/schabi/newpipelegacy/streams/WebMReader.java b/app/src/main/java/org/schabi/newpipelegacy/streams/WebMReader.java index 4cbf1e289..120de5804 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/streams/WebMReader.java +++ b/app/src/main/java/org/schabi/newpipelegacy/streams/WebMReader.java @@ -5,7 +5,6 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.NoSuchElementException; @@ -122,8 +121,9 @@ private long readNumber(final Element parent) throws IOException { return value; } + @SuppressWarnings("CharsetObjectCanBeUsed") private String readString(final Element parent) throws IOException { - return new String(readBlob(parent), "utf-8");// or use "utf-8" + return new String(readBlob(parent), "utf-8"); } private byte[] readBlob(final Element parent) throws IOException { diff --git a/app/src/main/java/org/schabi/newpipelegacy/streams/WebMWriter.java b/app/src/main/java/org/schabi/newpipelegacy/streams/WebMWriter.java index a86ee31a0..0345c98c9 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/streams/WebMWriter.java +++ b/app/src/main/java/org/schabi/newpipelegacy/streams/WebMWriter.java @@ -13,7 +13,6 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; /** @@ -671,6 +670,7 @@ private byte[] encode(final long number, final boolean withLength) { return buffer; } + @SuppressWarnings("CharsetObjectCanBeUsed") private ArrayList encode(final String value) { byte[] str = null; try { @@ -680,6 +680,7 @@ private ArrayList encode(final String value) { } ArrayList buffer = new ArrayList<>(2); + // noinspection ConstantConditions buffer.add(encode(str.length, false)); buffer.add(str); diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml index a4fc516f2..b4faf2098 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle-suppressions.xml @@ -15,7 +15,7 @@ files="ListHelper.java" lines="278,310"/> - + @@ -24,6 +24,10 @@ files="Mp4FromDashWriter.java" lines="643"/> + + @@ -31,7 +35,28 @@ + + + + + + + + + + +