From c796e2ae3c4d103c01dec6d172a6c6601061f682 Mon Sep 17 00:00:00 2001 From: Ethan Budd Date: Thu, 18 Jun 2020 22:43:06 -0500 Subject: [PATCH 01/16] Fixes crash when a file is deleted then redownloaded --- app/src/main/java/us/shandian/giga/io/StoredFileHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/us/shandian/giga/io/StoredFileHelper.java b/app/src/main/java/us/shandian/giga/io/StoredFileHelper.java index ad3ceec3d..eba9437e1 100644 --- a/app/src/main/java/us/shandian/giga/io/StoredFileHelper.java +++ b/app/src/main/java/us/shandian/giga/io/StoredFileHelper.java @@ -315,6 +315,7 @@ public class StoredFileHelper implements Serializable { return false; if (this.isInvalid() || storage.isInvalid()) { + if (this.srcName == null || storage.srcName == null || this.srcType == null || storage.srcType == null) return false; return this.srcName.equalsIgnoreCase(storage.srcName) && this.srcType.equalsIgnoreCase(storage.srcType); } From 5cc60ed760980e6a0074b2d6d3bf4675c5d05d64 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 28 Jun 2020 13:33:08 +0200 Subject: [PATCH 02/16] Show dialog with open options in case of an unsupported url --- .../org/schabi/newpipe/RouterActivity.java | 42 +++++++++++-------- .../fragments/list/search/SearchFragment.java | 2 +- app/src/main/res/values-ar/strings.xml | 2 +- app/src/main/res/values-b+ast/strings.xml | 2 +- .../main/res/values-b+zh+HANS+CN/strings.xml | 2 +- app/src/main/res/values-be/strings.xml | 2 +- app/src/main/res/values-bg/strings.xml | 2 +- app/src/main/res/values-bn-rBD/strings.xml | 2 +- app/src/main/res/values-ca/strings.xml | 2 +- app/src/main/res/values-cs/strings.xml | 2 +- app/src/main/res/values-da/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-el/strings.xml | 2 +- app/src/main/res/values-eo/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-et/strings.xml | 2 +- app/src/main/res/values-eu/strings.xml | 2 +- app/src/main/res/values-fa/strings.xml | 2 +- app/src/main/res/values-fi/strings.xml | 2 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values-gl/strings.xml | 2 +- app/src/main/res/values-he/strings.xml | 2 +- app/src/main/res/values-hi/strings.xml | 2 +- app/src/main/res/values-hr/strings.xml | 2 +- app/src/main/res/values-hu/strings.xml | 2 +- app/src/main/res/values-ia/strings.xml | 2 +- app/src/main/res/values-in/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 2 +- app/src/main/res/values-ko/strings.xml | 2 +- app/src/main/res/values-ku/strings.xml | 2 +- app/src/main/res/values-lt/strings.xml | 2 +- app/src/main/res/values-mk/strings.xml | 2 +- app/src/main/res/values-ml/strings.xml | 2 +- app/src/main/res/values-ms/strings.xml | 2 +- app/src/main/res/values-nb-rNO/strings.xml | 2 +- app/src/main/res/values-ne/strings.xml | 2 +- app/src/main/res/values-nl-rBE/strings.xml | 2 +- app/src/main/res/values-nl/strings.xml | 2 +- app/src/main/res/values-pa/strings.xml | 2 +- app/src/main/res/values-pl/strings.xml | 2 +- app/src/main/res/values-pt-rBR/strings.xml | 2 +- app/src/main/res/values-pt/strings.xml | 2 +- app/src/main/res/values-ro/strings.xml | 2 +- app/src/main/res/values-ru/strings.xml | 2 +- app/src/main/res/values-sk/strings.xml | 2 +- app/src/main/res/values-sl/strings.xml | 2 +- app/src/main/res/values-sq/strings.xml | 2 +- app/src/main/res/values-sr/strings.xml | 2 +- app/src/main/res/values-sv/strings.xml | 2 +- app/src/main/res/values-ta/strings.xml | 2 +- app/src/main/res/values-te/strings.xml | 2 +- app/src/main/res/values-th/strings.xml | 2 +- app/src/main/res/values-tr/strings.xml | 2 +- app/src/main/res/values-uk/strings.xml | 2 +- app/src/main/res/values-ur/strings.xml | 2 +- app/src/main/res/values-vi/strings.xml | 2 +- app/src/main/res/values-zh-rCN/strings.xml | 2 +- app/src/main/res/values-zh-rHK/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values/strings.xml | 3 +- 61 files changed, 86 insertions(+), 77 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 39f6b217d..3d996f35c 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -50,6 +50,7 @@ import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PermissionHelper; +import org.schabi.newpipe.util.ShareUtils; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.urlfinder.UrlFinder; import org.schabi.newpipe.views.FocusOverlayView; @@ -159,27 +160,36 @@ public class RouterActivity extends AppCompatActivity { if (result) { onSuccess(); } else { - onError(); + showUnsupportedUrlDialog(url); } - }, this::handleError)); + }, throwable -> handleError(throwable, url))); } - private void handleError(final Throwable error) { - error.printStackTrace(); + private void handleError(final Throwable throwable, final String url) { + throwable.printStackTrace(); - if (error instanceof ExtractionException) { - Toast.makeText(this, R.string.url_not_supported_toast, Toast.LENGTH_LONG).show(); + if (throwable instanceof ExtractionException) { + showUnsupportedUrlDialog(url); } else { - ExtractorHelper.handleGeneralException(this, -1, null, error, + ExtractorHelper.handleGeneralException(this, -1, url, throwable, UserAction.SOMETHING_ELSE, null); + finish(); } - - finish(); } - private void onError() { - Toast.makeText(this, R.string.url_not_supported_toast, Toast.LENGTH_LONG).show(); - finish(); + private void showUnsupportedUrlDialog(final String url) { + final Context context = getThemeWrapperContext(); + new AlertDialog.Builder(context) + .setTitle(R.string.unsupported_url) + .setMessage(R.string.unsupported_url_dialog_message) + .setIcon(ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_share)) + .setPositiveButton(R.string.open_in_browser, + (dialog, which) -> ShareUtils.openUrlInBrowser(this, url)) + .setNegativeButton(R.string.share, + (dialog, which) -> ShareUtils.shareUrl(this, "", url)) // no subject + .setNeutralButton(R.string.cancel, null) + .setOnDismissListener(dialog -> finish()) + .show(); } protected void onSuccess() { @@ -459,7 +469,7 @@ public class RouterActivity extends AppCompatActivity { startActivity(intent); finish(); - }, this::handleError) + }, throwable -> handleError(throwable, currentUrl)) ); return; } @@ -492,11 +502,9 @@ public class RouterActivity extends AppCompatActivity { downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex); downloadDialog.show(fm, "downloadDialog"); fm.executePendingTransactions(); - downloadDialog.getDialog().setOnDismissListener(dialog -> { - finish(); - }); + downloadDialog.getDialog().setOnDismissListener(dialog -> finish()); }, (@NonNull Throwable throwable) -> { - onError(); + showUnsupportedUrlDialog(currentUrl); }); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 9bfead4f0..060a5c9c9 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -798,7 +798,7 @@ public class SearchFragment extends BaseListFragment - showError(getString(R.string.url_not_supported_toast), false))); + showError(getString(R.string.unsupported_url), false))); return; } } catch (Exception ignored) { diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 5d2fe413a..a6360502e 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -46,7 +46,7 @@ عرض خيار التشغيل بواسطة كودي السمة تم النشر بتاريخ %1$s - رابط URL غير معتمد + رابط URL غير معتمد استخدام مشغل صوت خارجي استخدام مشغل فيديو خارجي (إختبارية) إجراء التنزيلات من خلال استخدام بروكسي Tor لزيادة الخصوصية ( تشغيل الفيديو المباشر غير مدعوم حتى الأن ). diff --git a/app/src/main/res/values-b+ast/strings.xml b/app/src/main/res/values-b+ast/strings.xml index 247c76b3f..99dae05de 100644 --- a/app/src/main/res/values-b+ast/strings.xml +++ b/app/src/main/res/values-b+ast/strings.xml @@ -277,7 +277,7 @@ Tempu Tonu Refugar - La URL nun se sofita + La URL nun se sofita Reproduciendo en segundu planu Reproduciendo nel mou ventanu Atroxa llocalmente les consultes de gueta diff --git a/app/src/main/res/values-b+zh+HANS+CN/strings.xml b/app/src/main/res/values-b+zh+HANS+CN/strings.xml index fa6f9fe25..40f246e4e 100644 --- a/app/src/main/res/values-b+zh+HANS+CN/strings.xml +++ b/app/src/main/res/values-b+zh+HANS+CN/strings.xml @@ -29,7 +29,7 @@ 黑色 下载 下一个 - 不支持的 URL + 不支持的 URL 外观 其他 全部 diff --git a/app/src/main/res/values-be/strings.xml b/app/src/main/res/values-be/strings.xml index fbd7a99c0..c8f026ab9 100644 --- a/app/src/main/res/values-be/strings.xml +++ b/app/src/main/res/values-be/strings.xml @@ -85,7 +85,7 @@ \"Наступнае\" и \"Прапанаванае\" відэа \"Зацісніце, каб дадаць\" Паказаць падказку пры націсканні \"У акне\" ці \"У фоне\" на старонцы звестак аб відэа - URL не падтрымліваецца + URL не падтрымліваецца Краіна кантэнту па змаўчанні Сэрвіс Мова кантэнту па змаўчанні diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 400c8d280..0d41f3186 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -68,7 +68,7 @@ Следващ клип Показвай „следващ“ и „подобни“ Показвай съвет „задръж за добавяне“ - Непознат URL + Непознат URL Език на съдържанието по подразбиране Плейър Поведение diff --git a/app/src/main/res/values-bn-rBD/strings.xml b/app/src/main/res/values-bn-rBD/strings.xml index 6ad5e7ad0..8da0ba0ac 100644 --- a/app/src/main/res/values-bn-rBD/strings.xml +++ b/app/src/main/res/values-bn-rBD/strings.xml @@ -49,7 +49,7 @@ ডাউনলোড পরবর্তী ভিডিও পরবর্তী এবং অনুরূপ ভিডিওগুলি দেখাও - URL সমর্থিত নয় + URL সমর্থিত নয় কন্টেন্ট এর জন্য পছন্দসই ভাষা ভিডিও এবং অডিও পপআপ diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index d77c6a63a..abb65418d 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -281,7 +281,7 @@ Emmagatzema les cerques localment Crea un historial de vídeos visualitzats Reprèn automàticament - Aquest URL no és compatible + Aquest URL no és compatible Informe d\'error Més tard Filtra diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 20b9a8bc4..91e1d88da 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -35,7 +35,7 @@ Stáhnout Další Zobrazovat \'další\' a \'podobná\' videa - URL není podporováno + URL není podporováno Preferovaný jazyk obsahu Video a zvuk Vzhled diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 91ca1040f..3cc1cef30 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -92,7 +92,7 @@ Vis \'Næste\' og \'Lignende\' videoer Vis \"Hold for at tilføje\"-tip Vis et tip når der trykkes på baggrunds- eller pop op-knappen på siden med videodetaljer - Denne webadresse er ikke understøttet + Denne webadresse er ikke understøttet Standardland for indhold Tjeneste Standardsprog for indhold diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4f5c6e018..8704adc84 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -28,7 +28,7 @@ Herunterladen Nächste „Nächste“ und „Ähnliche“ Videos anzeigen - Nicht unterstützte URL + Nicht unterstützte URL Video & Audio Bevorzugte Sprache des Inhalts Video-Vorschaubild diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index ed5a6b299..ca14bcd31 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -35,7 +35,7 @@ Λήψη Επόμενο Εμφάνιση \"Επόμενου\" και \"Σχετικών\" βίντεο - Δεν υποστηρίζεται η διεύθυνση URL + Δεν υποστηρίζεται η διεύθυνση URL Προεπιλεγμένη γλώσσα περιεχομένου Βίντεο & Ήχος Εμφάνιση diff --git a/app/src/main/res/values-eo/strings.xml b/app/src/main/res/values-eo/strings.xml index c7ea0df18..930a27e77 100644 --- a/app/src/main/res/values-eo/strings.xml +++ b/app/src/main/res/values-eo/strings.xml @@ -25,7 +25,7 @@ Luma Elŝuti Vica filmeto - Ligilo ne subtenita + Ligilo ne subtenita Preferata enhavlingvo Filmeto kaj sono Apero diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index db9c65046..e8ad132f0 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -27,7 +27,7 @@ Formato de audio predeterminado Descargar Siguiente - No se admite el URL + No se admite el URL Usar reproductor de vídeo externo Usar reproductor de audio externo Tema diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml index a32d26af2..383c16e89 100644 --- a/app/src/main/res/values-et/strings.xml +++ b/app/src/main/res/values-et/strings.xml @@ -84,7 +84,7 @@ Kuva \'järgmine\' ja \'sarnased\' videod Kuva vihjet \"lisamiseks hoia\" Kuva vihje, kui videoandmete lehel vajutatakse tausta või hüpikakna nupule - Mitte toetatud URL + Mitte toetatud URL Sisu vaikimisi riik Teenus Sisu vaikimisi keel diff --git a/app/src/main/res/values-eu/strings.xml b/app/src/main/res/values-eu/strings.xml index 635e89d95..2a20817a2 100644 --- a/app/src/main/res/values-eu/strings.xml +++ b/app/src/main/res/values-eu/strings.xml @@ -25,7 +25,7 @@ Deskargatu Hurrengoa Erakutsi \'hurrengo\' eta \'antzeko\' bideoak - URLak ez du euskarririk + URLak ez du euskarririk Edukiaren hizkuntz lehenetsia Bideoa eta Audioa Erreproduzitu diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index ca78bc8dd..4aa8757a8 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -38,7 +38,7 @@ بارگیری بعدی نماش ویدیوهای «بعدی» و «مشابه» - نشانی پشتیبانی نشده + نشانی پشتیبانی نشده زبان محتوای ترجیحی ویدیو و صدا ظاهر diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 44ffc5126..a351d2063 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -67,7 +67,7 @@ Lataus Seuraava video Näytä seuraavia ja samankaltaisia videoita - URL ei tueta + URL ei tueta Oletus-sisällon kieli Soitin Käyttäytyminen diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index dc4ca619e..f92347947 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -27,7 +27,7 @@ Télécharger Suivant Afficher les vidéos « Suivantes » et « Similaires » - URL non pris en charge + URL non pris en charge Vidéo et audio Autre Miniature d’aperçu vidéo diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index 8450d60c8..9c6ac9a8d 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -90,7 +90,7 @@ Mostrar vídeos «seguintes» e «semellantes» Mostrar a suxestión «Manteña presionado para engadir á cola» Mostrar unha suxestión ao premer o botón de segundo plano ou o de popup na páxina de detalles do vídeo - Este URL non está soportado + Este URL non está soportado País predeterminado para o contido Servizo Reprodutor diff --git a/app/src/main/res/values-he/strings.xml b/app/src/main/res/values-he/strings.xml index 512c46ad3..bf339a360 100644 --- a/app/src/main/res/values-he/strings.xml +++ b/app/src/main/res/values-he/strings.xml @@ -54,7 +54,7 @@ הורדה הבא להציג סרטונים דומים ובאים בתור - כתובת לא נתמכת + כתובת לא נתמכת שפת התוכן המועדפת סרטונים ושמע חלון צף diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index ad1f3f5fc..58095e006 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -96,7 +96,7 @@ \'अगला\' और \'पहले समान\' वीडियो दिखाए \"जोड़ने के लिए पकड़ें रहे\" दिखाए जब बैकग्राउंड और पॉपअप बटन विडियो के विवरण पन्ने में दबाई जाए तो tip को दिखाए - ये वाला URL इसमें नहीं चलेगा + ये वाला URL इसमें नहीं चलेगा डिफ़ॉल्ट विषय की भाषा प्लेयर चाल चलन diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 95703bdd2..35c0a6253 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -68,7 +68,7 @@ Preuzmi Sljedeće Prikaži \'Sljedeće\' i \'Slične\' videozapise - URL nije podržan + URL nije podržan Zadani jezik sadržaja Video i zvuk Skočni prozor diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 6b6f1c1ed..53f7a64f5 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -26,7 +26,7 @@ Alapértelmezett hang formátum Letöltés Következő - Nem támogatott webcím + Nem támogatott webcím Külső videólejátszó használata Külső hanglejátszó használata Válaszd ki a hangfájlok letöltési helyét diff --git a/app/src/main/res/values-ia/strings.xml b/app/src/main/res/values-ia/strings.xml index 150046340..25eb5c65e 100644 --- a/app/src/main/res/values-ia/strings.xml +++ b/app/src/main/res/values-ia/strings.xml @@ -66,7 +66,7 @@ Sequente Reproduction automatic Monstrar le videos sequente e simile - URL non supportate + URL non supportate Pais predefinite del contentos Servicio Lingua predefinite del contento diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index c567b4479..70dc31fa8 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -34,7 +34,7 @@ Unduh Berikutnya Tampilkan video \'Berikutnya\' dan \'Serupa\' - URL tidak didukung + URL tidak didukung Bahasa konten Video & Audio Tampilan diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 06348d427..ae1b97f4f 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -27,7 +27,7 @@ Scarica Prossimo Mostra video \"Prossimo\" e \"Simili\" - URL non supportato + URL non supportato Lingua Predefinita per Contenuti Video e Audio Copertina di anteprima video diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index d9506c770..d4d6c27ee 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -26,7 +26,7 @@ 保存 「次の動画」と「関連動画」を表示 - URLは使用できません + URLは使用できません 優先言語 動画と音声 %1$s ビュー diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 190c13b71..680462cd0 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -27,7 +27,7 @@ 다운로드 다음 다음/유사한 비디오 표시 - 지원하지 않는 URL입니다 + 지원하지 않는 URL입니다 기본 컨텐츠 언어 비디오 & 오디오 비디오 미리보기 썸네일 diff --git a/app/src/main/res/values-ku/strings.xml b/app/src/main/res/values-ku/strings.xml index cf04b9732..f83e26a05 100644 --- a/app/src/main/res/values-ku/strings.xml +++ b/app/src/main/res/values-ku/strings.xml @@ -81,7 +81,7 @@ داگرتن دواتر پیشاندانی ’دواتر’ و ڤیدیۆ ’هاوشێوەکان’ - بەستەرەکە پشتگیری نەکراوە + بەستەرەکە پشتگیری نەکراوە وڵاتی بنەڕەتی خزمەتگوزاری کارپێکەر diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index fb05da09c..562fce75c 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -56,7 +56,7 @@ Atsisiųsti Kitas vaizdo įrašas Rodyti kitus panašius vaizdo įrašus - URL nepalaikoma + URL nepalaikoma Numatytoji tūrinio kalba Vaizdas ir garsas Iššokantis langas diff --git a/app/src/main/res/values-mk/strings.xml b/app/src/main/res/values-mk/strings.xml index 660148f01..95614bd56 100644 --- a/app/src/main/res/values-mk/strings.xml +++ b/app/src/main/res/values-mk/strings.xml @@ -85,7 +85,7 @@ Прикажи „следни“ и „слични“ видеа Прикажи „задржи за прикачување“ Покажи совет при притискање на позадината или кога скок копчето е притиснато на видео \"Детали:\" - Неподдржана URL врска + Неподдржана URL врска Земја на прикажани видеа Услуга Стандарден јазик на содржина diff --git a/app/src/main/res/values-ml/strings.xml b/app/src/main/res/values-ml/strings.xml index aa5362b80..227ec25f4 100644 --- a/app/src/main/res/values-ml/strings.xml +++ b/app/src/main/res/values-ml/strings.xml @@ -366,7 +366,7 @@ സ്ഥിര കന്റെന്റ്‌ ഭാഷ സേവനം സ്ഥിര കന്റെന്റ് രാജ്യം - അനുയോജ്യമല്ലാത്ത URL + അനുയോജ്യമല്ലാത്ത URL പോപ്പപ്പ്/ബാക്ക്ഗ്രൗണ്ട് ബട്ടൺ അമർത്തുമ്പോൾ \"വിശദാംശങ്ങൾ\" എന്ന ടിപ് കാണിക്കും \"ഹോൾഡ് ടു അപ്പെൻഡ്\" എന്ന ടിപ് കാണിക്കുക \'അടുത്ത\' , \'സമാനമായ\' വീഡിയോകൾ കാണിക്കുക diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml index 1944877f8..c9c24174f 100644 --- a/app/src/main/res/values-ms/strings.xml +++ b/app/src/main/res/values-ms/strings.xml @@ -92,7 +92,7 @@ Paparkan video \'Seterusnya\' dan \'Berkaitan\' Tunjukkan tip \"Pegang untuk menambahkan\" Tunjukkan tip apabila butang latar belakang atau popup ditekan pada halaman butiran video - URL tidak disokong + URL tidak disokong Negara kandungan utama Perkhidmatan Bahasa kandungan utama diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index e6e3198e5..d80b3249c 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -35,7 +35,7 @@ Last ned Neste Vis \"Neste\" og \"Lignende\" -videoer - Nettadressen støttes ikke + Nettadressen støttes ikke Foretrukket innholdsspråk Video og lyd Utseende diff --git a/app/src/main/res/values-ne/strings.xml b/app/src/main/res/values-ne/strings.xml index f91ae0452..6c47e7938 100644 --- a/app/src/main/res/values-ne/strings.xml +++ b/app/src/main/res/values-ne/strings.xml @@ -94,7 +94,7 @@ \'अर्को\' र \'समान\' भिडियो देखाउन \"होल्ड संलग्न गर्न\" टिप देखाउन पृष्ठभूमि वा भिडियो मा पपअप बटन थिच्दा टिप देखाउन \"विवरण:\" - असमर्थित URL + असमर्थित URL पूर्वनिर्धारित सामग्री देश सेवा पूर्वनिर्धारित सामग्री भाषा diff --git a/app/src/main/res/values-nl-rBE/strings.xml b/app/src/main/res/values-nl-rBE/strings.xml index a80cec9cc..813831a6b 100644 --- a/app/src/main/res/values-nl-rBE/strings.xml +++ b/app/src/main/res/values-nl-rBE/strings.xml @@ -85,7 +85,7 @@ Toont ‘Volgende’ en ‘Vergelijkbare’ video’s Toont tip ‘Ingedrukt houden voor toe te voegen’ Toont tip wanneer dat den achtergrond- of pop-upknop wordt ingedrukt op de videogegevenspagina - URL wordt niet ondersteund + URL wordt niet ondersteund Standaardinhoudsland Dienst Standaardtaal voor inhoud diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 67677799f..c14770100 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -26,7 +26,7 @@ Standaardaudioformaat Downloaden Volgende - URL wordt niet ondersteund + URL wordt niet ondersteund ‘volgende’ en ‘vergelijkbare’ video’s weergeven Standaardtaal voor inhoud Externe videospeler gebruiken diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 6a84b99a4..c1892d02c 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -85,7 +85,7 @@ \'ਅੱਗੇ\' ਅਤੇ \'ਸਮਾਨਅੰਤਰ\' ਵੀਡੀਓ ਦਿਖਾਓ \"Hold to append\" ਸੁਝਾਅ ਦਿਖਾਓ ਵੀਡੀਓ ਵੇਰਵੇ ਪੰਨੇ ਤੇ ਬੈਕਗ੍ਰਾਉਂਡ ਜਾਂ ਪੌਪ-ਅਪ ਬਟਨ ਦਬਾਉਣ ਤੇ ਸੰਕੇਤ ਦਿਖਾਓ - ਅਣ-ਸਹਾਇਕ URL + ਅਣ-ਸਹਾਇਕ URL ਮੂਲ ਦੇਸ਼ Content ਸੇਵਾ ਪਲੇਯਰ diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 0f029e001..e2f06f7b3 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -38,7 +38,7 @@ Pobrane Dalej Pokaż \"następne\" i \"podobne\" filmy - Nieobsługiwany adres URL + Nieobsługiwany adres URL Domyślny język treści Wideo i audio Wygląd diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 16293c528..faf714f83 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -69,7 +69,7 @@ Permita acesso ao armazenamento primeiramente Tema Publicado em %1$s - Link não suportado + Link não suportado Ao vivo Downloads Downloads diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 3a2a9d4d8..fa026c703 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -29,7 +29,7 @@ Transferir Seguinte Mostrar vídeos \'Seguintes\' e \'Semelhantes\' - URL não suportado + URL não suportado Idioma do conteúdo predefinido Vídeo e áudio Miniatura de pré-visualização de vídeo diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 2d08addb9..dfe732d5f 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -36,7 +36,7 @@ Descărcați Următorul Arată videoclipurile care urmează și similare - URL nesuportat + URL nesuportat Limba dorită a conținutului Video & Audio Aspect diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 2670da7eb..0bd9da4e7 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -26,7 +26,7 @@ Формат аудио по умолчанию Скачать Следующее - URL не поддерживается + URL не поддерживается \"Следующее\" и похожие видео Язык контента по умолчанию Видео и аудио diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 17ba3f3f3..69fa424ae 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -35,7 +35,7 @@ Prevziať Ďalšie Ukázať \'Ďalšie\' a \'Podobné\' videá - URL nie je podporovaná + URL nie je podporovaná Preferovaný jazyk obsahu Video & zvuk Vzhľad diff --git a/app/src/main/res/values-sl/strings.xml b/app/src/main/res/values-sl/strings.xml index c1cc8d963..189cf86fe 100644 --- a/app/src/main/res/values-sl/strings.xml +++ b/app/src/main/res/values-sl/strings.xml @@ -28,7 +28,7 @@ Prejem Naslednji video Pokaži naslednji video in podobne posnetke - Zapis naslova URL ni podprt. + Zapis naslova URL ni podprt. Privzeti jezik vsebine Video in Zvok Sličica predogleda videa diff --git a/app/src/main/res/values-sq/strings.xml b/app/src/main/res/values-sq/strings.xml index 1d3614bf1..16dcd196e 100644 --- a/app/src/main/res/values-sq/strings.xml +++ b/app/src/main/res/values-sq/strings.xml @@ -546,7 +546,7 @@ Zgjidhni instancat tuaja të preferuara të PeerTube Instancat PeerTube Shteti i parazgjedhur i përmbajtjes - URL e pambështetur + URL e pambështetur Trego ndihmën kur shtypet sfondi ose butoni i popup në \"Detajet:\" e videos Trego ndihmën \"Mbaje shtypur për ta shtuar në listë\" Trego \'Tjetra\' dhe videot \'E ngjashme\' diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 1cd4d2baa..af0002879 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -26,7 +26,7 @@ Подразумевани формат звука Преузми Следећи видео - УРЛ није подржан + УРЛ није подржан Прикажи следећи и слични видео Подразумевани језик садржаја Видео и аудио diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 3a83b8676..d97baaac0 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -52,7 +52,7 @@ Ladda ned Nästa Visa \'Nästa\' och \'Liknande\' videor - Webbadressen stöds inte + Webbadressen stöds inte Standard innehållsspråk Video & Ljud Popup-ruta diff --git a/app/src/main/res/values-ta/strings.xml b/app/src/main/res/values-ta/strings.xml index 52ef33abe..257b39b75 100644 --- a/app/src/main/res/values-ta/strings.xml +++ b/app/src/main/res/values-ta/strings.xml @@ -119,7 +119,7 @@ "தொலைபேசி அழைப்பு போன்ற குறுக்கீடுகளுக்கு பிறகு தொடரவும் " \'அடுத்து\' மற்றும் \'ஒப்பான\' காணொளிகலை காண்பி தேடப்பட்ட வாக்கியத்தை அமைவிடத்தில் சேமிக்கவும் - ஆதரிக்கப்படாத URL + ஆதரிக்கப்படாத URL இயல்புநிலை தகவல்களின் நாடு பிழைதிருத்து உள்ளடக்கம் diff --git a/app/src/main/res/values-te/strings.xml b/app/src/main/res/values-te/strings.xml index 1f2fd4ce1..1f344bf23 100644 --- a/app/src/main/res/values-te/strings.xml +++ b/app/src/main/res/values-te/strings.xml @@ -46,7 +46,7 @@ తదుపరి వీడియో తదుపరి వీడియో మరియు ఇలాంటి వీడియో చిట్కాను అనుబంధించడానికి హోల్డ్ను చూపు - Url మద్దతు లేదు + Url మద్దతు లేదు డిఫాల్ట్ భాష ప్లేయర్ ప్రవర్తన diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index 7910a29c7..20999eb9a 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -91,7 +91,7 @@ แสดงวิดีโอ \'ถัดไป\' และ \'ที่คล้ายกัน\' แสดงเคล็ดลับ \"แตะค้างเพื่อเพิ่ม\" แสดงเคล็ดลับเมื่อกดปุ่มพื้นหลังหรือป๊อปอัพในหน้ารายละเอียดวิดีโอ - URL ที่ไม่สนับสนุน + URL ที่ไม่สนับสนุน ประเทศเริ่มต้นของเนื้อหา บริการ ภาษาของเนื้อหาเริ่มต้น diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index cbfe624f8..3ceebd471 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -37,7 +37,7 @@ İndir Sonraki \'Sonraki\' ve \'Benzer\' videoları göster - Desteklenmeyen URL + Desteklenmeyen URL Öntanımlı içerik dili Ses Video ve ses diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 594a6e224..798821e99 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -37,7 +37,7 @@ Завантажити Наступне Показувати \"Наступне\" і \"Схожі\" відео - URL не підтримується + URL не підтримується Переважна мова контенту Відео та Аудіо Зовнішній вигляд diff --git a/app/src/main/res/values-ur/strings.xml b/app/src/main/res/values-ur/strings.xml index d222022d6..9f0989424 100644 --- a/app/src/main/res/values-ur/strings.xml +++ b/app/src/main/res/values-ur/strings.xml @@ -85,7 +85,7 @@ \'اگلی\' اور \'ملتی جلتی\' ویڈیوز دکھائیں ’’شامل کرنے کے لئے پکڑیں‘‘ اشارہ دکھائیں ویڈیو تفصیلات کے صفحے پر جب پس منظر یا پاپ اپ بٹن دبائے جانے پر ٹپ دکھائیں - غیر موافق URL + غیر موافق URL مشمولات کا طے شدہ ملک خدمت پلیئر diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index a16c93013..0e64d2857 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -53,7 +53,7 @@ Tải về Tiếp theo Hiển thị video \"Tiếp theo\" và \"Tương tự\" - URL không được hỗ trợ + URL không được hỗ trợ Hiển thị Khác Phát ở chế độ nền diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 604ad0605..92aea3d64 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -29,7 +29,7 @@ 黑色 下载 下一个 - 不支持的 URL + 不支持的 URL 外观 其他 全部 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index c06867012..d9893b8a2 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -28,7 +28,7 @@ 下載 下一部影片 顯示下一部及相關的影片 - 不支援此網址 + 不支援此網址 預設內容語言 影片及聲音 外觀 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b5e4fcbdf..4fd15e95e 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -32,7 +32,7 @@ 下載 下一個 顯示「下一部」與「相關」的影片 - 不支援此網址 + 不支援此網址 預設內容語言 影片和音訊 外觀 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f2e79a79b..1e8a6b049 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -106,7 +106,8 @@ Show \'Next\' and \'Similar\' videos Show \"Hold to append\" tip Show tip when pressing the background or the popup button in video \"Details:\" - Unsupported URL + Unsupported URL + NewPipe could not recognize the provided url. Open it with another method? Default content country Service Default content language From 8030312924400d73084acb6bc0a7c1874c0e8e56 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Mon, 17 Aug 2020 17:42:32 +0300 Subject: [PATCH 03/16] Prevent jumping of the player on devices with cutout --- .../newpipe/fragments/detail/VideoDetailFragment.java | 10 ++++++++++ 1 file changed, 10 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 50ad1ae57..9e8a650a5 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 @@ -1982,6 +1982,11 @@ public class VideoDetailFragment return; } + // Prevent jumping of the player on devices with cutout + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + activity.getWindow().getAttributes().layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT; + } activity.getWindow().getDecorView().setSystemUiVisibility(0); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } @@ -1995,6 +2000,11 @@ public class VideoDetailFragment return; } + // Prevent jumping of the player on devices with cutout + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + activity.getWindow().getAttributes().layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; + } final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION From e833d415e322eb83c65d2f8e9085f35d2ace2dc0 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Mon, 17 Aug 2020 20:18:16 +0300 Subject: [PATCH 04/16] Fixed wrong padding on devices with cutout on vertical videos --- .../newpipe/player/VideoPlayerImpl.java | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 0e06c1aaf..c21dca16f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -915,8 +915,8 @@ public class VideoPlayerImpl extends VideoPlayer // show kodi button if it supports the current service and it is enabled in settings final boolean showKodiButton = playQueue != null && playQueue.getItem() != null && KoreUtil.isServiceSupportedByKore(playQueue.getItem().getServiceId()) - && PreferenceManager.getDefaultSharedPreferences(context) - .getBoolean(context.getString(R.string.show_play_with_kodi_key), false); + && PreferenceManager.getDefaultSharedPreferences(context) + .getBoolean(context.getString(R.string.show_play_with_kodi_key), false); playWithKodi.setVisibility(videoPlayerSelected() && kodiEnabled && showKodiButton ? View.VISIBLE : View.GONE); } @@ -1499,9 +1499,10 @@ public class VideoPlayerImpl extends VideoPlayer // It doesn't include NavigationBar, notches, etc. display.getSize(size); + final boolean isLandscape = service.isLandscape(); final int width = isFullscreen - ? (service.isLandscape() - ? size.x : size.y) : ViewGroup.LayoutParams.MATCH_PARENT; + ? (isLandscape ? size.x : size.y) + : ViewGroup.LayoutParams.MATCH_PARENT; final int gravity = isFullscreen ? (display.getRotation() == Surface.ROTATION_90 ? Gravity.START : Gravity.END) @@ -1532,14 +1533,15 @@ public class VideoPlayerImpl extends VideoPlayer // And the situations when we need to set custom height is // in fullscreen mode in tablet in non-multiWindow mode or with vertical video. // Other than that MATCH_PARENT is good - final boolean navBarAtTheBottom = DeviceUtils.isTablet(service) || !service.isLandscape(); + final boolean navBarAtTheBottom = DeviceUtils.isTablet(service) || !isLandscape; controlsRoot.getLayoutParams().height = isFullscreen && !isInMultiWindow() && navBarAtTheBottom ? size.y : ViewGroup.LayoutParams.MATCH_PARENT; controlsRoot.requestLayout(); - final int topPadding = isFullscreen && !isInMultiWindow() ? getStatusBarHeight() : 0; - getRootView().findViewById(R.id.playbackWindowRoot).setPadding(0, topPadding, 0, 0); - getRootView().findViewById(R.id.playbackWindowRoot).requestLayout(); + int topPadding = isFullscreen && !isInMultiWindow() ? getStatusBarHeight() : 0; + topPadding = !isLandscape && hasCutout(topPadding) ? 0 : topPadding; + getRootView().findViewById(R.id.playbackWindowRoot).setTranslationY(topPadding); + getBottomControlsRoot().setTranslationY(-topPadding); } /** @@ -1548,8 +1550,12 @@ public class VideoPlayerImpl extends VideoPlayer */ private int getStatusBarHeight() { int statusBarHeight = 0; - final int resourceId = service.getResources().getIdentifier( - "status_bar_height_landscape", "dimen", "android"); + final int resourceId = service.isLandscape() + ? service.getResources().getIdentifier( + "status_bar_height_landscape", "dimen", "android") + : service.getResources().getIdentifier( + "status_bar_height", "dimen", "android"); + if (resourceId > 0) { statusBarHeight = service.getResources().getDimensionPixelSize(resourceId); } @@ -1563,6 +1569,20 @@ public class VideoPlayerImpl extends VideoPlayer return statusBarHeight; } + /* + * Compares current status bar height with default status bar height in Android and decides, + * does the device has cutout or not + * */ + private boolean hasCutout(final float statusBarHeight) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + final DisplayMetrics metrics = getRootView().getResources().getDisplayMetrics(); + final float defaultStatusBarHeight = TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_DIP, 25, metrics); + return statusBarHeight > defaultStatusBarHeight; + } + return false; + } + protected void setMuteButton(final ImageButton button, final boolean isMuted) { button.setImageDrawable(AppCompatResources.getDrawable(service, isMuted ? R.drawable.ic_volume_off_white_24dp : R.drawable.ic_volume_up_white_24dp)); @@ -2081,7 +2101,7 @@ public class VideoPlayerImpl extends VideoPlayer * This will be called when a user goes to another app/activity, turns off a screen. * We don't want to interrupt playback and don't want to see notification so * next lines of code will enable audio-only playback only if needed - * */ + */ private void onFragmentStopped() { if (videoPlayerSelected() && (isPlaying() || isLoading())) { if (backgroundPlaybackEnabled()) { From b8a35e9e4aae29800739a1d2dd470e97e5327df3 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Thu, 3 Sep 2020 15:44:36 +0300 Subject: [PATCH 05/16] Moved device-specific code into DeviceUtils --- .../schabi/newpipe/player/VideoPlayerImpl.java | 17 ++--------------- .../org/schabi/newpipe/util/DeviceUtils.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index c21dca16f..fce70138a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -1538,8 +1538,9 @@ public class VideoPlayerImpl extends VideoPlayer && navBarAtTheBottom ? size.y : ViewGroup.LayoutParams.MATCH_PARENT; controlsRoot.requestLayout(); + final DisplayMetrics metrics = getRootView().getResources().getDisplayMetrics(); int topPadding = isFullscreen && !isInMultiWindow() ? getStatusBarHeight() : 0; - topPadding = !isLandscape && hasCutout(topPadding) ? 0 : topPadding; + topPadding = !isLandscape && DeviceUtils.hasCutout(topPadding, metrics) ? 0 : topPadding; getRootView().findViewById(R.id.playbackWindowRoot).setTranslationY(topPadding); getBottomControlsRoot().setTranslationY(-topPadding); } @@ -1569,20 +1570,6 @@ public class VideoPlayerImpl extends VideoPlayer return statusBarHeight; } - /* - * Compares current status bar height with default status bar height in Android and decides, - * does the device has cutout or not - * */ - private boolean hasCutout(final float statusBarHeight) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - final DisplayMetrics metrics = getRootView().getResources().getDisplayMetrics(); - final float defaultStatusBarHeight = TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, 25, metrics); - return statusBarHeight > defaultStatusBarHeight; - } - return false; - } - protected void setMuteButton(final ImageButton button, final boolean isMuted) { button.setImageDrawable(AppCompatResources.getDrawable(service, isMuted ? R.drawable.ic_volume_off_white_24dp : R.drawable.ic_volume_up_white_24dp)); diff --git a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java index d852c2296..7592d2f35 100644 --- a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java @@ -6,6 +6,8 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.os.BatteryManager; import android.os.Build; +import android.util.DisplayMetrics; +import android.util.TypedValue; import android.view.KeyEvent; import androidx.annotation.NonNull; @@ -72,4 +74,17 @@ public final class DeviceUtils { return false; } } + + /* + * Compares current status bar height with default status bar height in Android and decides, + * does the device has cutout or not + * */ + public static boolean hasCutout(final float statusBarHeight, final DisplayMetrics metrics) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + final float defaultStatusBarHeight = TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_DIP, 25, metrics); + return statusBarHeight > defaultStatusBarHeight; + } + return false; + } } From 79e2bb382f83b8fe53c261cf482735ae0df30b7b Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 26 Aug 2020 22:49:03 -0400 Subject: [PATCH 06/16] Update ExoPlayer, OkHttp, use Kotlin JDK8 --- app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 345f45f66..9648a67b7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -84,7 +84,7 @@ ext { checkstyleVersion = '8.32' stethoVersion = '1.5.1' leakCanaryVersion = '2.2' - exoPlayerVersion = '2.11.6' + exoPlayerVersion = '2.11.8' androidxLifecycleVersion = '2.2.0' androidxRoomVersion = '2.2.5' groupieVersion = '2.8.0' @@ -139,7 +139,7 @@ afterEvaluate { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "frankiesardo:icepick:${icepickVersion}" kapt "frankiesardo:icepick-processor:${icepickVersion}" @@ -169,7 +169,7 @@ dependencies { implementation "com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751" implementation "org.jsoup:jsoup:1.13.1" - implementation "com.squareup.okhttp3:okhttp:3.12.11" + implementation "com.squareup.okhttp3:okhttp:3.12.12" implementation "com.google.android.exoplayer:exoplayer:${exoPlayerVersion}" implementation "com.google.android.exoplayer:extension-mediasession:${exoPlayerVersion}" From ba6c7de35a87c92f65a3b5d9f0f65d3c0aaa22c7 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:55:57 -0400 Subject: [PATCH 07/16] Use AndroidX preference --- .../newpipe/CheckForNewAppVersionTask.java | 2 +- .../org/schabi/newpipe/DownloaderImpl.java | 2 +- .../org/schabi/newpipe/ImageDownloader.java | 2 +- .../java/org/schabi/newpipe/MainActivity.java | 2 +- .../org/schabi/newpipe/RouterActivity.java | 2 +- .../newpipe/download/DownloadDialog.java | 4 ++-- .../newpipe/fragments/MainFragment.java | 6 ++--- .../fragments/detail/VideoDetailFragment.java | 12 ++++------ .../fragments/list/BaseListFragment.java | 2 +- .../fragments/list/search/SearchFragment.java | 2 +- .../list/videos/RelatedVideosFragment.java | 9 +++---- .../holder/StreamInfoItemHolder.java | 2 +- .../newpipe/local/BaseLocalListFragment.java | 2 +- .../local/feed/service/FeedLoadService.kt | 2 +- .../local/history/HistoryRecordManager.java | 2 +- .../subscription/SubscriptionFragment.kt | 2 +- .../org/schabi/newpipe/player/BasePlayer.java | 2 +- .../org/schabi/newpipe/player/MainPlayer.java | 2 +- .../schabi/newpipe/player/VideoPlayer.java | 2 +- .../newpipe/player/VideoPlayerImpl.java | 2 +- .../helper/PlaybackParameterDialog.java | 7 +++--- .../newpipe/player/helper/PlayerHelper.java | 2 +- .../settings/BasePreferenceFragment.java | 4 ++-- .../settings/ContentSettingsFragment.java | 10 ++++---- .../PeertubeInstanceListFragment.java | 2 +- .../newpipe/settings/tabs/TabsManager.java | 2 +- .../schabi/newpipe/util/FilenameUtils.java | 2 +- .../org/schabi/newpipe/util/ListHelper.java | 2 +- .../org/schabi/newpipe/util/Localization.java | 2 +- .../schabi/newpipe/util/NavigationHelper.java | 2 +- .../schabi/newpipe/util/PeertubeHelper.java | 2 +- .../schabi/newpipe/util/ServiceHelper.java | 2 +- .../org/schabi/newpipe/util/ThemeHelper.java | 2 +- .../giga/service/DownloadManagerService.java | 2 +- .../giga/ui/fragment/MissionsFragment.java | 4 ++-- app/src/main/res/xml/appearance_settings.xml | 2 +- app/src/main/res/xml/content_settings.xml | 14 +++++------ app/src/main/res/xml/debug_settings.xml | 6 ++--- app/src/main/res/xml/download_settings.xml | 6 ++--- app/src/main/res/xml/history_settings.xml | 8 +++---- app/src/main/res/xml/update_settings.xml | 2 +- app/src/main/res/xml/video_audio_settings.xml | 24 +++++++++---------- 42 files changed, 86 insertions(+), 86 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java index 0d211fdfd..d91230765 100644 --- a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java +++ b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java @@ -11,7 +11,7 @@ import android.content.pm.Signature; import android.net.ConnectivityManager; import android.net.Uri; import android.os.AsyncTask; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import androidx.core.app.NotificationCompat; diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java index 9cba0667b..c1c3eb0cd 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java +++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java @@ -2,7 +2,7 @@ package org.schabi.newpipe; import android.content.Context; import android.os.Build; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; diff --git a/app/src/main/java/org/schabi/newpipe/ImageDownloader.java b/app/src/main/java/org/schabi/newpipe/ImageDownloader.java index ca61c9655..c2897cff1 100644 --- a/app/src/main/java/org/schabi/newpipe/ImageDownloader.java +++ b/app/src/main/java/org/schabi/newpipe/ImageDownloader.java @@ -4,7 +4,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import com.nostra13.universalimageloader.core.download.BaseImageDownloader; diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index c3086d02c..aedf64231 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -27,7 +27,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import android.view.KeyEvent; diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 70fceaf07..391574e56 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -8,7 +8,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.text.TextUtils; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index ab44e0fc1..17d079d50 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -10,7 +10,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; @@ -295,7 +295,7 @@ public class DownloadDialog extends DialogFragment initToolbar(view.findViewById(R.id.toolbar)); setupDownloadOptions(); - prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + prefs = PreferenceManager.getDefaultSharedPreferences(requireContext()); final int threads = prefs.getInt(getString(R.string.default_download_threads), 3); threadsCountTextView.setText(String.valueOf(threads)); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 472dc3409..d138a298c 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -3,7 +3,7 @@ package org.schabi.newpipe.fragments; import android.content.Context; import android.content.res.ColorStateList; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -74,7 +74,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte youtubeRestrictedModeEnabledKey = getString(R.string.youtube_restricted_mode_enabled); previousYoutubeRestrictedModeEnabled = - PreferenceManager.getDefaultSharedPreferences(getContext()) + PreferenceManager.getDefaultSharedPreferences(requireContext()) .getBoolean(youtubeRestrictedModeEnabledKey, false); } @@ -105,7 +105,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte super.onResume(); final boolean youtubeRestrictedModeEnabled = - PreferenceManager.getDefaultSharedPreferences(getContext()) + PreferenceManager.getDefaultSharedPreferences(requireContext()) .getBoolean(youtubeRestrictedModeEnabledKey, false); if (previousYoutubeRestrictedModeEnabled != youtubeRestrictedModeEnabled) { previousYoutubeRestrictedModeEnabled = youtubeRestrictedModeEnabled; 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 b92becbd1..863c4eb7e 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 @@ -16,7 +16,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.provider.Settings; import android.text.Html; import android.text.Spanned; @@ -427,7 +427,7 @@ public class VideoDetailFragment currentWorker.dispose(); } saveCurrentAndRestoreDefaultBrightness(); - PreferenceManager.getDefaultSharedPreferences(getContext()) + PreferenceManager.getDefaultSharedPreferences(requireContext()) .edit() .putString(getString(R.string.stream_info_selected_tab_key), pageAdapter.getItemTitle(viewPager.getCurrentItem())) @@ -553,7 +553,6 @@ public class VideoDetailFragment Serializable serializable = savedState.getSerializable(INFO_KEY); if (serializable instanceof StreamInfo) { - //noinspection unchecked currentInfo = (StreamInfo) serializable; InfoCache.getInstance().putInfo(serviceId, url, currentInfo, InfoItem.InfoType.STREAM); } @@ -673,7 +672,7 @@ public class VideoDetailFragment } break; case R.id.detail_title_root_layout: - ShareUtils.copyToClipboard(getContext(), videoTitleTextView.getText().toString()); + ShareUtils.copyToClipboard(requireContext(), videoTitleTextView.getText().toString()); break; } @@ -1106,7 +1105,7 @@ public class VideoDetailFragment player.toggleFullscreen(); } - if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) { + if (!useExternalAudioPlayer) { openNormalBackgroundPlayer(append); } else { startOnExternalPlayer(activity, currentInfo, audioStream); @@ -1308,7 +1307,6 @@ public class VideoDetailFragment if (Build.VERSION.SDK_INT >= 24) { parsedDescription = Html.fromHtml(descriptionText, 0); } else { - //noinspection deprecation parsedDescription = Html.fromHtml(descriptionText); } return parsedDescription; @@ -1320,7 +1318,7 @@ public class VideoDetailFragment videoDescriptionView.setVisibility(View.VISIBLE); })); } else if (description.getType() == Description.MARKDOWN) { - final Markwon markwon = Markwon.builder(getContext()) + final Markwon markwon = Markwon.builder(requireContext()) .usePlugin(LinkifyPlugin.create()) .build(); markwon.setMarkdown(videoDescriptionView, description.getContent()); 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 152221c4c..37598eb1a 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 @@ -6,7 +6,7 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 44cdb8164..18c7fb1dd 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -5,7 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.text.Editable; import android.text.Html; import android.text.TextUtils; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java index 0aef68d90..9d1f5acbd 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java @@ -3,7 +3,7 @@ package org.schabi.newpipe.fragments.list.videos; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -78,11 +78,11 @@ public class RelatedVideosFragment extends BaseListInfoFragment - PreferenceManager.getDefaultSharedPreferences(getContext()).edit() + PreferenceManager.getDefaultSharedPreferences(requireContext()).edit() .putBoolean(getString(R.string.auto_queue_key), b).apply()); return headerRootLayout; } else { @@ -201,7 +201,8 @@ public class RelatedVideosFragment extends BaseListInfoFragment { // save whether pitch and tempo are unhooked or not - PreferenceManager.getDefaultSharedPreferences(getContext()) + PreferenceManager.getDefaultSharedPreferences(requireContext()) .edit() .putBoolean(getString(R.string.playback_unhook_key), isChecked) .apply(); diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java index 09072340b..2d29082f0 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java @@ -3,7 +3,7 @@ package org.schabi.newpipe.player.helper; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.provider.Settings; import android.view.accessibility.CaptioningManager; diff --git a/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java b/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java index d8b686297..c49be8c56 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.settings; import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.view.View; import androidx.annotation.Nullable; @@ -20,7 +20,7 @@ public abstract class BasePreferenceFragment extends PreferenceFragmentCompat { @Override public void onCreate(@Nullable final Bundle savedInstanceState) { - defaultPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); + defaultPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); super.onCreate(savedInstanceState); } 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 6ea2cc8a6..df30a21f3 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -7,7 +7,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import android.widget.Toast; @@ -74,7 +74,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { initialSelectedContentCountry = org.schabi.newpipe.util.Localization .getPreferredContentCountry(requireContext()); initialLanguage = PreferenceManager - .getDefaultSharedPreferences(getContext()).getString("app_language_key", "en"); + .getDefaultSharedPreferences(requireContext()).getString("app_language_key", "en"); } @Override @@ -148,7 +148,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { final ContentCountry selectedContentCountry = org.schabi.newpipe.util.Localization .getPreferredContentCountry(requireContext()); final String selectedLanguage = PreferenceManager - .getDefaultSharedPreferences(getContext()).getString("app_language_key", "en"); + .getDefaultSharedPreferences(requireContext()).getString("app_language_key", "en"); if (!selectedLocalization.equals(initialSelectedLocalization) || !selectedContentCountry.equals(initialSelectedContentCountry) @@ -217,7 +217,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { try { output = new ObjectOutputStream(new FileOutputStream(dst)); final SharedPreferences pref - = PreferenceManager.getDefaultSharedPreferences(getContext()); + = PreferenceManager.getDefaultSharedPreferences(requireContext()); output.writeObject(pref.getAll()); } catch (final IOException e) { @@ -299,7 +299,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { try { input = new ObjectInputStream(new FileInputStream(src)); final SharedPreferences.Editor prefEdit = PreferenceManager - .getDefaultSharedPreferences(getContext()).edit(); + .getDefaultSharedPreferences(requireContext()).edit(); prefEdit.clear(); final Map entries = (Map) input.readObject(); for (final Map.Entry entry : entries.entrySet()) { diff --git a/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java b/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java index dfa975eef..7dc96e882 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java @@ -4,7 +4,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.text.InputType; import android.view.LayoutInflater; import android.view.Menu; diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java index 316e3a835..02b0c3df5 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/TabsManager.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.settings.tabs; import android.content.Context; import android.content.SharedPreferences; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.widget.Toast; import org.schabi.newpipe.R; diff --git a/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java b/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java index dda01b60c..27e1f3048 100644 --- a/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/FilenameUtils.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.SharedPreferences; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; diff --git a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java index be0630cac..7a428a05d 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java @@ -3,7 +3,7 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import androidx.annotation.Nullable; import androidx.annotation.StringRes; diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index 3642216ff..767cebcea 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -5,7 +5,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.text.TextUtils; import android.util.DisplayMetrics; diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 96dfc1925..693265fcd 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -7,7 +7,7 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import android.widget.Toast; diff --git a/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java b/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java index 5481b519c..e28095798 100644 --- a/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.SharedPreferences; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonObject; diff --git a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java index 1ab54343a..8f3423b22 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.SharedPreferences; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; diff --git a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java index 88e1a31cd..051fbbcf8 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java @@ -21,7 +21,7 @@ package org.schabi.newpipe.util; import android.content.Context; import android.content.res.TypedArray; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.TypedValue; import android.view.ContextThemeWrapper; diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index 3da0e75b8..a78c0db42 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -24,7 +24,7 @@ import android.os.Handler.Callback; import android.os.IBinder; import android.os.Message; import android.os.Parcelable; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.util.Log; import android.util.SparseArray; import android.widget.Toast; diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 09f4d0c79..35f40aa82 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -11,7 +11,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -97,7 +97,7 @@ public class MissionsFragment extends Fragment { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.missions, container, false); - mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + mPrefs = PreferenceManager.getDefaultSharedPreferences(requireActivity()); mLinear = mPrefs.getBoolean("linear", false); // Bind the service diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml index 31be267af..8049da868 100644 --- a/app/src/main/res/xml/appearance_settings.xml +++ b/app/src/main/res/xml/appearance_settings.xml @@ -13,7 +13,7 @@ android:summary="%s" android:title="@string/theme_title"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date: Thu, 27 Aug 2020 16:56:12 -0400 Subject: [PATCH 08/16] Fix some deprecations --- app/build.gradle | 1 - .../schabi/newpipe/report/ErrorInfoTest.java | 2 +- .../schabi/newpipe/about/AboutActivity.java | 2 +- .../org/schabi/newpipe/database/BasicDAO.java | 6 ++--- .../newpipe/download/DownloadActivity.java | 2 +- .../newpipe/fragments/detail/TabAdaptor.java | 2 +- .../schabi/newpipe/local/feed/FeedFragment.kt | 4 +-- .../subscription/SubscriptionFragment.kt | 4 +-- .../dialog/FeedGroupReorderDialog.kt | 4 +-- .../schabi/newpipe/player/VideoPlayer.java | 27 ++++++++----------- 10 files changed, 24 insertions(+), 30 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9648a67b7..80171be62 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -187,7 +187,6 @@ dependencies { implementation "androidx.lifecycle:lifecycle-livedata:${androidxLifecycleVersion}" implementation "androidx.lifecycle:lifecycle-viewmodel:${androidxLifecycleVersion}" - implementation "androidx.lifecycle:lifecycle-extensions:${androidxLifecycleVersion}" implementation "androidx.room:room-runtime:${androidxRoomVersion}" implementation "androidx.room:room-rxjava2:${androidxRoomVersion}" diff --git a/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java b/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java index 972737d25..a3aa28059 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java @@ -2,9 +2,9 @@ package org.schabi.newpipe.report; import android.os.Parcel; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import org.schabi.newpipe.R; diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java index 3041c3d6c..81ba78ba9 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java @@ -167,7 +167,7 @@ public class AboutActivity extends AppCompatActivity { */ public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(final FragmentManager fm) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java b/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java index bcb9ece10..dd526ecc8 100644 --- a/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java @@ -14,13 +14,13 @@ import io.reactivex.Flowable; @Dao public interface BasicDAO { /* Inserts */ - @Insert(onConflict = OnConflictStrategy.FAIL) + @Insert(onConflict = OnConflictStrategy.ABORT) long insert(Entity entity); - @Insert(onConflict = OnConflictStrategy.FAIL) + @Insert(onConflict = OnConflictStrategy.ABORT) List insertAll(Entity... entities); - @Insert(onConflict = OnConflictStrategy.FAIL) + @Insert(onConflict = OnConflictStrategy.ABORT) List insertAll(Collection entities); /* Searches */ diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java index bc160d873..979f8be75 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.download; -import android.app.FragmentTransaction; import android.content.Intent; import android.os.Bundle; import android.view.Menu; @@ -11,6 +10,7 @@ import android.view.ViewTreeObserver; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.FragmentTransaction; import org.schabi.newpipe.R; import org.schabi.newpipe.util.DeviceUtils; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java index 74609777c..c03f79dff 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java @@ -16,7 +16,7 @@ public class TabAdaptor extends FragmentPagerAdapter { private final FragmentManager fragmentManager; public TabAdaptor(final FragmentManager fm) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); this.fragmentManager = fm; } diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index 8018e2cd8..915bc3ec0 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -30,7 +30,7 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import androidx.lifecycle.Observer -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.preference.PreferenceManager import icepick.State import java.util.Calendar @@ -82,7 +82,7 @@ class FeedFragment : BaseListFragment() { override fun onViewCreated(rootView: View, savedInstanceState: Bundle?) { super.onViewCreated(rootView, savedInstanceState) - viewModel = ViewModelProviders.of(this, FeedViewModel.Factory(requireContext(), groupId)).get(FeedViewModel::class.java) + viewModel = ViewModelProvider(this, FeedViewModel.Factory(requireContext(), groupId)).get(FeedViewModel::class.java) viewModel.stateLiveData.observe(viewLifecycleOwner, Observer { it?.let(::handleResult) }) } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index 7ebfec50e..b0d0fe801 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -17,7 +17,7 @@ import android.view.MenuInflater import android.view.View import android.view.ViewGroup import android.widget.Toast -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager @@ -277,7 +277,7 @@ class SubscriptionFragment : BaseStateFragment() { } items_list.adapter = groupAdapter - viewModel = ViewModelProviders.of(this).get(SubscriptionViewModel::class.java) + viewModel = ViewModelProvider(this).get(SubscriptionViewModel::class.java) viewModel.stateLiveData.observe(viewLifecycleOwner, androidx.lifecycle.Observer { it?.let(this::handleResult) }) viewModel.feedGroupsLiveData.observe(viewLifecycleOwner, androidx.lifecycle.Observer { it?.let(this::handleFeedGroups) }) } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt index 92c063b4b..48f40e219 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt @@ -6,7 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.DialogFragment import androidx.lifecycle.Observer -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback import androidx.recyclerview.widget.LinearLayoutManager @@ -49,7 +49,7 @@ class FeedGroupReorderDialog : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - viewModel = ViewModelProviders.of(this).get(FeedGroupReorderDialogViewModel::class.java) + viewModel = ViewModelProvider(this).get(FeedGroupReorderDialogViewModel::class.java) viewModel.groupsLiveData.observe(viewLifecycleOwner, Observer(::handleGroups)) viewModel.dialogEventLiveData.observe(viewLifecycleOwner, Observer { when (it) { diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 57e5d1a27..587d414a9 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -30,6 +30,7 @@ import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.os.Build; import android.os.Handler; import androidx.preference.PreferenceManager; @@ -210,18 +211,18 @@ public abstract class VideoPlayer extends BasePlayer this.captionTextView = view.findViewById(R.id.captionTextView); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); - } - this.playbackSeekBar.getProgressDrawable(). - setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY); + playbackSeekBar.getThumb() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN)); + this.playbackSeekBar.getProgressDrawable() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY)); this.qualityPopupMenu = new PopupMenu(context, qualityTextView); this.playbackSpeedPopupMenu = new PopupMenu(context, playbackSpeedTextView); this.captionPopupMenu = new PopupMenu(context, captionTextView); ((ProgressBar) this.loadingPanel.findViewById(R.id.progressBarLoadingPanel)) - .getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY); + .getIndeterminateDrawable() + .setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY)); } protected abstract void setupSubtitleView(@NonNull SubtitleView view, float captionScale, @@ -456,11 +457,8 @@ public abstract class VideoPlayer extends BasePlayer animateView(controlsRoot, false, DEFAULT_CONTROLS_DURATION); playbackSeekBar.setEnabled(false); - // Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, - // so sets the color again - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); - } + playbackSeekBar.getThumb() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN)); loadingPanel.setBackgroundColor(Color.BLACK); animateView(loadingPanel, true, 0); @@ -476,11 +474,8 @@ public abstract class VideoPlayer extends BasePlayer showAndAnimateControl(-1, true); playbackSeekBar.setEnabled(true); - // Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, - // so sets the color again - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); - } + playbackSeekBar.getThumb() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN)); loadingPanel.setVisibility(View.GONE); From 6cb16be5dfad60d0d5333d6b789affdd524a73af Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:56:26 -0400 Subject: [PATCH 09/16] Use enhanced 'for' loops --- .../FragmentStatePagerAdapterMenuWorkaround.java | 4 ++-- .../newpipe/views/LargeTextMovementMethod.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java index 5840b0f7e..471360c60 100644 --- a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java +++ b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java @@ -300,8 +300,8 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt mSavedState.clear(); mFragments.clear(); if (fss != null) { - for (int i = 0; i < fss.length; i++) { - mSavedState.add((Fragment.SavedState) fss[i]); + for (final Parcelable parcelable : fss) { + mSavedState.add((Fragment.SavedState) parcelable); } } final Iterable keys = bundle.keySet(); diff --git a/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java b/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java index 36e0eabb0..1219304e1 100644 --- a/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java +++ b/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java @@ -155,13 +155,13 @@ public class LargeTextMovementMethod extends LinkMovementMethod { int bestStart = -1; int bestEnd = -1; - for (int i = 0; i < candidates.length; i++) { - final int start = buffer.getSpanStart(candidates[i]); - final int end = buffer.getSpanEnd(candidates[i]); + for (final ClickableSpan candidate : candidates) { + final int start = buffer.getSpanStart(candidate); + final int end = buffer.getSpanEnd(candidate); if ((end < selEnd || selStart == selEnd) && start >= visibleStart) { if (end > bestEnd) { - bestStart = buffer.getSpanStart(candidates[i]); + bestStart = buffer.getSpanStart(candidate); bestEnd = end; } } @@ -224,14 +224,14 @@ public class LargeTextMovementMethod extends LinkMovementMethod { int bestStart = Integer.MAX_VALUE; int bestEnd = Integer.MAX_VALUE; - for (int i = 0; i < candidates.length; i++) { - final int start = buffer.getSpanStart(candidates[i]); - final int end = buffer.getSpanEnd(candidates[i]); + for (final ClickableSpan candidate : candidates) { + final int start = buffer.getSpanStart(candidate); + final int end = buffer.getSpanEnd(candidate); if ((start > selStart || selStart == selEnd) && end <= visibleEnd) { if (start < bestStart) { bestStart = start; - bestEnd = buffer.getSpanEnd(candidates[i]); + bestEnd = buffer.getSpanEnd(candidate); } } } From 273c287fbf7c6306ab6f3b4ec15be7dbf63b6bbd Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:56:41 -0400 Subject: [PATCH 10/16] Fix some lambdas --- .../java/org/schabi/newpipe/RouterActivity.java | 8 ++------ .../fragments/list/BaseListInfoFragment.java | 2 +- .../local/bookmark/BookmarkFragment.java | 5 ++--- .../local/playlist/LocalPlaylistFragment.java | 5 ++--- .../schabi/newpipe/report/ErrorActivity.java | 17 +++++++---------- .../settings/PeertubeInstanceListFragment.java | 5 ++--- .../newpipe/settings/SelectChannelFragment.java | 7 +------ .../org/schabi/newpipe/util/AnimationUtils.java | 16 ++++------------ .../org/schabi/newpipe/util/StateSaver.java | 9 ++------- 9 files changed, 23 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 391574e56..482e3d32f 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -492,12 +492,8 @@ public class RouterActivity extends AppCompatActivity { downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex); downloadDialog.show(fm, "downloadDialog"); fm.executePendingTransactions(); - downloadDialog.getDialog().setOnDismissListener(dialog -> { - finish(); - }); - }, (@NonNull Throwable throwable) -> { - onError(); - }); + downloadDialog.getDialog().setOnDismissListener(dialog -> finish()); + }, (@NonNull Throwable throwable) -> onError()); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java index 86b093e45..f21eb5291 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java @@ -133,7 +133,7 @@ public abstract class BaseListInfoFragment currentInfo = result; currentNextPage = result.getNextPage(); handleResult(result); - }, (@NonNull Throwable throwable) -> onError(throwable)); + }, this::onError); } /** diff --git a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java index b27b1c1d1..d7555a79d 100644 --- a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java @@ -271,9 +271,8 @@ public final class BookmarkFragment extends BaseLocalListFragment { - changeLocalPlaylistName(selectedItem.uid, editText.getText().toString()); - }) + .setPositiveButton(R.string.rename_playlist, (dialog, which) -> + changeLocalPlaylistName(selectedItem.uid, editText.getText().toString())) .setNegativeButton(R.string.cancel, null) .setNeutralButton(R.string.delete, (dialog, which) -> { showDeleteDialog(selectedItem.name, 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 4c0521e44..3b66fd73f 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 @@ -553,9 +553,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment { - changePlaylistName(nameEdit.getText().toString()); - }); + .setPositiveButton(R.string.rename, (dialogInterface, i) -> + changePlaylistName(nameEdit.getText().toString())); dialogBuilder.show(); } diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 7ff3af91a..433fcf7ae 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -216,18 +216,16 @@ public class ErrorActivity extends AppCompatActivity { addGuruMeditation(); currentTimeStamp = getCurrentTimeStamp(); - reportEmailButton.setOnClickListener((View v) -> { - openPrivacyPolicyDialog(this, "EMAIL"); - }); + reportEmailButton.setOnClickListener((View v) -> + openPrivacyPolicyDialog(this, "EMAIL")); copyButton.setOnClickListener((View v) -> { ShareUtils.copyToClipboard(this, buildMarkdown()); Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show(); }); - reportGithubButton.setOnClickListener((View v) -> { - openPrivacyPolicyDialog(this, "GITHUB"); - }); + reportGithubButton.setOnClickListener((View v) -> + openPrivacyPolicyDialog(this, "GITHUB")); // normal bugreport @@ -278,10 +276,9 @@ public class ErrorActivity extends AppCompatActivity { .setTitle(R.string.privacy_policy_title) .setMessage(R.string.start_accept_privacy_policy) .setCancelable(false) - .setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> { - ShareUtils.openUrlInBrowser(context, - context.getString(R.string.privacy_policy_url)); - }) + .setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> + ShareUtils.openUrlInBrowser(context, + context.getString(R.string.privacy_policy_url))) .setPositiveButton(R.string.accept, (dialog, which) -> { if (action.equals("EMAIL")) { // send on email final Intent i = new Intent(Intent.ACTION_SENDTO) diff --git a/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java b/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java index 7dc96e882..61cee7b20 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java @@ -213,9 +213,8 @@ public class PeertubeInstanceListFragment extends Fragment { private void initButton(final View rootView) { final FloatingActionButton fab = rootView.findViewById(R.id.addInstanceButton); - fab.setOnClickListener(v -> { - showAddItemDialog(requireContext()); - }); + fab.setOnClickListener(v -> + showAddItemDialog(requireContext())); } private void showAddItemDialog(final Context c) { 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 1bc65da70..96e2781f5 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java @@ -208,12 +208,7 @@ public class SelectChannelFragment extends DialogFragment { public void onBindViewHolder(final SelectChannelItemHolder holder, final int position) { final SubscriptionEntity entry = subscriptions.get(position); holder.titleView.setText(entry.getName()); - holder.view.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View view) { - clickedItem(position); - } - }); + holder.view.setOnClickListener(view -> clickedItem(position)); imageLoader.displayImage(entry.getAvatarUrl(), holder.thumbnailView, DISPLAY_IMAGE_OPTIONS); } diff --git a/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java b/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java index 9220891a9..4f9053c05 100644 --- a/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java @@ -162,13 +162,9 @@ public final class AnimationUtils { .ofObject(new ArgbEvaluator(), colorStart, colorEnd); viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator()); viewPropertyAnimator.setDuration(duration); - viewPropertyAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(final ValueAnimator animation) { + viewPropertyAnimator.addUpdateListener(animation -> ViewCompat.setBackgroundTintList(view, - new ColorStateList(empty, new int[]{(int) animation.getAnimatedValue()})); - } - }); + new ColorStateList(empty, new int[]{(int) animation.getAnimatedValue()}))); viewPropertyAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { @@ -205,12 +201,8 @@ public final class AnimationUtils { .ofObject(new ArgbEvaluator(), colorStart, colorEnd); viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator()); viewPropertyAnimator.setDuration(duration); - viewPropertyAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(final ValueAnimator animation) { - view.setTextColor((int) animation.getAnimatedValue()); - } - }); + viewPropertyAnimator.addUpdateListener(animation -> + view.setTextColor((int) animation.getAnimatedValue())); viewPropertyAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { diff --git a/app/src/main/java/org/schabi/newpipe/util/StateSaver.java b/app/src/main/java/org/schabi/newpipe/util/StateSaver.java index cfe2b3272..ba095a4c5 100644 --- a/app/src/main/java/org/schabi/newpipe/util/StateSaver.java +++ b/app/src/main/java/org/schabi/newpipe/util/StateSaver.java @@ -36,7 +36,6 @@ import org.schabi.newpipe.MainActivity; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.FilenameFilter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -254,12 +253,8 @@ public final class StateSaver { return new SavedState(prefixFileName, file.getAbsolutePath()); } else { // Delete any file that contains the prefix - final File[] files = cacheDir.listFiles(new FilenameFilter() { - @Override - public boolean accept(final File dir, final String name) { - return name.contains(prefixFileName); - } - }); + final File[] files = cacheDir.listFiles((dir, name) -> + name.contains(prefixFileName)); for (final File fileToDelete : files) { fileToDelete.delete(); } From f86b40302d35915ed9d058de6d37a2ba291117da Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:56:58 -0400 Subject: [PATCH 11/16] Some general-purpose lint cleanup --- app/src/main/java/org/schabi/newpipe/DownloaderImpl.java | 4 ++-- app/src/main/java/org/schabi/newpipe/RouterActivity.java | 2 +- .../newpipe/fragments/detail/VideoDetailFragment.java | 3 ++- .../fragments/list/videos/RelatedVideosFragment.java | 2 -- .../newpipe/local/subscription/dialog/FeedGroupDialog.kt | 2 +- .../newpipe/player/resolver/VideoPlaybackResolver.java | 2 +- .../newpipe/settings/VideoAudioSettingsFragment.java | 2 +- .../main/java/org/schabi/newpipe/streams/DataReader.java | 2 +- .../java/org/schabi/newpipe/streams/Mp4DashReader.java | 8 ++------ .../main/java/org/schabi/newpipe/streams/WebMReader.java | 6 +++--- .../main/java/org/schabi/newpipe/util/AnimationUtils.java | 4 ++-- .../java/org/schabi/newpipe/util/RelatedStreamInfo.java | 3 +-- .../org/schabi/newpipe/util/TLSSocketFactoryCompat.java | 2 +- .../main/java/us/shandian/giga/get/DownloadMission.java | 2 +- app/src/main/java/us/shandian/giga/io/FileStream.java | 4 ++-- .../us/shandian/giga/postprocessing/Postprocessing.java | 2 +- .../java/us/shandian/giga/ui/adapter/MissionAdapter.java | 5 ++--- 17 files changed, 24 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java index c1c3eb0cd..69bfdfc2a 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java +++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java @@ -114,8 +114,8 @@ public final class DownloaderImpl extends Downloader { // Necessary because some servers (e.g. Framatube.org) // don't support the old cipher suites. // https://github.com/square/okhttp/issues/4053#issuecomment-402579554 - final List cipherSuites = new ArrayList<>(); - cipherSuites.addAll(ConnectionSpec.MODERN_TLS.cipherSuites()); + final List cipherSuites = + new ArrayList<>(ConnectionSpec.MODERN_TLS.cipherSuites()); cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA); cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA); final ConnectionSpec legacyTLS = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 482e3d32f..27fa94bef 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -568,7 +568,7 @@ public class RouterActivity extends AppCompatActivity { } } } - return result.toArray(new String[result.size()]); + return result.toArray(new String[0]); } private static class AdapterChoiceItem { 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 863c4eb7e..2885c9f7b 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 @@ -672,7 +672,8 @@ public class VideoDetailFragment } break; case R.id.detail_title_root_layout: - ShareUtils.copyToClipboard(requireContext(), videoTitleTextView.getText().toString()); + ShareUtils.copyToClipboard(requireContext(), + videoTitleTextView.getText().toString()); break; } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java index 9d1f5acbd..da7e8df8b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java @@ -166,12 +166,10 @@ public class RelatedVideosFragment extends BaseListInfoFragment { info.getOriginalUrl(), info.getUrl(), info.getId(), Collections.emptyList(), null); final RelatedStreamInfo relatedStreamInfo = new RelatedStreamInfo( info.getServiceId(), handler, info.getName()); - final List streams = new ArrayList<>(); - streams.addAll(info.getRelatedStreams()); + final List streams = new ArrayList<>(info.getRelatedStreams()); relatedStreamInfo.setRelatedItems(streams); return relatedStreamInfo; } diff --git a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java index a83e844ea..89dc08f38 100644 --- a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java +++ b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java @@ -106,7 +106,7 @@ public class TLSSocketFactoryCompat extends SSLSocketFactory { } private Socket enableTLSOnSocket(final Socket socket) { - if (socket != null && (socket instanceof SSLSocket)) { + if (socket instanceof SSLSocket) { ((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1.1", "TLSv1.2"}); } return socket; diff --git a/app/src/main/java/us/shandian/giga/get/DownloadMission.java b/app/src/main/java/us/shandian/giga/get/DownloadMission.java index 3f651d2ee..d7c586083 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadMission.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadMission.java @@ -633,7 +633,7 @@ public class DownloadMission extends Mission { calculated = offsets[current < offsets.length ? current : (offsets.length - 1)] + length; calculated -= offsets[0];// don't count reserved space - return calculated > nearLength ? calculated : nearLength; + return Math.max(calculated, nearLength); } /** diff --git a/app/src/main/java/us/shandian/giga/io/FileStream.java b/app/src/main/java/us/shandian/giga/io/FileStream.java index 2cc4d5db8..bbc56b20c 100644 --- a/app/src/main/java/us/shandian/giga/io/FileStream.java +++ b/app/src/main/java/us/shandian/giga/io/FileStream.java @@ -30,12 +30,12 @@ public class FileStream extends SharpStream { } @Override - public int read(byte b[]) throws IOException { + public int read(byte[] b) throws IOException { return source.read(b); } @Override - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { return source.read(b, off, len); } diff --git a/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java b/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java index 680f484e6..50dbd1c3d 100644 --- a/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java +++ b/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java @@ -115,7 +115,7 @@ public abstract class Postprocessing implements Serializable { mission.done = 0; long length = mission.storage.length() - mission.offsets[0]; - mission.length = length > mission.nearLength ? length : mission.nearLength; + mission.length = Math.max(length, mission.nearLength); final ProgressReport readProgress = (long position) -> { position -= mission.offsets[0]; diff --git a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java index d490bcb0f..c9518e477 100644 --- a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java +++ b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java @@ -49,6 +49,7 @@ import java.io.File; import java.lang.ref.WeakReference; import java.net.URI; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import us.shandian.giga.get.DownloadMission; @@ -302,9 +303,7 @@ public class MissionAdapter extends Adapter implements Handler.Callb float averageSpeed = speed; if (h.lastSpeedIdx < 0) { - for (int i = 0; i < h.lastSpeed.length; i++) { - h.lastSpeed[i] = speed; - } + Arrays.fill(h.lastSpeed, speed); h.lastSpeedIdx = 0; } else { for (int i = 0; i < h.lastSpeed.length; i++) { From 6c5ef567edecbc084aa6919fdeea21b757ed1b3a Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:59:09 -0400 Subject: [PATCH 12/16] Replace deprecated Html#fromHtml with HtmlCompat#fromHtml --- .../fragments/detail/VideoDetailFragment.java | 16 +++++----------- .../fragments/list/search/SearchFragment.java | 9 ++++----- 2 files changed, 9 insertions(+), 16 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 2885c9f7b..5e202eaa6 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 @@ -16,9 +16,9 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; +import androidx.core.text.HtmlCompat; import androidx.preference.PreferenceManager; import android.provider.Settings; -import android.text.Html; import android.text.Spanned; import android.text.TextUtils; import android.text.util.Linkify; @@ -1303,18 +1303,12 @@ public class VideoDetailFragment if (description.getType() == Description.HTML) { disposables.add(Single.just(description.getContent()) - .map((@NonNull String descriptionText) -> { - final Spanned parsedDescription; - if (Build.VERSION.SDK_INT >= 24) { - parsedDescription = Html.fromHtml(descriptionText, 0); - } else { - parsedDescription = Html.fromHtml(descriptionText); - } - return parsedDescription; - }) + .map((@NonNull final String descriptionText) -> + HtmlCompat.fromHtml(descriptionText, + HtmlCompat.FROM_HTML_MODE_LEGACY)) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull Spanned spanned) -> { + .subscribe((@NonNull final Spanned spanned) -> { videoDescriptionView.setText(spanned); videoDescriptionView.setVisibility(View.VISIBLE); })); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 18c7fb1dd..7ce4c6c84 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import androidx.core.text.HtmlCompat; import androidx.preference.PreferenceManager; import android.text.Editable; import android.text.Html; @@ -73,7 +74,6 @@ import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; import io.reactivex.subjects.PublishSubject; -import static android.text.Html.escapeHtml; import static androidx.recyclerview.widget.ItemTouchHelper.Callback.makeMovementFlags; import static java.util.Arrays.asList; import static org.schabi.newpipe.util.AnimationUtils.animateView; @@ -1005,10 +1005,9 @@ public class SearchFragment extends BaseListFragment" + escapeHtml(searchSuggestion) + ""; - correctSuggestion.setText( - Html.fromHtml(String.format(helperText, highlightedSearchSuggestion))); - + "" + Html.escapeHtml(searchSuggestion) + ""; + final String text = String.format(helperText, highlightedSearchSuggestion); + correctSuggestion.setText(HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY)); correctSuggestion.setOnClickListener(v -> { correctSuggestion.setVisibility(View.GONE); From 06d54ef77ea33117237cd89aa5fc10fc4d2a0e23 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:59:29 -0400 Subject: [PATCH 13/16] Clean up SDK version checks --- app/src/main/java/org/schabi/newpipe/App.java | 2 +- app/src/main/java/org/schabi/newpipe/ExitActivity.java | 2 +- .../java/org/schabi/newpipe/PanicResponderActivity.java | 2 +- .../main/java/org/schabi/newpipe/player/MainPlayer.java | 4 +--- .../main/java/org/schabi/newpipe/player/VideoPlayer.java | 2 +- .../java/org/schabi/newpipe/player/VideoPlayerImpl.java | 2 +- .../org/schabi/newpipe/player/helper/PlayerHelper.java | 9 --------- .../java/org/schabi/newpipe/report/ErrorActivity.java | 3 ++- .../java/org/schabi/newpipe/util/PermissionHelper.java | 6 ++---- .../java/org/schabi/newpipe/views/FocusOverlayView.java | 2 +- .../org/schabi/newpipe/views/NewPipeRecyclerView.java | 2 +- .../us/shandian/giga/service/DownloadManagerService.java | 8 ++++---- 12 files changed, 16 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 00842ec46..962679cd0 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -220,7 +220,7 @@ public class App extends Application { } public void initNotificationChannel() { - if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return; } diff --git a/app/src/main/java/org/schabi/newpipe/ExitActivity.java b/app/src/main/java/org/schabi/newpipe/ExitActivity.java index d4a4e3125..d457500aa 100644 --- a/app/src/main/java/org/schabi/newpipe/ExitActivity.java +++ b/app/src/main/java/org/schabi/newpipe/ExitActivity.java @@ -42,7 +42,7 @@ public class ExitActivity extends Activity { protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (Build.VERSION.SDK_INT >= 21) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAndRemoveTask(); } else { finish(); diff --git a/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java b/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java index 75304a2b9..b4fbdfb28 100644 --- a/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java +++ b/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java @@ -40,7 +40,7 @@ public class PanicResponderActivity extends Activity { ExitActivity.exitAndRemoveFromRecentApps(this); } - if (Build.VERSION.SDK_INT >= 21) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAndRemoveTask(); } else { finish(); diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index e562deb61..273f37cc8 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -310,9 +310,7 @@ public final class MainPlayer extends Service { setLockScreenThumbnail(builder); } - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { - builder.setPriority(NotificationCompat.PRIORITY_MAX); - } + builder.setPriority(NotificationCompat.PRIORITY_MAX); return builder; } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 587d414a9..a5a53f7a9 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -250,7 +250,7 @@ public abstract class VideoPlayer extends BasePlayer simpleExoPlayer.addTextOutput(cues -> subtitleView.onCues(cues)); // Setup audio session with onboard equalizer - if (Build.VERSION.SDK_INT >= 21) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { trackSelector.setParameters(trackSelector.buildUponParameters() .setTunnelingAudioSessionId(C.generateAudioSessionIdV21(context))); } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 9dfefec0b..05680baeb 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -1925,7 +1925,7 @@ public class VideoPlayerImpl extends VideoPlayer } private int popupLayoutParamType() { - return Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O + return Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? WindowManager.LayoutParams.TYPE_PHONE : WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java index 2d29082f0..6667d0ecb 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java @@ -2,7 +2,6 @@ package org.schabi.newpipe.player.helper; import android.content.Context; import android.content.SharedPreferences; -import android.os.Build; import androidx.preference.PreferenceManager; import android.provider.Settings; import android.view.accessibility.CaptioningManager; @@ -303,10 +302,6 @@ public final class PlayerHelper { @NonNull public static CaptionStyleCompat getCaptionStyle(@NonNull final Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return CaptionStyleCompat.DEFAULT; - } - final CaptioningManager captioningManager = (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE); if (captioningManager == null || !captioningManager.isEnabled()) { @@ -331,10 +326,6 @@ public final class PlayerHelper { * @return caption scaling */ public static float getCaptionScale(@NonNull final Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return 1f; - } - final CaptioningManager captioningManager = (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE); if (captioningManager == null || !captioningManager.isEnabled()) { diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 433fcf7ae..b83f9fd97 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -466,7 +466,8 @@ public class ErrorActivity extends AppCompatActivity { } private String getOsString() { - final String osBase = Build.VERSION.SDK_INT >= 23 ? Build.VERSION.BASE_OS : "Android"; + final String osBase = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M + ? Build.VERSION.BASE_OS : "Android"; return System.getProperty("os.name") + " " + (osBase.isEmpty() ? "Android" : osBase) + " " + Build.VERSION.RELEASE diff --git a/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java b/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java index ba157e6be..03400bdbb 100644 --- a/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java @@ -26,10 +26,8 @@ public final class PermissionHelper { private PermissionHelper() { } public static boolean checkStoragePermissions(final Activity activity, final int requestCode) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - if (!checkReadStoragePermissions(activity, requestCode)) { - return false; - } + if (!checkReadStoragePermissions(activity, requestCode)) { + return false; } return checkWriteStoragePermissions(activity, requestCode); } diff --git a/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java b/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java index 4a342784e..dc5bf7133 100644 --- a/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java +++ b/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java @@ -259,7 +259,7 @@ public final class FocusOverlayView extends Drawable implements // keyboard META key for moving between clusters). We have to fix this unfortunate accident // While we are at it, let's deal with touchscreenBlocksFocus too. - if (Build.VERSION.SDK_INT < 26) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return; } diff --git a/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java b/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java index 6350f80a5..a4f7a0506 100644 --- a/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java +++ b/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java @@ -142,7 +142,7 @@ public class NewPipeRecyclerView extends RecyclerView { } private boolean tryFocusFinder(final int direction) { - if (Build.VERSION.SDK_INT >= 28) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { // Android 9 implemented bunch of handy changes to focus, that render code below less // useful, and also broke findNextFocusFromRect in way, that render this hack useless return false; diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index a78c0db42..828f1adaf 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -160,7 +160,7 @@ public class DownloadManagerService extends Service { mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mNetworkStateListenerL = new ConnectivityManager.NetworkCallback() { @Override public void onAvailable(Network network) { @@ -240,7 +240,7 @@ public class DownloadManagerService extends Service { manageLock(false); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mConnectivityManager.unregisterNetworkCallback(mNetworkStateListenerL); else unregisterReceiver(mNetworkStateListener); @@ -466,7 +466,7 @@ public class DownloadManagerService extends Service { if (downloadDoneCount < 1) { downloadDoneList.append(name); - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { downloadDoneNotification.setContentTitle(getString(R.string.app_name)); } else { downloadDoneNotification.setContentTitle(null); @@ -505,7 +505,7 @@ public class DownloadManagerService extends Service { .setContentIntent(mOpenDownloadList); } - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { downloadFailedNotification.setContentTitle(getString(R.string.app_name)); downloadFailedNotification.setStyle(new NotificationCompat.BigTextStyle() .bigText(getString(R.string.download_failed).concat(": ").concat(mission.storage.getName()))); From 5b631e0387140a396ce2d1f465a0d04366b004bf Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 6 Sep 2020 14:01:59 +0200 Subject: [PATCH 14/16] Revert to deprecated BEHAVIOR_SET_USER_VISIBLE_HINT in TabAdapter Also added comment explaining why --- .../detail/{TabAdaptor.java => TabAdapter.java} | 17 ++++++++++++----- .../fragments/detail/VideoDetailFragment.java | 4 ++-- .../list/comments/CommentsFragment.java | 10 +--------- 3 files changed, 15 insertions(+), 16 deletions(-) rename app/src/main/java/org/schabi/newpipe/fragments/detail/{TabAdaptor.java => TabAdapter.java} (76%) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdapter.java similarity index 76% rename from app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java rename to app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdapter.java index c03f79dff..1a11836d4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdapter.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.fragments.detail; import android.view.ViewGroup; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -10,16 +11,20 @@ import androidx.fragment.app.FragmentPagerAdapter; import java.util.ArrayList; import java.util.List; -public class TabAdaptor extends FragmentPagerAdapter { +public class TabAdapter extends FragmentPagerAdapter { private final List mFragmentList = new ArrayList<>(); private final List mFragmentTitleList = new ArrayList<>(); private final FragmentManager fragmentManager; - public TabAdaptor(final FragmentManager fm) { - super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); + public TabAdapter(final FragmentManager fm) { + // if changed to BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT => crash if enqueueing stream in + // the background and then clicking on it to open VideoDetailFragment: + // "Cannot setMaxLifecycle for Fragment not attached to FragmentManager" + super(fm, BEHAVIOR_SET_USER_VISIBLE_HINT); this.fragmentManager = fm; } + @NonNull @Override public Fragment getItem(final int position) { return mFragmentList.get(position); @@ -57,7 +62,7 @@ public class TabAdaptor extends FragmentPagerAdapter { } @Override - public int getItemPosition(final Object object) { + public int getItemPosition(@NonNull final Object object) { if (mFragmentList.contains(object)) { return mFragmentList.indexOf(object); } else { @@ -82,7 +87,9 @@ public class TabAdaptor extends FragmentPagerAdapter { } @Override - public void destroyItem(final ViewGroup container, final int position, final Object object) { + public void destroyItem(@NonNull final ViewGroup container, + final int position, + @NonNull final Object object) { fragmentManager.beginTransaction().remove((Fragment) object).commitNowAllowingStateLoss(); } 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 5e202eaa6..42a5cbf02 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 @@ -244,7 +244,7 @@ public class VideoDetailFragment private AppBarLayout appBarLayout; private ViewPager viewPager; - private TabAdaptor pageAdapter; + private TabAdapter pageAdapter; private TabLayout tabLayout; private FrameLayout relatedStreamsLayout; @@ -752,7 +752,7 @@ public class VideoDetailFragment appBarLayout = rootView.findViewById(R.id.appbarlayout); viewPager = rootView.findViewById(R.id.viewpager); - pageAdapter = new TabAdaptor(getChildFragmentManager()); + pageAdapter = new TabAdapter(getChildFragmentManager()); viewPager.setAdapter(pageAdapter); tabLayout = rootView.findViewById(R.id.tablayout); tabLayout.setupWithViewPager(viewPager); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java index ff02dd790..fc61a4518 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java @@ -26,8 +26,6 @@ import io.reactivex.disposables.CompositeDisposable; public class CommentsFragment extends BaseListInfoFragment { private CompositeDisposable disposables = new CompositeDisposable(); - private boolean mIsVisibleToUser = false; - public static CommentsFragment getInstance(final int serviceId, final String url, final String name) { final CommentsFragment instance = new CommentsFragment(); @@ -39,12 +37,6 @@ public class CommentsFragment extends BaseListInfoFragment { // LifeCycle //////////////////////////////////////////////////////////////////////////*/ - @Override - public void setUserVisibleHint(final boolean isVisibleToUser) { - super.setUserVisibleHint(isVisibleToUser); - mIsVisibleToUser = isVisibleToUser; - } - @Override public void onAttach(final Context context) { super.onAttach(context); @@ -92,7 +84,7 @@ public class CommentsFragment extends BaseListInfoFragment { public void handleResult(@NonNull final CommentsInfo result) { super.handleResult(result); - AnimationUtils.slideUp(getView(), 120, 150, 0.06f); + AnimationUtils.slideUp(requireView(), 120, 150, 0.06f); if (!result.getErrors().isEmpty()) { showSnackBarError(result.getErrors(), UserAction.REQUESTED_COMMENTS, From 4e98c2e7f6c5bbb0615b9f7683a5a3aec8a5562e Mon Sep 17 00:00:00 2001 From: opusforlife2 <53176348+opusforlife2@users.noreply.github.com> Date: Tue, 8 Sep 2020 10:43:11 +0000 Subject: [PATCH 15/16] Add string for auto queue toggle --- app/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2e061077a..01a357cda 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -85,6 +85,7 @@ Metadata cache wiped Auto-queue next stream Continue ending (non-repeating) playback queue by appending a related stream + Auto-queue Volume gesture control Use gestures to control player volume Brightness gesture control From a5a23138515d31151566d64234e51ea814c1c5d1 Mon Sep 17 00:00:00 2001 From: opusforlife2 <53176348+opusforlife2@users.noreply.github.com> Date: Tue, 8 Sep 2020 10:44:58 +0000 Subject: [PATCH 16/16] Use new string for auto-queue toggle --- app/src/main/res/layout/related_streams_header.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/related_streams_header.xml b/app/src/main/res/layout/related_streams_header.xml index b98244b7e..35d039efa 100644 --- a/app/src/main/res/layout/related_streams_header.xml +++ b/app/src/main/res/layout/related_streams_header.xml @@ -27,6 +27,6 @@ android:switchPadding="5dp" android:textSize="12sp" android:textColor="@android:color/tab_indicator_text" - android:text="@string/autoplay_title" /> + android:text="@string/auto_queue_toggle" /> - \ No newline at end of file +