1
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-09-20 23:00:50 +02:00

Compare commits

...

139 Commits

Author SHA1 Message Date
Tobi
94b4c76749 Merge pull request #6840 from TeamNewPipe/release_0.21.9
Release 0.21.9
2021-08-22 22:21:36 +02:00
TobiGr
8715e7dd98 Only show "mark as watched" context menu entry when watch history is enabled 2021-08-22 22:15:05 +02:00
TobiGr
ccc2d892c1 Update extractor version to 0.21.9 2021-08-22 20:23:01 +02:00
TobiGr
d1ce8e7baa Removed unsued string from translations: item_in_history 2021-08-22 20:23:01 +02:00
TobiGr
82fbbbecac Fixed plurals 2021-08-22 20:23:01 +02:00
Hosted Weblate
4e15f0ddac Translated using Weblate (Finnish)
Currently translated at 10.7% (6 of 56 strings)

Translated using Weblate (Finnish)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Spanish)

Currently translated at 53.5% (30 of 56 strings)

Translated using Weblate (Polish)

Currently translated at 51.7% (29 of 56 strings)

Translated using Weblate (Swedish)

Currently translated at 99.5% (675 of 678 strings)

Translated using Weblate (Swedish)

Currently translated at 99.5% (675 of 678 strings)

Translated using Weblate (Swedish)

Currently translated at 99.5% (675 of 678 strings)

Translated using Weblate (Galician)

Currently translated at 93.6% (635 of 678 strings)

Translated using Weblate (Estonian)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Croatian)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Indonesian)

Currently translated at 99.8% (677 of 678 strings)

Translated using Weblate (Japanese)

Currently translated at 99.8% (677 of 678 strings)

Translated using Weblate (Croatian)

Currently translated at 97.0% (658 of 678 strings)

Translated using Weblate (Croatian)

Currently translated at 97.0% (658 of 678 strings)

Translated using Weblate (Vietnamese)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Somali)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Swedish)

Currently translated at 3.5% (2 of 56 strings)

Translated using Weblate (Swedish)

Currently translated at 98.0% (665 of 678 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (German)

Currently translated at 99.8% (677 of 678 strings)

Translated using Weblate (Ukrainian)

Currently translated at 53.5% (30 of 56 strings)

Translated using Weblate (Italian)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (French)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 53.5% (30 of 56 strings)

Translated using Weblate (Portuguese)

Currently translated at 53.5% (30 of 56 strings)

Translated using Weblate (Croatian)

Currently translated at 96.7% (656 of 678 strings)

Translated using Weblate (Swedish)

Currently translated at 97.1% (659 of 678 strings)

Translated using Weblate (Portuguese)

Currently translated at 100.0% (678 of 678 strings)

Translated using Weblate (English)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (Italian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Ukrainian)

Currently translated at 53.5% (30 of 56 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Albanian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Arabic)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Portuguese)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (56 of 56 strings)

Translated using Weblate (Polish)

Currently translated at 48.2% (27 of 56 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 94.2% (640 of 679 strings)

Translated using Weblate (Lithuanian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Persian)

Currently translated at 94.4% (641 of 679 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (French)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (Sardinian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (Somali)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Hebrew)

Currently translated at 48.1% (26 of 54 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Chinese (Traditional))

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Arabic)

Currently translated at 99.7% (677 of 679 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Greek)

Currently translated at 99.7% (677 of 679 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (French)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (Spanish)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (German)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (German)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (German)

Currently translated at 99.8% (678 of 679 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (679 of 679 strings)

Translated using Weblate (Tamil)

Currently translated at 36.6% (248 of 677 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Esperanto)

Currently translated at 85.6% (580 of 677 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 26.4% (14 of 53 strings)

Translated using Weblate (Estonian)

Currently translated at 99.8% (676 of 677 strings)

Translated using Weblate (Swedish)

Currently translated at 97.4% (660 of 677 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Korean)

Currently translated at 76.0% (515 of 677 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Spanish)

Currently translated at 28.3% (15 of 53 strings)

Translated using Weblate (Estonian)

Currently translated at 97.0% (657 of 677 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Basque)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Hungarian)

Currently translated at 85.6% (580 of 677 strings)

Translated using Weblate (Hungarian)

Currently translated at 85.6% (580 of 677 strings)

Translated using Weblate (Hungarian)

Currently translated at 85.6% (580 of 677 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Swedish)

Currently translated at 3.7% (2 of 53 strings)

Translated using Weblate (French)

Currently translated at 67.9% (36 of 53 strings)

Translated using Weblate (Vietnamese)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Swedish)

Currently translated at 97.3% (659 of 677 strings)

Translated using Weblate (Swedish)

Currently translated at 97.3% (659 of 677 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Latvian)

Currently translated at 94.5% (640 of 677 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 24.5% (13 of 53 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (German)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Sardinian)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Galician)

Currently translated at 91.5% (620 of 677 strings)

Translated using Weblate (Arabic)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Arabic)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Japanese)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (French)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Japanese)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Japanese)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Bengali (Bangladesh))

Currently translated at 59.6% (404 of 677 strings)

Translated using Weblate (Somali)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Norwegian Bokmål)

Currently translated at 97.1% (658 of 677 strings)

Translated using Weblate (Lithuanian)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Chinese (Traditional))

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Indonesian)

Currently translated at 99.8% (676 of 677 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Italian)

Currently translated at 100.0% (677 of 677 strings)

Translated using Weblate (Russian)

Currently translated at 99.8% (676 of 677 strings)

Translated using Weblate (French)

Currently translated at 99.8% (676 of 677 strings)

Translated using Weblate (Romanian)

Currently translated at 93.0% (626 of 673 strings)

Translated using Weblate (Kurdish (Central))

Currently translated at 3.7% (2 of 53 strings)

Translated using Weblate (Kurdish (Central))

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Chinese (Traditional))

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Kurdish (Central))

Currently translated at 90.3% (608 of 673 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Arabic)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Kurdish (Central))

Currently translated at 87.9% (592 of 673 strings)

Translated using Weblate (Lithuanian)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (French)

Currently translated at 100.0% (673 of 673 strings)

Translated using Weblate (Somali)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Albanian)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Bulgarian)

Currently translated at 1.8% (1 of 53 strings)

Translated using Weblate (Bulgarian)

Currently translated at 57.8% (389 of 672 strings)

Translated using Weblate (Bulgarian)

Currently translated at 57.8% (389 of 672 strings)

Translated using Weblate (Bulgarian)

Currently translated at 57.8% (389 of 672 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Bulgarian)

Currently translated at 57.4% (386 of 672 strings)

Translated using Weblate (Bulgarian)

Currently translated at 57.4% (386 of 672 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (672 of 672 strings)

Translated using Weblate (Gujarati)

Currently translated at 15.3% (103 of 672 strings)

Translated using Weblate (Hindi)

Currently translated at 81.6% (549 of 672 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (672 of 672 strings)

Added translation using Weblate (Gujarati)

Co-authored-by: Agnieszka C <aga_04@o2.pl>
Co-authored-by: AioiLight <info@aioilight.space>
Co-authored-by: Ajeje Brazorf <lmelonimamo@yahoo.it>
Co-authored-by: Allan Nordhøy <epost@anotheragency.no>
Co-authored-by: Andrij Mizyk <andmizyk@gmail.com>
Co-authored-by: AntonAkovP <anton.akov@gmail.com>
Co-authored-by: Anxhelo Lushka <anxhelo1995@gmail.com>
Co-authored-by: Ashune <ashune@protonmail.com>
Co-authored-by: Blaise Pascal <blaisepcl00@gmail.com>
Co-authored-by: ButterflyOfFire <ButterflyOfFire@protonmail.com>
Co-authored-by: Cerins <cerins4141@gmail.com>
Co-authored-by: Christian Draxl <draxl.koever@gmail.com>
Co-authored-by: Christian Eichert <c@zp1.net>
Co-authored-by: Danial Behzadi <dani.behzi@ubuntu.com>
Co-authored-by: Deleted User <noreply+34051@weblate.org>
Co-authored-by: Eduardo Caron <eduardocaron10@gmail.com>
Co-authored-by: Emin Tufan Çetin <etcetin@gmail.com>
Co-authored-by: Eric <spice2wolf@gmail.com>
Co-authored-by: Evo <weblate@verahawk.com>
Co-authored-by: Garden Hose <maxmammath@gmail.com>
Co-authored-by: Gediminas Murauskas <muziejusinfo@gmail.com>
Co-authored-by: GnuPGを使うべきだ <dieeeazpnnqbpddh@cock.email>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Igor Nedoboy <i.nedoboy@mail.ru>
Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com>
Co-authored-by: Isak Holmström <isak@kajko.se>
Co-authored-by: J. Lavoie <j.lavoie@net-c.ca>
Co-authored-by: JY3 <GeeyunJY3@gmail.com>
Co-authored-by: Jeff Huang <s8321414@gmail.com>
Co-authored-by: Jesus Cass <cjesusenrique1@gmail.com>
Co-authored-by: Joel A <joeax910@student.liu.se>
Co-authored-by: Jonatan Nyberg <jonatan@autistici.org>
Co-authored-by: Kaantaja <ufdbvgoljrjkrkyyub@ianvvn.com>
Co-authored-by: Kristjan Räts <kristjanrats@gmail.com>
Co-authored-by: Laszlo Almasi <almalaci@posteo.net>
Co-authored-by: Ldm Public <ldmpub@gmail.com>
Co-authored-by: Martin Constantino–Bodin <martin.bodin@ens-lyon.org>
Co-authored-by: Matyas-Cerny <matyas.c.404@gmail.com>
Co-authored-by: MohammedSR Vevo <mohammednajmidin@gmail.com>
Co-authored-by: Nadir Nour <dudethatwascool2@gmail.com>
Co-authored-by: Nikita Epifanov <nikgreens@protonmail.com>
Co-authored-by: Ordtrogen Översättning <johan@ordtrogen.se>
Co-authored-by: Rahul Dev Sharma <sci94tune@gmail.com>
Co-authored-by: Rex_sa <rex.sa@pm.me>
Co-authored-by: Ricardo <contatorms7@tutamail.com>
Co-authored-by: S3aBreeze <paperwork@evilcorp.ltd>
Co-authored-by: Saravanan Selvaraju <saravanan036@outlook.com>
Co-authored-by: Sergio Varela <sergitroll9@gmail.com>
Co-authored-by: SomeRetardedThatTranslatesStuff <the.eumitosis@simplelogin.fr>
Co-authored-by: Thiago Carmona Monteiro <Guarakami1807@protonmail.ch>
Co-authored-by: TiA4f8R <avdivers84@gmail.com>
Co-authored-by: TobiGr <tobigr@mail.de>
Co-authored-by: ToldYouThat <itoldyouthat@protonmail.com>
Co-authored-by: Vasilis K <skyhirules@gmail.com>
Co-authored-by: VfBFan <drop0815@posteo.de>
Co-authored-by: WB <web0nst@tuta.io>
Co-authored-by: WaldiS <sto@tutanota.de>
Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Co-authored-by: bomzhellino <adm.bomzh@gmail.com>
Co-authored-by: brokenPipe <ythunar@btcminers.tk>
Co-authored-by: bruh <quangtrung02hn16@gmail.com>
Co-authored-by: chr56 <chr0056@gmail.com>
Co-authored-by: michaloM <michalsvoboda2004@gmail.com>
Co-authored-by: nautilusx <translate@disroot.org>
Co-authored-by: nzgha <nzghafoss.ldxwe@slmail.me>
Co-authored-by: nzgha <osmshrn21.upogs@slmail.me>
Co-authored-by: pjammo <adrianoghr@hotmail.it>
Co-authored-by: random r <epsilin@yopmail.com>
Co-authored-by: ssantos <ssantos@web.de>
Co-authored-by: thami simo <simo.azad@gmail.com>
Co-authored-by: translator <yasinoc375@advew.com>
Co-authored-by: zeritti <woodenmo@posteo.de>
Co-authored-by: zmni <zmni@outlook.com>
Co-authored-by: Ács Zoltán <acszoltan111@gmail.com>
Co-authored-by: Ákos Surányi <akosuranyi@tutanota.com>
Co-authored-by: Андрей Станков <astankov84@gmail.com>
Co-authored-by: мачко <martinpeev@tutanota.com>
Co-authored-by: 정주찬 <ju1801@outlook.com>
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/bg/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/ckb/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/es/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/fi/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/fr/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/he/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/pl/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/pt/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/pt_PT/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/sv/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/uk/
Translate-URL: https://hosted.weblate.org/projects/newpipe/metadata/zh_Hans/
Translation: NewPipe/Metadata
2021-08-22 19:55:52 +02:00
TobiGr
9dd2a82b7d Update extractor version 2021-08-10 12:20:08 +02:00
Stypox
a3440cc8ef Merge pull request #6814 from Stypox/channel-grid-span-count
Fix channel item span count for SubscriptionFragment
2021-08-05 14:25:39 +02:00
Tobi
c3349e18a5 Merge pull request #6847 from Stypox/play-queue-theme
Play queue theme
2021-08-04 22:30:17 +02:00
Stypox
a2297fb5b8 Fix play queue theme 2021-08-04 18:41:23 +02:00
Stypox
23a6973291 v0.21.9 (975) changelog 2021-08-04 11:51:29 +02:00
Stypox
340a84e583 Release 0.21.9 (975) 2021-08-04 10:38:59 +02:00
Stypox
4291877830 Merge branch 'master' into dev 2021-08-04 10:36:59 +02:00
Mohammed Anas
c7f75bf7d1 Ignore paths unrelated to builds in CI (#6789) 2021-08-02 13:29:39 +00:00
Stypox
4bf5ddbfe9 Merge pull request #6792 from XiangRongLin/update_extractor
Update extractor, thus including throttling fixes
2021-08-01 20:11:21 +02:00
Stypox
a9623f8e6a Merge pull request #6550 from Douile/fix/clickthrough-feed-refresh
Disable feed click events while refresh overlay is shown
2021-08-01 13:11:24 +02:00
Stypox
bc74bb6bf6 Merge pull request #6633 from Isira-Seneviratne/Use_NotificationChannelCompat
Use NotificationChannelCompat.
2021-08-01 11:58:38 +02:00
Isira Seneviratne
d32450255c Use NotificationChannelCompat. 2021-08-01 14:59:30 +05:30
Robin
896aec5295 Merge pull request #6719 from TacoTheDank/core-lifecycle-bump
Update some AndroidX libraries
2021-08-01 11:24:33 +02:00
Stypox
d42a534fc3 Merge pull request #6741 from KalleStruik/comment-hearts
Show hearts in comments
2021-08-01 11:12:58 +02:00
XiangRongLin
398007ca90 Update extractor, thus including throttling fixes 2021-08-01 10:36:03 +02:00
Stypox
551e8df8b8 Merge pull request #6773 from nschulzke/mark-as-played
Add ability to mark an item as played
2021-08-01 10:30:36 +02:00
Nathan Schulzke
dc0a28b93d Upsert the complete info if we fetch it for marking as watched 2021-07-31 09:50:41 -06:00
Stypox
644396149b Fix channel item span count for SubscriptionFragment 2021-07-31 11:02:57 +02:00
Stypox
a25bb2618a Merge pull request #6808 from litetex/ci-run-format-ktlin-before-building
Check formatting of kotlin files in CI
2021-07-31 10:35:53 +02:00
Nathan Schulzke
0e12cdea7c Save the fetched duration to the database so that it can render the view correctly. 2021-07-29 20:59:23 -06:00
litetex
903296014a Check formatting of kotlin files in CI 2021-07-28 21:03:51 +02:00
Tobi
cd713db029 Merge pull request #6778 from Stypox/invalid-storage-npe
Fix NullPointerException when checking if storage exists
2021-07-28 16:54:57 +02:00
Nathan Schulzke
bdd16e06e0 Add comments describing the purpose of the markAsWatched method 2021-07-28 08:25:39 -06:00
Nathan Schulzke
4c632810ec Fetch the stream info via a network request if no duration is found when attempting to mark as watched. 2021-07-27 15:21:56 -06:00
Nathan Schulzke
f451bdbfa4 Do not add Mark as Watched to a live stream. 2021-07-27 15:21:56 -06:00
Kalle Struik
bfac73b992 Make heart visible in android studio and move logic to the right file. 2021-07-27 22:34:59 +02:00
Nathan Schulzke
2b41f710a8 Change played to watched 2021-07-27 13:26:51 -06:00
Stypox
5924edb289 Merge pull request #6782 from TacoTheDank/fix-fill-parent
Fix deprecated fill_parent attributes
2021-07-27 19:45:51 +02:00
Stypox
5ceec31adf Merge pull request #6720 from TacoTheDank/alertdialog-edittext
Consolidate edittext alert dialogs into one common layout
2021-07-27 19:42:51 +02:00
TacoTheDank
e2791cdf0f Fix deprecated fill_parent attributes 2021-07-27 13:38:59 -04:00
TacoTheDank
50f3b08c59 Consolidate edittext alert dialogs into one layout 2021-07-27 13:31:58 -04:00
Stypox
2aebf6ceaf Add log when existsAsFile() is called on an invalid StoredFileHelper 2021-07-27 17:56:41 +02:00
Stypox
7ceea2cd8d Merge pull request #6771 from litetex/fix-ToolbarSearchInputTheme
Fixed the ToolbarSearchTheme
2021-07-27 11:49:55 +02:00
Stypox
0cb801179c Merge pull request #6733 from Douile/fix/recaptcha-webview-background-activity
Prevent recaptcha webview from keeping youtube loaded in background
2021-07-27 11:41:17 +02:00
Stypox
1822d21676 Fix NullPointerException when checking if storage exists 2021-07-27 11:36:14 +02:00
Nathan Schulzke
7fd2ebc252 Add ability to mark an item as played 2021-07-26 20:51:41 -06:00
litetex
f709ac16f8 Fixed the toolbarSearchTheme
The toolbarSearchTheme was accidently broken with https://github.com/TeamNewPipe/NewPipe/pull/6456, see https://github.com/TeamNewPipe/NewPipe/pull/6456#issuecomment-885920235 for details.
This commit restores the old behavior
2021-07-26 21:05:12 +02:00
Kalle Struik
74173317de Change heart color to be red, add else clause for non hearted comments, and apply some code style suggestions. 2021-07-23 19:43:25 +02:00
Kalle Struik
3874e16187 Added support for showing when a comment has received a heart from the creator of a video. 2021-07-23 17:30:47 +02:00
Tobi
39722a5563 Merge pull request #6721 from Stypox/pending-mission-crash
Delete pending missions with invalid storage
2021-07-22 16:22:58 +02:00
Robin
1f9ad12593 Merge pull request #6712 from Stypox/fix-duplicate-items-queue
Fix duplicate items in queue causing endless buffering
2021-07-22 13:26:01 +02:00
Tom
52c136439e Use loadUrl instead of loadData
Co-authored-by: Stypox <stypox@pm.me>
2021-07-22 10:47:47 +00:00
Douile
cd86ed3877 Prevent recaptcha webview from keeping youtube loaded in background
After the cookies are extracted from the recaptcha webview make it load an empty
page to prevent youtube being loaded unecessarily in the background.
2021-07-22 02:41:01 +01:00
TacoTheDank
1d85661ab9 Update some AndroidX libraries 2021-07-21 19:31:41 -04:00
Stypox
736cefed5a Add tests for play queue items' equals() 2021-07-21 18:22:17 +02:00
Stypox
fa8630ddae Use url comparison between queue items when disabling preloading
From #4562: Disable player stream preloading only if the current stream is going to be replaced for sure (see this). equals() was implemented for PlayQueueItems, so that (only) the url is compared when checking them.
2021-07-21 18:09:18 +02:00
Stypox
4a2bd7bd7b Remove equals() method from PlayQueueItem 2021-07-21 18:09:18 +02:00
Stypox
a9e21a35ea Delete pending missions with invalid storage 2021-07-21 10:52:04 +02:00
Tobi
fd4e1b8d2c Merge pull request #6715 from TeamNewPipe/readd_api_29
Readd api level 29 to android CI tests
2021-07-20 23:46:49 +02:00
TobiGr
420f0505ae Merge branch 'master' into dev 2021-07-20 23:29:12 +02:00
XiangRongLin
c422f65935 Readd api level 29 to android CI tests
The action got fixed and released https://github.com/ReactiveCircus/android-emulator-runner/releases/tag/v2.19.1
2021-07-20 18:28:46 +02:00
Tobi
63fdc100d6 Merge pull request #6705 from Stypox/big-text-info-items
Fix grid span count calculation
2021-07-19 22:45:48 +02:00
Tobi
9e2ece78dd Merge pull request #6701 from Stypox/dismiss-download-dialog
Dismiss download dialog correctly
2021-07-19 21:47:12 +02:00
Tobi
cebcaf4d6a Merge pull request #6706 from litetex/fix-format-of-some-kotlin-files
Fix format of some kotlin files
2021-07-19 21:20:00 +02:00
Stypox
4a242e43a7 Merge pull request #6689 from Isira-Seneviratne/Use_WindowInsetsCompat_getInsets
Use WindowInsetsCompat's getInsets() method.
2021-07-19 21:19:06 +02:00
Tobi
d8f442cc89 Merge pull request #6707 from litetex/use-correct-extractor-dependency
Use the correct extractor dependency
2021-07-19 21:17:27 +02:00
litetex
f6923e073e Use the correct extractor dependency 2021-07-19 21:03:15 +02:00
litetex
f02c6be10d Fix format of some kotlin files
so that it doesn't annoy people that are building this repo ;)
2021-07-19 20:59:29 +02:00
Stypox
5ba3ef0a25 Fix grid span count calculation; remove duplicate methods 2021-07-19 20:47:50 +02:00
Stypox
ca282f2be8 Merge pull request #6675 from Isira-Seneviratne/Use_Kotlin_methods
Use Kotlin methods in LicenseFragment.
2021-07-19 13:19:02 +02:00
Robin
0cde08c46e Merge pull request #6702 from Isira-Seneviratne/Update_AppCompat_to_1.3.0
Update AppCompat to 1.3.0.
2021-07-19 11:58:17 +02:00
Stypox
bec8512c7b Merge pull request #6659 from TeamNewPipe/Redirion-kotlin-section
Added a Kotlin section in CONTRIBUTING.md
2021-07-19 11:54:48 +02:00
Stypox
46e7da4e21 Merge pull request #6688 from litetex/fix-some-build-warnings
Fix some build warnings
2021-07-19 11:52:24 +02:00
Isira Seneviratne
c7b8bd3436 Update AppCompat to 1.3.0. 2021-07-19 15:20:44 +05:30
Isira Seneviratne
1721817fdb Use WindowInsetsCompat's getInsets() method. 2021-07-19 15:17:44 +05:30
Stypox
d57bfde604 Merge pull request #6434 from litetex/playerSeekbarPreview
Player seekbar thumbnail preview
2021-07-19 11:42:10 +02:00
Stypox
3167ab3ba0 Merge pull request #6654 from Isira-Seneviratne/Bump_compileSdk
Bump compileSdkVersion to 30.
2021-07-19 11:11:18 +02:00
Stypox
8f559965f6 Call DownloadDialog dismiss() in the correct way 2021-07-19 10:59:45 +02:00
Stypox
35e005caaa Improve method order in DownloadDialog and add separator comments 2021-07-18 14:23:38 +02:00
Stypox
6c25ce56a3 Merge pull request #6456 from TeamNewPipe/feature/switch-theme
Apply theme to switches
2021-07-18 13:12:47 +02:00
Stypox
baa12c7069 Merge pull request #6536 from TacoTheDank/moar-onactivityresult
More onActivityResult deprecation fixes
2021-07-18 10:24:00 +02:00
Isira Seneviratne
e2b044d2ee Use Kotlin methods in LicenseFragment. 2021-07-18 07:47:12 +05:30
litetex
621af8d812 Removed unused import (rebasing/merge problem) 2021-07-17 16:52:24 +02:00
litetex
efd038a536 Increased padding of preview thumbnail 2021-07-17 16:43:04 +02:00
litetex
0b2629e910 Moved time to the top 2021-07-17 16:43:03 +02:00
litetex
a9b5ef3bd3 Set minWidth to 10dp so that the popup player works (mostly) correctly 2021-07-17 16:43:03 +02:00
litetex
2a24532e1d Fine tuned padding
Moved seekbar preview up a bit, so the finger is not obstructing the view
2021-07-17 16:43:02 +02:00
litetex
88c4195260 Enlarged currentDisplaySeek-text on large-handed player 2021-07-17 16:43:01 +02:00
litetex
c5f2eb1dd8 Enlarged currentDisplaySeek a bit 2021-07-17 16:43:01 +02:00
litetex
384d964827 Added seekbarThumbnailPreview 2021-07-17 16:43:00 +02:00
litetex
253526e565 Updated build.gradle so the PR-build works 2021-07-17 16:42:18 +02:00
litetex
2e2dbaf77f Added seekbar-preview to the player layout 2021-07-17 16:41:54 +02:00
litetex
43133df2ad Added settings for seekbar-preview-thumbnail 2021-07-17 16:41:53 +02:00
Stypox
eef568b24c Merge pull request #5531 from XiangRongLin/tests
Add instrumented tests for LocalPlaylistManager.createPlaylist
2021-07-17 13:21:20 +02:00
Stypox
e7d5011f42 Merge pull request #6483 from litetex/addDisabledComments
Added comments disabled functionallity
2021-07-17 13:19:34 +02:00
litetex
36c198fc33 One textview is enough for disabled comments
Ref: https://github.com/TeamNewPipe/NewPipe/pull/6483#discussion_r654793920
2021-07-17 13:14:50 +02:00
litetex
75a8edf20f Added corresponding required code changes from Extractor branch 2021-07-17 13:14:48 +02:00
litetex
81107df53f Added comments disabled functionallity 2021-07-17 13:10:44 +02:00
Stypox
a932bc2503 Merge pull request #6637 from Isira-Seneviratne/Use_GestureDetectorCompat
Use GestureDetectorCompat.
2021-07-17 12:58:43 +02:00
litetex
f4e2eca256 Simplified code and adjusted the style so that it's similar to FeedFragment 2021-07-16 21:21:10 +02:00
litetex
08d5dfa49c Removed updateRelativeTimeViews when the activity is paused
We don't need to call ``updateRelativeTimeViews`` when the activity is paused, because the user likely won't  notice it.
Despite that onResume already calls ``updateRelativeTimeViews`` so there is no need to do that twice.
2021-07-16 21:04:32 +02:00
Tobi
e7f339a946 Merge pull request #6678 from TeamNewPipe/XiangRongLin-patch-1
Remove api level 29 from android ci tests
2021-07-16 11:30:23 +02:00
XiangRongLin
d3375a921d Remove api level 29 from android ci tests 2021-07-16 10:19:58 +02:00
Robin
a2eb810df0 removed Extractor line 2021-07-14 13:23:01 +02:00
Robin
6e576a165c Added a Kotlin section in CONTRIBUTING.md
Core team does not want to convert to Kotlin yet and sees Java as the easier to learn and more well adopted language.

This stance might of course change in the future. For example it could be reasonable to do a complete transition to Kotlin once it is decides that the minSdk is raised to 21 or higher, as we then could use Jetpack particularly Lifecycle and Compose.
2021-07-14 13:08:07 +02:00
Tobi
dfa941a9e7 Merge pull request #6503 from evermind-zz/fixes-for-upstream
Prevent error msg: 'Unrecoverable player error occurred' while playin…
2021-07-14 09:53:30 +02:00
Tobi
1584028995 Merge pull request #6531 from XiangRongLin/immediat_pref_commit
Remove option to immediately commit pref changes on import
2021-07-14 09:48:58 +02:00
Tobi
14dab85ff0 Merge pull request #6566 from evermind-zz/various-fixes-for-upstream
Convert PlayerHolder to Singleton; cleanup in VideoDetailFragment; Player/MainPlayer do not call onDestroy() directly
2021-07-14 09:46:04 +02:00
Isira Seneviratne
403e336a64 Bump compileSdkVersion to 30. 2021-07-13 08:06:56 +05:30
XiangRongLin
2aa5f68b7b Add comment explaining usage Schedulers.trampoline in detail 2021-07-12 18:31:37 +02:00
XiangRongLin
56ea526cce Add instrumented tests for LocalPlaylistManager.createPlaylist 2021-07-12 18:31:37 +02:00
Tobi
96f5cd9f17 Merge pull request #6463 from Stypox/metadata-tags
Improved metadata layout, better tags accessibility
2021-07-12 16:18:11 +02:00
Tobi
64efb89cce Merge pull request #6616 from litetex/fix-minimized-player-thumbnail
Made the thumbnail in the minimized player visible again
2021-07-12 16:17:12 +02:00
Tobi
4d5b68792b Merge pull request #6560 from TeamNewPipe/fix_ci_emulator
Specify emulator-build version in CI job
2021-07-12 16:16:06 +02:00
Tobi
85d813a94b Merge pull request #6540 from TacoTheDank/library-bumps
Update some libraries
2021-07-12 16:15:21 +02:00
Tobi
e9b008ee84 Merge pull request #6538 from TacoTheDank/bump-gradle
Bump gradle
2021-07-12 16:14:04 +02:00
Douile
2e053ea25a Fix crash when refreshing feed 2021-07-11 03:00:32 +01:00
Isira Seneviratne
6711dae4e0 Use GestureDetectorCompat. 2021-07-10 15:35:11 +05:30
litetex
85e864a01e Made the thumbnail in the minimized player visible again 2021-07-06 21:40:57 +02:00
TacoTheDank
573839c0ff Update Gradle to 7.x, AGP to 4.2.x 2021-07-06 12:16:20 -04:00
XiangRongLin
9c636f5ee2 Specify emulator-build version in CI job
This is a workaround for the emulator bug https://github.com/ReactiveCircus/android-emulator-runner/issues/160
2021-07-06 16:26:01 +02:00
evermind
f78d2a5ed8 Prevent error msg: 'Unrecoverable player error occurred' while playing video during rotation (#6502)
Playing a video in VideoDetailFragment and rotating the screen to landscape (back and forth more often)
can trigger this error message. Especially if rotation for whatever reason takes long or
playing a high resolution (1080p) video.

The underlying logcat error messages:
05-12 16:38:38.251 24920 26037 E Surface : getSlotFromBufferLocked: unknown buffer: 0x923fc810
05-12 16:38:38.251 24920 26037 W ACodec  : [OMX.qcom.video.decoder.avc] can not return buffer 35 to native window

The problem is that that Exoplayer is trying to write to our -- during rotation -- no longer existant
(VideoDetailFragment) SurfaceView.

Solution:
Implementing SurfaceHolder.Callback and using DummySurface we can now handle the lifecycle of the Surface.

How?: In case we are no longer able to write to the Surface eg. through rotation/putting in
background we can set a DummySurface. Although it only works on API >= 23.
Result: we get a little video interruption (audio is still fine) but we won't get the
'Unrecoverable player error occurred' error message.

This implementation is based on and more background information:
 'ExoPlayer stuck in buffering after re-adding the surface view a few time 2703'

 -> exoplayer fix suggestion link
  https://github.com/google/ExoPlayer/issues/2703#issuecomment-300599981
2021-07-06 12:49:56 +02:00
evermind
48c2c156cb convert PlayerHolder to Singleton, handle context within, bugfix ServiceConnection leak
- bugfix: have ServiceConnection created only once!

- select the context within the PlayerHolder to start, stop, bind or unbind the service
  -> we have to make sure the Service is started AND stopped within the same context
  -> so let PlayerHolder be the one to select the context

- remove removeListener() and replace the call with setListener(null)
- Compatibility: use ContextCompat.startForegroundService instead of startService()
2021-07-06 12:31:26 +02:00
evermind
435813355f use viewBinding correctly 2021-07-06 07:56:05 +02:00
evermind
e30a552b6c remove duplicated code for toggle Fullscreen 2021-07-06 07:56:00 +02:00
evermind
22a4a4b2df move null checks for player and playerService to helper methods
- code is easier to read
- duplication of code reduced
2021-07-06 07:55:52 +02:00
evermind
aaa3e20c5a service.onDestroy() should only be called from the system and not manually
instead use service.stopService() which inturn calls stopSelf() and
triggers hopefully onDestroy() to be called. Eventually we have to make
sure that all ServiceConnections are closed to successfully stop the service
now!

Cleanup within stopService() and not only onDestroy()

So we make sure that all listeners can react to onServiceStopped()
and close their ServiceConnections. Afterwards the android framework
is ready to stop the Service.
2021-06-24 10:15:07 +02:00
Douile
cb1a138140 #6081: Disable feed click handlers during refresh
This patch changes click handlers for feed (Whats new) so that they do
nothing while the feed is refreshing and the items being clicked are not
visible.
2021-06-22 19:42:20 +01:00
TacoTheDank
afe06b379f Update some libraries 2021-06-20 17:26:59 -04:00
TacoTheDank
08d4651ef0 Add mavenCentral, de-prioritize jcenter 2021-06-20 15:44:17 -04:00
TacoTheDank
02b0909829 Fix onActivityResult deprecation in MissionsFragment 2021-06-20 14:14:54 -04:00
TacoTheDank
ae39b31c68 Fix onActivityResult deprecation in DownloadDialog 2021-06-20 14:14:44 -04:00
TacoTheDank
e5a1438673 Fix onActivityResult deprecation in DownloadSettingsFragment 2021-06-20 14:11:00 -04:00
TacoTheDank
72d305b283 Update AndroidX Fragment to 1.3.5 2021-06-20 13:47:12 -04:00
XiangRongLin
785c0376f8 Remove variable ContentSettingsFragment.lastImportExportDataUri
Instead pass the value through the methods as parameter
2021-06-20 09:30:59 +02:00
XiangRongLin
0bdf8de38e Resolve sonar issues in ContentSettingsFragment
https://sonarcloud.io/organizations/teamnewpipe/rules?open=java%3AS2885&rule_key=java%3AS2885

https://sonarcloud.io/organizations/teamnewpipe/rules?open=java%3AS112&rule_key=java%3AS112
2021-06-20 09:30:59 +02:00
XiangRongLin
9767e98e50 Remove option to immediately commit pref changes on import
System is now not restarted with `System.exit(0)`.
Instead it is done properly by finishing the activity and restarting the activity. This allows preference changes which are queued up asynchronously through `apply` to be applied.
2021-06-20 09:17:55 +02:00
Stypox
40a2df847b Move tags layout at the bottom, use multiple lines 2021-06-13 21:56:06 +02:00
Stypox
fa1d7ffac3 Const text width for metadata; scrollable tags layout 2021-06-09 15:32:07 +02:00
Stypox
272d589518 Convert related_items_header to ConstraintLayout 2021-06-09 13:10:26 +02:00
Stypox
6ab4787e97 Use SwitchCompat to make switch uniform across versions
Also just use colorControlActivated in the base V19 theme, instead of using the prefix android: in each V21 service theme
2021-06-09 13:04:21 +02:00
TobiGr
060f09ff55 Apply service color to switches 2021-06-08 20:11:05 +02:00
TobiGr
f47ae3668f [Bandcamp Add v21 styles 2021-06-08 20:11:05 +02:00
160 changed files with 3679 additions and 1525 deletions

View File

@@ -39,6 +39,10 @@ You'll see *exactly* what is sent, be able to add **your comments**, and then se
* Create PRs that cover only **one specific issue/solution/bug**. Do not create PRs that are huge monoliths and could have been split into multiple independent contributions.
* NewPipe uses [NewPipeExtractor](https://github.com/TeamNewPipe/NewPipeExtractor) to fetch data from services. If you need to change something there, you must test your changes in NewPipe. Telling NewPipe to use your extractor version can be accomplished by editing the `app/build.gradle` file: the comments under the "NewPipe libraries" section of `dependencies` will help you out.
### Kotlin in NewPipe
* NewPipe will remain mostly Java for time being
* Contributions containing a simple conversion from Java to Kotlin should be avoided. Conversions to Kotlin should only be done if Kotlin actually brings improvements like bug fixes or better performance which are not, or only with much more effort, implementable in Java. The core team sees Java as an easier to learn and generally well adopted programming language.
### Creating a Pull Request (PR)
* Make changes on a **separate branch** with a meaningful name, not on the _master_ branch or the _dev_ branch. This is commonly known as *feature branch workflow*. You may then send your changes as a pull request (PR) on GitHub.

View File

@@ -5,10 +5,20 @@ on:
branches:
- dev
- master
paths-ignore:
- 'README*.md'
- 'fastlane/**'
- 'assets/**'
- '.github/**/*.md'
push:
branches:
- dev
- master
paths-ignore:
- 'README*.md'
- 'fastlane/**'
- 'assets/**'
- '.github/**/*.md'
jobs:
build-and-test-jvm:
@@ -34,6 +44,9 @@ jobs:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Check if kotlin files are formatted correctly
run: ./gradlew runKtlint
- name: Build debug APK and run jvm tests
run: ./gradlew assembleDebug lintDebug testDebugUnitTest --stacktrace
@@ -44,35 +57,36 @@ jobs:
name: app
path: app/build/outputs/apk/debug/*.apk
# Disabled until emulator works again. see https://github.com/TeamNewPipe/NewPipe/pull/6560
# test-android:
# macos has hardware acceleration. See android-emulator-runner action
# runs-on: macos-latest
# strategy:
# matrix:
# api-level 19 is min sdk, but throws errors related to desugaring
# api-level: [21, 29]
# steps:
# - uses: actions/checkout@v2
#
# - name: set up JDK 8
# uses: actions/setup-java@v2
# with:
# java-version: 8
# distribution: "adopt"
#
# - name: Cache Gradle dependencies
# uses: actions/cache@v2
# with:
# path: ~/.gradle/caches
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
# restore-keys: ${{ runner.os }}-gradle
#
# - name: Run android tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ matrix.api-level }}
# script: ./gradlew connectedCheck
test-android:
# macos has hardware acceleration. See android-emulator-runner action
runs-on: macos-latest
strategy:
matrix:
# api-level 19 is min sdk, but throws errors related to desugaring
api-level: [ 21, 29 ]
steps:
- uses: actions/checkout@v2
- name: set up JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: "adopt"
- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Run android tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160
emulator-build: 7425822
script: ./gradlew connectedCheck
# sonar:
# runs-on: ubuntu-latest

View File

@@ -9,16 +9,16 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'checkstyle'
android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileSdkVersion 30
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "org.schabi.newpipe"
resValue "string", "app_name", "NewPipe"
minSdkVersion 19
targetSdkVersion 29
versionCode 974
versionName "0.21.8"
versionCode 975
versionName "0.21.9"
multiDexEnabled true
@@ -101,17 +101,17 @@ android {
ext {
checkstyleVersion = '8.38'
androidxLifecycleVersion = '2.2.0'
androidxLifecycleVersion = '2.3.1'
androidxRoomVersion = '2.3.0'
icepickVersion = '3.2.0'
exoPlayerVersion = '2.12.3'
googleAutoServiceVersion = '1.0-rc7'
googleAutoServiceVersion = '1.0'
groupieVersion = '2.8.1'
markwonVersion = '4.6.0'
markwonVersion = '4.6.2'
leakCanaryVersion = '2.5'
stethoVersion = '1.5.1'
stethoVersion = '1.6.0'
mockitoVersion = '3.6.0'
}
@@ -121,7 +121,7 @@ configurations {
}
checkstyle {
configDir rootProject.file(".")
getConfigDirectory().set(rootProject.file("."))
ignoreFailures false
showViolations true
toolVersion = checkstyleVersion
@@ -140,8 +140,8 @@ task runCheckstyle(type: Checkstyle) {
showViolations true
reports {
xml.enabled true
html.enabled true
xml.getRequired().set(true)
html.getRequired().set(true)
}
}
@@ -151,7 +151,7 @@ def inputFiles = project.fileTree(dir: "src", include: "**/*.kt")
task runKtlint(type: JavaExec) {
inputs.files(inputFiles)
outputs.dir(outputDir)
main = "com.pinterest.ktlint.Main"
getMainClass().set("com.pinterest.ktlint.Main")
classpath = configurations.ktlint
args "src/**/*.kt"
}
@@ -159,7 +159,7 @@ task runKtlint(type: JavaExec) {
task formatKtlint(type: JavaExec) {
inputs.files(inputFiles)
outputs.dir(outputDir)
main = "com.pinterest.ktlint.Main"
getMainClass().set("com.pinterest.ktlint.Main")
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}
@@ -186,7 +186,7 @@ dependencies {
// name and the commit hash with the commit hash of the (pushed) commit you want to test
// This works thanks to JitPack: https://jitpack.io/
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.8'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.9'
/** Checkstyle **/
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
@@ -196,16 +196,16 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
/** AndroidX **/
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.fragment:fragment-ktx:1.3.5'
implementation 'androidx.fragment:fragment-ktx:1.3.6'
implementation "androidx.lifecycle:lifecycle-livedata:${androidxLifecycleVersion}"
implementation "androidx.lifecycle:lifecycle-viewmodel:${androidxLifecycleVersion}"
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.media:media:1.2.1'
implementation 'androidx.media:media:1.3.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
@@ -237,8 +237,8 @@ dependencies {
kapt "com.google.auto.service:auto-service:${googleAutoServiceVersion}"
// Manager for complex RecyclerView layouts
implementation "com.xwray:groupie:${groupieVersion}"
implementation "com.xwray:groupie-viewbinding:${groupieVersion}"
implementation "com.github.lisawray.groupie:groupie:${groupieVersion}"
implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}"
// Circular ImageView
implementation "de.hdodenhof:circleimageview:3.1.0"

View File

@@ -0,0 +1,85 @@
package org.schabi.newpipe.local.playlist
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.Timeout
import org.schabi.newpipe.database.AppDatabase
import org.schabi.newpipe.database.stream.model.StreamEntity
import org.schabi.newpipe.extractor.stream.StreamType
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule
import java.util.concurrent.TimeUnit
class LocalPlaylistManagerTest {
private lateinit var manager: LocalPlaylistManager
private lateinit var database: AppDatabase
@get:Rule
val trampolineScheduler = TrampolineSchedulerRule()
@get:Rule
val timeout = Timeout(10, TimeUnit.SECONDS)
@Before
fun setup() {
database = Room.inMemoryDatabaseBuilder(
ApplicationProvider.getApplicationContext(),
AppDatabase::class.java
)
.allowMainThreadQueries()
.build()
manager = LocalPlaylistManager(database)
}
@After
fun cleanUp() {
database.close()
}
@Test
fun createPlaylist() {
val stream = StreamEntity(
serviceId = 1, url = "https://newpipe.net/", title = "title",
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
)
val result = manager.createPlaylist("name", listOf(stream))
// This should not behave like this.
// Currently list of all stream ids is returned instead of playlist id
result.test().await().assertValue(listOf(1L))
}
@Test
fun createPlaylist_emptyPlaylistMustReturnEmpty() {
val result = manager.createPlaylist("name", emptyList())
// This should not behave like this.
// It should throw an error because currently the result is null
result.test().await().assertComplete()
manager.playlists.test().awaitCount(1).assertValue(emptyList())
}
@Test()
fun createPlaylist_nonExistentStreamsAreUpserted() {
val stream = StreamEntity(
serviceId = 1, url = "https://newpipe.net/", title = "title",
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
)
database.streamDAO().insert(stream)
val upserted = StreamEntity(
serviceId = 1, url = "https://newpipe.net/2", title = "title2",
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
)
val result = manager.createPlaylist("name", listOf(stream, upserted))
result.test().await().assertComplete()
database.streamDAO().all.test().awaitCount(1).assertValue(listOf(stream, upserted))
}
}

View File

@@ -0,0 +1,37 @@
package org.schabi.newpipe.testUtil
import io.reactivex.rxjava3.android.plugins.RxAndroidPlugins
import io.reactivex.rxjava3.plugins.RxJavaPlugins
import io.reactivex.rxjava3.schedulers.Schedulers
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
/**
* Always run on [Schedulers.trampoline].
* This executes the task in the current thread in FIFO manner.
* This ensures that tasks are run quickly inside the tests
* and not scheduled away to another thread for later execution
*/
class TrampolineSchedulerRule : TestRule {
private val scheduler = Schedulers.trampoline()
override fun apply(base: Statement, description: Description): Statement =
object : Statement() {
override fun evaluate() {
try {
RxJavaPlugins.setComputationSchedulerHandler { scheduler }
RxJavaPlugins.setIoSchedulerHandler { scheduler }
RxJavaPlugins.setNewThreadSchedulerHandler { scheduler }
RxJavaPlugins.setSingleSchedulerHandler { scheduler }
RxAndroidPlugins.setInitMainThreadSchedulerHandler { scheduler }
base.evaluate()
} finally {
RxJavaPlugins.reset()
RxAndroidPlugins.reset()
}
}
}
}

View File

@@ -1,14 +1,13 @@
package org.schabi.newpipe;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationChannelCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.multidex.MultiDexApplication;
import androidx.preference.PreferenceManager;
@@ -233,38 +232,31 @@ public class App extends MultiDexApplication {
}
private void initNotificationChannels() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return;
}
// Keep the importance below DEFAULT to avoid making noise on every notification update for
// the main and update channels
final NotificationChannelCompat mainChannel = new NotificationChannelCompat
.Builder(getString(R.string.notification_channel_id),
NotificationManagerCompat.IMPORTANCE_LOW)
.setName(getString(R.string.notification_channel_name))
.setDescription(getString(R.string.notification_channel_description))
.build();
String id = getString(R.string.notification_channel_id);
String name = getString(R.string.notification_channel_name);
String description = getString(R.string.notification_channel_description);
final NotificationChannelCompat appUpdateChannel = new NotificationChannelCompat
.Builder(getString(R.string.app_update_notification_channel_id),
NotificationManagerCompat.IMPORTANCE_LOW)
.setName(getString(R.string.app_update_notification_channel_name))
.setDescription(getString(R.string.app_update_notification_channel_description))
.build();
// Keep this below DEFAULT to avoid making noise on every notification update for the main
// and update channels
int importance = NotificationManager.IMPORTANCE_LOW;
final NotificationChannelCompat hashChannel = new NotificationChannelCompat
.Builder(getString(R.string.hash_channel_id),
NotificationManagerCompat.IMPORTANCE_HIGH)
.setName(getString(R.string.hash_channel_name))
.setDescription(getString(R.string.hash_channel_description))
.build();
final NotificationChannel mainChannel = new NotificationChannel(id, name, importance);
mainChannel.setDescription(description);
id = getString(R.string.app_update_notification_channel_id);
name = getString(R.string.app_update_notification_channel_name);
description = getString(R.string.app_update_notification_channel_description);
final NotificationChannel appUpdateChannel = new NotificationChannel(id, name, importance);
appUpdateChannel.setDescription(description);
id = getString(R.string.hash_channel_id);
name = getString(R.string.hash_channel_name);
description = getString(R.string.hash_channel_description);
importance = NotificationManager.IMPORTANCE_HIGH;
final NotificationChannel hashChannel = new NotificationChannel(id, name, importance);
hashChannel.setDescription(description);
final NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannels(Arrays.asList(mainChannel,
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.createNotificationChannelsCompat(Arrays.asList(mainChannel,
appUpdateChannel, hashChannel));
}

View File

@@ -402,7 +402,7 @@ public class MainActivity extends AppCompatActivity {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
getSupportFragmentManager().popBackStack(null,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
recreate();
ActivityCompat.recreate(MainActivity.this);
}, 300);
}
@@ -823,7 +823,7 @@ public class MainActivity extends AppCompatActivity {
return;
}
if (PlayerHolder.isPlayerOpen()) {
if (PlayerHolder.getInstance().isPlayerOpen()) {
// if the player is already open, no need for a broadcast receiver
openMiniPlayerIfMissing();
} else {

View File

@@ -453,7 +453,7 @@ public class RouterActivity extends AppCompatActivity {
returnList.add(showInfo);
returnList.add(videoPlayer);
} else {
final MainPlayer.PlayerType playerType = PlayerHolder.getType();
final MainPlayer.PlayerType playerType = PlayerHolder.getInstance().getType();
if (capabilities.contains(VIDEO)
&& PlayerHelper.isAutoplayAllowedByUser(context)
&& playerType == null || playerType == MainPlayer.PlayerType.VIDEO) {

View File

@@ -11,8 +11,6 @@ import org.schabi.newpipe.R
import org.schabi.newpipe.about.LicenseFragmentHelper.showLicense
import org.schabi.newpipe.databinding.FragmentLicensesBinding
import org.schabi.newpipe.databinding.ItemSoftwareComponentBinding
import java.util.Arrays
import java.util.Objects
/**
* Fragment containing the software licenses.
@@ -24,16 +22,10 @@ class LicenseFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
softwareComponents =
arguments?.getParcelableArray(ARG_COMPONENTS) as Array<SoftwareComponent>
if (savedInstanceState != null) {
val license = savedInstanceState.getSerializable(LICENSE_KEY)
if (license != null) {
activeLicense = license as License?
}
}
softwareComponents = arguments?.getParcelableArray(ARG_COMPONENTS) as Array<SoftwareComponent>
activeLicense = savedInstanceState?.getSerializable(LICENSE_KEY) as? License
// Sort components by name
Arrays.sort(softwareComponents, Comparator.comparing(SoftwareComponent::name))
softwareComponents.sortBy { it.name }
}
override fun onDestroy() {
@@ -74,19 +66,13 @@ class LicenseFragment : Fragment() {
binding.licensesSoftwareComponents.addView(root)
registerForContextMenu(root)
}
if (activeLicense != null) {
compositeDisposable.add(
showLicense(activity, activeLicense!!)
)
}
activeLicense?.let { compositeDisposable.add(showLicense(activity, it)) }
return binding.root
}
override fun onSaveInstanceState(savedInstanceState: Bundle) {
super.onSaveInstanceState(savedInstanceState)
if (activeLicense != null) {
savedInstanceState.putSerializable(LICENSE_KEY, activeLicense)
}
activeLicense?.let { savedInstanceState.putSerializable(LICENSE_KEY, it) }
}
companion object {
@@ -94,8 +80,7 @@ class LicenseFragment : Fragment() {
private const val LICENSE_KEY = "ACTIVE_LICENSE"
fun newInstance(softwareComponents: Array<SoftwareComponent>): LicenseFragment {
val fragment = LicenseFragment()
fragment.arguments =
bundleOf(ARG_COMPONENTS to Objects.requireNonNull(softwareComponents))
fragment.arguments = bundleOf(ARG_COMPONENTS to softwareComponents)
return fragment
}
}

View File

@@ -162,6 +162,9 @@ public class ReCaptchaActivity extends AppCompatActivity {
setResult(RESULT_OK);
}
// Navigate to blank page (unloads youtube to prevent background playback)
recaptchaBinding.reCaptchaWebView.loadUrl("about:blank");
final Intent intent = new Intent(this, org.schabi.newpipe.MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
NavUtils.navigateUpTo(this, intent);

View File

@@ -151,8 +151,6 @@ public class DescriptionFragment extends BaseFragment {
addMetadataItem(inflater, layout, false,
R.string.metadata_category, streamInfo.getCategory());
addTagsMetadataItem(inflater, layout);
addMetadataItem(inflater, layout, false,
R.string.metadata_licence, streamInfo.getLicence());
@@ -174,6 +172,8 @@ public class DescriptionFragment extends BaseFragment {
R.string.metadata_host, streamInfo.getHost());
addMetadataItem(inflater, layout, true,
R.string.metadata_thumbnail_url, streamInfo.getThumbnailUrl());
addTagsMetadataItem(inflater, layout);
}
private void addMetadataItem(final LayoutInflater inflater,

View File

@@ -353,7 +353,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
final List<StreamDialogEntry> entries = new ArrayList<>();
if (PlayerHolder.getType() != null) {
if (PlayerHolder.getInstance().getType() != null) {
entries.add(StreamDialogEntry.enqueue);
}
if (item.getStreamType() == StreamType.AUDIO_STREAM) {

View File

@@ -6,6 +6,7 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -24,6 +25,8 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable;
public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
private final CompositeDisposable disposables = new CompositeDisposable();
private TextView emptyStateDesc;
public static CommentsFragment getInstance(final int serviceId, final String url,
final String name) {
final CommentsFragment instance = new CommentsFragment();
@@ -35,6 +38,13 @@ public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
super(UserAction.REQUESTED_COMMENTS);
}
@Override
protected void initViews(final View rootView, final Bundle savedInstanceState) {
super.initViews(rootView, savedInstanceState);
emptyStateDesc = rootView.findViewById(R.id.empty_state_desc);
}
/*//////////////////////////////////////////////////////////////////////////
// LifeCycle
//////////////////////////////////////////////////////////////////////////*/
@@ -73,6 +83,12 @@ public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
@Override
public void handleResult(@NonNull final CommentsInfo result) {
super.handleResult(result);
emptyStateDesc.setText(
result.isCommentsDisabled()
? R.string.comments_are_disabled
: R.string.no_comments);
ViewUtils.slideUp(requireView(), 120, 150, 0.06f);
disposables.clear();
}

View File

@@ -144,7 +144,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
final ArrayList<StreamDialogEntry> entries = new ArrayList<>();
if (PlayerHolder.getType() != null) {
if (PlayerHolder.getInstance().getType() != null) {
entries.add(StreamDialogEntry.enqueue);
}
if (item.getStreamType() == StreamType.AUDIO_STREAM) {

View File

@@ -1,6 +1,8 @@
package org.schabi.newpipe.info_list.holder;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.schabi.newpipe.R;
@@ -31,11 +33,13 @@ import org.schabi.newpipe.local.history.HistoryRecordManager;
public class CommentsInfoItemHolder extends CommentsMiniInfoItemHolder {
public final TextView itemTitleView;
private final ImageView itemHeartView;
public CommentsInfoItemHolder(final InfoItemBuilder infoItemBuilder, final ViewGroup parent) {
super(infoItemBuilder, R.layout.list_comments_item, parent);
itemTitleView = itemView.findViewById(R.id.itemTitleView);
itemHeartView = itemView.findViewById(R.id.detail_heart_image_view);
}
@Override
@@ -49,5 +53,7 @@ public class CommentsInfoItemHolder extends CommentsMiniInfoItemHolder {
final CommentsInfoItem item = (CommentsInfoItem) infoItem;
itemTitleView.setText(item.getUploaderName());
itemHeartView.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE);
}
}

View File

@@ -2,11 +2,11 @@ package org.schabi.newpipe.local.bookmark;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.InputType;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -22,6 +22,7 @@ import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.database.playlist.PlaylistLocalItem;
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity;
import org.schabi.newpipe.databinding.DialogEditTextBinding;
import org.schabi.newpipe.error.ErrorInfo;
import org.schabi.newpipe.error.UserAction;
import org.schabi.newpipe.local.BaseLocalListFragment;
@@ -255,14 +256,18 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
}
private void showLocalDialog(final PlaylistMetadataEntry selectedItem) {
final View dialogView = View.inflate(getContext(), R.layout.dialog_bookmark, null);
final EditText editText = dialogView.findViewById(R.id.playlist_name_edit_text);
editText.setText(selectedItem.name);
final DialogEditTextBinding dialogBinding
= DialogEditTextBinding.inflate(getLayoutInflater());
dialogBinding.dialogEditText.setHint(R.string.name);
dialogBinding.dialogEditText.setInputType(InputType.TYPE_CLASS_TEXT);
dialogBinding.dialogEditText.setText(selectedItem.name);
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(dialogView)
builder.setView(dialogBinding.getRoot())
.setPositiveButton(R.string.rename_playlist, (dialog, which) ->
changeLocalPlaylistName(selectedItem.uid, editText.getText().toString()))
changeLocalPlaylistName(
selectedItem.uid,
dialogBinding.dialogEditText.getText().toString()))
.setNegativeButton(R.string.cancel, null)
.setNeutralButton(R.string.delete, (dialog, which) -> {
showDeleteDialog(selectedItem.name,

View File

@@ -2,8 +2,7 @@ package org.schabi.newpipe.local.dialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.text.InputType;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -13,6 +12,7 @@ import androidx.appcompat.app.AlertDialog;
import org.schabi.newpipe.NewPipeDatabase;
import org.schabi.newpipe.R;
import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.databinding.DialogEditTextBinding;
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
import java.util.List;
@@ -43,16 +43,18 @@ public final class PlaylistCreationDialog extends PlaylistDialog {
return super.onCreateDialog(savedInstanceState);
}
final View dialogView = View.inflate(getContext(), R.layout.dialog_playlist_name, null);
final EditText nameInput = dialogView.findViewById(R.id.playlist_name);
final DialogEditTextBinding dialogBinding
= DialogEditTextBinding.inflate(getLayoutInflater());
dialogBinding.dialogEditText.setHint(R.string.name);
dialogBinding.dialogEditText.setInputType(InputType.TYPE_CLASS_TEXT);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext())
.setTitle(R.string.create_playlist)
.setView(dialogView)
.setView(dialogBinding.getRoot())
.setCancelable(true)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.create, (dialogInterface, i) -> {
final String name = nameInput.getText().toString();
final String name = dialogBinding.dialogEditText.getText().toString();
final LocalPlaylistManager playlistManager =
new LocalPlaylistManager(NewPipeDatabase.getInstance(requireContext()));
final Toast successToast = Toast.makeText(getActivity(),

View File

@@ -73,7 +73,7 @@ import org.schabi.newpipe.player.helper.PlayerHolder
import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.StreamDialogEntry
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCount
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountStreams
import org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout
import java.time.OffsetDateTime
import java.util.ArrayList
@@ -96,6 +96,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
private var onSettingsChangeListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
private var updateListViewModeOnResume = false
private var isRefreshing = false
init {
setHasOptionsMenu(true)
@@ -160,20 +161,12 @@ class FeedFragment : BaseStateFragment<FeedState>() {
fun setupListViewMode() {
// does everything needed to setup the layouts for grid or list modes
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCount(context) else 1
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCountStreams(context) else 1
feedBinding.itemsList.layoutManager = GridLayoutManager(requireContext(), groupAdapter.spanCount).apply {
spanSizeLookup = groupAdapter.spanSizeLookup
}
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
if (!isVisibleToUser && view != null) {
updateRelativeTimeViews()
}
}
override fun initListeners() {
super.initListeners()
feedBinding.refreshRootView.setOnClickListener { reloadContent() }
@@ -267,6 +260,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
feedBinding.refreshRootView.animate(false, 0)
feedBinding.loadingProgressText.animate(true, 200)
feedBinding.swipeRefreshLayout.isRefreshing = true
isRefreshing = true
}
override fun hideLoading() {
@@ -275,6 +269,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
feedBinding.refreshRootView.animate(true, 200)
feedBinding.loadingProgressText.animate(false, 0)
feedBinding.swipeRefreshLayout.isRefreshing = false
isRefreshing = false
}
override fun showEmptyState() {
@@ -301,6 +296,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
feedBinding.refreshRootView.animate(false, 0)
feedBinding.loadingProgressText.animate(false, 0)
feedBinding.swipeRefreshLayout.isRefreshing = false
isRefreshing = false
}
private fun handleProgressState(progressState: FeedState.ProgressState) {
@@ -330,7 +326,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
if (context == null || context.resources == null || activity == null) return
val entries = ArrayList<StreamDialogEntry>()
if (PlayerHolder.getType() != null) {
if (PlayerHolder.getInstance().getType() != null) {
entries.add(StreamDialogEntry.enqueue)
}
if (item.streamType == StreamType.AUDIO_STREAM) {
@@ -354,6 +350,19 @@ class FeedFragment : BaseStateFragment<FeedState>() {
)
}
// show "mark as watched" only when watch history is enabled
val isWatchHistoryEnabled = PreferenceManager
.getDefaultSharedPreferences(context)
.getBoolean(getString(R.string.enable_watch_history_key), false)
if (item.streamType != StreamType.AUDIO_LIVE_STREAM &&
item.streamType != StreamType.LIVE_STREAM &&
isWatchHistoryEnabled
) {
entries.add(
StreamDialogEntry.mark_as_watched
)
}
StreamDialogEntry.setEnabledEntries(entries)
InfoItemDialog(activity, item, StreamDialogEntry.getCommands(context)) { _, which ->
StreamDialogEntry.clickOn(which, this, item)
@@ -362,7 +371,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
private val listenerStreamItem = object : OnItemClickListener, OnItemLongClickListener {
override fun onItemClick(item: Item<*>, view: View) {
if (item is StreamItem) {
if (item is StreamItem && !isRefreshing) {
val stream = item.streamWithState.stream
NavigationHelper.openVideoDetailFragment(
requireContext(), fm,
@@ -372,7 +381,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
}
override fun onItemLongClick(item: Item<*>, view: View): Boolean {
if (item is StreamItem) {
if (item is StreamItem && !isRefreshing) {
showStreamDialog(item.streamWithState.stream.toStreamInfoItem())
return true
}

View File

@@ -28,6 +28,7 @@ import org.schabi.newpipe.NewPipeDatabase;
import org.schabi.newpipe.R;
import org.schabi.newpipe.database.AppDatabase;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.database.feed.dao.FeedDAO;
import org.schabi.newpipe.database.history.dao.SearchHistoryDAO;
import org.schabi.newpipe.database.history.dao.StreamHistoryDAO;
import org.schabi.newpipe.database.history.model.SearchHistoryEntry;
@@ -42,7 +43,10 @@ import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.local.feed.FeedViewModel;
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
import org.schabi.newpipe.util.ExtractorHelper;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
@@ -81,6 +85,68 @@ public class HistoryRecordManager {
// Watch History
///////////////////////////////////////////////////////
/**
* Marks a stream item as watched such that it is hidden from the feed if watched videos are
* hidden. Adds a history entry and updates the stream progress to 100%.
*
* @see FeedDAO#getLiveOrNotPlayedStreams
* @see FeedViewModel#togglePlayedItems
* @param info the item to mark as watched
* @return a Maybe containing the ID of the item if successful
*/
public Maybe<Long> markAsWatched(final StreamInfoItem info) {
if (!isStreamHistoryEnabled()) {
return Maybe.empty();
}
final OffsetDateTime currentTime = OffsetDateTime.now(ZoneOffset.UTC);
return Maybe.fromCallable(() -> database.runInTransaction(() -> {
final long streamId;
final long duration;
// Duration will not exist if the item was loaded with fast mode, so fetch it if empty
if (info.getDuration() < 0) {
final StreamInfo completeInfo = ExtractorHelper.getStreamInfo(
info.getServiceId(),
info.getUrl(),
false
)
.subscribeOn(Schedulers.io())
.blockingGet();
duration = completeInfo.getDuration();
streamId = streamTable.upsert(new StreamEntity(completeInfo));
} else {
duration = info.getDuration();
streamId = streamTable.upsert(new StreamEntity(info));
}
// Update the stream progress to the full duration of the video
final List<StreamStateEntity> states = streamStateTable.getState(streamId)
.blockingFirst();
if (!states.isEmpty()) {
final StreamStateEntity entity = states.get(0);
entity.setProgressMillis(duration * 1000);
streamStateTable.update(entity);
} else {
final StreamStateEntity entity = new StreamStateEntity(
streamId,
duration * 1000
);
streamStateTable.insert(entity);
}
// Add a history entry
final StreamHistoryEntity latestEntry = streamHistoryTable.getLatestEntry(streamId);
if (latestEntry != null) {
streamHistoryTable.delete(latestEntry);
latestEntry.setAccessDate(currentTime);
latestEntry.setRepeatCount(latestEntry.getRepeatCount() + 1);
return streamHistoryTable.insert(latestEntry);
} else {
return streamHistoryTable.insert(new StreamHistoryEntity(streamId, currentTime));
}
})).subscribeOn(Schedulers.io());
}
public Maybe<Long> onViewed(final StreamInfo info) {
if (!isStreamHistoryEnabled()) {
return Maybe.empty();

View File

@@ -340,7 +340,7 @@ public class StatisticsPlaylistFragment
final ArrayList<StreamDialogEntry> entries = new ArrayList<>();
if (PlayerHolder.getType() != null) {
if (PlayerHolder.getInstance().getType() != null) {
entries.add(StreamDialogEntry.enqueue);
}
if (infoItem.getStreamType() == StreamType.AUDIO_STREAM) {

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@@ -13,7 +14,6 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -32,6 +32,7 @@ import org.schabi.newpipe.database.history.model.StreamHistoryEntry;
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry;
import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
import org.schabi.newpipe.databinding.DialogEditTextBinding;
import org.schabi.newpipe.databinding.LocalPlaylistHeaderBinding;
import org.schabi.newpipe.databinding.PlaylistControlBinding;
import org.schabi.newpipe.error.ErrorInfo;
@@ -526,18 +527,20 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
return;
}
final View dialogView = View.inflate(getContext(), R.layout.dialog_playlist_name, null);
final EditText nameEdit = dialogView.findViewById(R.id.playlist_name);
nameEdit.setText(name);
nameEdit.setSelection(nameEdit.getText().length());
final DialogEditTextBinding dialogBinding
= DialogEditTextBinding.inflate(getLayoutInflater());
dialogBinding.dialogEditText.setHint(R.string.name);
dialogBinding.dialogEditText.setInputType(InputType.TYPE_CLASS_TEXT);
dialogBinding.dialogEditText.setSelection(dialogBinding.dialogEditText.getText().length());
dialogBinding.dialogEditText.setText(name);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext())
.setTitle(R.string.rename_playlist)
.setView(dialogView)
.setView(dialogBinding.getRoot())
.setCancelable(true)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.rename, (dialogInterface, i) ->
changePlaylistName(nameEdit.getText().toString()));
changePlaylistName(dialogBinding.dialogEditText.getText().toString()));
dialogBuilder.show();
}
@@ -750,7 +753,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
final ArrayList<StreamDialogEntry> entries = new ArrayList<>();
if (PlayerHolder.getType() != null) {
if (PlayerHolder.getInstance().getType() != null) {
entries.add(StreamDialogEntry.enqueue);
}
if (infoItem.getStreamType() == StreamType.AUDIO_STREAM) {

View File

@@ -58,7 +58,7 @@ import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService
import org.schabi.newpipe.streams.io.StoredFileHelper
import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.OnClickGesture
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCount
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountChannels
import org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout
import org.schabi.newpipe.util.external_communication.ShareUtils
import java.text.SimpleDateFormat
@@ -110,13 +110,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
setupInitialLayout()
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
if (activity != null && isVisibleToUser) {
setTitle(activity.getString(R.string.tab_subscriptions))
}
}
override fun onAttach(context: Context) {
super.onAttach(context)
subscriptionManager = SubscriptionManager(requireContext())
@@ -154,11 +147,8 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
val supportActionBar = activity.supportActionBar
if (supportActionBar != null) {
supportActionBar.setDisplayShowTitleEnabled(true)
setTitle(getString(R.string.tab_subscriptions))
}
activity.supportActionBar?.setDisplayShowTitleEnabled(true)
activity.supportActionBar?.setTitle(R.string.tab_subscriptions)
}
private fun setupBroadcastReceiver() {
@@ -277,7 +267,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
super.initViews(rootView, savedInstanceState)
_binding = FragmentSubscriptionBinding.bind(rootView)
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCount(context) else 1
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCountChannels(context) else 1
binding.itemsList.layoutManager = GridLayoutManager(requireContext(), groupAdapter.spanCount).apply {
spanSizeLookup = groupAdapter.spanSizeLookup
}

View File

@@ -178,7 +178,10 @@ public final class MainPlayer extends Service {
if (DEBUG) {
Log.d(TAG, "destroy() called");
}
cleanup();
}
private void cleanup() {
if (player != null) {
// Exit from fullscreen when user closes the player via notification
if (player.isFullscreen()) {
@@ -191,9 +194,14 @@ public final class MainPlayer extends Service {
player.stopActivityBinding();
player.removePopupFromView();
player.destroy();
}
player = null;
}
}
public void stopService() {
NotificationUtil.getInstance().cancelNotificationAndStopForeground(this);
cleanup();
stopSelf();
}

View File

@@ -1,5 +1,9 @@
package org.schabi.newpipe.player;
import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -40,15 +44,12 @@ import org.schabi.newpipe.player.playqueue.PlayQueueItemTouchCallback;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.ThemeHelper;
import java.util.Collections;
import java.util.List;
import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText;
public final class PlayQueueActivity extends AppCompatActivity
implements PlayerEventListener, SeekBar.OnSeekBarChangeListener,
View.OnClickListener, PlaybackParameterDialog.Callback {
@@ -83,7 +84,7 @@ public final class PlayQueueActivity extends AppCompatActivity
protected void onCreate(final Bundle savedInstanceState) {
assureCorrectAppLanguage(this);
super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this);
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
queueControlBinding = ActivityPlayerQueueControlBinding.inflate(getLayoutInflater());
setContentView(queueControlBinding.getRoot());

File diff suppressed because it is too large Load Diff

View File

@@ -8,6 +8,7 @@ import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
@@ -22,18 +23,27 @@ import org.schabi.newpipe.player.event.PlayerServiceExtendedEventListener;
import org.schabi.newpipe.player.playqueue.PlayQueue;
public final class PlayerHolder {
private PlayerHolder() {
}
private static final boolean DEBUG = MainActivity.DEBUG;
private static final String TAG = "PlayerHolder";
private static PlayerHolder instance;
public static synchronized PlayerHolder getInstance() {
if (PlayerHolder.instance == null) {
PlayerHolder.instance = new PlayerHolder();
}
return PlayerHolder.instance;
}
private static PlayerServiceExtendedEventListener listener;
private final boolean DEBUG = MainActivity.DEBUG;
private final String TAG = PlayerHolder.class.getSimpleName();
private static ServiceConnection serviceConnection;
public static boolean bound;
private static MainPlayer playerService;
private static Player player;
private PlayerServiceExtendedEventListener listener;
private final PlayerServiceConnection serviceConnection = new PlayerServiceConnection();
public boolean bound;
private MainPlayer playerService;
private Player player;
/**
* Returns the current {@link MainPlayer.PlayerType} of the {@link MainPlayer} service,
@@ -42,26 +52,31 @@ public final class PlayerHolder {
* @return Current PlayerType
*/
@Nullable
public static MainPlayer.PlayerType getType() {
public MainPlayer.PlayerType getType() {
if (player == null) {
return null;
}
return player.getPlayerType();
}
public static boolean isPlaying() {
public boolean isPlaying() {
if (player == null) {
return false;
}
return player.isPlaying();
}
public static boolean isPlayerOpen() {
public boolean isPlayerOpen() {
return player != null;
}
public static void setListener(final PlayerServiceExtendedEventListener newListener) {
public void setListener(@Nullable final PlayerServiceExtendedEventListener newListener) {
listener = newListener;
if (listener == null) {
return;
}
// Force reload data from service
if (player != null) {
listener.onServiceConnected(player, playerService, false);
@@ -69,14 +84,15 @@ public final class PlayerHolder {
}
}
public static void removeListener() {
listener = null;
// helper to handle context in common place as using the same
// context to bind/unbind a service is crucial
private Context getCommonContext() {
return App.getApp();
}
public static void startService(final Context context,
final boolean playAfterConnect,
final PlayerServiceExtendedEventListener newListener) {
public void startService(final boolean playAfterConnect,
final PlayerServiceExtendedEventListener newListener) {
final Context context = getCommonContext();
setListener(newListener);
if (bound) {
return;
@@ -85,58 +101,65 @@ public final class PlayerHolder {
// and NullPointerExceptions inside the service because the service will be
// bound twice. Prevent it with unbinding first
unbind(context);
context.startService(new Intent(context, MainPlayer.class));
serviceConnection = getServiceConnection(context, playAfterConnect);
ContextCompat.startForegroundService(context, new Intent(context, MainPlayer.class));
serviceConnection.doPlayAfterConnect(playAfterConnect);
bind(context);
}
public static void stopService(final Context context) {
public void stopService() {
final Context context = getCommonContext();
unbind(context);
context.stopService(new Intent(context, MainPlayer.class));
}
private static ServiceConnection getServiceConnection(final Context context,
final boolean playAfterConnect) {
return new ServiceConnection() {
@Override
public void onServiceDisconnected(final ComponentName compName) {
if (DEBUG) {
Log.d(TAG, "Player service is disconnected");
}
class PlayerServiceConnection implements ServiceConnection {
unbind(context);
private boolean playAfterConnect = false;
public void doPlayAfterConnect(final boolean playAfterConnection) {
this.playAfterConnect = playAfterConnection;
}
@Override
public void onServiceDisconnected(final ComponentName compName) {
if (DEBUG) {
Log.d(TAG, "Player service is disconnected");
}
@Override
public void onServiceConnected(final ComponentName compName, final IBinder service) {
if (DEBUG) {
Log.d(TAG, "Player service is connected");
}
final MainPlayer.LocalBinder localBinder = (MainPlayer.LocalBinder) service;
final Context context = getCommonContext();
unbind(context);
}
playerService = localBinder.getService();
player = localBinder.getPlayer();
if (listener != null) {
listener.onServiceConnected(player, playerService, playAfterConnect);
}
startPlayerListener();
@Override
public void onServiceConnected(final ComponentName compName, final IBinder service) {
if (DEBUG) {
Log.d(TAG, "Player service is connected");
}
};
}
final MainPlayer.LocalBinder localBinder = (MainPlayer.LocalBinder) service;
private static void bind(final Context context) {
playerService = localBinder.getService();
player = localBinder.getPlayer();
if (listener != null) {
listener.onServiceConnected(player, playerService, playAfterConnect);
}
startPlayerListener();
}
};
private void bind(final Context context) {
if (DEBUG) {
Log.d(TAG, "bind() called");
}
final Intent serviceIntent = new Intent(context, MainPlayer.class);
bound = context.bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
bound = context.bindService(serviceIntent, serviceConnection,
Context.BIND_AUTO_CREATE);
if (!bound) {
context.unbindService(serviceConnection);
}
}
private static void unbind(final Context context) {
private void unbind(final Context context) {
if (DEBUG) {
Log.d(TAG, "unbind() called");
}
@@ -153,21 +176,19 @@ public final class PlayerHolder {
}
}
private static void startPlayerListener() {
private void startPlayerListener() {
if (player != null) {
player.setFragmentListener(INNER_LISTENER);
player.setFragmentListener(internalListener);
}
}
private static void stopPlayerListener() {
private void stopPlayerListener() {
if (player != null) {
player.removeFragmentListener(INNER_LISTENER);
player.removeFragmentListener(internalListener);
}
}
private static final PlayerServiceEventListener INNER_LISTENER =
private final PlayerServiceEventListener internalListener =
new PlayerServiceEventListener() {
@Override
public void onFullscreenStateChanged(final boolean fullscreen) {
@@ -242,7 +263,7 @@ public final class PlayerHolder {
if (listener != null) {
listener.onServiceStopped();
}
unbind(App.getApp());
unbind(getCommonContext());
}
};
}

View File

@@ -0,0 +1,62 @@
package org.schabi.newpipe.player.playback;
import android.content.Context;
import android.view.SurfaceHolder;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.video.DummySurface;
/**
* Prevent error message: 'Unrecoverable player error occurred'
* In case of rotation some users see this kind of an error which is preventable
* having a Callback that handles the lifecycle of the surface.
* <p>
* How?: In case we are no longer able to write to the surface eg. through rotation/putting in
* background we set set a DummySurface. Although it it works on API >= 23 only.
* Result: we get a little video interruption (audio is still fine) but we won't get the
* 'Unrecoverable player error occurred' error message.
* <p>
* This implementation is based on:
* 'ExoPlayer stuck in buffering after re-adding the surface view a few time #2703'
* <p>
* -> exoplayer fix suggestion link
* https://github.com/google/ExoPlayer/issues/2703#issuecomment-300599981
*/
public final class SurfaceHolderCallback implements SurfaceHolder.Callback {
private final Context context;
private final SimpleExoPlayer player;
private DummySurface dummySurface;
public SurfaceHolderCallback(final Context context, final SimpleExoPlayer player) {
this.context = context;
this.player = player;
}
@Override
public void surfaceCreated(final SurfaceHolder holder) {
player.setVideoSurface(holder.getSurface());
}
@Override
public void surfaceChanged(final SurfaceHolder holder,
final int format,
final int width,
final int height) {
}
@Override
public void surfaceDestroyed(final SurfaceHolder holder) {
if (dummySurface == null) {
dummySurface = DummySurface.newInstanceV17(context, false);
}
player.setVideoSurface(dummySurface);
}
public void release() {
if (dummySurface != null) {
dummySurface.release();
dummySurface = null;
}
}
}

View File

@@ -64,20 +64,6 @@ public class PlayQueueItem implements Serializable {
this.recoveryPosition = RECOVERY_UNSET;
}
@Override
public boolean equals(final Object o) {
if (o instanceof PlayQueueItem) {
return url.equals(((PlayQueueItem) o).url);
} else {
return false;
}
}
@Override
public int hashCode() {
return url.hashCode();
}
@NonNull
public String getTitle() {
return title;

View File

@@ -0,0 +1,108 @@
package org.schabi.newpipe.player.seekbarpreview;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import org.schabi.newpipe.R;
import org.schabi.newpipe.util.DeviceUtils;
import java.lang.annotation.Retention;
import java.util.Objects;
import java.util.Optional;
import java.util.function.IntSupplier;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import static org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper.SeekbarPreviewThumbnailType.HIGH_QUALITY;
import static org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper.SeekbarPreviewThumbnailType.LOW_QUALITY;
import static org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper.SeekbarPreviewThumbnailType.NONE;
/**
* Helper for the seekbar preview.
*/
public final class SeekbarPreviewThumbnailHelper {
// This has to be <= 23 chars on devices running Android 7 or lower (API <= 25)
// or it fails with an IllegalArgumentException
// https://stackoverflow.com/a/54744028
public static final String TAG = "SeekbarPrevThumbHelper";
private SeekbarPreviewThumbnailHelper() {
// No impl pls
}
@Retention(SOURCE)
@IntDef({HIGH_QUALITY, LOW_QUALITY,
NONE})
public @interface SeekbarPreviewThumbnailType {
int HIGH_QUALITY = 0;
int LOW_QUALITY = 1;
int NONE = 2;
}
////////////////////////////////////////////////////////////////////////////
// Settings Resolution
///////////////////////////////////////////////////////////////////////////
@SeekbarPreviewThumbnailType
public static int getSeekbarPreviewThumbnailType(@NonNull final Context context) {
final String type = PreferenceManager.getDefaultSharedPreferences(context).getString(
context.getString(R.string.seekbar_preview_thumbnail_key), "");
if (type.equals(context.getString(R.string.seekbar_preview_thumbnail_none))) {
return NONE;
} else if (type.equals(context.getString(R.string.seekbar_preview_thumbnail_low_quality))) {
return LOW_QUALITY;
} else {
return HIGH_QUALITY; // default
}
}
public static void tryResizeAndSetSeekbarPreviewThumbnail(
@NonNull final Context context,
@NonNull final Optional<Bitmap> optPreviewThumbnail,
@NonNull final ImageView currentSeekbarPreviewThumbnail,
@NonNull final IntSupplier baseViewWidthSupplier) {
if (!optPreviewThumbnail.isPresent()) {
currentSeekbarPreviewThumbnail.setVisibility(View.GONE);
return;
}
currentSeekbarPreviewThumbnail.setVisibility(View.VISIBLE);
final Bitmap srcBitmap = optPreviewThumbnail.get();
// Resize original bitmap
try {
Objects.requireNonNull(srcBitmap);
final int srcWidth = srcBitmap.getWidth() > 0 ? srcBitmap.getWidth() : 1;
final int newWidth = Math.max(
Math.min(
// Use 1/4 of the width for the preview
Math.round(baseViewWidthSupplier.getAsInt() / 4f),
// Scaling more than that factor looks really pixelated -> max
Math.round(srcWidth * 2.5f)
),
// Min width = 10dp
DeviceUtils.dpToPx(10, context)
);
final float scaleFactor = (float) newWidth / srcWidth;
final int newHeight = (int) (srcBitmap.getHeight() * scaleFactor);
currentSeekbarPreviewThumbnail.setImageBitmap(
Bitmap.createScaledBitmap(srcBitmap, newWidth, newHeight, true));
} catch (final Exception ex) {
Log.e(TAG, "Failed to resize and set seekbar preview thumbnail", ex);
currentSeekbarPreviewThumbnail.setVisibility(View.GONE);
} finally {
srcBitmap.recycle();
}
}
}

View File

@@ -0,0 +1,252 @@
package org.schabi.newpipe.player.seekbarpreview;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.common.base.Stopwatch;
import com.nostra13.universalimageloader.core.ImageLoader;
import org.schabi.newpipe.extractor.stream.Frameset;
import org.schabi.newpipe.util.ImageDisplayConstants;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import static org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper.SeekbarPreviewThumbnailType;
public class SeekbarPreviewThumbnailHolder {
// This has to be <= 23 chars on devices running Android 7 or lower (API <= 25)
// or it fails with an IllegalArgumentException
// https://stackoverflow.com/a/54744028
public static final String TAG = "SeekbarPrevThumbHolder";
// Key = Position of the picture in milliseconds
// Supplier = Supplies the bitmap for that position
private final Map<Integer, Supplier<Bitmap>> seekbarPreviewData = new ConcurrentHashMap<>();
// This ensures that if the reset is still undergoing
// and another reset starts, only the last reset is processed
private UUID currentUpdateRequestIdentifier = UUID.randomUUID();
public synchronized void resetFrom(
@NonNull final Context context,
final List<Frameset> framesets) {
final int seekbarPreviewType =
SeekbarPreviewThumbnailHelper.getSeekbarPreviewThumbnailType(context);
final UUID updateRequestIdentifier = UUID.randomUUID();
this.currentUpdateRequestIdentifier = updateRequestIdentifier;
final ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
try {
resetFromAsync(seekbarPreviewType, framesets, updateRequestIdentifier);
} catch (final Exception ex) {
Log.e(TAG, "Failed to execute async", ex);
}
});
// ensure that the executorService stops/destroys it's threads
// after the task is finished
executorService.shutdown();
}
private void resetFromAsync(
final int seekbarPreviewType,
final List<Frameset> framesets,
final UUID updateRequestIdentifier) {
Log.d(TAG, "Clearing seekbarPreviewData");
seekbarPreviewData.clear();
if (seekbarPreviewType == SeekbarPreviewThumbnailType.NONE) {
Log.d(TAG, "Not processing seekbarPreviewData due to settings");
return;
}
final Frameset frameset = getFrameSetForType(framesets, seekbarPreviewType);
if (frameset == null) {
Log.d(TAG, "No frameset was found to fill seekbarPreviewData");
return;
}
Log.d(TAG, "Frameset quality info: "
+ "[width=" + frameset.getFrameWidth()
+ ", heigh=" + frameset.getFrameHeight() + "]");
// Abort method execution if we are not the latest request
if (!isRequestIdentifierCurrent(updateRequestIdentifier)) {
return;
}
generateDataFrom(frameset, updateRequestIdentifier);
}
private Frameset getFrameSetForType(
final List<Frameset> framesets,
final int seekbarPreviewType) {
if (seekbarPreviewType == SeekbarPreviewThumbnailType.HIGH_QUALITY) {
Log.d(TAG, "Strategy for seekbarPreviewData: high quality");
return framesets.stream()
.max(Comparator.comparingInt(fs -> fs.getFrameHeight() * fs.getFrameWidth()))
.orElse(null);
} else {
Log.d(TAG, "Strategy for seekbarPreviewData: low quality");
return framesets.stream()
.min(Comparator.comparingInt(fs -> fs.getFrameHeight() * fs.getFrameWidth()))
.orElse(null);
}
}
private void generateDataFrom(
final Frameset frameset,
final UUID updateRequestIdentifier) {
Log.d(TAG, "Starting generation of seekbarPreviewData");
final Stopwatch sw = Log.isLoggable(TAG, Log.DEBUG) ? Stopwatch.createStarted() : null;
int currentPosMs = 0;
int pos = 1;
final int frameCountPerUrl = frameset.getFramesPerPageX() * frameset.getFramesPerPageY();
// Process each url in the frameset
for (final String url : frameset.getUrls()) {
// get the bitmap
final Bitmap srcBitMap = getBitMapFrom(url);
// The data is not added directly to "seekbarPreviewData" due to
// concurrency and checks for "updateRequestIdentifier"
final Map<Integer, Supplier<Bitmap>> generatedDataForUrl = new HashMap<>();
// The bitmap consists of several images, which we process here
// foreach frame in the returned bitmap
for (int i = 0; i < frameCountPerUrl; i++) {
// Frames outside the video length are skipped
if (pos > frameset.getTotalCount()) {
break;
}
// Get the bounds where the frame is found
final int[] bounds = frameset.getFrameBoundsAt(currentPosMs);
generatedDataForUrl.put(currentPosMs, () -> {
// It can happen, that the original bitmap could not be downloaded
// In such a case - we don't want a NullPointer - simply return null
if (srcBitMap == null) {
return null;
}
// Cut out the corresponding bitmap form the "srcBitMap"
return Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2],
frameset.getFrameWidth(), frameset.getFrameHeight());
});
currentPosMs += frameset.getDurationPerFrame();
pos++;
}
// Check if we are still the latest request
// If not abort method execution
if (isRequestIdentifierCurrent(updateRequestIdentifier)) {
seekbarPreviewData.putAll(generatedDataForUrl);
} else {
Log.d(TAG, "Aborted of generation of seekbarPreviewData");
break;
}
}
if (sw != null) {
Log.d(TAG, "Generation of seekbarPreviewData took " + sw.stop().toString());
}
}
private Bitmap getBitMapFrom(final String url) {
if (url == null) {
Log.w(TAG, "url is null; This should never happen");
return null;
}
final Stopwatch sw = Log.isLoggable(TAG, Log.DEBUG) ? Stopwatch.createStarted() : null;
try {
final SyncImageLoadingListener syncImageLoadingListener =
new SyncImageLoadingListener();
Log.d(TAG, "Downloading bitmap for seekbarPreview from '" + url + "'");
// Ensure that everything is running
ImageLoader.getInstance().resume();
// Load the image
// Impl-Note:
// Ensure that your are not running on the main-Thread this will otherwise hang
ImageLoader.getInstance().loadImage(
url,
ImageDisplayConstants.DISPLAY_SEEKBAR_PREVIEW_OPTIONS,
syncImageLoadingListener);
// Get the bitmap within the timeout
final Bitmap bitmap =
syncImageLoadingListener.waitForBitmapOrThrow(30, TimeUnit.SECONDS);
if (sw != null) {
Log.d(TAG,
"Download of bitmap for seekbarPreview from '" + url
+ "' took " + sw.stop().toString());
}
return bitmap;
} catch (final Exception ex) {
Log.w(TAG,
"Failed to get bitmap for seekbarPreview from url='" + url
+ "' in time",
ex);
return null;
}
}
private boolean isRequestIdentifierCurrent(final UUID requestIdentifier) {
return this.currentUpdateRequestIdentifier.equals(requestIdentifier);
}
public Optional<Bitmap> getBitmapAt(final int positionInMs) {
// Check if the BitmapData is empty
if (seekbarPreviewData.isEmpty()) {
return Optional.empty();
}
// Get the closest frame to the requested position
final int closestIndexPosition =
seekbarPreviewData.keySet().stream()
.min(Comparator.comparingInt(i -> Math.abs(i - positionInMs)))
.orElse(-1);
// this should never happen, because
// it indicates that "seekbarPreviewData" is empty which was already checked
if (closestIndexPosition == -1) {
return Optional.empty();
}
try {
// Get the bitmap for the position (executes the supplier)
return Optional.ofNullable(seekbarPreviewData.get(closestIndexPosition).get());
} catch (final Exception ex) {
// If there is an error, log it and return Optional.empty
Log.w(TAG, "Unable to get seekbar preview", ex);
return Optional.empty();
}
}
}

View File

@@ -0,0 +1,87 @@
package org.schabi.newpipe.player.seekbarpreview;
import android.graphics.Bitmap;
import android.view.View;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* Listener for synchronously downloading of an image/bitmap.
*/
public class SyncImageLoadingListener extends SimpleImageLoadingListener {
private final CountDownLatch countDownLatch = new CountDownLatch(1);
private Bitmap bitmap;
private boolean cancelled = false;
private FailReason failReason = null;
@SuppressWarnings("checkstyle:HiddenField")
@Override
public void onLoadingFailed(
final String imageUri,
final View view,
final FailReason failReason) {
this.failReason = failReason;
countDownLatch.countDown();
}
@Override
public void onLoadingComplete(
final String imageUri,
final View view,
final Bitmap loadedImage) {
bitmap = loadedImage;
countDownLatch.countDown();
}
@Override
public void onLoadingCancelled(final String imageUri, final View view) {
cancelled = true;
countDownLatch.countDown();
}
public Bitmap waitForBitmapOrThrow(final long timeout, final TimeUnit timeUnit)
throws InterruptedException, TimeoutException {
// Wait for the download to finish
if (!countDownLatch.await(timeout, timeUnit)) {
throw new TimeoutException("Couldn't get the image in time");
}
if (isCancelled()) {
throw new CancellationException("Download of image was cancelled");
}
if (getFailReason() != null) {
throw new RuntimeException("Failed to download image" + getFailReason().getType(),
getFailReason().getCause());
}
if (getBitmap() == null) {
throw new NullPointerException("Bitmap is null");
}
return getBitmap();
}
public Bitmap getBitmap() {
return bitmap;
}
public boolean isCancelled() {
return cancelled;
}
public FailReason getFailReason() {
return failReason;
}
}

Some files were not shown because too many files have changed in this diff Show More