From 3de1836a2f8d7a645197e9d7eb846829dfd47f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9clairevoyant?= <848000+eclairevoyant@users.noreply.github.com> Date: Fri, 21 Oct 2022 03:25:42 -0400 Subject: [PATCH 001/516] fix: handle duration string timestamps (#1275) --- .../libretube/ui/activities/RouterActivity.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/activities/RouterActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/RouterActivity.kt index e66f02fd2..e231584e6 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/RouterActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/RouterActivity.kt @@ -10,6 +10,7 @@ import com.github.libretube.constants.IntentData import com.github.libretube.extensions.TAG import com.github.libretube.ui.base.BaseActivity import com.github.libretube.util.NavigationHelper +import kotlin.time.Duration class RouterActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -75,14 +76,14 @@ class RouterActivity : BaseActivity() { intent.putExtra(IntentData.videoId, videoId) uri.getQueryParameter("t") - ?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) } + ?.let { intent.putExtra(IntentData.timeStamp, parseTimestamp(it)) } } else -> { val videoId = uri.path!!.replace("/", "") intent.putExtra(IntentData.videoId, videoId) uri.getQueryParameter("t") - ?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) } + ?.let { intent.putExtra(IntentData.timeStamp, parseTimestamp(it)) } } } return intent @@ -99,4 +100,12 @@ class RouterActivity : BaseActivity() { ) this.finishAndRemoveTask() } + + private fun parseTimestamp(t: String): Long? { + if (t.all { c -> c.isDigit() }) { + return t.toLong() + } + + return Duration.parseOrNull(t)?.inWholeSeconds + } } From a10ce9ae78c16dd6212425f6076e8fb70bac479f Mon Sep 17 00:00:00 2001 From: Bnyro <82752168+Bnyro@users.noreply.github.com> Date: Fri, 21 Oct 2022 16:11:53 +0000 Subject: [PATCH 002/516] Fix grammar in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a112cfb4f..6b870061c 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ If creating a pull request, please make sure to format your code (preferred ktli Translation status -## 🌗 Differences from NewPipe +## 🌗 Differences to NewPipe With NewPipe, the extraction is done locally on your phone, and all the requests sent towards YouTube/Google are done directly from the network you're connected to, which doesn't use a middleman server in between. Therefore, Google can still access information such as the user's IP address. Aside from that, subscriptions can only be stored locally. From b0bb7f0c94c8753e507e430efc2afaf45de39f59 Mon Sep 17 00:00:00 2001 From: Fjuro Date: Thu, 20 Oct 2022 18:23:20 +0000 Subject: [PATCH 003/516] Translated using Weblate (Czech) Currently translated at 100.0% (354 of 354 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/cs/ --- app/src/main/res/values-cs/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 1e8b95107..88dff6138 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -353,4 +353,5 @@ Nedávno aktualizované (obráceně) Časové razítko Zobrazit více + Přidáno do playlistu \ No newline at end of file From 703f5be96a378e442a35372de325edd117a4721a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81cs=20Zolt=C3=A1n?= Date: Thu, 20 Oct 2022 05:31:36 +0000 Subject: [PATCH 004/516] Translated using Weblate (Hungarian) Currently translated at 98.8% (350 of 354 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/hu/ --- app/src/main/res/values-hu/strings.xml | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index f2407f261..d0bd3b3c4 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -140,7 +140,7 @@ Divatos tűz Trendi fáklya Forgalmi díjas - V %1$s + Verzió: %1$s Ismerje meg a LibreTube csapatát és azt, hogy hogyan történik mindez. Hiba Másolva @@ -225,7 +225,7 @@ Töltse be a nevet és az API URL-t. Maximális másodpercnyi videó a puffereléshez. Léptetés időköze - Újraindítja az alkalmazást\? + Ehhez a módosításhoz az alkalmazás újraindítása szükséges. Nyomja meg az \'Ok\' gombot az újraindításhoz. Tiszta fehér/fekete téma Adattakarékos üzemmód Videó előnézet @@ -319,7 +319,7 @@ Mobiladat Indikátor az új videókhoz Jelvény megjelenítése az új videók számával, ha több van. - Törlés + Törlés a letöltésekből Lejátszási lista átnevezése Helyi feliratkozások Beállítások @@ -333,4 +333,25 @@ Értesítés megjelenítése média letöltésekor. Válasszon ki legalább egy elemet megtekintés + Egy alacsonyabb érték lehet, hogy felgyorsítja a kezdeti videóbetöltést. + A feliratkozott videók folyamának betöltése a háttérben, és annak megakadályozása, hogy automatikusan frissüljön. + Megjelenít egy értesítést a hanglejátszó vezérlésére szolgáló gombokkal. + Szegmens kihagyása + Manuális kihagyás + Ne hagyja ki a szegmenseket automatikusan, mindig kérdezzen előtte. + Alapértelmezett + Hangmagasság + Progresszív betöltési intervallum mérete + Videófolyam betöltése a háttérben + A felkapott úgy tűnik, hogy nem elérhető a jelenlegi régió számára. Válasszon egy másikat a beállításokban. + Hozzáadva a lejátszási listához + HLS korlátozása 1080p-re + Érvénytelen fájlnév! + Fájlnév + Lejátszási lista neve (fordítva) + Lejátszási lista sorrend + Mostanában frissített + Mostanában frissített (fordítva) + Több megjelenítése + Időpont \ No newline at end of file From f1068380efbd90d3a4ed9f35165ae6914ad70c33 Mon Sep 17 00:00:00 2001 From: Daniel Rozario Date: Thu, 20 Oct 2022 10:01:08 +0000 Subject: [PATCH 005/516] Translated using Weblate (Bengali) Currently translated at 92.0% (326 of 354 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/bn/ --- app/src/main/res/values-bn/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index d7407183c..066674153 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -323,4 +323,8 @@ খুলুন মান এবং ফর্ম্যাট প্লেলিস্ট পুনঃনামকরণ + সরাসরি সেগমেন্ট স্কিপ না করে প্রমট দেখান। + Metered + নতুন ভিডিওর সংখ্যাসহ ব্যাজ দেখান। + পছন্দসমূহ \ No newline at end of file From b499eb0358ed65452a4d4c709fcb9feb6109880f Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 21 Oct 2022 18:25:35 +0200 Subject: [PATCH 006/516] sort qualities --- .../libretube/ui/fragments/PlayerFragment.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index b54c098b7..5606b1bbb 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -1153,7 +1153,22 @@ class PlayerFragment : BaseFragment() { videosUrlArray += streams.hls!!.toUri() } - for (vid in streams.videoStreams!!) { + val videoStreams = try { + // attempt to sort the qualities, catch if there was an error ih parsing + streams.videoStreams?.sortedBy { + it.quality + .toString() + .split("p") + .first() + .replace("p", "") + .toLong() + }?.reversed() + .orEmpty() + } catch (_: Exception) { + streams.videoStreams.orEmpty() + } + + for (vid in videoStreams) { // append quality to list if it has the preferred format (e.g. MPEG) val preferredMimeType = "video/${PlayerHelper.videoFormatPreference}" if (vid.url != null && vid.mimeType == preferredMimeType) { // preferred format From 3b13cc4efbb354646d839629454087347e9b17b0 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 21 Oct 2022 18:35:35 +0200 Subject: [PATCH 007/516] Fix the wrong error on the subscriptions page --- .../com/github/libretube/services/BackgroundMode.kt | 13 ++++++++----- .../libretube/ui/fragments/SubscriptionsFragment.kt | 5 ++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 226643432..9cda3e3cc 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -100,18 +100,21 @@ class BackgroundMode : Service() { */ override fun onCreate() { super.onCreate() - if (Build.VERSION.SDK_INT >= 26) { - val channelId = BACKGROUND_CHANNEL_ID + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel( - channelId, + BACKGROUND_CHANNEL_ID, "Background Service", NotificationManager.IMPORTANCE_DEFAULT ) val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager notificationManager.createNotificationChannel(channel) - val notification: Notification = Notification.Builder(this, channelId) + + // see https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification) + val notification: Notification = Notification.Builder(this, BACKGROUND_CHANNEL_ID) .setContentTitle(getString(R.string.app_name)) - .setContentText(getString(R.string.playingOnBackground)).build() + .setContentText(getString(R.string.playingOnBackground)) + .build() + startForeground(PLAYER_NOTIFICATION_ID, notification) } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt index 7af018805..5b6fb34e5 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt @@ -62,7 +62,10 @@ class SubscriptionsFragment : BaseFragment() { // listen for error responses viewModel.errorResponse.observe(viewLifecycleOwner) { - if (it) Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() + if (it) { + Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() + viewModel.errorResponse.value = false + } } viewModel.videoFeed.observe(viewLifecycleOwner) { From 234ca8c08f766b4628dbe43c44446956dbfed11f Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sat, 22 Oct 2022 14:59:33 +0530 Subject: [PATCH 008/516] Simplified the download notification --- .../com/github/libretube/services/DownloadService.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index dc5893993..706dcff04 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -48,7 +48,7 @@ class DownloadService : Service() { } if (downloadType != DownloadType.NONE) { - downloadManager() + downloadManager(videoName) } else { onDestroy() } @@ -60,7 +60,7 @@ class DownloadService : Service() { TODO("Not yet implemented") } - private fun downloadManager() { + private fun downloadManager(videoName: String) { // initialize and create the directories to download into val videoDownloadDir = DownloadHelper.getVideoDir(this) @@ -74,7 +74,7 @@ class DownloadService : Service() { ) if (downloadType in listOf(DownloadType.VIDEO, DownloadType.AUDIO_VIDEO)) { videoDownloadId = downloadManagerRequest( - getString(R.string.video), + videoName, getString(R.string.downloading), videoUrl, Uri.fromFile( @@ -82,9 +82,9 @@ class DownloadService : Service() { ) ) } - if (downloadType in listOf(DownloadType.AUDIO, DownloadType.AUDIO_VIDEO)) { + else if (downloadType in listOf(DownloadType.AUDIO, DownloadType.AUDIO_VIDEO)) { audioDownloadId = downloadManagerRequest( - getString(R.string.audio), + videoName, getString(R.string.downloading), audioUrl, Uri.fromFile( From cef6f8df53a543954a46934aec898851c4cad8fc Mon Sep 17 00:00:00 2001 From: rozari0 Date: Sat, 22 Oct 2022 16:36:11 +0600 Subject: [PATCH 009/516] Sign debug APK. --- .github/tg.py | 2 +- .github/workflows/ci.yml | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/tg.py b/.github/tg.py index 0c99f83ba..d6014548d 100644 --- a/.github/tg.py +++ b/.github/tg.py @@ -21,7 +21,7 @@ def bot(): Signed-off-by: {data['commit']['author']['name']} ''', parse_mode=telegram.ParseMode.MARKDOWN) - bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-universal-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))]) + bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-universal-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-x86-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug-signed.apk', 'rb'))]) system('killall -9 python') if __name__ == '__main__': diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c86d6a6c6..ffbea94b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,17 @@ jobs: cd .. ./gradlew assembleDebug + - name: Sign Apk + id: sign_apk + uses: ilharp/sign-android-release@v1 + with: + releaseDir: app/build/outputs/apk/debug + signingKey: ${{ secrets.ANDROID_SIGNING_KEY }} + keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }} + keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} + + - name: Upload to Archive continue-on-error: true run: | @@ -61,7 +72,7 @@ jobs: echo "GH_REPO = '${{ github.repository }}'" > tgconfig.py git clone https://github.com/LibreTubeAlpha/Archive archive rm -rf archive/*.apk - mv app/build/outputs/apk/debug/*.apk archive/ + mv app/build/outputs/apk/debug/*-signed.apk archive/ cd archive python ../uploader.py @@ -86,4 +97,5 @@ jobs: uses: actions/upload-artifact@v3 with: name: app - path: archive/*.apk + path: archive/*-signed.apk + From 886835f12899a85ab8a76ef91bf15f2c8ac1eb02 Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 22 Oct 2022 16:11:56 +0100 Subject: [PATCH 010/516] Added metadata to lockscreen. Closes #1470. --- .../libretube/util/NowPlayingNotification.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index aec065c26..afb1444e0 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -8,6 +8,7 @@ import android.content.Intent import android.graphics.Bitmap import android.graphics.drawable.BitmapDrawable import android.os.Build +import android.support.v4.media.MediaDescriptionCompat import android.support.v4.media.session.MediaSessionCompat import coil.request.ImageRequest import com.github.libretube.api.obj.Streams @@ -18,6 +19,7 @@ import com.github.libretube.ui.activities.MainActivity import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector +import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator import com.google.android.exoplayer2.ui.PlayerNotificationManager class NowPlayingNotification( @@ -169,6 +171,19 @@ class NowPlayingNotification( setUseFastForwardActionInCompactView(true) setUseRewindActionInCompactView(true) } + mediaSessionConnector = MediaSessionConnector(mediaSession) + mediaSessionConnector.setQueueNavigator(object : TimelineQueueNavigator(mediaSession) { + override fun getMediaDescription( + player: Player, + windowIndex: Int + ): MediaDescriptionCompat { + return MediaDescriptionCompat.Builder().apply { + setTitle(streams?.title!!) + setSubtitle(streams?.uploader) + }.build() + } + }) + mediaSessionConnector.setPlayer(player) } /** From 76e5aa4008b628b4cca72484ac4d0ed33db8d488 Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 22 Oct 2022 16:37:49 +0100 Subject: [PATCH 011/516] Moved mediadescriptioncompat code into relevant area. Added more detail to metadata. --- .../libretube/util/NowPlayingNotification.kt | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index afb1444e0..1c5aa7f27 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -5,12 +5,15 @@ import android.app.NotificationManager import android.app.PendingIntent import android.content.Context import android.content.Intent +import android.content.res.Resources import android.graphics.Bitmap +import android.graphics.BitmapFactory import android.graphics.drawable.BitmapDrawable import android.os.Build import android.support.v4.media.MediaDescriptionCompat import android.support.v4.media.session.MediaSessionCompat import coil.request.ImageRequest +import com.github.libretube.R import com.github.libretube.api.obj.Streams import com.github.libretube.constants.BACKGROUND_CHANNEL_ID import com.github.libretube.constants.IntentData @@ -131,6 +134,19 @@ class NowPlayingNotification( mediaSession.isActive = true mediaSessionConnector = MediaSessionConnector(mediaSession) + mediaSessionConnector.setQueueNavigator(object : TimelineQueueNavigator(mediaSession) { + override fun getMediaDescription( + player: Player, + windowIndex: Int + ): MediaDescriptionCompat { + return MediaDescriptionCompat.Builder().apply { + setTitle(streams?.title!!) + setSubtitle(streams?.uploader) + setIconBitmap(BitmapFactory.decodeResource( + Resources.getSystem(), R.drawable.ic_launcher_monochrome)) + }.build() + } + }) mediaSessionConnector.setPlayer(player) } @@ -171,19 +187,6 @@ class NowPlayingNotification( setUseFastForwardActionInCompactView(true) setUseRewindActionInCompactView(true) } - mediaSessionConnector = MediaSessionConnector(mediaSession) - mediaSessionConnector.setQueueNavigator(object : TimelineQueueNavigator(mediaSession) { - override fun getMediaDescription( - player: Player, - windowIndex: Int - ): MediaDescriptionCompat { - return MediaDescriptionCompat.Builder().apply { - setTitle(streams?.title!!) - setSubtitle(streams?.uploader) - }.build() - } - }) - mediaSessionConnector.setPlayer(player) } /** From ae87a1d05f5f08f3d096ad9d30b3993eecf5d7a5 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sat, 22 Oct 2022 23:33:19 +0530 Subject: [PATCH 012/516] Added the permission for hidden notification --- app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 02a10b7ca..61d32266e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ - + From a066363e88e85248d81c4e7e6bed12c73aed1854 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sat, 22 Oct 2022 23:34:55 +0530 Subject: [PATCH 013/516] Modified the notification visibility for audio --- .../com/github/libretube/services/DownloadService.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 706dcff04..a6bea09bb 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -1,6 +1,7 @@ package com.github.libretube.services import android.app.DownloadManager +import android.app.DownloadManager.Request.VISIBILITY_HIDDEN import android.app.Service import android.content.BroadcastReceiver import android.content.Context @@ -77,16 +78,18 @@ class DownloadService : Service() { videoName, getString(R.string.downloading), videoUrl, + false, Uri.fromFile( File(videoDownloadDir, videoName) ) ) } - else if (downloadType in listOf(DownloadType.AUDIO, DownloadType.AUDIO_VIDEO)) { + if (downloadType in listOf(DownloadType.AUDIO, DownloadType.AUDIO_VIDEO)) { audioDownloadId = downloadManagerRequest( videoName, getString(R.string.downloading), audioUrl, + true, Uri.fromFile( File(audioDownloadDir, videoName) ) @@ -123,6 +126,7 @@ class DownloadService : Service() { title: String, descriptionText: String, url: String, + isAudio: Boolean, destination: Uri ): Long { val request: DownloadManager.Request = @@ -132,6 +136,9 @@ class DownloadService : Service() { .setDestinationUri(destination) .setAllowedOverMetered(true) // Set if download is allowed on Mobile network .setAllowedOverRoaming(true) + if (isAudio) { + request.setNotificationVisibility(VISIBILITY_HIDDEN) + } val downloadManager: DownloadManager = applicationContext.getSystemService(DOWNLOAD_SERVICE) as DownloadManager From f920f8ae6b6be4bf33d742bd0bc653514aff07b3 Mon Sep 17 00:00:00 2001 From: Daniel <61970262+rozari0@users.noreply.github.com> Date: Sun, 23 Oct 2022 11:09:47 +0600 Subject: [PATCH 014/516] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffbea94b6..40b1ac025 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: ./gradlew assembleDebug - name: Sign Apk + continue-on-error: true id: sign_apk uses: ilharp/sign-android-release@v1 with: From d6232b1ddcd1575b8c5680be17e719cba0abb7be Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 11:12:02 +0200 Subject: [PATCH 015/516] Playing queue layout --- .../ui/adapters/PlayingQueueAdapter.kt | 7 ++ .../libretube/ui/sheets/PlayingQueueSheet.kt | 27 ++++++++ .../ui/viewholders/PlayingQueueViewHolder.kt | 8 +++ app/src/main/res/layout/queue_row.xml | 65 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt create mode 100644 app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt create mode 100644 app/src/main/java/com/github/libretube/ui/viewholders/PlayingQueueViewHolder.kt create mode 100644 app/src/main/res/layout/queue_row.xml diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt new file mode 100644 index 000000000..fe5c96302 --- /dev/null +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt @@ -0,0 +1,7 @@ +package com.github.libretube.ui.adapters + +import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.ui.viewholders.PlayingQueueViewHolder + +class PlayingQueueAdapter: RecyclerView.Adapter { +} \ No newline at end of file diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt new file mode 100644 index 000000000..e65fd3a2a --- /dev/null +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -0,0 +1,27 @@ +package com.github.libretube.ui.sheets + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.github.libretube.databinding.BottomSheetBinding +import com.google.android.material.bottomsheet.BottomSheetDialogFragment + +class PlayingQueueSheet: BottomSheetDialogFragment() { + private lateinit var binding: BottomSheetBinding + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = BottomSheetBinding.inflate(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + + } +} diff --git a/app/src/main/java/com/github/libretube/ui/viewholders/PlayingQueueViewHolder.kt b/app/src/main/java/com/github/libretube/ui/viewholders/PlayingQueueViewHolder.kt new file mode 100644 index 000000000..9fe6f200d --- /dev/null +++ b/app/src/main/java/com/github/libretube/ui/viewholders/PlayingQueueViewHolder.kt @@ -0,0 +1,8 @@ +package com.github.libretube.ui.viewholders + +import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.databinding.QueueRowBinding + +class PlayingQueueViewHolder( + val binding: QueueRowBinding +) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/res/layout/queue_row.xml b/app/src/main/res/layout/queue_row.xml new file mode 100644 index 000000000..cab788305 --- /dev/null +++ b/app/src/main/res/layout/queue_row.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From afe25fc67a0016c43784f1d113a64287c8f6e1f2 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 11:33:35 +0200 Subject: [PATCH 016/516] Queue bottom sheet in player fragment --- .../ui/adapters/PlayingQueueAdapter.kt | 34 +++++- .../libretube/ui/fragments/HomeFragment.kt | 3 + .../libretube/ui/fragments/PlayerFragment.kt | 5 + .../libretube/ui/sheets/PlayingQueueSheet.kt | 10 +- .../com/github/libretube/util/PlayingQueue.kt | 3 + app/src/main/res/layout/fragment_player.xml | 115 ++++++++++++------ app/src/main/res/layout/queue_row.xml | 10 +- app/src/main/res/values/strings.xml | 1 + 8 files changed, 136 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt index fe5c96302..83363a80b 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt @@ -1,7 +1,37 @@ package com.github.libretube.ui.adapters +import android.text.format.DateUtils +import android.view.LayoutInflater +import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.api.obj.StreamItem +import com.github.libretube.databinding.QueueRowBinding import com.github.libretube.ui.viewholders.PlayingQueueViewHolder +import com.github.libretube.util.ImageHelper -class PlayingQueueAdapter: RecyclerView.Adapter { -} \ No newline at end of file +class PlayingQueueAdapter( + private val items: List +) : RecyclerView.Adapter() { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlayingQueueViewHolder { + val binding = QueueRowBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) + return PlayingQueueViewHolder(binding) + } + + override fun getItemCount(): Int { + return items.size + } + + override fun onBindViewHolder(holder: PlayingQueueViewHolder, position: Int) { + val streamItem = items[position] + holder.binding.apply { + ImageHelper.loadImage(streamItem.thumbnail, thumbnail) + title.text = streamItem.title + uploader.text = streamItem.uploaderName + duration.text = streamItem.duration?.let { DateUtils.formatElapsedTime(it) } + } + } +} diff --git a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt index c5a7566cf..ca5b8a0ff 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt @@ -20,6 +20,7 @@ import com.github.libretube.ui.adapters.ChannelAdapter import com.github.libretube.ui.adapters.TrendingAdapter import com.github.libretube.ui.base.BaseFragment import com.github.libretube.util.LocaleHelper +import com.github.libretube.util.PlayingQueue import com.github.libretube.util.PreferenceHelper import com.google.android.material.snackbar.Snackbar import retrofit2.HttpException @@ -80,6 +81,8 @@ class HomeFragment : BaseFragment() { } finally { binding.homeRefresh.isRefreshing = false } + // TODO() REMOVE TESTING + PlayingQueue.streams = response runOnUiThread { binding.progressBar.visibility = View.GONE diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 5606b1bbb..7a639500f 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -64,6 +64,7 @@ import com.github.libretube.ui.base.BaseFragment import com.github.libretube.ui.dialogs.AddToPlaylistDialog import com.github.libretube.ui.dialogs.DownloadDialog import com.github.libretube.ui.dialogs.ShareDialog +import com.github.libretube.ui.sheets.PlayingQueueSheet import com.github.libretube.ui.views.BottomSheet import com.github.libretube.util.AutoPlayHelper import com.github.libretube.util.BackgroundHelper @@ -409,6 +410,10 @@ class PlayerFragment : BaseFragment() { toggleComments() } + binding.queueToggle.setOnClickListener { + PlayingQueueSheet().show(childFragmentManager, null) + } + // FullScreen button trigger // hide fullscreen button if auto rotation enabled playerBinding.fullscreen.visibility = diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index e65fd3a2a..e76dc62b3 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -4,10 +4,13 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.LinearLayoutManager import com.github.libretube.databinding.BottomSheetBinding +import com.github.libretube.ui.adapters.PlayingQueueAdapter +import com.github.libretube.util.PlayingQueue import com.google.android.material.bottomsheet.BottomSheetDialogFragment -class PlayingQueueSheet: BottomSheetDialogFragment() { +class PlayingQueueSheet : BottomSheetDialogFragment() { private lateinit var binding: BottomSheetBinding override fun onCreateView( @@ -22,6 +25,9 @@ class PlayingQueueSheet: BottomSheetDialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - + binding.optionsRecycler.layoutManager = LinearLayoutManager(context) + binding.optionsRecycler.adapter = PlayingQueueAdapter( + PlayingQueue.streams + ) } } diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 7063c1d7d..3938eb437 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -1,8 +1,11 @@ package com.github.libretube.util +import com.github.libretube.api.obj.StreamItem + object PlayingQueue { private val queue = mutableListOf() private var currentVideoId: String? = null + var streams: List = listOf() fun add(videoId: String) { if (currentVideoId == videoId) return diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 01cfb7bdd..a0680cc65 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -298,6 +298,81 @@ app:cornerRadius="11dp" /> + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - @@ -54,7 +55,7 @@ android:id="@+id/duration" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="10dp" + android:layout_marginStart="15dp" android:textSize="14sp" tools:text="10:00" /> @@ -62,4 +63,11 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ece153900..3d097ad91 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -348,6 +348,7 @@ Show more Time code Added to playlist + Playing queue Download Service From 93c4732978b6bc6a229cfd898d3d81934c3098f5 Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sun, 23 Oct 2022 10:53:28 +0100 Subject: [PATCH 017/516] Added artist metadata to AOD. --- .../libretube/util/NowPlayingNotification.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index 1c5aa7f27..3b7c3dcfc 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -1,5 +1,6 @@ package com.github.libretube.util +import android.R.attr.data import android.annotation.SuppressLint import android.app.NotificationManager import android.app.PendingIntent @@ -10,7 +11,9 @@ import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.drawable.BitmapDrawable import android.os.Build +import android.os.Bundle import android.support.v4.media.MediaDescriptionCompat +import android.support.v4.media.MediaMetadataCompat import android.support.v4.media.session.MediaSessionCompat import coil.request.ImageRequest import com.github.libretube.R @@ -142,8 +145,16 @@ class NowPlayingNotification( return MediaDescriptionCompat.Builder().apply { setTitle(streams?.title!!) setSubtitle(streams?.uploader) - setIconBitmap(BitmapFactory.decodeResource( - Resources.getSystem(), R.drawable.ic_launcher_monochrome)) + val extras = Bundle() + val appIcon = BitmapFactory.decodeResource( + Resources.getSystem(), + R.drawable.ic_launcher_monochrome + ) + extras.putParcelable(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, appIcon) + extras.putString(MediaMetadataCompat.METADATA_KEY_TITLE, streams?.title!!) + extras.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, streams?.uploader) + setIconBitmap(appIcon) + setExtras(extras) }.build() } }) From 41162fafac7c6969e9ec243f680c4ad700fcb9c0 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 13:39:15 +0200 Subject: [PATCH 018/516] Add functionality --- .../libretube/extensions/ToStreamItem.kt | 22 ++++++++ .../libretube/services/BackgroundMode.kt | 13 +++-- .../libretube/ui/fragments/HomeFragment.kt | 2 - .../libretube/ui/fragments/PlayerFragment.kt | 11 ++-- .../libretube/ui/sheets/PlayingQueueSheet.kt | 2 +- .../ui/sheets/VideoOptionsBottomSheet.kt | 27 +++++++++- .../github/libretube/util/AutoPlayHelper.kt | 28 +--------- .../com/github/libretube/util/PlayingQueue.kt | 53 ++++++++++--------- 8 files changed, 95 insertions(+), 63 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt diff --git a/app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt b/app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt new file mode 100644 index 000000000..f58d4d298 --- /dev/null +++ b/app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt @@ -0,0 +1,22 @@ +package com.github.libretube.extensions + +import com.github.libretube.api.obj.StreamItem +import com.github.libretube.api.obj.Streams + +fun Streams?.toStreamItem(videoId: String): StreamItem { + if (this == null) return StreamItem() + return StreamItem( + url = videoId, + title = title, + thumbnail = thumbnailUrl, + uploaderName = uploader, + uploaderUrl = uploaderUrl, + uploaderAvatar = uploaderAvatar, + uploadedDate = uploadDate, + uploaded = null, + duration = duration, + views = views, + uploaderVerified = uploaderVerified, + shortDescription = description + ) +} diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 9cda3e3cc..f6b617682 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -25,6 +25,7 @@ import com.github.libretube.db.DatabaseHelper import com.github.libretube.db.DatabaseHolder import com.github.libretube.extensions.awaitQuery import com.github.libretube.extensions.toID +import com.github.libretube.extensions.toStreamItem import com.github.libretube.util.AutoPlayHelper import com.github.libretube.util.NowPlayingNotification import com.github.libretube.util.PlayerHelper @@ -146,7 +147,9 @@ class BackgroundMode : Service() { } private fun updateWatchPosition() { - player?.currentPosition?.let { DatabaseHelper.saveWatchPosition(videoId, it) } + player?.currentPosition?.let { + DatabaseHelper.saveWatchPosition(videoId, it) + } handler.postDelayed(this::updateWatchPosition, 500) } @@ -158,7 +161,7 @@ class BackgroundMode : Service() { seekToPosition: Long = 0 ) { // append the video to the playing queue - PlayingQueue.add(videoId) + PlayingQueue.add(streams.toStreamItem(videoId)) CoroutineScope(Dispatchers.IO).launch { try { streams = RetrofitInstance.api.getStreams(videoId) @@ -166,6 +169,8 @@ class BackgroundMode : Service() { return@launch } + PlayingQueue.updateCurrent(streams.toStreamItem(videoId)) + handler.post { playAudio(seekToPosition) } @@ -175,8 +180,6 @@ class BackgroundMode : Service() { private fun playAudio( seekToPosition: Long ) { - PlayingQueue.updateCurrent(videoId) - initializePlayer() setMediaItem() @@ -280,7 +283,7 @@ class BackgroundMode : Service() { if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId!!) // search for the next videoId in the playlist CoroutineScope(Dispatchers.IO).launch { - nextStreamId = autoPlayHelper.getNextVideoId(videoId, streams!!.relatedStreams!!) + nextStreamId = autoPlayHelper.getNextVideoId(videoId) } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt index ca5b8a0ff..38dc23e3f 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt @@ -81,8 +81,6 @@ class HomeFragment : BaseFragment() { } finally { binding.homeRefresh.isRefreshing = false } - // TODO() REMOVE TESTING - PlayingQueue.streams = response runOnUiThread { binding.progressBar.visibility = View.GONE diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 7a639500f..fa360bbb5 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -52,6 +52,7 @@ import com.github.libretube.extensions.formatShort import com.github.libretube.extensions.hideKeyboard import com.github.libretube.extensions.query import com.github.libretube.extensions.toID +import com.github.libretube.extensions.toStreamItem import com.github.libretube.models.PlayerViewModel import com.github.libretube.models.interfaces.PlayerOptionsInterface import com.github.libretube.services.BackgroundMode @@ -635,8 +636,6 @@ class PlayerFragment : BaseFragment() { private fun playVideo() { lifecycleScope.launchWhenCreated { - PlayingQueue.updateCurrent(videoId!!) - streams = try { RetrofitInstance.api.getStreams(videoId!!) } catch (e: IOException) { @@ -650,6 +649,12 @@ class PlayerFragment : BaseFragment() { return@launchWhenCreated } + PlayingQueue.updateCurrent(streams.toStreamItem(videoId!!)) + + if (PlayingQueue.size() <= 1) PlayingQueue.add( + *streams.relatedStreams.orEmpty().toTypedArray() + ) + runOnUiThread { // hide the button to skip SponsorBlock segments manually binding.sbSkipBtn.visibility = View.GONE @@ -694,7 +699,7 @@ class PlayerFragment : BaseFragment() { if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId) // search for the next videoId in the playlist lifecycleScope.launchWhenCreated { - nextStreamId = autoPlayHelper.getNextVideoId(videoId!!, streams.relatedStreams) + nextStreamId = autoPlayHelper.getNextVideoId(videoId!!) } } diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index e76dc62b3..87d6c8c8b 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -27,7 +27,7 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { binding.optionsRecycler.layoutManager = LinearLayoutManager(context) binding.optionsRecycler.adapter = PlayingQueueAdapter( - PlayingQueue.streams + PlayingQueue.getStreams() ) } } diff --git a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt index f174e2a33..5310b75a1 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt @@ -3,8 +3,10 @@ package com.github.libretube.ui.sheets import android.os.Bundle import android.widget.Toast import com.github.libretube.R +import com.github.libretube.api.RetrofitInstance import com.github.libretube.constants.IntentData import com.github.libretube.constants.ShareObjectType +import com.github.libretube.extensions.toStreamItem import com.github.libretube.ui.dialogs.AddToPlaylistDialog import com.github.libretube.ui.dialogs.DownloadDialog import com.github.libretube.ui.dialogs.ShareDialog @@ -12,6 +14,9 @@ import com.github.libretube.ui.views.BottomSheet import com.github.libretube.util.BackgroundHelper import com.github.libretube.util.PlayingQueue import com.github.libretube.util.PreferenceHelper +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch /** * Dialog with different options for a selected video. @@ -79,10 +84,28 @@ class VideoOptionsBottomSheet( shareDialog.show(parentFragmentManager, ShareDialog::class.java.name) } context?.getString(R.string.play_next) -> { - PlayingQueue.addAsNext(videoId) + CoroutineScope(Dispatchers.IO).launch { + try { + PlayingQueue.addAsNext( + RetrofitInstance.api.getStreams(videoId) + .toStreamItem(videoId) + ) + } catch (e: Exception) { + e.printStackTrace() + } + } } context?.getString(R.string.add_to_queue) -> { - PlayingQueue.add(videoId) + CoroutineScope(Dispatchers.IO).launch { + try { + PlayingQueue.add( + RetrofitInstance.api.getStreams(videoId) + .toStreamItem(videoId) + ) + } catch (e: Exception) { + e.printStackTrace() + } + } } } } diff --git a/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt b/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt index 1e1f17e1f..645d58fa9 100644 --- a/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt +++ b/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt @@ -16,13 +16,10 @@ class AutoPlayHelper( * get the id of the next video to be played */ suspend fun getNextVideoId( - currentVideoId: String, - relatedStreams: List? + currentVideoId: String ): String? { return if (playlistId == null) { - getNextTrendingVideoId( - relatedStreams - ) + null } else { getNextPlaylistVideoId( currentVideoId @@ -30,27 +27,6 @@ class AutoPlayHelper( } } - /** - * get the id of the next related video - */ - private fun getNextTrendingVideoId( - relatedStreams: List? - ): String? { - // don't play a video if it got played before already - if (relatedStreams == null || relatedStreams.isEmpty()) return null - var index = 0 - var nextStreamId: String? = null - while (nextStreamId == null || PlayingQueue.containsBeforeCurrent(nextStreamId)) { - nextStreamId = relatedStreams[index].url!!.toID() - if (index + 1 < relatedStreams.size) { - index += 1 - } else { - break - } - } - return nextStreamId - } - /** * get the videoId of the next video in a playlist */ diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 3938eb437..cb827f89d 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -1,58 +1,63 @@ package com.github.libretube.util import com.github.libretube.api.obj.StreamItem +import com.github.libretube.extensions.toID object PlayingQueue { - private val queue = mutableListOf() - private var currentVideoId: String? = null - var streams: List = listOf() + private val queue = mutableListOf() + private var currentStream: StreamItem? = null - fun add(videoId: String) { - if (currentVideoId == videoId) return - if (queue.contains(videoId)) queue.remove(videoId) - queue.add(videoId) + fun add(vararg streamItem: StreamItem) { + streamItem.forEach { + if (currentStream != it) { + if (queue.contains(it)) queue.remove(it) + queue.add(it) + } + } } - fun addAsNext(videoId: String) { - if (currentVideoId == videoId) return - if (queue.contains(videoId)) queue.remove(videoId) + fun addAsNext(streamItem: StreamItem) { + if (currentStream == streamItem) return + if (queue.contains(streamItem)) queue.remove(streamItem) queue.add( - queue.indexOf(currentVideoId) + 1, - videoId + currentIndex() + 1, + streamItem ) } fun getNext(): String? { return try { - queue[currentIndex() + 1] + queue[currentIndex() + 1].url?.toID() } catch (e: Exception) { null } } fun getPrev(): String? { - val index = queue.indexOf(currentVideoId) - return if (index > 0) queue[index - 1] else null + val index = queue.indexOf(currentStream) + return if (index > 0) queue[index - 1].url?.toID() else null } fun hasPrev(): Boolean { - return queue.indexOf(currentVideoId) > 0 + return queue.indexOf(currentStream) > 0 } - fun updateCurrent(videoId: String) { - currentVideoId = videoId - queue.add(videoId) + fun updateCurrent(streamItem: StreamItem) { + currentStream = streamItem + queue.add(streamItem) } fun isNotEmpty() = queue.isNotEmpty() + fun isEmpty() = queue.isEmpty() + fun clear() = queue.clear() - fun currentIndex() = queue.indexOf(currentVideoId) + fun size() = queue.size - fun contains(videoId: String) = queue.contains(videoId) + private fun currentIndex() = queue.indexOf(currentStream) - fun containsBeforeCurrent(videoId: String): Boolean { - return queue.contains(videoId) && queue.indexOf(videoId) < currentIndex() - } + fun contains(streamItem: StreamItem) = queue.contains(streamItem) + + fun getStreams() = queue } From 02d4321a2dc1ecd2ac57d489dd1d7a0a4d30edfc Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 14:43:47 +0200 Subject: [PATCH 019/516] Replace the autoPlayHelper with the PlayingQueue --- .../libretube/services/BackgroundMode.kt | 48 +++---------- .../ui/adapters/PlayingQueueAdapter.kt | 14 ++-- .../libretube/ui/fragments/HomeFragment.kt | 1 - .../libretube/ui/fragments/PlayerFragment.kt | 47 +++++-------- .../libretube/ui/sheets/PlayingQueueSheet.kt | 5 +- .../github/libretube/util/AutoPlayHelper.kt | 68 ------------------- .../com/github/libretube/util/PlayingQueue.kt | 42 +++++++++++- 7 files changed, 74 insertions(+), 151 deletions(-) delete mode 100644 app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index f6b617682..3faab91e9 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -24,9 +24,7 @@ import com.github.libretube.constants.PreferenceKeys import com.github.libretube.db.DatabaseHelper import com.github.libretube.db.DatabaseHolder import com.github.libretube.extensions.awaitQuery -import com.github.libretube.extensions.toID import com.github.libretube.extensions.toStreamItem -import com.github.libretube.util.AutoPlayHelper import com.github.libretube.util.NowPlayingNotification import com.github.libretube.util.PlayerHelper import com.github.libretube.util.PlayingQueue @@ -81,16 +79,6 @@ class BackgroundMode : Service() { */ private lateinit var nowPlayingNotification: NowPlayingNotification - /** - * The [videoId] of the next stream for autoplay - */ - private var nextStreamId: String? = null - - /** - * Helper for finding the next video in the playlist - */ - private lateinit var autoPlayHelper: AutoPlayHelper - /** * Autoplay Preference */ @@ -133,9 +121,6 @@ class BackgroundMode : Service() { playlistId = intent.getStringExtra(IntentData.playlistId) val position = intent.getLongExtra(IntentData.position, 0L) - // initialize the playlist autoPlay Helper - autoPlayHelper = AutoPlayHelper(playlistId) - // play the audio in the background loadAudio(videoId, position) @@ -169,7 +154,12 @@ class BackgroundMode : Service() { return@launch } - PlayingQueue.updateCurrent(streams.toStreamItem(videoId)) + // add the playlist video to the queue + if (playlistId != null && PlayingQueue.isEmpty()) { + PlayingQueue.insertPlaylist(playlistId!!, streams.toStreamItem(videoId)) + } else { + PlayingQueue.updateCurrent(streams.toStreamItem(videoId)) + } handler.post { playAudio(seekToPosition) @@ -221,8 +211,6 @@ class BackgroundMode : Service() { player?.setPlaybackSpeed(playbackSpeed) fetchSponsorBlockSegments() - - if (PlayerHelper.autoPlayEnabled) setNextStream() } /** @@ -271,32 +259,16 @@ class BackgroundMode : Service() { }) } - /** - * set the videoId of the next stream for autoplay - */ - private fun setNextStream() { - if (streams!!.relatedStreams!!.isNotEmpty()) { - nextStreamId = streams?.relatedStreams!![0].url!!.toID() - } - - if (playlistId == null) return - if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId!!) - // search for the next videoId in the playlist - CoroutineScope(Dispatchers.IO).launch { - nextStreamId = autoPlayHelper.getNextVideoId(videoId) - } - } - /** * Plays the first related video to the current (used when the playback of the current video ended) */ private fun playNextVideo() { - if (nextStreamId == null || nextStreamId == videoId) return - val nextQueueVideo = PlayingQueue.getNext() - if (nextQueueVideo != null) nextStreamId = nextQueueVideo + val nextVideo = PlayingQueue.getNext() // play new video on background - this.videoId = nextStreamId!! + if (nextVideo != null) { + this.videoId = nextVideo + } this.segmentData = null loadAudio(videoId) } diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt index 83363a80b..fae141ffc 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt @@ -4,14 +4,12 @@ import android.text.format.DateUtils import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import com.github.libretube.api.obj.StreamItem import com.github.libretube.databinding.QueueRowBinding import com.github.libretube.ui.viewholders.PlayingQueueViewHolder import com.github.libretube.util.ImageHelper +import com.github.libretube.util.PlayingQueue -class PlayingQueueAdapter( - private val items: List -) : RecyclerView.Adapter() { +class PlayingQueueAdapter() : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlayingQueueViewHolder { val binding = QueueRowBinding.inflate( LayoutInflater.from(parent.context), @@ -22,16 +20,18 @@ class PlayingQueueAdapter( } override fun getItemCount(): Int { - return items.size + return PlayingQueue.size() } override fun onBindViewHolder(holder: PlayingQueueViewHolder, position: Int) { - val streamItem = items[position] + val streamItem = PlayingQueue.getStreams()[position] holder.binding.apply { ImageHelper.loadImage(streamItem.thumbnail, thumbnail) title.text = streamItem.title uploader.text = streamItem.uploaderName - duration.text = streamItem.duration?.let { DateUtils.formatElapsedTime(it) } + duration.text = streamItem.duration?.let { + DateUtils.formatElapsedTime(it) + } } } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt index 38dc23e3f..c5a7566cf 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt @@ -20,7 +20,6 @@ import com.github.libretube.ui.adapters.ChannelAdapter import com.github.libretube.ui.adapters.TrendingAdapter import com.github.libretube.ui.base.BaseFragment import com.github.libretube.util.LocaleHelper -import com.github.libretube.util.PlayingQueue import com.github.libretube.util.PreferenceHelper import com.google.android.material.snackbar.Snackbar import retrofit2.HttpException diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index fa360bbb5..b0ad5a07f 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -67,7 +67,6 @@ import com.github.libretube.ui.dialogs.DownloadDialog import com.github.libretube.ui.dialogs.ShareDialog import com.github.libretube.ui.sheets.PlayingQueueSheet import com.github.libretube.ui.views.BottomSheet -import com.github.libretube.util.AutoPlayHelper import com.github.libretube.util.BackgroundHelper import com.github.libretube.util.ImageHelper import com.github.libretube.util.NowPlayingNotification @@ -155,12 +154,6 @@ class PlayerFragment : BaseFragment() { private var token = PreferenceHelper.getToken() private var videoShownInExternalPlayer = false - /** - * for autoplay - */ - private var nextStreamId: String? = null - private lateinit var autoPlayHelper: AutoPlayHelper - /** * for the player notification */ @@ -649,11 +642,20 @@ class PlayerFragment : BaseFragment() { return@launchWhenCreated } - PlayingQueue.updateCurrent(streams.toStreamItem(videoId!!)) - - if (PlayingQueue.size() <= 1) PlayingQueue.add( - *streams.relatedStreams.orEmpty().toTypedArray() - ) + if (PlayingQueue.size() == 0) { + CoroutineScope(Dispatchers.IO).launch { + if (playlistId != null) { + PlayingQueue.insertPlaylist(playlistId!!, streams.toStreamItem(videoId!!)) + } else { + PlayingQueue.updateCurrent(streams.toStreamItem(videoId!!)) + PlayingQueue.add( + *streams.relatedStreams.orEmpty().toTypedArray() + ) + } + } + } else { + PlayingQueue.updateCurrent(streams.toStreamItem(videoId!!)) + } runOnUiThread { // hide the button to skip SponsorBlock segments manually @@ -678,8 +680,6 @@ class PlayerFragment : BaseFragment() { if (PlayerHelper.sponsorBlockEnabled) fetchSponsorBlockSegments() // show comments if related streams disabled if (!PlayerHelper.relatedStreamsEnabled) toggleComments() - // prepare for autoplay - if (binding.player.autoplayEnabled) setNextStream() // add the video to the watch history if (PlayerHelper.watchHistoryEnabled) { @@ -692,17 +692,6 @@ class PlayerFragment : BaseFragment() { } } - /** - * set the videoId of the next stream for autoplay - */ - private fun setNextStream() { - if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId) - // search for the next videoId in the playlist - lifecycleScope.launchWhenCreated { - nextStreamId = autoPlayHelper.getNextVideoId(videoId!!) - } - } - /** * fetch the segments for SponsorBlock */ @@ -768,17 +757,14 @@ class PlayerFragment : BaseFragment() { // used for autoplay and skipping to next video private fun playNextVideo() { - if (nextStreamId == null) return - // check whether there is a new video in the queue - val nextQueueVideo = PlayingQueue.getNext() - if (nextQueueVideo != null) nextStreamId = nextQueueVideo + val nextVideo = PlayingQueue.getNext() // by making sure that the next and the current video aren't the same saveWatchPosition() // forces the comments to reload for the new video commentsLoaded = false binding.commentsRecView.adapter = null // save the id of the next stream as videoId and load the next video - videoId = nextStreamId + videoId = nextVideo playVideo() } @@ -876,7 +862,6 @@ class PlayerFragment : BaseFragment() { @Suppress("DEPRECATION") if ( playbackState == Player.STATE_ENDED && - nextStreamId != null && !transitioning && binding.player.autoplayEnabled ) { diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 87d6c8c8b..fa09f5913 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -7,7 +7,6 @@ import android.view.ViewGroup import androidx.recyclerview.widget.LinearLayoutManager import com.github.libretube.databinding.BottomSheetBinding import com.github.libretube.ui.adapters.PlayingQueueAdapter -import com.github.libretube.util.PlayingQueue import com.google.android.material.bottomsheet.BottomSheetDialogFragment class PlayingQueueSheet : BottomSheetDialogFragment() { @@ -26,8 +25,6 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { super.onViewCreated(view, savedInstanceState) binding.optionsRecycler.layoutManager = LinearLayoutManager(context) - binding.optionsRecycler.adapter = PlayingQueueAdapter( - PlayingQueue.getStreams() - ) + binding.optionsRecycler.adapter = PlayingQueueAdapter() } } diff --git a/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt b/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt deleted file mode 100644 index 645d58fa9..000000000 --- a/app/src/main/java/com/github/libretube/util/AutoPlayHelper.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.github.libretube.util - -import com.github.libretube.api.RetrofitInstance -import com.github.libretube.extensions.toID -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext - -class AutoPlayHelper( - private val playlistId: String? -) { - - private val playlistStreamIds = mutableListOf() - private var playlistNextPage: String? = null - - /** - * get the id of the next video to be played - */ - suspend fun getNextVideoId( - currentVideoId: String - ): String? { - return if (playlistId == null) { - null - } else { - getNextPlaylistVideoId( - currentVideoId - ) - } - } - - /** - * get the videoId of the next video in a playlist - */ - private suspend fun getNextPlaylistVideoId(currentVideoId: String): String? { - // if the playlists contain the video, then save the next video as next stream - if (playlistStreamIds.contains(currentVideoId)) { - val index = playlistStreamIds.indexOf(currentVideoId) - // check whether there's a next video - return if (index + 1 < playlistStreamIds.size) { - playlistStreamIds[index + 1] - } else if (playlistNextPage == null) { - null - } else { - getNextPlaylistVideoId(currentVideoId) - } - } else if (playlistStreamIds.isEmpty() || playlistNextPage != null) { - // fetch the next page of the playlist - return withContext(Dispatchers.IO) { - // fetch the playlists or its nextPage's videos - val playlist = - if (playlistNextPage == null) { - RetrofitInstance.authApi.getPlaylist(playlistId!!) - } else { - RetrofitInstance.authApi.getPlaylistNextPage( - playlistId!!, - playlistNextPage!! - ) - } - // save the playlist urls to the list - playlistStreamIds += playlist.relatedStreams!!.map { it.url!!.toID() } - // save playlistNextPage for usage if video is not contained - playlistNextPage = playlist.nextpage - return@withContext getNextPlaylistVideoId(currentVideoId) - } - } - // return null when no nextPage is found - return null - } -} diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index cb827f89d..2c12ceddc 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -1,7 +1,11 @@ package com.github.libretube.util +import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.StreamItem import com.github.libretube.extensions.toID +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch object PlayingQueue { private val queue = mutableListOf() @@ -44,7 +48,7 @@ object PlayingQueue { fun updateCurrent(streamItem: StreamItem) { currentStream = streamItem - queue.add(streamItem) + if (!contains(streamItem)) queue.add(streamItem) } fun isNotEmpty() = queue.isNotEmpty() @@ -57,7 +61,41 @@ object PlayingQueue { private fun currentIndex() = queue.indexOf(currentStream) - fun contains(streamItem: StreamItem) = queue.contains(streamItem) + fun contains(streamItem: StreamItem) = queue.any { it.url?.toID() == streamItem.url?.toID() } fun getStreams() = queue + + private fun fetchMoreFromPlaylist(playlistId: String, nextPage: String?) { + var playlistNextPage: String? = nextPage + CoroutineScope(Dispatchers.IO).launch { + while (playlistNextPage != null) { + RetrofitInstance.authApi.getPlaylistNextPage( + playlistId, + playlistNextPage!! + ).apply { + add( + *this.relatedStreams.orEmpty().toTypedArray() + ) + playlistNextPage = this.nextpage + } + } + } + } + + fun insertPlaylist(playlistId: String, newCurrentStream: StreamItem) { + CoroutineScope(Dispatchers.IO).launch { + try { + val response = RetrofitInstance.authApi.getPlaylist(playlistId) + add( + *response.relatedStreams + .orEmpty() + .toTypedArray() + ) + updateCurrent(newCurrentStream) + fetchMoreFromPlaylist(playlistId, response.nextpage) + } catch (e: Exception) { + e.printStackTrace() + } + } + } } From e7ef03047339203db8a5e3f9ee0f03b9ce14756b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 14:54:02 +0200 Subject: [PATCH 020/516] Add swipe gestures to remove from queue --- .../libretube/ui/sheets/PlayingQueueSheet.kt | 33 ++++++++++++++++++- .../com/github/libretube/util/PlayingQueue.kt | 4 ++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index fa09f5913..0c3f33d60 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -4,9 +4,12 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import com.github.libretube.databinding.BottomSheetBinding import com.github.libretube.ui.adapters.PlayingQueueAdapter +import com.github.libretube.util.PlayingQueue import com.google.android.material.bottomsheet.BottomSheetDialogFragment class PlayingQueueSheet : BottomSheetDialogFragment() { @@ -25,6 +28,34 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { super.onViewCreated(view, savedInstanceState) binding.optionsRecycler.layoutManager = LinearLayoutManager(context) - binding.optionsRecycler.adapter = PlayingQueueAdapter() + val adapter = PlayingQueueAdapter() + binding.optionsRecycler.adapter = adapter + + val callback = object : ItemTouchHelper.SimpleCallback( + 0, + ItemTouchHelper.LEFT + ) { + override fun onMove( + recyclerView: RecyclerView, + viewHolder: RecyclerView.ViewHolder, + target: RecyclerView.ViewHolder + ): Boolean { + TODO("Not yet implemented") + } + + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { + val position = viewHolder.absoluteAdapterPosition + if (position == PlayingQueue.currentIndex()) { + adapter.notifyItemChanged(position) + return + } + PlayingQueue.remove(position) + adapter.notifyItemRemoved(position) + adapter.notifyItemRangeChanged(position, adapter.itemCount) + } + } + + val itemTouchHelper = ItemTouchHelper(callback) + itemTouchHelper.attachToRecyclerView(binding.optionsRecycler) } } diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 2c12ceddc..e825ae63a 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -59,12 +59,14 @@ object PlayingQueue { fun size() = queue.size - private fun currentIndex() = queue.indexOf(currentStream) + fun currentIndex() = queue.indexOf(currentStream) fun contains(streamItem: StreamItem) = queue.any { it.url?.toID() == streamItem.url?.toID() } fun getStreams() = queue + fun remove(index: Int) = queue.removeAt(index) + private fun fetchMoreFromPlaylist(playlistId: String, nextPage: String?) { var playlistNextPage: String? = nextPage CoroutineScope(Dispatchers.IO).launch { From 1962268460a88755b32b32f7ed8b23b3bc403541 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 15:09:58 +0200 Subject: [PATCH 021/516] Dragging and dropping items --- .../java/com/github/libretube/extensions/Move.kt | 7 +++++++ .../libretube/ui/adapters/PlayingQueueAdapter.kt | 8 +++++++- .../libretube/ui/sheets/PlayingQueueSheet.kt | 15 ++++++++++++++- .../com/github/libretube/util/PlayingQueue.kt | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/extensions/Move.kt diff --git a/app/src/main/java/com/github/libretube/extensions/Move.kt b/app/src/main/java/com/github/libretube/extensions/Move.kt new file mode 100644 index 000000000..bd556be87 --- /dev/null +++ b/app/src/main/java/com/github/libretube/extensions/Move.kt @@ -0,0 +1,7 @@ +package com.github.libretube.extensions + +fun MutableList.move(oldPosition: Int, newPosition: Int) { + val item = this.get(oldPosition) + this.removeAt(oldPosition) + this.add(newPosition, item) +} diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt index fae141ffc..77aa4bf5b 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt @@ -8,8 +8,9 @@ import com.github.libretube.databinding.QueueRowBinding import com.github.libretube.ui.viewholders.PlayingQueueViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.PlayingQueue +import com.github.libretube.util.ThemeHelper -class PlayingQueueAdapter() : RecyclerView.Adapter() { +class PlayingQueueAdapter : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlayingQueueViewHolder { val binding = QueueRowBinding.inflate( LayoutInflater.from(parent.context), @@ -32,6 +33,11 @@ class PlayingQueueAdapter() : RecyclerView.Adapter() { duration.text = streamItem.duration?.let { DateUtils.formatElapsedTime(it) } + if (PlayingQueue.currentIndex() == position) { + root.setBackgroundColor( + ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight) + ) + } } } } diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 0c3f33d60..71f3de37e 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -35,12 +35,25 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { 0, ItemTouchHelper.LEFT ) { + override fun getMovementFlags( + recyclerView: RecyclerView, + viewHolder: RecyclerView.ViewHolder + ): Int { + val dragFlags = ItemTouchHelper.UP or ItemTouchHelper.DOWN + return makeMovementFlags(dragFlags, 0) + } + override fun onMove( recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder ): Boolean { - TODO("Not yet implemented") + val from = viewHolder.absoluteAdapterPosition + val to = target.absoluteAdapterPosition + + adapter.notifyItemMoved(from, to) + PlayingQueue.move(from, to) + return true } override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index e825ae63a..578843554 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -2,6 +2,7 @@ package com.github.libretube.util import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.StreamItem +import com.github.libretube.extensions.move import com.github.libretube.extensions.toID import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -67,6 +68,8 @@ object PlayingQueue { fun remove(index: Int) = queue.removeAt(index) + fun move(from: Int, to: Int) = queue.move(from, to) + private fun fetchMoreFromPlaylist(playlistId: String, nextPage: String?) { var playlistNextPage: String? = nextPage CoroutineScope(Dispatchers.IO).launch { From fb21dd254319215bac35b2323e1c6cc1732b283b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 15:19:14 +0200 Subject: [PATCH 022/516] Minor fixes --- .../github/libretube/ui/sheets/PlayingQueueSheet.kt | 10 +--------- .../java/com/github/libretube/util/PlayingQueue.kt | 12 +++++++++++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 71f3de37e..1292b7377 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -32,17 +32,9 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { binding.optionsRecycler.adapter = adapter val callback = object : ItemTouchHelper.SimpleCallback( - 0, + ItemTouchHelper.UP or ItemTouchHelper.DOWN, ItemTouchHelper.LEFT ) { - override fun getMovementFlags( - recyclerView: RecyclerView, - viewHolder: RecyclerView.ViewHolder - ): Int { - val dragFlags = ItemTouchHelper.UP or ItemTouchHelper.DOWN - return makeMovementFlags(dragFlags, 0) - } - override fun onMove( recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 578843554..863cd004a 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -1,5 +1,6 @@ package com.github.libretube.util +import android.util.Log import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.StreamItem import com.github.libretube.extensions.move @@ -32,6 +33,7 @@ object PlayingQueue { fun getNext(): String? { return try { + Log.e("new video", queue[currentIndex() + 1].toString()) queue[currentIndex() + 1].url?.toID() } catch (e: Exception) { null @@ -60,7 +62,15 @@ object PlayingQueue { fun size() = queue.size - fun currentIndex() = queue.indexOf(currentStream) + fun currentIndex(): Int { + return try { + queue.indexOf( + queue.first { it.url?.toID() == currentStream?.url?.toID() } + ) + } catch (e: Exception) { + 0 + } + } fun contains(streamItem: StreamItem) = queue.any { it.url?.toID() == streamItem.url?.toID() } From b5c6a27264822a9fdb10397b44e8342de728ec8a Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 15:22:36 +0200 Subject: [PATCH 023/516] Fix a crash when the queue is empty --- .../libretube/ui/fragments/PlayerFragment.kt | 16 ++++++++++------ app/src/main/res/values/strings.xml | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index b0ad5a07f..398800cc0 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -757,15 +757,19 @@ class PlayerFragment : BaseFragment() { // used for autoplay and skipping to next video private fun playNextVideo() { - val nextVideo = PlayingQueue.getNext() + val nextVideoId = PlayingQueue.getNext() // by making sure that the next and the current video aren't the same saveWatchPosition() - // forces the comments to reload for the new video - commentsLoaded = false - binding.commentsRecView.adapter = null + // save the id of the next stream as videoId and load the next video - videoId = nextVideo - playVideo() + if (nextVideoId != null) { + videoId = nextVideoId + + // forces the comments to reload for the new video + commentsLoaded = false + binding.commentsRecView.adapter = null + playVideo() + } } private fun prepareExoPlayerView() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d097ad91..e69f7711e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -349,6 +349,7 @@ Time code Added to playlist Playing queue + Queue Download Service From 220f131cb82398c9ccd974ba9e4ba52165408515 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 15:49:12 +0200 Subject: [PATCH 024/516] Open queue from navbar menu --- .../libretube/ui/activities/MainActivity.kt | 15 +++++++++++ .../ui/adapters/PlayingQueueAdapter.kt | 9 ++++--- .../com/github/libretube/util/PlayingQueue.kt | 1 - app/src/main/res/layout/queue_row.xml | 27 +++++-------------- app/src/main/res/menu/action_bar.xml | 6 +++++ 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index 32286d1dd..bdf30f72c 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -8,6 +8,7 @@ import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper +import android.util.Log import android.view.Menu import android.view.MenuItem import android.view.View @@ -34,8 +35,10 @@ import com.github.libretube.services.ClosingService import com.github.libretube.ui.base.BaseActivity import com.github.libretube.ui.dialogs.ErrorDialog import com.github.libretube.ui.fragments.PlayerFragment +import com.github.libretube.ui.sheets.PlayingQueueSheet import com.github.libretube.util.NavBarHelper import com.github.libretube.util.NetworkHelper +import com.github.libretube.util.PlayingQueue import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -195,6 +198,11 @@ class MainActivity : BaseActivity() { ) } + override fun onPrepareOptionsMenu(menu: Menu?): Boolean { + menu?.findItem(R.id.action_queue)?.isVisible = PlayingQueue.isNotEmpty() + return super.onPrepareOptionsMenu(menu) + } + /** * Initialize the notification badge showing the amount of new videos */ @@ -302,6 +310,13 @@ class MainActivity : BaseActivity() { startActivity(communityIntent) true } + R.id.action_queue -> { + Log.e("open queue", "open queue") + supportFragmentManager.let { + PlayingQueueSheet().show(it, null) + } + true + } else -> super.onOptionsItemSelected(item) } } diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt index 77aa4bf5b..af9236e46 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlayingQueueAdapter.kt @@ -1,5 +1,6 @@ package com.github.libretube.ui.adapters +import android.annotation.SuppressLint import android.text.format.DateUtils import android.view.LayoutInflater import android.view.ViewGroup @@ -24,15 +25,15 @@ class PlayingQueueAdapter : RecyclerView.Adapter() { return PlayingQueue.size() } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: PlayingQueueViewHolder, position: Int) { val streamItem = PlayingQueue.getStreams()[position] holder.binding.apply { ImageHelper.loadImage(streamItem.thumbnail, thumbnail) title.text = streamItem.title - uploader.text = streamItem.uploaderName - duration.text = streamItem.duration?.let { - DateUtils.formatElapsedTime(it) - } + videoInfo.text = streamItem.uploaderName + " • " + + DateUtils.formatElapsedTime(streamItem.duration ?: 0) + if (PlayingQueue.currentIndex() == position) { root.setBackgroundColor( ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight) diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 863cd004a..03e420218 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -33,7 +33,6 @@ object PlayingQueue { fun getNext(): String? { return try { - Log.e("new video", queue[currentIndex() + 1].toString()) queue[currentIndex() + 1].url?.toID() } catch (e: Exception) { null diff --git a/app/src/main/res/layout/queue_row.xml b/app/src/main/res/layout/queue_row.xml index 52100c7cd..29d8a2c9c 100644 --- a/app/src/main/res/layout/queue_row.xml +++ b/app/src/main/res/layout/queue_row.xml @@ -39,27 +39,14 @@ android:maxLines="1" tools:text="I am Hardstyle - Episode 111" /> - - - - - - - + android:ellipsize="end" + android:maxLines="1" + android:textSize="14sp" + tools:text="Brennan Heart" /> diff --git a/app/src/main/res/menu/action_bar.xml b/app/src/main/res/menu/action_bar.xml index 960c25e58..90488f1d8 100644 --- a/app/src/main/res/menu/action_bar.xml +++ b/app/src/main/res/menu/action_bar.xml @@ -27,4 +27,10 @@ android:title="@string/about" app:showAsAction="never" /> + + \ No newline at end of file From a4b08578799122a9640cee743911abe1b71ae07f Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 15:50:45 +0200 Subject: [PATCH 025/516] layout improvements --- app/src/main/res/layout/queue_row.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/queue_row.xml b/app/src/main/res/layout/queue_row.xml index 29d8a2c9c..e03c06e5f 100644 --- a/app/src/main/res/layout/queue_row.xml +++ b/app/src/main/res/layout/queue_row.xml @@ -34,9 +34,10 @@ android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="5dp" android:ellipsize="end" android:maxLines="1" + android:textSize="16sp" + android:textStyle="bold" tools:text="I am Hardstyle - Episode 111" /> From 2e4b6beb2f05f71c5ce63ed71270dd814e607d76 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 15:58:06 +0200 Subject: [PATCH 026/516] Add a toggle at the player fragment --- .../libretube/ui/activities/MainActivity.kt | 5 +-- .../libretube/ui/fragments/PlayerFragment.kt | 3 +- app/src/main/res/drawable/ic_queue.xml | 10 +++++ .../layout/exo_styled_player_control_view.xml | 9 +++- app/src/main/res/layout/fragment_player.xml | 43 +------------------ app/src/main/res/layout/queue_row.xml | 1 + 6 files changed, 23 insertions(+), 48 deletions(-) create mode 100644 app/src/main/res/drawable/ic_queue.xml diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index bdf30f72c..d1d6f1840 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -311,10 +311,7 @@ class MainActivity : BaseActivity() { true } R.id.action_queue -> { - Log.e("open queue", "open queue") - supportFragmentManager.let { - PlayingQueueSheet().show(it, null) - } + PlayingQueueSheet().show(supportFragmentManager, null) true } else -> super.onOptionsItemSelected(item) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 398800cc0..6f470ce70 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -404,7 +404,8 @@ class PlayerFragment : BaseFragment() { toggleComments() } - binding.queueToggle.setOnClickListener { + playerBinding.queueToggle.visibility = View.VISIBLE + playerBinding.queueToggle.setOnClickListener { PlayingQueueSheet().show(childFragmentManager, null) } diff --git a/app/src/main/res/drawable/ic_queue.xml b/app/src/main/res/drawable/ic_queue.xml new file mode 100644 index 000000000..1bc9c0aad --- /dev/null +++ b/app/src/main/res/drawable/ic_queue.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index 6aaeb0d73..e508662f6 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -67,10 +67,17 @@ android:layout_gravity="center" android:layoutDirection="ltr"> + + diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index a0680cc65..f6326dda2 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -298,53 +298,12 @@ app:cornerRadius="11dp" /> - - - - - - - - - - - - Date: Sun, 23 Oct 2022 16:04:15 +0200 Subject: [PATCH 027/516] Add the queue to the background mode --- .../com/github/libretube/extensions/ToStreamItem.kt | 3 +-- .../com/github/libretube/services/BackgroundMode.kt | 10 ++++++---- .../github/libretube/ui/fragments/PlayerFragment.kt | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt b/app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt index f58d4d298..fee0f85a9 100644 --- a/app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt +++ b/app/src/main/java/com/github/libretube/extensions/ToStreamItem.kt @@ -3,8 +3,7 @@ package com.github.libretube.extensions import com.github.libretube.api.obj.StreamItem import com.github.libretube.api.obj.Streams -fun Streams?.toStreamItem(videoId: String): StreamItem { - if (this == null) return StreamItem() +fun Streams.toStreamItem(videoId: String): StreamItem { return StreamItem( url = videoId, title = title, diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 3faab91e9..4134ab485 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -145,8 +145,6 @@ class BackgroundMode : Service() { videoId: String, seekToPosition: Long = 0 ) { - // append the video to the playing queue - PlayingQueue.add(streams.toStreamItem(videoId)) CoroutineScope(Dispatchers.IO).launch { try { streams = RetrofitInstance.api.getStreams(videoId) @@ -156,9 +154,13 @@ class BackgroundMode : Service() { // add the playlist video to the queue if (playlistId != null && PlayingQueue.isEmpty()) { - PlayingQueue.insertPlaylist(playlistId!!, streams.toStreamItem(videoId)) + streams?.toStreamItem(videoId) + ?.let { PlayingQueue.insertPlaylist(playlistId!!, it) } } else { - PlayingQueue.updateCurrent(streams.toStreamItem(videoId)) + streams?.toStreamItem(videoId)?.let { PlayingQueue.updateCurrent(it) } + streams?.relatedStreams?.toTypedArray()?.let { + PlayingQueue.add(*it) + } } handler.post { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 6f470ce70..c7ea66253 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -405,7 +405,7 @@ class PlayerFragment : BaseFragment() { } playerBinding.queueToggle.visibility = View.VISIBLE - playerBinding.queueToggle.setOnClickListener { + playerBinding.queueToggle.setOnClickListener { PlayingQueueSheet().show(childFragmentManager, null) } @@ -643,7 +643,7 @@ class PlayerFragment : BaseFragment() { return@launchWhenCreated } - if (PlayingQueue.size() == 0) { + if (PlayingQueue.isEmpty()) { CoroutineScope(Dispatchers.IO).launch { if (playlistId != null) { PlayingQueue.insertPlaylist(playlistId!!, streams.toStreamItem(videoId!!)) From e0e457cd6c1a4bf9bf4e65877ea33ec26ab1171b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 16:06:12 +0200 Subject: [PATCH 028/516] ktlint --- .../main/java/com/github/libretube/ui/activities/MainActivity.kt | 1 - app/src/main/java/com/github/libretube/util/PlayingQueue.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index d1d6f1840..b366b2b63 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -8,7 +8,6 @@ import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper -import android.util.Log import android.view.Menu import android.view.MenuItem import android.view.View diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 03e420218..887185ae8 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -1,6 +1,5 @@ package com.github.libretube.util -import android.util.Log import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.StreamItem import com.github.libretube.extensions.move From b026bc69174b7ee7af059ef35c4325ae28ee31fb Mon Sep 17 00:00:00 2001 From: Daviteusz Date: Fri, 21 Oct 2022 20:54:40 +0000 Subject: [PATCH 029/516] Translated using Weblate (Polish) Currently translated at 100.0% (354 of 354 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/pl/ --- app/src/main/res/values-pl/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 282f1d340..a74be155b 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -353,4 +353,5 @@ Nazwa listy odtwarzania (odwrotnie) Ogranicz HLS do 1080p Niższa wartość może przyspieszyć początkowe ładowanie wideo. + Dodano do listy odtwarzania \ No newline at end of file From 6de34302faf241ffdb975df12a8438f233afdcd2 Mon Sep 17 00:00:00 2001 From: Daniel Rozario Date: Sun, 23 Oct 2022 09:24:49 +0000 Subject: [PATCH 030/516] Translated using Weblate (Bengali) Currently translated at 99.4% (352 of 354 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/bn/ --- app/src/main/res/values-bn/strings.xml | 29 +++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 066674153..c8c6f9c94 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -224,7 +224,7 @@ ম্যাট্রিক্স প্লে-ব্যাকের গতি বাছাইকৃত - এই চেঞ্জটি কার্যকর করতে হলে রিস্টার্ট হওয়া প্রয়োজন। অ্যাপ রিস্টার্ট করুন\? + এই চেঞ্জটি কার্যকর করতে হলে রিস্টার্ট হওয়া প্রয়োজন। অ্যাপ রিস্টার্ট করতে \'আচ্ছা\'তে চাপুন। চ্যাপ্টার অ্যাপের রিস্টার্ট প্রয়োজন অথেন্টিকেশন ইন্সটেন্স @@ -327,4 +327,31 @@ Metered নতুন ভিডিওর সংখ্যাসহ ব্যাজ দেখান। পছন্দসমূহ + ফিড ব্যাকগ্রাউন্ডে লোড করুন + ফিড ব্যাকগ্রাউন্ডে লোড করুন এবং অটো রিফ্রেশ হওয়া বন্ধ করুন। + কম ভ্যালু ভিডিওর লোডিংয়ের সময় কমিয়ে আনে। + পরেরটা চালান + প্লে-লিস্টে অ্যাড করুন + নোটিফিকেশন ওয়ার্কার + নতুন স্ট্রিম আসলে নোটিফিকেশন দেখান। + নেভিগেশনবার + অন্তত একটি আইটেম সিলেক্ট করুন + কাস্টম ইন্সটেন্সগুলো + ডিফল্ট + Progressive load interval size + পিচ + ডাউনলোড সার্ভিস + অডিও প্লেয়ার নিয়ন্ত্রণের জন্য নোটিফিকেশনে বাটন দেখান। + বর্তমান এলাকায় ট্রেডিং অ্যাভেলেবল নেই। সেটিংসে গিয়ে অন্যটি বাছুন। + ডাউনলোডের সময় নোটিফিকেশন দেখান। + ব্যাকগ্রাউন্ড মোড + HLSকে 1080p তে সীমাবদ্ধ করুন + ফাইলের নাম + ইনভ্যালিড ফাইলনেম! + প্লে-লিস্টের অর্ডার + নাম (উল্টো) + সম্প্রতি আপডেট করা হয়েছে + সম্প্রতি আপডেট করা হয়েছে (উল্টো) + আরো দেখান + সময় কোড \ No newline at end of file From 42ce52bf29e7411e1d69404afdcee979000f1278 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sun, 23 Oct 2022 21:23:20 +0530 Subject: [PATCH 031/516] Changed the download notification title --- .../com/github/libretube/services/DownloadService.kt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index a6bea09bb..a02933279 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -1,7 +1,6 @@ package com.github.libretube.services import android.app.DownloadManager -import android.app.DownloadManager.Request.VISIBILITY_HIDDEN import android.app.Service import android.content.BroadcastReceiver import android.content.Context @@ -27,7 +26,6 @@ class DownloadService : Service() { private lateinit var videoUrl: String private lateinit var audioUrl: String private var downloadType: Int = 3 - private var videoDownloadId: Long? = null private var audioDownloadId: Long? = null @@ -75,10 +73,9 @@ class DownloadService : Service() { ) if (downloadType in listOf(DownloadType.VIDEO, DownloadType.AUDIO_VIDEO)) { videoDownloadId = downloadManagerRequest( - videoName, + "[Video] $videoName", getString(R.string.downloading), videoUrl, - false, Uri.fromFile( File(videoDownloadDir, videoName) ) @@ -86,10 +83,9 @@ class DownloadService : Service() { } if (downloadType in listOf(DownloadType.AUDIO, DownloadType.AUDIO_VIDEO)) { audioDownloadId = downloadManagerRequest( - videoName, + "[Audio] $videoName", getString(R.string.downloading), audioUrl, - true, Uri.fromFile( File(audioDownloadDir, videoName) ) @@ -126,7 +122,6 @@ class DownloadService : Service() { title: String, descriptionText: String, url: String, - isAudio: Boolean, destination: Uri ): Long { val request: DownloadManager.Request = @@ -136,9 +131,6 @@ class DownloadService : Service() { .setDestinationUri(destination) .setAllowedOverMetered(true) // Set if download is allowed on Mobile network .setAllowedOverRoaming(true) - if (isAudio) { - request.setNotificationVisibility(VISIBILITY_HIDDEN) - } val downloadManager: DownloadManager = applicationContext.getSystemService(DOWNLOAD_SERVICE) as DownloadManager From 3b2c4d06d4ef4bdfdcb44cdb0e758449d19f02d9 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sun, 23 Oct 2022 21:25:21 +0530 Subject: [PATCH 032/516] Removed the permission for hidden notification --- app/src/main/AndroidManifest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 61d32266e..1fd90ad13 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,6 @@ - From 57535dabffbf4a000c95f7381a3bde7ab35dfbe2 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 23 Oct 2022 18:59:04 +0200 Subject: [PATCH 033/516] fix the updater --- app/build.gradle | 2 ++ app/proguard-rules.pro | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6b2a3c870..874395016 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,6 +41,8 @@ android { } debug { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' debuggable true applicationIdSuffix ".debug" resValue "string", "app_name", "LibreTube Debug" diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index c035dfb82..db9143d05 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -16,15 +16,16 @@ # debugging stack traces. -keepattributes SourceFile,LineNumberTable +# prevents obfuscation in debug logs +-dontobfuscate + # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + #uncomment for debug #-keepnames class ** + +# Keep data classes used for Retrofit -keep class com.github.libretube.obj.** { *; } - -# prevents android from removing it --keep class com.github.libretube.obj.**.** { *; } - -# prevents obfuscation in debug logs --dontobfuscate \ No newline at end of file +-keep class com.github.libretube.obj.update.** { *; } From 5ffebcaacb816ced7882f6a62897e6c70133f76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Sun, 23 Oct 2022 14:07:53 +0000 Subject: [PATCH 034/516] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegi?= =?UTF-8?q?an=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 78.6% (280 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/nb_NO/ --- app/src/main/res/values-nb-rNO/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 37430aad6..cf9ea5e76 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -351,4 +351,9 @@ På vei opp ser ut til å være utilgjengelig for nåværende region. Velg en annen i innstillingene. Ugyldig filnavn Spillelisterekkefølge + Spillekø + + Lagt til på spillelisten + Vis mer + Tidskode \ No newline at end of file From a260cb4c1e051eeefff9c9b8f7706a384cab74dc Mon Sep 17 00:00:00 2001 From: Nizami Date: Sun, 23 Oct 2022 14:46:54 +0000 Subject: [PATCH 035/516] Translated using Weblate (Azerbaijani) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/az/ --- app/src/main/res/values-az/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index 57011f551..a8ef59196 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -354,4 +354,6 @@ Daha çox göstər Vaxt kodu Pleylistə əlavə edildi + Oynatma növbəsi + Növbə \ No newline at end of file From 536b3ba190b6c32941b8ecb273757c48f74de844 Mon Sep 17 00:00:00 2001 From: Eric Date: Sun, 23 Oct 2022 14:09:34 +0000 Subject: [PATCH 036/516] Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/zh_Hans/ --- app/src/main/res/values-zh-rCN/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 24dc3e061..c3ab6ee41 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -354,4 +354,6 @@ 显示更多 时间码 已添加到播放列表 + 播放队列 + 队列 \ No newline at end of file From 88025db6fdf417522cbd44255ba03a3dd014ca87 Mon Sep 17 00:00:00 2001 From: gallegonovato Date: Sun, 23 Oct 2022 16:00:22 +0000 Subject: [PATCH 037/516] Translated using Weblate (Spanish) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/es/ --- app/src/main/res/values-es/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index c0de899e3..8d438a55f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -354,4 +354,6 @@ Mostrar más código de tiempo Se ha añadido a la lista de reproducción + Cola + Cola de la reproducción \ No newline at end of file From 6ac8b3a9476b7bef8f06fc3d4de5f447a2daaaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Sun, 23 Oct 2022 15:50:25 +0000 Subject: [PATCH 038/516] Translated using Weblate (Turkish) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/tr/ --- app/src/main/res/values-tr/strings.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 9e8e2cdcc..85dd09854 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -49,7 +49,7 @@ VLC\'de açılamadı, kurulmamış olabilir. Seç… Özel - Sunucuyla ilgili bir sorun var. Başka bir örnek deneyelim mi\? + Sunucuyla ilgili bir sorun var. Başka bir örnek denensin mi\? Ağ sütunları YouTube veya NewPipe\'tan Oynatma listesi adı boş olamaz @@ -148,7 +148,7 @@ Hafıza kartı Müzik klasörü Varsayılan - Pergar eğilimi + Akıcı değişim Moda ateş Şık fener Hızlandırılmış kuş @@ -233,9 +233,9 @@ Sıfırla Küçük resimleri ve diğer resimleri gösterme. Yeni LibreTube sürümü şimdi yüklensin mi\? - Navigasyon çubuğundaki etiket görünürlüğü + Gezinme çubuğundaki etiket görünürlüğü Her zaman - Seçildi + Seçilen Hiçbir zaman Otomatik tam ekran Cihaz döndüğünde tam ekran oynatma. @@ -354,4 +354,6 @@ Zaman kodu Daha fazla göster Oynatma listesine eklendi + Sıra + Oynatma sırası \ No newline at end of file From bd9e904d1241d6a3e0a31a2c90600593a1d4ed5d Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Sun, 23 Oct 2022 16:51:43 +0000 Subject: [PATCH 039/516] Translated using Weblate (Ukrainian) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/uk/ --- app/src/main/res/values-uk/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index caaf9551a..d44e87c00 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -354,4 +354,6 @@ Показати більше Часовий код Додано в добірку + Черга відтворення + Черга \ No newline at end of file From 8bd8be15223113792c42d35ff9a4271f8397a142 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sun, 23 Oct 2022 22:55:34 +0530 Subject: [PATCH 040/516] Fixed string resources --- .../java/com/github/libretube/services/DownloadService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index a02933279..9a803e52d 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -26,6 +26,7 @@ class DownloadService : Service() { private lateinit var videoUrl: String private lateinit var audioUrl: String private var downloadType: Int = 3 + private var videoDownloadId: Long? = null private var audioDownloadId: Long? = null @@ -73,7 +74,7 @@ class DownloadService : Service() { ) if (downloadType in listOf(DownloadType.VIDEO, DownloadType.AUDIO_VIDEO)) { videoDownloadId = downloadManagerRequest( - "[Video] $videoName", + "[${getString(R.string.video)}] $videoName", getString(R.string.downloading), videoUrl, Uri.fromFile( @@ -83,7 +84,7 @@ class DownloadService : Service() { } if (downloadType in listOf(DownloadType.AUDIO, DownloadType.AUDIO_VIDEO)) { audioDownloadId = downloadManagerRequest( - "[Audio] $videoName", + "[${getString(R.string.audio)}] $videoName", getString(R.string.downloading), audioUrl, Uri.fromFile( From d1ae2e5096b06d36718a26f1ec7f1282eb3ddcb5 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sun, 23 Oct 2022 23:12:33 +0530 Subject: [PATCH 041/516] Formatted with ktlint --- .../main/java/com/github/libretube/services/DownloadService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 9a803e52d..a9658d393 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -26,7 +26,7 @@ class DownloadService : Service() { private lateinit var videoUrl: String private lateinit var audioUrl: String private var downloadType: Int = 3 - + private var videoDownloadId: Long? = null private var audioDownloadId: Long? = null From 3c878c3148a702083d613b636e025632721a27fd Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Mon, 24 Oct 2022 10:59:56 +0530 Subject: [PATCH 042/516] minor fix --- .../java/com/github/libretube/services/DownloadService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index a9658d393..e135cd32e 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -48,7 +48,7 @@ class DownloadService : Service() { } if (downloadType != DownloadType.NONE) { - downloadManager(videoName) + downloadManager() } else { onDestroy() } @@ -60,7 +60,7 @@ class DownloadService : Service() { TODO("Not yet implemented") } - private fun downloadManager(videoName: String) { + private fun downloadManager() { // initialize and create the directories to download into val videoDownloadDir = DownloadHelper.getVideoDir(this) From 4b90a208e1f72c7119212f28f37e17fc5e9ed5da Mon Sep 17 00:00:00 2001 From: Linerly Date: Sun, 23 Oct 2022 21:31:48 +0000 Subject: [PATCH 043/516] Translated using Weblate (Indonesian) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/id/ --- app/src/main/res/values-in/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index de922df42..57b9be52d 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -354,4 +354,6 @@ Tampilkan lebih banyak Kode waktu Ditambahkan ke daftar putar + Antrean main + Antrean \ No newline at end of file From bf059933f65cfef28786839c898d42da765e464a Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Sun, 23 Oct 2022 17:13:37 +0000 Subject: [PATCH 044/516] Translated using Weblate (Hebrew) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/he/ --- app/src/main/res/values-iw/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index dfc59f974..a0d5dbcc6 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -354,4 +354,6 @@ להציג עוד קוד זמן נוסף לרשימת נגינה + תור + תור נגינה \ No newline at end of file From 5e1e891cd532eca08b4e9cd8a8e384030266a6fa Mon Sep 17 00:00:00 2001 From: Gediminas Murauskas Date: Mon, 24 Oct 2022 12:07:03 +0200 Subject: [PATCH 045/516] Added translation using Weblate (Lithuanian) --- app/src/main/res/values-lt/strings.xml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/src/main/res/values-lt/strings.xml diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml new file mode 100644 index 000000000..a6b3daec9 --- /dev/null +++ b/app/src/main/res/values-lt/strings.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file From e5bf3662ce4cdd6a13b08325518427aed6182d06 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 15:14:02 +0000 Subject: [PATCH 046/516] Update navigation to v2.5.3 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f8353b32c..22324bd66 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ appcompat = "1.5.1" lifecycle = "2.5.1" constraintlayout = "2.1.4" material = "1.8.0-alpha01" -navigation = "2.5.2" +navigation = "2.5.3" legacySupport = "1.0.0" preference = "1.2.0" extJunit = "1.1.3" From fc5a6673aab898ab3ea01bd986d8d1c9c730a760 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:27:01 +0000 Subject: [PATCH 047/516] Update dependency com.google.android.material:material to v1.8.0-alpha02 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 22324bd66..e68e26480 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ appcompat = "1.5.1" lifecycle = "2.5.1" constraintlayout = "2.1.4" -material = "1.8.0-alpha01" +material = "1.8.0-alpha02" navigation = "2.5.3" legacySupport = "1.0.0" preference = "1.2.0" From b32a8289ace10464385c36221e8377888a7950c4 Mon Sep 17 00:00:00 2001 From: Rex_sa Date: Mon, 24 Oct 2022 17:34:47 +0000 Subject: [PATCH 048/516] Translated using Weblate (Arabic) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/ar/ --- app/src/main/res/values-ar/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 8bc31470c..6860a26e8 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -354,4 +354,6 @@ اظهار المزيد رمز التوقيت تمت الإضافة إلى قائمة التشغيل + تشغيل قائمة الانتظار + الانتظار \ No newline at end of file From d1c7c988d65eaa3d074d2466b55949f211c1974a Mon Sep 17 00:00:00 2001 From: Gediminas Murauskas Date: Mon, 24 Oct 2022 10:07:24 +0000 Subject: [PATCH 049/516] Translated using Weblate (Lithuanian) Currently translated at 81.4% (290 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/lt/ --- app/src/main/res/values-lt/strings.xml | 294 ++++++++++++++++++++++++- 1 file changed, 293 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index a6b3daec9..824db78f9 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -1,2 +1,294 @@ - \ No newline at end of file + + Pagrindinis + Prenumeratos + Biblioteka + Taip + Kokybė + Dalintis + Ieškoti + Atsisiųsti + Išsaugoti + Vartotojo vardas + Prisijungti + Registruotis + Atsijungti + Atšaukti + Prisijungta. + Užsiregistruota. Dabar galite prenumeruoti kanalus. + Jau prisijungta. Galite atsijungti nuo savo paskyros. + Pasirinkti… + Pasirinktinis + Regionas + Prisijungti / registruotis + Pirmiausia užsiprenumeruokite kuriuos nors kanalus. + Prisijunkite ir bandykite dar kartą. + Kažkas nutiko ne taip. + Nepavyko atidaryti naudojant VLC, programėlė gali būti neįdiegta. + Tai skirta Piped paskyrai. + Vaizdo įrašų raiška + Tinklelio stulpeliai + Čia nieko nėra. + Ištrinti grojaraštį + Ištrinti grojaraštį\? + Grojaraščio pavadinimas negali būti tuščias + Pridėti į grojaraštį + Atlikta. + Kalba + Sistemos + Sistemos + Šviesi + Tamsi + Nustatymai + Vietovė + Perdavimo šaltinis + Interneto svetainė + Pirmiausia prisijunkite prie interneto. + Kanalai + Visi + Grojaraščiai + Paieškos istorija + Išvalyti istoriją + YT Music dainos + YT Music vaizdo įrašai + YT Music albumai + YT Music grojaraščiai + SponsorBlock + Naudoja https://sponsor.ajay.app API + Praleistas segmentas + Licencija + Akcentai + Piktograma + Įjungta + Groti fone + Yra galima versija %1$s + Išvaizda + Elgesys + Vaizdo įrašo formatas + Failų konvertavimas, jei kuomet atsisiunčiamas ir garsas, ir vaizdas. + Atsisiųsti į + Kur saugoma atsisiųsta medija. + Paaukoti + Ieškoti naujos versijos + Spustelėkite, kad sužinotumėte, ar programėlė atnaujinta. + Įdiegta naujausia versija. + Naudojate naujausią versiją. + Atkūrimo greitis + Išplėstiniai + Pritaikykite programėlę pagal savo skonį. + Tiesiogiai + Šis komentaras neturi atsakymų. + Autoriai + Aplanko, kuriame saugoma atsisiųsta medija, pavadinimas. + Vidinė atmintis + Numatytoji + Piped, prisijungimas ir prenumeratos + Pridėti… + Perdavimo šaltinio pavadinimas + URL į perdavimo šaltinio API + Įveskite pavadinimą ir API URL. + Įveskite veikiantį URL + Versija %1$s + Susipažinkite su LibreTube komanda ir kaip visa tai veikia. + Susijęs turinys + Rodyti skyrius + Slėpti skyrius + Išankstinis įkėlimas + Grotuvo vaizdo įrašų formatas + Nėra garso + Nėra vaizdo + Garsas + Vaizdas + Atsiunčiama… + Automatinis atkūrimas + URL į perdavimo šaltinio sąsają + Kokybė + Automatinis pristabdymas + Pristabdykite atkūrimą, kai ekranas išjungtas. + Automatiškai paleiskite kitą vaizdo įrašą po dabartinio. + Atkurti numatytuosius nustatymus + Paskyra + Tęsti nuo paskutinės buvusios atkūrimo pozicijos + Autentifikavimo perdavimo šaltinis + GitHub + Garsas ir vaizdas + Portretas + Bendruomenė + Discord + Matrix + Telegram + Reddit + Twitter + Norėdami prisijungti prie interneto, įjunkite Wi-Fi arba mobiliuosius duomenis. + Skyriai + Būtina iš naujo paleisti programėlę + Norint atlikti šį pakeitimą, programėlė turi būti paleista iš naujo. Paspauskite „Gerai“, kad paleistumėte iš naujo dabar. + Naršymo juostos etiketės matomumas + Atidaryti… + Niekada + Automatinis viso ekrano režimas + Duomenų taupymo režimas + Praleisti miniatiūras ir kitus vaizdus. + Atsiminti paieškas + Kaupti peržiūrėtų video istorija vietoje + Žiūrėjimo ir paieškos istorija + Atstatyti + Sistemos antraštės stilius + Antraštės + Įdiegti naują LibreTube versiją dabar\? + Atsisiunčiamas APK… + Grotuvo garso formatas + Garso kokybė + Blogiausia + Pranešimai apie naujas transliacijas + %1$s naujos transliacijos + Naujos %1$s transliacijos… + Ar tikrai\? To nebus galima atšaukti! + Kanalo pavadinimas (A-Z) + Kanalo pavadinimas (Z-A) + Rikiavimas + Eksportuoti prenumeratas + Praleidimo mygtukai + Rodyti mygtukus, kad pereitumėte prie kito arba ankstesnio vaizdo įrašo. + Didžiausias istorijos dydis + Neribotas + Fono režimas + Įtraukti į eilę + Įvairūs + Priminimas apie pertrauką + Laikas padaryti pertrauką + Programėlėje jau praleidote %1$s minučių, laikas padaryti pertrauką. + Trumpi filmukai + Joks + Dabartinis + Atsarginė kopija ir atkūrimas + Atsarginė kopija + Dydžio keitimo režimas + Didžiausias vaizdų talpyklos dydis + Nukopijuota į iškarpinę + Atidaryti + Minutės iki priminimo + Wi-Fi + Mobilieji duomenys + Naujų vaizdo įrašų indikatorius + Rodyti ženklelį su naujų vaizdo įrašų kiekiu, jei tokių yra. + Praleisti segmentą + Vietinės prenumeratos + Nuostatos + Įkelti sklaidos kanalą fone + Atrodo, kad dabartiniame regione tendencijos yra neprieinamos. Nustatymuose pasirinkite kitą. + Apriboti HLS iki 1080p + Mažesnė vertė gali pagreitinti pradinį vaizdo įrašų įkėlimą. + Numatytoji + Pikinė + Failo pavadinimas + Netinkamas failo pavadinimas! + Grojaraščių tvarka + Grojaraščio pavadinimas (atvirkštinis) + Neseniai atnaujinta + Rodyti daugiau + Laiko kodas + Pridėti į grojaraštį + Grojimo eilė + Eilė + Atsisiuntimo paslauga + Rodomas pranešimas, kai atsisiunčiama medija. + Atsijungta. + Fono režimas + Rodomas pranešimas su garso grotuvo valdymo mygtukais. + Rodo pranešimą, kai pasiekiamos naujos transliacijos. + Vaizdo įrašai + Prenumeruoti + Atšaukti prenumeratą + Slaptažodis + Vaizdo įrašo peržiūra + Bendrieji + Leidžiama fone… + Pranešimai + Tik per Wi-Fi + Istorijos dar nėra. + Seniausia + Įrenginio informacija + Vertimas + Klaida + Nukopijuota + Atsisiųsti pavyko + Senasis prenumeratų rodinys + Mažiausiai peržiūrų + Subtitrų nėra + Alternatyvus tendencijų išdėstymas + Pervardyti grojaraštį + Kartojimo režimas + Užpildyti + Padidinti + Ištrinti iš atsisiuntimų + Talpinti + Pirmiausia prisijunkite arba užsiregistruokite nustatymuose. + Kitas atsisiuntimas jau vyksta, palaukite, kol jis bus baigtas. + Iškilo serverio problema. Bandyti kitą perdavimo šaltinį\? + Praleisti rankiniu būdu + Naršymo juosta + Pasirinkite bent vieną elementą + Neseniai atnaujinta (atvirkštinis) + Atsisiuntimas baigtas. + Iš YouTube arba NewPipe + Tema + Užprenumeruota + Nepavyksta atsisiųsti šios transliacijos. + Atsisiųsti nepavyko. + Importuoti prenumeratas + Atidaryti VLC + Filmų aplankas + peržiūros + Sukurti grojaraštį + Apie + Pasirinkite paieškos filtrą + Tinklo klaida. + Grojaraštis sukurtas. + Komentarai + Istorija + Turite įvesti vartotojo vardą ir slaptažodį. + Grojaraščio pavadinimas + Nepavyko :( + Gerai + Piped + Atsisiuntimo aplankas + Įjungta + Segmentai + Rėmėjas + Neapmokama / savireklama + Pavadinimas + Muzikos aplankas + Išjungta + YouTube + %1$s peržiūrų + Grotuvas + SD kortelė + Daugiausiai peržiūrų + Ištrinti paskyrą + Žiūrėjimo istorija + Atsiminti poziciją + Paslėpti tendencijų puslapį + Elgesys + Pridėti perdavimo šaltinį + Klonuoti grojaraštį + Automatinis pasukimas + Iš naujo nustatyti visus nustatymus ir atsijungti\? + Ištrinkite savo Piped paskyrą + Atkurti + Naudokite kitą perdavimo šaltinį autentifikavimo užklausoms. + Pasirinkite autentifikavimo perdavimo šaltinį + Atkūrimas per visą ekraną, kai įrenginys pasukamas. + Gulsčias + Atkūrimo greitis + Kalba ir regionas + Visada + Nerastas joks išorinis grotuvas. Įsitikinkite, kad turite jį įdiegtą. + Pranešimai apie naują turinį iš kūrėjų, kuriuos stebite. + Tikrinama kas … + Geriausia + Subtitrų kalba + Nėra rezultatų. + Dalintis su laiko kodu + Kokybė ir formatas + \ No newline at end of file From 1d44924222d03b9ae8fa0efe54a1d622a0de7fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9clairevoyant?= <848000+eclairevoyant@users.noreply.github.com> Date: Wed, 26 Oct 2022 23:32:48 -0400 Subject: [PATCH 050/516] fix: correct title for break reminder modal --- .../java/com/github/libretube/ui/activities/MainActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index b366b2b63..d0189cde4 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -178,7 +178,7 @@ class MainActivity : BaseActivity() { { try { MaterialAlertDialogBuilder(this) - .setTitle(getString(R.string.share_with_time)) + .setTitle(getString(R.string.take_a_break)) .setMessage( getString( R.string.already_spent_time, From 0f1bc7c9b49f14a3a639d2c785486b453b908a80 Mon Sep 17 00:00:00 2001 From: Daviteusz Date: Tue, 25 Oct 2022 11:04:44 +0000 Subject: [PATCH 051/516] Translated using Weblate (Polish) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/pl/ --- app/src/main/res/values-pl/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a74be155b..a3edbd3f3 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -354,4 +354,6 @@ Ogranicz HLS do 1080p Niższa wartość może przyspieszyć początkowe ładowanie wideo. Dodano do listy odtwarzania + Odtwarzana kolejka + Kolejka \ No newline at end of file From de090f6358c4e6ae3a677786fc0e83957d8d9c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Veseli=20Kraji=C5=A1nik?= Date: Wed, 26 Oct 2022 18:10:42 +0000 Subject: [PATCH 052/516] Translated using Weblate (Serbian) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/sr/ --- app/src/main/res/values-sr/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index e4d7599f7..c92da83d0 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -351,4 +351,9 @@ Нижа вредност може убрзати почетно учитавање видео записа. Застарели приказ претплата Квалитет и формат + Редослед репродукције + Додато на плејлисту + Редослед + Прикажи више + Временски код \ No newline at end of file From c520a5f08ee596cb40bba1b7eb5ce9c822618d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9clairevoyant?= <848000+eclairevoyant@users.noreply.github.com> Date: Thu, 27 Oct 2022 02:48:51 -0400 Subject: [PATCH 053/516] fix: hide "Show more" button when hiding comment replies --- .../java/com/github/libretube/ui/adapters/CommentsAdapter.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index c54d089ae..941b1ded9 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -111,7 +111,10 @@ class CommentsAdapter( } } } - else -> repliesAdapter.clear() + else -> { + repliesAdapter.clear() + showMore.visibility = View.GONE + } } } } From adf93c4a30894029e55d38e20e5419b03e2e94f9 Mon Sep 17 00:00:00 2001 From: Daniel <61970262+rozari0@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:23:31 +0600 Subject: [PATCH 054/516] Action version update This will help to get rid of deprecated warning in actions. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40b1ac025..557c3ea3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 with: python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified From 382a111eb7378fff3010f4e736011edaf572ec00 Mon Sep 17 00:00:00 2001 From: rozari0 Date: Fri, 28 Oct 2022 17:57:06 +0600 Subject: [PATCH 055/516] TG upload with pyrogram. --- .github/tg.py | 67 ++++++++++++++++++++-------------------- .github/workflows/ci.yml | 5 +-- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/.github/tg.py b/.github/tg.py index d6014548d..77edb7b29 100644 --- a/.github/tg.py +++ b/.github/tg.py @@ -1,33 +1,34 @@ -import telegram -from tgconfig import * -from json import load -import multiprocessing -from os import system -from time import sleep as wait - -def deploy(): - system(f'./exec --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}') - -def bot(): - wait(10) - f = open('commit.json') - data = load(f) - f.close() - - bot = telegram.Bot(TG_TOKEN, base_url="http://0.0.0.0:8081/bot") - bot.send_photo(TG_POST_ID, open('alpha.png', 'rb'), f'''*Libretube {data['sha'][0:7]} // Alpha* - -[{data['commit']['message']}]({data['html_url']}) - -Signed-off-by: {data['commit']['author']['name']} -''', parse_mode=telegram.ParseMode.MARKDOWN) - bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-universal-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-x86-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug-signed.apk', 'rb'))]) - system('killall -9 python') - -if __name__ == '__main__': - multideploy = multiprocessing.Process(target=deploy) - multibot = multiprocessing.Process(target=bot) - multideploy.start() - multibot.start() - multideploy.join() - multibot.join() +import asyncio +from json import load +from os import listdir + +from pyrogram import Client +from pyrogram.types import InputMediaDocument +from tgconfig import * + +files = listdir() + +mediadocuments = [ + InputMediaDocument(file) for file in files if file.endswith("signed.apk") +] + +with open("commit.json") as f: + data = load(f) + +caption = f"""**Libretube {data['sha'][0:7]} // Alpha** + +{data['commit']['message']} + +Signed-off-by: {data['commit']['author']['name']} +""" + + +async def main(): + async with Client("libretube", TG_API_ID, TG_API_HASH, bot_token=TG_TOKEN) as app: + await app.send_photo( + int(TG_POST_ID), "https://libre-tube.github.io/images/Alpha.png", caption + ) + await app.send_media_group(int(TG_POST_ID), mediadocuments) + + +asyncio.run(main()) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 557c3ea3c..248a8c89c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,15 +81,12 @@ jobs: continue-on-error: true run: | cd archive - curl https://libre-tube.github.io/images/Alpha.png --output alpha.png - chmod 755 ./exec mv ../tgconfig.py . echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" >> tgconfig.py echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py - python -m pip install --upgrade pip - pip install python-telegram-bot + python -m pip install --upgrade pip TgCrypto Pyrogram mv ../.github/tg.py . mv ../.github/commit.json . python tg.py From 20cdb8274e41841667e1e38a7eaf0f0343e7c500 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Fri, 28 Oct 2022 19:43:38 +0530 Subject: [PATCH 056/516] passed an additional parameter to the constructor --- .../java/com/github/libretube/ui/adapters/ChannelAdapter.kt | 3 ++- .../java/com/github/libretube/ui/adapters/PlaylistAdapter.kt | 3 ++- .../java/com/github/libretube/ui/adapters/TrendingAdapter.kt | 3 ++- .../com/github/libretube/ui/adapters/WatchHistoryAdapter.kt | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt index d0467ad4b..9216445e2 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt @@ -66,8 +66,9 @@ class ChannelAdapter( } val videoId = video.url!!.toID() + val videoName = video.title!! root.setOnLongClickListener { - VideoOptionsBottomSheet(videoId) + VideoOptionsBottomSheet(videoId, videoName) .show(childFragmentManager, VideoOptionsBottomSheet::class.java.name) true } diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt index 0839cf3d9..f6d5a05db 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt @@ -59,8 +59,9 @@ class PlaylistAdapter( NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId) } val videoId = streamItem.url!!.toID() + val videoName = streamItem.title!! root.setOnLongClickListener { - VideoOptionsBottomSheet(videoId) + VideoOptionsBottomSheet(videoId, videoName) .show(childFragmentManager, VideoOptionsBottomSheet::class.java.name) true } diff --git a/app/src/main/java/com/github/libretube/ui/adapters/TrendingAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/TrendingAdapter.kt index c9137b104..f06ba83f1 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/TrendingAdapter.kt @@ -68,8 +68,9 @@ class TrendingAdapter( NavigationHelper.navigateVideo(root.context, trending.url) } val videoId = trending.url!!.toID() + val videoName = trending.title!! root.setOnLongClickListener { - VideoOptionsBottomSheet(videoId) + VideoOptionsBottomSheet(videoId, videoName) .show(childFragmentManager, VideoOptionsBottomSheet::class.java.name) true } diff --git a/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt index d6287289b..440d6a1fa 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt @@ -55,7 +55,7 @@ class WatchHistoryAdapter( NavigationHelper.navigateVideo(root.context, video.videoId) } root.setOnLongClickListener { - VideoOptionsBottomSheet(video.videoId) + VideoOptionsBottomSheet(video.videoId, video.title!!) .show(childFragmentManager, VideoOptionsBottomSheet::class.java.name) true } From 34e0f8673ecc05631ea7938514b0246e9f44b119 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Fri, 28 Oct 2022 19:45:31 +0530 Subject: [PATCH 057/516] passed an additional parameter to the constructor --- .../com/github/libretube/ui/adapters/PlaylistsAdapter.kt | 3 ++- .../java/com/github/libretube/ui/adapters/SearchAdapter.kt | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt index 65aeb5a95..84af7d286 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt @@ -73,7 +73,8 @@ class PlaylistsAdapter( root.setOnLongClickListener { val playlistOptionsDialog = PlaylistOptionsBottomSheet( playlistId = playlist.id!!, - isOwner = true + playlistName = playlist.name!!, + isOwner = true, ) playlistOptionsDialog.show( childFragmentManager, diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt index fcc71b98e..becd21500 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt @@ -100,8 +100,9 @@ class SearchAdapter( NavigationHelper.navigateVideo(root.context, item.url) } val videoId = item.url!!.toID() + val videoName = item.title!! root.setOnLongClickListener { - VideoOptionsBottomSheet(videoId) + VideoOptionsBottomSheet(videoId, videoName) .show(childFragmentManager, VideoOptionsBottomSheet::class.java.name) true } @@ -181,7 +182,8 @@ class SearchAdapter( } root.setOnLongClickListener { val playlistId = item.url!!.toID() - PlaylistOptionsBottomSheet(playlistId, false) + val playlistName = item.name!! + PlaylistOptionsBottomSheet(playlistId, playlistName, false) .show(childFragmentManager, PlaylistOptionsBottomSheet::class.java.name) true } From 3b69e1d50178c2803d3b2a97cbe5033dd8443f5f Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Fri, 28 Oct 2022 19:53:47 +0530 Subject: [PATCH 058/516] Passed the respective Video/Channel/Playlist name to ShareDialog --- .../com/github/libretube/ui/fragments/ChannelFragment.kt | 7 ++++--- .../com/github/libretube/ui/fragments/PlayerFragment.kt | 6 +++++- .../com/github/libretube/ui/fragments/PlaylistFragment.kt | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index 4f9584f2e..657f036da 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -17,6 +17,7 @@ import com.github.libretube.databinding.FragmentChannelBinding import com.github.libretube.extensions.TAG import com.github.libretube.extensions.formatShort import com.github.libretube.extensions.toID +import com.github.libretube.obj.ShareData import com.github.libretube.ui.adapters.ChannelAdapter import com.github.libretube.ui.base.BaseFragment import com.github.libretube.ui.dialogs.ShareDialog @@ -29,7 +30,7 @@ class ChannelFragment : BaseFragment() { private var channelId: String? = null private var channelName: String? = null - + private lateinit var shareData: ShareData private var nextPage: String? = null private var channelAdapter: ChannelAdapter? = null private var isLoading = true @@ -102,7 +103,7 @@ class ChannelFragment : BaseFragment() { } // needed if the channel gets loaded by the ID channelId = response.id - + shareData = ShareData(currentChannel = response.name) // fetch and update the subscription status isSubscribed = SubscriptionHelper.isSubscribed(channelId!!) if (isSubscribed == null) return@launchWhenCreated @@ -125,7 +126,7 @@ class ChannelFragment : BaseFragment() { } binding.channelShare.setOnClickListener { - val shareDialog = ShareDialog(response.id!!.toID(), ShareObjectType.CHANNEL) + val shareDialog = ShareDialog(response.id!!.toID(), ShareObjectType.CHANNEL, shareData) shareDialog.show(childFragmentManager, ShareDialog::class.java.name) } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index c7ea66253..6c27a975d 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -55,6 +55,7 @@ import com.github.libretube.extensions.toID import com.github.libretube.extensions.toStreamItem import com.github.libretube.models.PlayerViewModel import com.github.libretube.models.interfaces.PlayerOptionsInterface +import com.github.libretube.obj.ShareData import com.github.libretube.services.BackgroundMode import com.github.libretube.services.DownloadService import com.github.libretube.ui.activities.MainActivity @@ -159,6 +160,8 @@ class PlayerFragment : BaseFragment() { */ private lateinit var nowPlayingNotification: NowPlayingNotification + private lateinit var shareData: ShareData + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) arguments?.let { @@ -428,7 +431,7 @@ class PlayerFragment : BaseFragment() { // share button binding.relPlayerShare.setOnClickListener { val shareDialog = - ShareDialog(videoId!!, ShareObjectType.VIDEO, exoPlayer.currentPosition / 1000) + ShareDialog(videoId!!, ShareObjectType.VIDEO, shareData, exoPlayer.currentPosition / 1000) shareDialog.show(childFragmentManager, ShareDialog::class.java.name) } @@ -824,6 +827,7 @@ class PlayerFragment : BaseFragment() { titleTextView.text = response.title playerTitle.text = response.title + shareData = ShareData(currentVideo = response.title) playerDescription.text = response.description playerChannelSubCount.text = context?.getString( diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt index 931d71d9e..e2bdb0c0f 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt @@ -25,6 +25,7 @@ class PlaylistFragment : BaseFragment() { private lateinit var binding: FragmentPlaylistBinding private var playlistId: String? = null + private var playlistName: String? = null private var isOwner: Boolean = false private var nextPage: String? = null private var playlistAdapter: PlaylistAdapter? = null @@ -75,6 +76,7 @@ class PlaylistFragment : BaseFragment() { return@launchWhenCreated } nextPage = response.nextpage + playlistName = response.name isLoading = false runOnUiThread { binding.playlistProgress.visibility = View.GONE @@ -86,7 +88,7 @@ class PlaylistFragment : BaseFragment() { // show playlist options binding.optionsMenu.setOnClickListener { val optionsDialog = - PlaylistOptionsBottomSheet(playlistId!!, isOwner) + PlaylistOptionsBottomSheet(playlistId!!, playlistName!!, isOwner) optionsDialog.show( childFragmentManager, PlaylistOptionsBottomSheet::class.java.name From c95a6b350e7263324194f7fb955318c185bd5308 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Fri, 28 Oct 2022 19:55:46 +0530 Subject: [PATCH 059/516] Passed the respective Video/Playlist name to bottom sheet --- .../libretube/ui/sheets/PlaylistOptionsBottomSheet.kt | 6 ++++-- .../github/libretube/ui/sheets/VideoOptionsBottomSheet.kt | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlaylistOptionsBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlaylistOptionsBottomSheet.kt index a5d81f435..2bb1b75fe 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlaylistOptionsBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlaylistOptionsBottomSheet.kt @@ -11,6 +11,7 @@ import com.github.libretube.constants.ShareObjectType import com.github.libretube.databinding.DialogTextPreferenceBinding import com.github.libretube.extensions.TAG import com.github.libretube.extensions.toID +import com.github.libretube.obj.ShareData import com.github.libretube.ui.dialogs.ShareDialog import com.github.libretube.ui.views.BottomSheet import com.github.libretube.util.BackgroundHelper @@ -25,9 +26,10 @@ import java.io.IOException class PlaylistOptionsBottomSheet( private val playlistId: String, + private val playlistName: String, private val isOwner: Boolean ) : BottomSheet() { - + private val shareData = ShareData(currentPlaylist = playlistName) override fun onCreate(savedInstanceState: Bundle?) { // options for the dialog var optionsList = listOf( @@ -76,7 +78,7 @@ class PlaylistOptionsBottomSheet( } // share the playlist context?.getString(R.string.share) -> { - val shareDialog = ShareDialog(playlistId, ShareObjectType.PLAYLIST) + val shareDialog = ShareDialog(playlistId, ShareObjectType.PLAYLIST, shareData) // using parentFragmentManager, childFragmentManager doesn't work here shareDialog.show(parentFragmentManager, ShareDialog::class.java.name) } diff --git a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt index 5310b75a1..1e6751743 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt @@ -7,6 +7,7 @@ import com.github.libretube.api.RetrofitInstance import com.github.libretube.constants.IntentData import com.github.libretube.constants.ShareObjectType import com.github.libretube.extensions.toStreamItem +import com.github.libretube.obj.ShareData import com.github.libretube.ui.dialogs.AddToPlaylistDialog import com.github.libretube.ui.dialogs.DownloadDialog import com.github.libretube.ui.dialogs.ShareDialog @@ -24,9 +25,10 @@ import kotlinx.coroutines.launch * Needs the [videoId] to load the content from the right video. */ class VideoOptionsBottomSheet( - private val videoId: String + private val videoId: String, + private val videoName: String ) : BottomSheet() { - + private val shareData = ShareData(currentVideo = videoName) override fun onCreate(savedInstanceState: Bundle?) { // List that stores the different menu options. In the future could be add more options here. val optionsList = mutableListOf( @@ -79,7 +81,7 @@ class VideoOptionsBottomSheet( downloadDialog.show(parentFragmentManager, DownloadDialog::class.java.name) } context?.getString(R.string.share) -> { - val shareDialog = ShareDialog(videoId, ShareObjectType.VIDEO) + val shareDialog = ShareDialog(videoId, ShareObjectType.VIDEO, shareData) // using parentFragmentManager is important here shareDialog.show(parentFragmentManager, ShareDialog::class.java.name) } From 2b45a46b2c9e2dbd0ddbe31793ae7b78a54580bc Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Fri, 28 Oct 2022 20:00:50 +0530 Subject: [PATCH 060/516] Added the EXTRA_SUBJECT in the intent --- .../github/libretube/ui/dialogs/ShareDialog.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt index ba135be6e..48a943a54 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt @@ -13,12 +13,14 @@ import com.github.libretube.constants.YOUTUBE_FRONTEND_URL import com.github.libretube.databinding.DialogShareBinding import com.github.libretube.db.DatabaseHolder.Companion.Database import com.github.libretube.extensions.awaitQuery +import com.github.libretube.obj.ShareData import com.github.libretube.util.PreferenceHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder class ShareDialog( private val id: String, private val shareObjectType: Int, + private val shareData: ShareData, private val position: Long? = null ) : DialogFragment() { private var binding: DialogShareBinding? = null @@ -29,7 +31,7 @@ class ShareDialog( getString(R.string.youtube) ) val instanceUrl = getCustomInstanceFrontendUrl() - + val shareableTitle = getShareableTitle(shareData) // add instanceUrl option if custom instance frontend url available if (instanceUrl != "") shareOptions += getString(R.string.instance) @@ -63,6 +65,7 @@ class ShareDialog( intent.apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_TEXT, url) + putExtra(Intent.EXTRA_SUBJECT, shareableTitle) type = "text/plain" } context?.startActivity( @@ -104,4 +107,14 @@ class ShareDialog( } return "" } + private fun getShareableTitle(shareData: ShareData): String { + if (shareData.currentChannel != null) { + return shareData.currentChannel + } else if (shareData.currentPlaylist != null) { + return shareData.currentPlaylist + } else if (shareData.currentVideo != null) { + return shareData.currentVideo + } + return "" + } } From 433a929ac34aedb15a950a960ca549032901a7ca Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Fri, 28 Oct 2022 20:02:50 +0530 Subject: [PATCH 061/516] New class to share Video/Channel/Playlist name --- app/src/main/java/com/github/libretube/obj/ShareData.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 app/src/main/java/com/github/libretube/obj/ShareData.kt diff --git a/app/src/main/java/com/github/libretube/obj/ShareData.kt b/app/src/main/java/com/github/libretube/obj/ShareData.kt new file mode 100644 index 000000000..8ad00bb5a --- /dev/null +++ b/app/src/main/java/com/github/libretube/obj/ShareData.kt @@ -0,0 +1,7 @@ +package com.github.libretube.obj + +data class ShareData( + val currentChannel: String ? = null, + val currentVideo: String ? = null, + val currentPlaylist: String ? = null +) From 6de599a310b1dfb8c1bef33b5f04c2cb5d61d809 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 20:14:04 +0200 Subject: [PATCH 062/516] show sponsorblock markers --- .../libretube/ui/fragments/PlayerFragment.kt | 3 + .../libretube/ui/views/MarkableTimeBar.kt | 68 +++++++++++++++++++ .../layout/exo_styled_player_control_view.xml | 2 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index c7ea66253..3ebd91b41 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -706,6 +706,7 @@ class PlayerFragment : BaseFragment() { videoId!!, ObjectMapper().writeValueAsString(categories) ) + playerBinding.exoProgress.setSegments(segmentData.segments) } } } @@ -784,6 +785,8 @@ class PlayerFragment : BaseFragment() { player = exoPlayer } + playerBinding.exoProgress.setPlayer(exoPlayer) + if (PlayerHelper.useSystemCaptionStyle) { // set the subtitle style val captionStyle = PlayerHelper.getCaptionStyle(requireContext()) diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt new file mode 100644 index 000000000..ddb82d450 --- /dev/null +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -0,0 +1,68 @@ +package com.github.libretube.ui.views + +import android.content.Context +import android.graphics.Canvas +import android.graphics.Color +import android.graphics.Paint +import android.graphics.Rect +import android.util.AttributeSet +import com.github.libretube.api.obj.Segment +import com.google.android.exoplayer2.Player +import com.google.android.exoplayer2.ui.DefaultTimeBar + +class MarkableTimeBar( + context: Context, + attributeSet: AttributeSet? = null +) : DefaultTimeBar(context, attributeSet) { + + private val HORIZONTAL_OFFSET = 5 + + private var segments: List = listOf(Segment(segment = listOf(1f, 10f)), Segment(segment = listOf(20f, 30f))) + private var player: Player? = null + private var length: Int = 0 + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + drawSegments(canvas) + } + + private fun drawSegments(canvas: Canvas) { + if (player == null) return + + canvas.save() + length = canvas.width + + val marginY = canvas.height / 2 - 3 + + segments.forEach { + canvas.drawRect( + Rect( + it.segment!!.first().toLength(), + marginY, + it.segment.last().toLength(), + canvas.height - marginY + ), + Paint().apply { + color = Color.RED + } + ) + } + canvas.restore() + } + + private fun Float.toLength(): Int { + val position = (this * 1000 / player!!.duration * length).toInt() + return maxOf( + minOf(position, length - HORIZONTAL_OFFSET), + HORIZONTAL_OFFSET + ) + } + + fun setSegments(segments: List) { + this.segments = segments + } + + fun setPlayer(player: Player) { + this.player = player + } +} diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index e508662f6..55e80750f 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -209,7 +209,7 @@ android:layout_marginRight="10dp" android:layout_marginBottom="10dp"> - Date: Fri, 28 Oct 2022 21:21:46 +0200 Subject: [PATCH 063/516] layout improvements --- .../libretube/ui/fragments/PlayerFragment.kt | 2 ++ .../libretube/ui/views/MarkableTimeBar.kt | 17 +++++++++++++---- app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 3ebd91b41..8d19010ef 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -629,6 +629,8 @@ class PlayerFragment : BaseFragment() { } private fun playVideo() { + playerBinding.exoProgress.clearSegments() + lifecycleScope.launchWhenCreated { streams = try { RetrofitInstance.api.getStreams(videoId!!) diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt index ddb82d450..7ab544689 100644 --- a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -10,13 +10,14 @@ import com.github.libretube.api.obj.Segment import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.ui.DefaultTimeBar +/** + * TimeBar that can be marked with SponsorBlock Segments + */ class MarkableTimeBar( context: Context, attributeSet: AttributeSet? = null ) : DefaultTimeBar(context, attributeSet) { - private val HORIZONTAL_OFFSET = 5 - private var segments: List = listOf(Segment(segment = listOf(1f, 10f)), Segment(segment = listOf(20f, 30f))) private var player: Player? = null private var length: Int = 0 @@ -30,14 +31,14 @@ class MarkableTimeBar( if (player == null) return canvas.save() - length = canvas.width + length = canvas.width - 2 * HORIZONTAL_OFFSET val marginY = canvas.height / 2 - 3 segments.forEach { canvas.drawRect( Rect( - it.segment!!.first().toLength(), + it.segment!!.first().toLength() + HORIZONTAL_OFFSET, marginY, it.segment.last().toLength(), canvas.height - marginY @@ -62,7 +63,15 @@ class MarkableTimeBar( this.segments = segments } + fun clearSegments() { + segments = listOf() + } + fun setPlayer(player: Player) { this.player = player } + + companion object { + const val HORIZONTAL_OFFSET = 8 + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e69f7711e..7c8300a5d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -350,6 +350,8 @@ Added to playlist Playing queue Queue + TimeBar Markers + Mark the segments on the time bar. Download Service From 31a52f004e1d45c115ee7ecfc27934d8e2de756a Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 21:27:04 +0200 Subject: [PATCH 064/516] make it a preference --- .../java/com/github/libretube/constants/PreferenceKeys.kt | 1 + .../java/com/github/libretube/ui/views/MarkableTimeBar.kt | 8 ++++++-- app/src/main/res/xml/sponsorblock_settings.xml | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index 1fdd5e0ce..cc4ae84bb 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -77,6 +77,7 @@ object PreferenceKeys { const val PICTURE_IN_PICTURE = "picture_in_picture" const val PLAYER_RESIZE_MODE = "player_resize_mode" const val SB_SKIP_MANUALLY = "sb_skip_manually_key" + const val SB_SHOW_MARKERS = "sb_show_markers" const val LIMIT_HLS = "limit_hls" const val PROGRESSIVE_LOADING_INTERVAL_SIZE = "progressive_loading_interval" diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt index 7ab544689..1fd8bc2e0 100644 --- a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -7,6 +7,8 @@ import android.graphics.Paint import android.graphics.Rect import android.util.AttributeSet import com.github.libretube.api.obj.Segment +import com.github.libretube.constants.PreferenceKeys +import com.github.libretube.util.PreferenceHelper import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.ui.DefaultTimeBar @@ -30,6 +32,8 @@ class MarkableTimeBar( private fun drawSegments(canvas: Canvas) { if (player == null) return + if (!PreferenceHelper.getBoolean(PreferenceKeys.SB_SHOW_MARKERS, false)) return + canvas.save() length = canvas.width - 2 * HORIZONTAL_OFFSET @@ -38,9 +42,9 @@ class MarkableTimeBar( segments.forEach { canvas.drawRect( Rect( - it.segment!!.first().toLength() + HORIZONTAL_OFFSET, + (it.segment!!.first() + HORIZONTAL_OFFSET).toLength(), marginY, - it.segment.last().toLength(), + (it.segment.last() + HORIZONTAL_OFFSET).toLength(), canvas.height - marginY ), Paint().apply { diff --git a/app/src/main/res/xml/sponsorblock_settings.xml b/app/src/main/res/xml/sponsorblock_settings.xml index 8e7291d2c..fd4b143ab 100644 --- a/app/src/main/res/xml/sponsorblock_settings.xml +++ b/app/src/main/res/xml/sponsorblock_settings.xml @@ -22,6 +22,12 @@ app:key="sb_skip_manually_key" app:title="@string/sb_skip_manual" /> + + Date: Fri, 28 Oct 2022 21:39:36 +0200 Subject: [PATCH 065/516] use a theme color --- .../libretube/ui/views/MarkableTimeBar.kt | 18 ++++++++---------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt index 1fd8bc2e0..6b10b0ab8 100644 --- a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -2,13 +2,14 @@ package com.github.libretube.ui.views import android.content.Context import android.graphics.Canvas -import android.graphics.Color import android.graphics.Paint import android.graphics.Rect import android.util.AttributeSet +import com.github.libretube.R import com.github.libretube.api.obj.Segment import com.github.libretube.constants.PreferenceKeys import com.github.libretube.util.PreferenceHelper +import com.github.libretube.util.ThemeHelper import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.ui.DefaultTimeBar @@ -37,7 +38,7 @@ class MarkableTimeBar( canvas.save() length = canvas.width - 2 * HORIZONTAL_OFFSET - val marginY = canvas.height / 2 - 3 + val marginY = canvas.height / 2 - PROGRESS_HEIGHT / 2 segments.forEach { canvas.drawRect( @@ -45,10 +46,10 @@ class MarkableTimeBar( (it.segment!!.first() + HORIZONTAL_OFFSET).toLength(), marginY, (it.segment.last() + HORIZONTAL_OFFSET).toLength(), - canvas.height - marginY + canvas.height - marginY - 1 ), Paint().apply { - color = Color.RED + color = ThemeHelper.getThemeColor(context, R.attr.colorError) } ) } @@ -56,11 +57,7 @@ class MarkableTimeBar( } private fun Float.toLength(): Int { - val position = (this * 1000 / player!!.duration * length).toInt() - return maxOf( - minOf(position, length - HORIZONTAL_OFFSET), - HORIZONTAL_OFFSET - ) + return (this * 1000 / player!!.duration * length).toInt() } fun setSegments(segments: List) { @@ -76,6 +73,7 @@ class MarkableTimeBar( } companion object { - const val HORIZONTAL_OFFSET = 8 + const val HORIZONTAL_OFFSET = 10 + const val PROGRESS_HEIGHT = 6 } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7c8300a5d..3d6683c56 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -350,7 +350,7 @@ Added to playlist Playing queue Queue - TimeBar Markers + Markers Mark the segments on the time bar. From 6d4da959d39a60401b07152825dbb13a66034cdf Mon Sep 17 00:00:00 2001 From: Linerly Date: Thu, 27 Oct 2022 12:50:48 +0000 Subject: [PATCH 066/516] Translated using Weblate (Indonesian) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/id/ --- app/src/main/res/values-in/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 57b9be52d..14a8c2e37 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -49,7 +49,7 @@ Anda harus memasukkan nama pengguna dan kata sandi. Resolusi video Beranda - Berlangganan + Langganan Koleksi Tema Bahasa From 19082d27600ed22305a272d4855a49bf6ff0ddb5 Mon Sep 17 00:00:00 2001 From: Fjuro Date: Thu, 27 Oct 2022 09:31:41 +0000 Subject: [PATCH 067/516] Translated using Weblate (Czech) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/cs/ --- app/src/main/res/values-cs/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 88dff6138..34e354427 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -354,4 +354,6 @@ Časové razítko Zobrazit více Přidáno do playlistu + Fronta + Přehrávání fronty \ No newline at end of file From 6f4ead47db5ec2f431764afc27899dc24422dc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81cs=20Zolt=C3=A1n?= Date: Thu, 27 Oct 2022 19:21:51 +0000 Subject: [PATCH 068/516] Translated using Weblate (Hungarian) Currently translated at 98.8% (352 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/hu/ --- app/src/main/res/values-hu/strings.xml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index d0bd3b3c4..15bb7fc4e 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -11,7 +11,7 @@ Kijelentkezve. Válasszon… Bejelentkezés/regisztráció - Kérjük, először a beállításokban lépjen be vagy regisztráljon! + Először a beállításokban lépjen be vagy regisztráljon! Nem lehetséges ezt a streamet letölteni. Sikertelen letöltés. Megnyitás VLC-ben @@ -35,11 +35,11 @@ Bejelentkezés Regisztráció Jelszó - Kérjük, lépjen be és próbálja újra! + Lépjen be és próbálja újra! Biztosan törölni szeretné a lejátszási listát\? Téma Itt nincs semmi. - Egy másik letöltés már folyamatban van, kérjük, várjon amíg befejeződik. + Egy másik letöltés már folyamatban van, várjon amíg befejeződik. Egyéni A letöltés kész. Sikeres feliratkozás @@ -221,7 +221,7 @@ Hitelesítési példány Használjon másik példányt a hitelesített hívásokhoz. Pozíció megjegyzése - Kérjük, az internethez való csatlakozáshoz kapcsolja be a wifit vagy a mobiladat-kapcsolatot. + Az internethez való csatlakozáshoz kapcsolja be a wifit vagy a mobiladat-kapcsolatot. Töltse be a nevet és az API URL-t. Maximális másodpercnyi videó a puffereléshez. Léptetés időköze @@ -309,7 +309,7 @@ Átméretezés mód Példány hozzáadása Hozzáadott törlése - Kérjük, adjon meg egy működő URL-t + Adjon meg egy működő URL-t Hitelesítési példány kiválasztása Megtekintési és keresési előzmények Ismétlés mód @@ -354,4 +354,6 @@ Mostanában frissített (fordítva) Több megjelenítése Időpont + Lejátszási sor + Sor \ No newline at end of file From c8fa283aa0b0c722bda436dc3ac36fa9906c2382 Mon Sep 17 00:00:00 2001 From: Gediminas Murauskas Date: Thu, 27 Oct 2022 16:32:17 +0000 Subject: [PATCH 069/516] Translated using Weblate (Lithuanian) Currently translated at 100.0% (356 of 356 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/lt/ --- app/src/main/res/values-lt/strings.xml | 67 +++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 824db78f9..6fe26ac61 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -261,7 +261,7 @@ Muzikos aplankas Išjungta YouTube - %1$s peržiūrų + %1$s peržiūros Grotuvas SD kortelė Daugiausiai peržiūrų @@ -291,4 +291,69 @@ Nėra rezultatų. Dalintis su laiko kodu Kokybė ir formatas + %1$s prenumeratoriai + Pritaikymas + %1$s vaizdo įrašai + Bandyti dar kartą + Numatytoji kortelė + Apmokama reklama, apmokamos rekomendacijos ir tiesioginė reklama. Ne savireklama ar neapmokamas nuoširdus, kūrėjų, svetainių ir produktų reklamavimas. + Sąveikos priminimas (skatinimas pamėgti ir prenumeruoti) + Pertrauka / įžanginė animacija + Pabaigos kortelės ir padėkos + Informacija po turinio pabaigos. Neskirta išvadoms su informacija. + Užpildas / anekdotai + Mažai susijusios scenos, pridėtos tik užpildui ar humorui, žiūrint nereikia suprasti pagrindinio vaizdo įrašo turinio. + Muzika: su muzika nesusijusi dalis + Peržiūra / apibendrinimas + Rami raudona + Maloni mėlyna + Gaivi geltona + Žavinti žalia + Material You + Pranešimai + Atsiuntimai + Eiti į GitHub versijas, kad ją atsisiųstumėte\? + Prisidėjimas + Atsisiuntimai ir nustatymas iš naujo + Bendrinti URL su + Prarastas palikimas + Gilus gradientas + Užgožianti ugnis + Dirglus deglas + Fiktyvi forma + Linguojanti liepsna + Pasipūtęs paukštis + Ištrinti pridėtą + Rodyti panašias transliacijas šalia to, ką žiūrite. + Didžiausias užkrauto vaizdo įrašo sekundžių skaičius atmintyje. + Numatytieji nustatymai ir elgsena + Prasukimo žingsnio dydis + Automatinis + Viso ekrano padėtis + Pasirinktinė + Juodai balta tema + Gryna juodai balta tema + Paskutinė peržiūros vieta atsiminta + Jokios + Rodyti momentinę nuotrauką, kai velkate atkūrimo indikatorių. + Antraštės + Naujausia + Apskaičiuojamų duomenų + Būtinas ryšys + Visi + Vaizdas vaizde + Nepraleisti segmentų automatiškai, visada prieš tai įspėti. + Pasirinktiniai perdavimo šaltiniai + Fone įkelti prenumeratos kanalą ir neleisti, kad jis būtų automatiškai atnaujinamas. + Paleisti sekantį + Progresyvaus pakrovimo intervalo dydis + Pranešimų agentas + Panašus į „rėmimą“, išskyrus neapmokamą arba savęs reklamavimą. Tai apima skyrius apie prekes, aukas arba informaciją apie tai, su kuo kūrėjas bendradarbiavo. + Kai yra trumpas priminimas pamėgti, prenumeruoti arba sekti turinio viduryje. Jei tai ilgas segmentas ar skirta kam nors konkrečiam, tai turėtų būti savęs reklama. + Intervalas be faktinio turinio. Tai gali būti pauzė, statiškas kadras, pasikartojanti animacija. Neturėtų būti naudojamas perėjimams su informacija. + Juoda + Naudoti tik muzikiniuose vaizdo įrašuose. Ji turėtų apimti vaizdo įrašo dalis, kurios nėra oficialių miksų dalis. Galų gale vaizdo įrašas turėtų būti kuo panašesnis į „Spotify“ ar bet kurią kitą mišrią versiją arba turėtų sumažinti kalbėjimą ar kitus trukdžius. + Segmentams, kuriuose išsamiai nupasakojamas būsimas šio ar būsimų serijos vaizdo įrašų turinys, bet nepateikiama papildomos informacijos. Jei joje yra klipų, kurie rodomi tik čia, labai tikėtina, kad tai netinkama kategorija. + Viliojanti violetinė + Vaizdo įrašo rezoliucija \ No newline at end of file From e598b745f60c60b05d322192d65fd0f022be2e82 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 21:49:23 +0200 Subject: [PATCH 070/516] shorten the update string --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d6683c56..9561d0ba2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -134,7 +134,7 @@ Contributing Donate Look for new version - Click to find out if the app is up to date. + Check for update Running the latest version. You are running the latest version. Playback speed From 75ffce292c948217c5f2d9d82dbb712045022ece Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 21:52:26 +0200 Subject: [PATCH 071/516] Fix format short when the count is null --- .../java/com/github/libretube/extensions/FormatShort.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/extensions/FormatShort.kt b/app/src/main/java/com/github/libretube/extensions/FormatShort.kt index f0751db56..bb010765b 100644 --- a/app/src/main/java/com/github/libretube/extensions/FormatShort.kt +++ b/app/src/main/java/com/github/libretube/extensions/FormatShort.kt @@ -3,15 +3,17 @@ package com.github.libretube.extensions import java.math.BigDecimal import java.math.RoundingMode +@Suppress("KotlinConstantConditions") fun Long?.formatShort(): String = when { - this!! < 1000 -> { + this == null -> (0).toString() + this < 1000 -> { this.toString() } - this in 1000..999999 -> { + this in (1000..999999) -> { val decimal = BigDecimal(this / 1000).setScale(0, RoundingMode.HALF_EVEN) decimal.toString() + "K" } - this in 1000000..10000000 -> { + this in (1000000..10000000) -> { val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN) decimal.toString() + "M" } From 7837ce1c601cfbec988ca4b18a69d0a2deb7bdc4 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 22:08:50 +0200 Subject: [PATCH 072/516] add shuffle and clear to playing queue --- .../libretube/ui/sheets/PlayingQueueSheet.kt | 21 +++++- app/src/main/res/drawable/ic_shuffle.xml | 10 +++ .../main/res/layout/queue_bottom_sheet.xml | 66 +++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_shuffle.xml create mode 100644 app/src/main/res/layout/queue_bottom_sheet.xml diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 1292b7377..d8038e513 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -7,20 +7,20 @@ import android.view.ViewGroup import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.github.libretube.databinding.BottomSheetBinding +import com.github.libretube.databinding.QueueBottomSheetBinding import com.github.libretube.ui.adapters.PlayingQueueAdapter import com.github.libretube.util.PlayingQueue import com.google.android.material.bottomsheet.BottomSheetDialogFragment class PlayingQueueSheet : BottomSheetDialogFragment() { - private lateinit var binding: BottomSheetBinding + private lateinit var binding: QueueBottomSheetBinding override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { - binding = BottomSheetBinding.inflate(layoutInflater) + binding = QueueBottomSheetBinding.inflate(layoutInflater) return binding.root } @@ -31,6 +31,21 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { val adapter = PlayingQueueAdapter() binding.optionsRecycler.adapter = adapter + binding.shuffle.setOnClickListener { + val streams = PlayingQueue.getStreams() + streams.subList(PlayingQueue.currentIndex(), PlayingQueue.size()).shuffle() + adapter.notifyItemRangeChanged(0, PlayingQueue.size()) + } + + binding.clear.setOnClickListener { + val streams = PlayingQueue.getStreams() + streams.subList(PlayingQueue.currentIndex(), PlayingQueue.size()).clear() + } + + binding.bottomControls.setOnClickListener { + dialog?.dismiss() + } + val callback = object : ItemTouchHelper.SimpleCallback( ItemTouchHelper.UP or ItemTouchHelper.DOWN, ItemTouchHelper.LEFT diff --git a/app/src/main/res/drawable/ic_shuffle.xml b/app/src/main/res/drawable/ic_shuffle.xml new file mode 100644 index 000000000..76ff342cd --- /dev/null +++ b/app/src/main/res/drawable/ic_shuffle.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/queue_bottom_sheet.xml b/app/src/main/res/layout/queue_bottom_sheet.xml new file mode 100644 index 000000000..7f6a0a8eb --- /dev/null +++ b/app/src/main/res/layout/queue_bottom_sheet.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 67982186c644bd59504e287308d73ef81be396ce Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 22:18:18 +0200 Subject: [PATCH 073/516] bug fixes --- .../github/libretube/ui/sheets/PlayingQueueSheet.kt | 10 +++++++--- app/src/main/res/drawable/ic_shuffle.xml | 2 +- app/src/main/res/layout/queue_bottom_sheet.xml | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index d8038e513..59c0d8bb4 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -33,13 +33,17 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { binding.shuffle.setOnClickListener { val streams = PlayingQueue.getStreams() - streams.subList(PlayingQueue.currentIndex(), PlayingQueue.size()).shuffle() - adapter.notifyItemRangeChanged(0, PlayingQueue.size()) + val size = PlayingQueue.size() + streams.subList(PlayingQueue.currentIndex(), size).shuffle() + adapter.notifyItemRangeChanged(0, size) } binding.clear.setOnClickListener { val streams = PlayingQueue.getStreams() - streams.subList(PlayingQueue.currentIndex(), PlayingQueue.size()).clear() + val currentIndex = PlayingQueue.currentIndex() + val size = PlayingQueue.size() + streams.subList(currentIndex, size).clear() + adapter.notifyItemRangeRemoved(currentIndex + 1, size) } binding.bottomControls.setOnClickListener { diff --git a/app/src/main/res/drawable/ic_shuffle.xml b/app/src/main/res/drawable/ic_shuffle.xml index 76ff342cd..67d78b7a1 100644 --- a/app/src/main/res/drawable/ic_shuffle.xml +++ b/app/src/main/res/drawable/ic_shuffle.xml @@ -1,7 +1,7 @@ + android:layout_height="0dp" + android:layout_weight="1" /> Date: Fri, 28 Oct 2022 22:26:33 +0200 Subject: [PATCH 074/516] Fix the playback speed value --- .../main/java/com/github/libretube/extensions/Round.kt | 9 +++++++++ .../com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt | 5 +++-- .../com/github/libretube/ui/sheets/PlayingQueueSheet.kt | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/extensions/Round.kt diff --git a/app/src/main/java/com/github/libretube/extensions/Round.kt b/app/src/main/java/com/github/libretube/extensions/Round.kt new file mode 100644 index 000000000..0be63d173 --- /dev/null +++ b/app/src/main/java/com/github/libretube/extensions/Round.kt @@ -0,0 +1,9 @@ +package com.github.libretube.extensions + +import kotlin.math.pow +import kotlin.math.roundToInt + +fun Float.round(decimalPlaces: Int): Float { + return (this * 10.0.pow(decimalPlaces.toDouble())).roundToInt() / 10.0.pow(decimalPlaces.toDouble()) + .toFloat() +} diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt index 43f28e6b2..c0d19d559 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlaybackSpeedSheet.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.FragmentManager import com.github.libretube.databinding.PlaybackBottomSheetBinding +import com.github.libretube.extensions.round import com.google.android.exoplayer2.PlaybackParameters import com.google.android.exoplayer2.Player import com.google.android.material.bottomsheet.BottomSheetDialogFragment @@ -31,11 +32,11 @@ class PlaybackSpeedSheet( binding.pitch.value = player.playbackParameters.pitch binding.speed.addOnChangeListener { _, value, _ -> - onChange(value, binding.pitch.value) + onChange(value, binding.pitch.value.round(2)) } binding.pitch.addOnChangeListener { _, value, _ -> - onChange(binding.speed.value, value) + onChange(binding.speed.value.round(2), value) } } diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 59c0d8bb4..fef5f877f 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -33,7 +33,7 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { binding.shuffle.setOnClickListener { val streams = PlayingQueue.getStreams() - val size = PlayingQueue.size() + val size = PlayingQueue.size() streams.subList(PlayingQueue.currentIndex(), size).shuffle() adapter.notifyItemRangeChanged(0, size) } From 38d286bb94bd1808b1cd53e00abbc8aa03f37b16 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 23:04:44 +0200 Subject: [PATCH 075/516] fix shuffle and clear --- .../libretube/ui/sheets/PlayingQueueSheet.kt | 26 ++++++++++++++----- .../com/github/libretube/util/PlayingQueue.kt | 5 ++++ .../main/res/layout/queue_bottom_sheet.xml | 4 +++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index fef5f877f..13d4fc695 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -1,5 +1,6 @@ package com.github.libretube.ui.sheets +import android.annotation.SuppressLint import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -24,6 +25,7 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { return binding.root } + @SuppressLint("NotifyDataSetChanged") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -33,17 +35,27 @@ class PlayingQueueSheet : BottomSheetDialogFragment() { binding.shuffle.setOnClickListener { val streams = PlayingQueue.getStreams() - val size = PlayingQueue.size() - streams.subList(PlayingQueue.currentIndex(), size).shuffle() - adapter.notifyItemRangeChanged(0, size) + val currentIndex = PlayingQueue.currentIndex() + val current = streams[currentIndex] + + streams.shuffle() + streams.remove(current) + streams.add(currentIndex, current) + PlayingQueue.setStreams(streams) + + adapter.notifyDataSetChanged() } binding.clear.setOnClickListener { val streams = PlayingQueue.getStreams() - val currentIndex = PlayingQueue.currentIndex() - val size = PlayingQueue.size() - streams.subList(currentIndex, size).clear() - adapter.notifyItemRangeRemoved(currentIndex + 1, size) + val index = PlayingQueue.currentIndex() + + while (index >= PlayingQueue.size()) { + streams.removeAt(index) + } + + PlayingQueue.setStreams(streams) + adapter.notifyDataSetChanged() } binding.bottomControls.setOnClickListener { diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 887185ae8..18d60b7d4 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -74,6 +74,11 @@ object PlayingQueue { fun getStreams() = queue + fun setStreams(streams: List) { + queue.clear() + queue.addAll(streams) + } + fun remove(index: Int) = queue.removeAt(index) fun move(from: Int, to: Int) = queue.move(from, to) diff --git a/app/src/main/res/layout/queue_bottom_sheet.xml b/app/src/main/res/layout/queue_bottom_sheet.xml index 01b45506d..aeeb9863c 100644 --- a/app/src/main/res/layout/queue_bottom_sheet.xml +++ b/app/src/main/res/layout/queue_bottom_sheet.xml @@ -33,6 +33,7 @@ android:id="@+id/bottom_controls" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_margin="5dp" android:background="@drawable/rounded_ripple" android:padding="10dp"> @@ -41,11 +42,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" + android:padding="5dp" android:src="@drawable/ic_shuffle" /> From d3bdadb446ef160f9365e9f38ecce04e58110429 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 23:11:51 +0200 Subject: [PATCH 076/516] pass the playlist id to the background mode --- .../java/com/github/libretube/ui/fragments/PlayerFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 8d19010ef..48b9c0f57 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -440,7 +440,8 @@ class PlayerFragment : BaseFragment() { BackgroundHelper.playOnBackground( requireContext(), videoId!!, - exoPlayer.currentPosition + exoPlayer.currentPosition, + playlistId ) } From e4e71e6e8067b5e16c56229b1f5bef2fa3ac17eb Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 23:20:07 +0200 Subject: [PATCH 077/516] remove testing code --- app/src/main/AndroidManifest.xml | 1 + .../java/com/github/libretube/api/PipedApi.kt | 85 +++++++++++-------- .../libretube/ui/views/MarkableTimeBar.kt | 2 +- .../libretube/util/NowPlayingNotification.kt | 1 - app/src/main/res/menu/action_bar.xml | 4 +- 5 files changed, 54 insertions(+), 39 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fd90ad13..02a10b7ca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ + diff --git a/app/src/main/java/com/github/libretube/api/PipedApi.kt b/app/src/main/java/com/github/libretube/api/PipedApi.kt index a6eb42c6d..67d55a959 100644 --- a/app/src/main/java/com/github/libretube/api/PipedApi.kt +++ b/app/src/main/java/com/github/libretube/api/PipedApi.kt @@ -1,5 +1,20 @@ package com.github.libretube.api +import com.github.libretube.api.obj.Channel +import com.github.libretube.api.obj.CommentsPage +import com.github.libretube.api.obj.DeleteUserRequest +import com.github.libretube.api.obj.Login +import com.github.libretube.api.obj.Message +import com.github.libretube.api.obj.Playlist +import com.github.libretube.api.obj.PlaylistId +import com.github.libretube.api.obj.Playlists +import com.github.libretube.api.obj.SearchResult +import com.github.libretube.api.obj.Segments +import com.github.libretube.api.obj.StreamItem +import com.github.libretube.api.obj.Streams +import com.github.libretube.api.obj.Subscribe +import com.github.libretube.api.obj.Subscription +import com.github.libretube.api.obj.Token import retrofit2.http.Body import retrofit2.http.GET import retrofit2.http.Header @@ -9,25 +24,25 @@ import retrofit2.http.Query interface PipedApi { @GET("trending") - suspend fun getTrending(@Query("region") region: String): List + suspend fun getTrending(@Query("region") region: String): List @GET("streams/{videoId}") - suspend fun getStreams(@Path("videoId") videoId: String): com.github.libretube.api.obj.Streams + suspend fun getStreams(@Path("videoId") videoId: String): Streams @GET("comments/{videoId}") - suspend fun getComments(@Path("videoId") videoId: String): com.github.libretube.api.obj.CommentsPage + suspend fun getComments(@Path("videoId") videoId: String): CommentsPage @GET("sponsors/{videoId}") suspend fun getSegments( @Path("videoId") videoId: String, @Query("category") category: String - ): com.github.libretube.api.obj.Segments + ): Segments @GET("nextpage/comments/{videoId}") suspend fun getCommentsNextPage( @Path("videoId") videoId: String, @Query("nextpage") nextPage: String - ): com.github.libretube.api.obj.CommentsPage + ): CommentsPage @GET("search") suspend fun getSearchResults( @@ -40,49 +55,49 @@ interface PipedApi { @Query("q") searchQuery: String, @Query("filter") filter: String, @Query("nextpage") nextPage: String - ): com.github.libretube.api.obj.SearchResult + ): SearchResult @GET("suggestions") suspend fun getSuggestions(@Query("query") query: String): List @GET("channel/{channelId}") - suspend fun getChannel(@Path("channelId") channelId: String): com.github.libretube.api.obj.Channel + suspend fun getChannel(@Path("channelId") channelId: String): Channel @GET("user/{name}") - suspend fun getChannelByName(@Path("name") channelName: String): com.github.libretube.api.obj.Channel + suspend fun getChannelByName(@Path("name") channelName: String): Channel @GET("nextpage/channel/{channelId}") suspend fun getChannelNextPage( @Path("channelId") channelId: String, @Query("nextpage") nextPage: String - ): com.github.libretube.api.obj.Channel + ): Channel @GET("playlists/{playlistId}") - suspend fun getPlaylist(@Path("playlistId") playlistId: String): com.github.libretube.api.obj.Playlist + suspend fun getPlaylist(@Path("playlistId") playlistId: String): Playlist @GET("nextpage/playlists/{playlistId}") suspend fun getPlaylistNextPage( @Path("playlistId") playlistId: String, @Query("nextpage") nextPage: String - ): com.github.libretube.api.obj.Playlist + ): Playlist @POST("login") - suspend fun login(@Body login: com.github.libretube.api.obj.Login): com.github.libretube.api.obj.Token + suspend fun login(@Body login: Login): Token @POST("register") - suspend fun register(@Body login: com.github.libretube.api.obj.Login): com.github.libretube.api.obj.Token + suspend fun register(@Body login: Login): Token @POST("user/delete") suspend fun deleteAccount( @Header("Authorization") token: String, - @Body password: com.github.libretube.api.obj.DeleteUserRequest + @Body password: DeleteUserRequest ) @GET("feed") - suspend fun getFeed(@Query("authToken") token: String?): List + suspend fun getFeed(@Query("authToken") token: String?): List @GET("feed/unauthenticated") - suspend fun getUnauthenticatedFeed(@Query("channels") channels: String): List + suspend fun getUnauthenticatedFeed(@Query("channels") channels: String): List @GET("subscribed") suspend fun isSubscribed( @@ -91,66 +106,66 @@ interface PipedApi { ): com.github.libretube.api.obj.Subscribed @GET("subscriptions") - suspend fun subscriptions(@Header("Authorization") token: String): List + suspend fun subscriptions(@Header("Authorization") token: String): List @GET("subscriptions/unauthenticated") - suspend fun unauthenticatedSubscriptions(@Query("channels") channels: String): List + suspend fun unauthenticatedSubscriptions(@Query("channels") channels: String): List @POST("subscribe") suspend fun subscribe( @Header("Authorization") token: String, - @Body subscribe: com.github.libretube.api.obj.Subscribe - ): com.github.libretube.api.obj.Message + @Body subscribe: Subscribe + ): Message @POST("unsubscribe") suspend fun unsubscribe( @Header("Authorization") token: String, - @Body subscribe: com.github.libretube.api.obj.Subscribe - ): com.github.libretube.api.obj.Message + @Body subscribe: Subscribe + ): Message @POST("import") suspend fun importSubscriptions( @Query("override") override: Boolean, @Header("Authorization") token: String, @Body channels: List - ): com.github.libretube.api.obj.Message + ): Message @POST("import/playlist") suspend fun importPlaylist( @Header("Authorization") token: String, - @Body playlistId: com.github.libretube.api.obj.PlaylistId - ): com.github.libretube.api.obj.Message + @Body playlistId: PlaylistId + ): Message @GET("user/playlists") - suspend fun playlists(@Header("Authorization") token: String): List + suspend fun playlists(@Header("Authorization") token: String): List @POST("user/playlists/rename") suspend fun renamePlaylist( @Header("Authorization") token: String, - @Body playlistId: com.github.libretube.api.obj.PlaylistId + @Body playlistId: PlaylistId ) @POST("user/playlists/delete") suspend fun deletePlaylist( @Header("Authorization") token: String, - @Body playlistId: com.github.libretube.api.obj.PlaylistId - ): com.github.libretube.api.obj.Message + @Body playlistId: PlaylistId + ): Message @POST("user/playlists/create") suspend fun createPlaylist( @Header("Authorization") token: String, - @Body name: com.github.libretube.api.obj.Playlists - ): com.github.libretube.api.obj.PlaylistId + @Body name: Playlists + ): PlaylistId @POST("user/playlists/add") suspend fun addToPlaylist( @Header("Authorization") token: String, - @Body playlistId: com.github.libretube.api.obj.PlaylistId - ): com.github.libretube.api.obj.Message + @Body playlistId: PlaylistId + ): Message @POST("user/playlists/remove") suspend fun removeFromPlaylist( @Header("Authorization") token: String, - @Body playlistId: com.github.libretube.api.obj.PlaylistId - ): com.github.libretube.api.obj.Message + @Body playlistId: PlaylistId + ): Message } diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt index 6b10b0ab8..fcc06e236 100644 --- a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -21,7 +21,7 @@ class MarkableTimeBar( attributeSet: AttributeSet? = null ) : DefaultTimeBar(context, attributeSet) { - private var segments: List = listOf(Segment(segment = listOf(1f, 10f)), Segment(segment = listOf(20f, 30f))) + private var segments: List = listOf() private var player: Player? = null private var length: Int = 0 diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index 3b7c3dcfc..55bd7e3fd 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -1,6 +1,5 @@ package com.github.libretube.util -import android.R.attr.data import android.annotation.SuppressLint import android.app.NotificationManager import android.app.PendingIntent diff --git a/app/src/main/res/menu/action_bar.xml b/app/src/main/res/menu/action_bar.xml index 90488f1d8..93f22be43 100644 --- a/app/src/main/res/menu/action_bar.xml +++ b/app/src/main/res/menu/action_bar.xml @@ -30,7 +30,7 @@ + android:visible="false" + app:showAsAction="never" /> \ No newline at end of file From 8474471691d000890acda17903e01b39f2e7d5b0 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 28 Oct 2022 23:39:25 +0200 Subject: [PATCH 078/516] cleanup sponsorblock --- app/src/main/java/com/github/libretube/api/PipedApi.kt | 6 +++--- app/src/main/java/com/github/libretube/api/obj/Segment.kt | 8 +++++++- .../libretube/api/obj/{Segments.kt => SegmentData.kt} | 6 ++++-- .../java/com/github/libretube/services/BackgroundMode.kt | 6 +++--- .../com/github/libretube/ui/fragments/PlayerFragment.kt | 8 +++++--- .../java/com/github/libretube/ui/views/MarkableTimeBar.kt | 4 ++-- .../main/java/com/github/libretube/util/LocaleHelper.kt | 1 + 7 files changed, 25 insertions(+), 14 deletions(-) rename app/src/main/java/com/github/libretube/api/obj/{Segments.kt => SegmentData.kt} (52%) diff --git a/app/src/main/java/com/github/libretube/api/PipedApi.kt b/app/src/main/java/com/github/libretube/api/PipedApi.kt index 67d55a959..061ea5691 100644 --- a/app/src/main/java/com/github/libretube/api/PipedApi.kt +++ b/app/src/main/java/com/github/libretube/api/PipedApi.kt @@ -9,7 +9,7 @@ import com.github.libretube.api.obj.Playlist import com.github.libretube.api.obj.PlaylistId import com.github.libretube.api.obj.Playlists import com.github.libretube.api.obj.SearchResult -import com.github.libretube.api.obj.Segments +import com.github.libretube.api.obj.SegmentData import com.github.libretube.api.obj.StreamItem import com.github.libretube.api.obj.Streams import com.github.libretube.api.obj.Subscribe @@ -36,7 +36,7 @@ interface PipedApi { suspend fun getSegments( @Path("videoId") videoId: String, @Query("category") category: String - ): Segments + ): SegmentData @GET("nextpage/comments/{videoId}") suspend fun getCommentsNextPage( @@ -48,7 +48,7 @@ interface PipedApi { suspend fun getSearchResults( @Query("q") searchQuery: String, @Query("filter") filter: String - ): com.github.libretube.api.obj.SearchResult + ): SearchResult @GET("nextpage/search") suspend fun getSearchResultsNextPage( diff --git a/app/src/main/java/com/github/libretube/api/obj/Segment.kt b/app/src/main/java/com/github/libretube/api/obj/Segment.kt index ea92df057..951a7b472 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Segment.kt +++ b/app/src/main/java/com/github/libretube/api/obj/Segment.kt @@ -4,7 +4,13 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Segment( + val UUID: String? = null, val actionType: String? = null, val category: String? = null, - val segment: List? = arrayListOf() + val description: String? = null, + val locked: Int? = null, + val segment: List = listOf(), + val userID: String? = null, + val videoDuration: Double? = null, + val votes: Int? = null ) diff --git a/app/src/main/java/com/github/libretube/api/obj/Segments.kt b/app/src/main/java/com/github/libretube/api/obj/SegmentData.kt similarity index 52% rename from app/src/main/java/com/github/libretube/api/obj/Segments.kt rename to app/src/main/java/com/github/libretube/api/obj/SegmentData.kt index 704bd899c..a383cd801 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Segments.kt +++ b/app/src/main/java/com/github/libretube/api/obj/SegmentData.kt @@ -3,6 +3,8 @@ package com.github.libretube.api.obj import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) -data class Segments( - val segments: MutableList = arrayListOf() +data class SegmentData( + val hash: String? = null, + val segments: List = listOf(), + val videoID: String? = null ) diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 4134ab485..c6bfdc6ae 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -15,7 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.github.libretube.R import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.Segment -import com.github.libretube.api.obj.Segments +import com.github.libretube.api.obj.SegmentData import com.github.libretube.api.obj.Streams import com.github.libretube.constants.BACKGROUND_CHANNEL_ID import com.github.libretube.constants.IntentData @@ -72,7 +72,7 @@ class BackgroundMode : Service() { /** * SponsorBlock Segment data */ - private var segmentData: Segments? = null + private var segmentData: SegmentData? = null /** * [Notification] for the player @@ -325,7 +325,7 @@ class BackgroundMode : Service() { if (segmentData == null || segmentData!!.segments.isEmpty()) return segmentData!!.segments.forEach { segment: Segment -> - val segmentStart = (segment.segment!![0] * 1000f).toLong() + val segmentStart = (segment.segment[0] * 1000f).toLong() val segmentEnd = (segment.segment[1] * 1000f).toLong() val currentPosition = player?.currentPosition if (currentPosition in segmentStart until segmentEnd) { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 48b9c0f57..c91f3c5e4 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -38,6 +38,8 @@ import com.github.libretube.R import com.github.libretube.api.CronetHelper import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.SubscriptionHelper +import com.github.libretube.api.obj.ChapterSegment +import com.github.libretube.api.obj.SegmentData import com.github.libretube.constants.IntentData import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.ShareObjectType @@ -139,8 +141,8 @@ class PlayerFragment : BaseFragment() { */ private lateinit var exoPlayer: ExoPlayer private lateinit var trackSelector: DefaultTrackSelector - private lateinit var segmentData: com.github.libretube.api.obj.Segments - private lateinit var chapters: List + private lateinit var segmentData: SegmentData + private lateinit var chapters: List /** * for the player view @@ -598,7 +600,7 @@ class PlayerFragment : BaseFragment() { val currentPosition = exoPlayer.currentPosition segmentData.segments.forEach { segment: com.github.libretube.api.obj.Segment -> - val segmentStart = (segment.segment!![0] * 1000f).toLong() + val segmentStart = (segment.segment[0] * 1000f).toLong() val segmentEnd = (segment.segment[1] * 1000f).toLong() // show the button to manually skip the segment diff --git a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt index fcc06e236..e3f9b0582 100644 --- a/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt +++ b/app/src/main/java/com/github/libretube/ui/views/MarkableTimeBar.kt @@ -43,7 +43,7 @@ class MarkableTimeBar( segments.forEach { canvas.drawRect( Rect( - (it.segment!!.first() + HORIZONTAL_OFFSET).toLength(), + (it.segment.first() + HORIZONTAL_OFFSET).toLength(), marginY, (it.segment.last() + HORIZONTAL_OFFSET).toLength(), canvas.height - marginY - 1 @@ -56,7 +56,7 @@ class MarkableTimeBar( canvas.restore() } - private fun Float.toLength(): Int { + private fun Double.toLength(): Int { return (this * 1000 / player!!.duration * length).toInt() } diff --git a/app/src/main/java/com/github/libretube/util/LocaleHelper.kt b/app/src/main/java/com/github/libretube/util/LocaleHelper.kt index 5783b6d69..c0c4778e5 100644 --- a/app/src/main/java/com/github/libretube/util/LocaleHelper.kt +++ b/app/src/main/java/com/github/libretube/util/LocaleHelper.kt @@ -35,6 +35,7 @@ object LocaleHelper { val dm = res.displayMetrics val conf = res.configuration conf.setLocale(locale) + @Suppress("DEPRECATION") res.updateConfiguration(conf, dm) } From 30d662522e2a2be7d36959cdeb70f07880c470be Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sat, 29 Oct 2022 13:21:33 +0530 Subject: [PATCH 079/516] ktlint fix --- .../com/github/libretube/ui/adapters/PlaylistsAdapter.kt | 2 +- .../com/github/libretube/ui/fragments/PlayerFragment.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt index 84af7d286..e82bafd75 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt @@ -74,7 +74,7 @@ class PlaylistsAdapter( val playlistOptionsDialog = PlaylistOptionsBottomSheet( playlistId = playlist.id!!, playlistName = playlist.name!!, - isOwner = true, + isOwner = true ) playlistOptionsDialog.show( childFragmentManager, diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 6c27a975d..22373a0be 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -431,7 +431,12 @@ class PlayerFragment : BaseFragment() { // share button binding.relPlayerShare.setOnClickListener { val shareDialog = - ShareDialog(videoId!!, ShareObjectType.VIDEO, shareData, exoPlayer.currentPosition / 1000) + ShareDialog( + videoId!!, + ShareObjectType.VIDEO, + shareData, + exoPlayer.currentPosition / 1000 + ) shareDialog.show(childFragmentManager, ShareDialog::class.java.name) } From e39f97925fe5eefe608886436148f7ce2d66bc9d Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sat, 29 Oct 2022 13:23:35 +0530 Subject: [PATCH 080/516] moved variable declaration --- .../com/github/libretube/ui/fragments/ChannelFragment.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index 657f036da..ae29c0cfd 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -30,7 +30,6 @@ class ChannelFragment : BaseFragment() { private var channelId: String? = null private var channelName: String? = null - private lateinit var shareData: ShareData private var nextPage: String? = null private var channelAdapter: ChannelAdapter? = null private var isLoading = true @@ -103,7 +102,7 @@ class ChannelFragment : BaseFragment() { } // needed if the channel gets loaded by the ID channelId = response.id - shareData = ShareData(currentChannel = response.name) + val shareData = ShareData(currentChannel = response.name) // fetch and update the subscription status isSubscribed = SubscriptionHelper.isSubscribed(channelId!!) if (isSubscribed == null) return@launchWhenCreated @@ -126,7 +125,11 @@ class ChannelFragment : BaseFragment() { } binding.channelShare.setOnClickListener { - val shareDialog = ShareDialog(response.id!!.toID(), ShareObjectType.CHANNEL, shareData) + val shareDialog = ShareDialog( + response.id!!.toID(), + ShareObjectType.CHANNEL, + shareData + ) shareDialog.show(childFragmentManager, ShareDialog::class.java.name) } } From 3f56311939fe695329fb81bc24608f43b25a6cf4 Mon Sep 17 00:00:00 2001 From: shantanu1k Date: Sat, 29 Oct 2022 13:49:03 +0530 Subject: [PATCH 081/516] refactoring with scope functions --- .../github/libretube/ui/dialogs/ShareDialog.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt index 48a943a54..c3918903f 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt @@ -108,12 +108,16 @@ class ShareDialog( return "" } private fun getShareableTitle(shareData: ShareData): String { - if (shareData.currentChannel != null) { - return shareData.currentChannel - } else if (shareData.currentPlaylist != null) { - return shareData.currentPlaylist - } else if (shareData.currentVideo != null) { - return shareData.currentVideo + shareData.apply { + currentChannel?.let { + return it + } + currentVideo?.let { + return it + } + currentPlaylist?.let { + return it + } } return "" } From 36e2da52fb4a4a7a890c81566db817ea33016683 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 11:20:34 +0200 Subject: [PATCH 082/516] Channel Tabs backend --- .../main/java/com/github/libretube/api/PipedApi.kt | 7 +++++++ .../java/com/github/libretube/api/obj/Channel.kt | 3 ++- .../java/com/github/libretube/api/obj/ChannelTab.kt | 9 +++++++++ .../github/libretube/api/obj/ChannelTabResponse.kt | 6 ++++++ .../api/obj/{SearchItem.kt => ContentItem.kt} | 2 +- .../com/github/libretube/api/obj/SearchResult.kt | 2 +- .../github/libretube/ui/adapters/SearchAdapter.kt | 12 ++++++------ .../github/libretube/ui/fragments/ChannelFragment.kt | 8 ++++++++ 8 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/api/obj/ChannelTab.kt create mode 100644 app/src/main/java/com/github/libretube/api/obj/ChannelTabResponse.kt rename app/src/main/java/com/github/libretube/api/obj/{SearchItem.kt => ContentItem.kt} (97%) diff --git a/app/src/main/java/com/github/libretube/api/PipedApi.kt b/app/src/main/java/com/github/libretube/api/PipedApi.kt index 061ea5691..f182fcae6 100644 --- a/app/src/main/java/com/github/libretube/api/PipedApi.kt +++ b/app/src/main/java/com/github/libretube/api/PipedApi.kt @@ -1,6 +1,7 @@ package com.github.libretube.api import com.github.libretube.api.obj.Channel +import com.github.libretube.api.obj.ChannelTabResponse import com.github.libretube.api.obj.CommentsPage import com.github.libretube.api.obj.DeleteUserRequest import com.github.libretube.api.obj.Login @@ -63,6 +64,12 @@ interface PipedApi { @GET("channel/{channelId}") suspend fun getChannel(@Path("channelId") channelId: String): Channel + @GET("channels/tabs") + suspend fun getChannelTab( + @Query("data") data: String, + @Query("nextpage") nextPage: String? = null + ): ChannelTabResponse + @GET("user/{name}") suspend fun getChannelByName(@Path("name") channelName: String): Channel diff --git a/app/src/main/java/com/github/libretube/api/obj/Channel.kt b/app/src/main/java/com/github/libretube/api/obj/Channel.kt index d255187dd..e1b261df4 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Channel.kt +++ b/app/src/main/java/com/github/libretube/api/obj/Channel.kt @@ -12,5 +12,6 @@ data class Channel( var nextpage: String? = null, var subscriberCount: Long = 0, var verified: Boolean = false, - var relatedStreams: List? = null + var relatedStreams: List? = listOf(), + var tabs: List? = listOf() ) diff --git a/app/src/main/java/com/github/libretube/api/obj/ChannelTab.kt b/app/src/main/java/com/github/libretube/api/obj/ChannelTab.kt new file mode 100644 index 000000000..c7e2d63de --- /dev/null +++ b/app/src/main/java/com/github/libretube/api/obj/ChannelTab.kt @@ -0,0 +1,9 @@ +package com.github.libretube.api.obj + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + +@JsonIgnoreProperties(ignoreUnknown = true) +data class ChannelTab( + val name: String? = null, + val data: String? = null +) diff --git a/app/src/main/java/com/github/libretube/api/obj/ChannelTabResponse.kt b/app/src/main/java/com/github/libretube/api/obj/ChannelTabResponse.kt new file mode 100644 index 000000000..6c6fd7bae --- /dev/null +++ b/app/src/main/java/com/github/libretube/api/obj/ChannelTabResponse.kt @@ -0,0 +1,6 @@ +package com.github.libretube.api.obj + +data class ChannelTabResponse( + val content: List = listOf(), + val nextpage: String? = null +) diff --git a/app/src/main/java/com/github/libretube/api/obj/SearchItem.kt b/app/src/main/java/com/github/libretube/api/obj/ContentItem.kt similarity index 97% rename from app/src/main/java/com/github/libretube/api/obj/SearchItem.kt rename to app/src/main/java/com/github/libretube/api/obj/ContentItem.kt index f55604d8b..af7181e5c 100644 --- a/app/src/main/java/com/github/libretube/api/obj/SearchItem.kt +++ b/app/src/main/java/com/github/libretube/api/obj/ContentItem.kt @@ -3,7 +3,7 @@ package com.github.libretube.api.obj import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) -data class SearchItem( +data class ContentItem( var url: String? = null, var thumbnail: String? = null, var uploaderName: String? = null, diff --git a/app/src/main/java/com/github/libretube/api/obj/SearchResult.kt b/app/src/main/java/com/github/libretube/api/obj/SearchResult.kt index 42ff66005..8ec7699f0 100644 --- a/app/src/main/java/com/github/libretube/api/obj/SearchResult.kt +++ b/app/src/main/java/com/github/libretube/api/obj/SearchResult.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class SearchResult( - val items: MutableList? = arrayListOf(), + val items: MutableList? = arrayListOf(), val nextpage: String? = "", val suggestion: String? = "", val corrected: Boolean? = null diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt index fcc71b98e..9043446b1 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt @@ -8,7 +8,7 @@ import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.api.SubscriptionHelper -import com.github.libretube.api.obj.SearchItem +import com.github.libretube.api.obj.ContentItem import com.github.libretube.databinding.ChannelRowBinding import com.github.libretube.databinding.PlaylistSearchRowBinding import com.github.libretube.databinding.VideoRowBinding @@ -26,12 +26,12 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch class SearchAdapter( - private val searchItems: MutableList, + private val searchItems: MutableList, private val childFragmentManager: FragmentManager ) : RecyclerView.Adapter() { - fun updateItems(newItems: List) { + fun updateItems(newItems: List) { val searchItemsSize = searchItems.size searchItems.addAll(newItems) notifyItemRangeInserted(searchItemsSize, newItems.size) @@ -81,7 +81,7 @@ class SearchAdapter( } } - private fun bindWatch(item: SearchItem, binding: VideoRowBinding) { + private fun bindWatch(item: ContentItem, binding: VideoRowBinding) { binding.apply { ImageHelper.loadImage(item.thumbnail, thumbnail) thumbnailDuration.setFormattedDuration(item.duration!!) @@ -114,7 +114,7 @@ class SearchAdapter( @SuppressLint("SetTextI18n") private fun bindChannel( - item: SearchItem, + item: ContentItem, binding: ChannelRowBinding ) { binding.apply { @@ -164,7 +164,7 @@ class SearchAdapter( } private fun bindPlaylist( - item: SearchItem, + item: ContentItem, binding: PlaylistSearchRowBinding ) { binding.apply { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index 4f9584f2e..d5d276857 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -171,6 +171,14 @@ class ChannelFragment : BaseFragment() { ) binding.channelRecView.adapter = channelAdapter } + + response.tabs?.forEach { + try { + RetrofitInstance.api.getChannelTab(it.data!!).toString() + } catch (e: Exception) { + Log.e("error", e.toString()) + } + } } } From 18eebe663bd0131ec5128a38d5cb5c07b71b2192 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 12:06:25 +0200 Subject: [PATCH 083/516] UI for channel tabs --- .../libretube/ui/fragments/ChannelFragment.kt | 89 ++++++++++++++++--- app/src/main/res/layout/fragment_channel.xml | 41 +++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/style.xml | 9 ++ 4 files changed, 130 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index d5d276857..5e94096eb 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -6,11 +6,13 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView +import androidx.core.view.children import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import com.github.libretube.R import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.SubscriptionHelper +import com.github.libretube.api.obj.ChannelTab import com.github.libretube.constants.IntentData import com.github.libretube.constants.ShareObjectType import com.github.libretube.databinding.FragmentChannelBinding @@ -18,9 +20,14 @@ import com.github.libretube.extensions.TAG import com.github.libretube.extensions.formatShort import com.github.libretube.extensions.toID import com.github.libretube.ui.adapters.ChannelAdapter +import com.github.libretube.ui.adapters.SearchAdapter import com.github.libretube.ui.base.BaseFragment import com.github.libretube.ui.dialogs.ShareDialog import com.github.libretube.util.ImageHelper +import com.google.android.material.chip.Chip +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch import retrofit2.HttpException import java.io.IOException @@ -35,6 +42,10 @@ class ChannelFragment : BaseFragment() { private var isLoading = true private var isSubscribed: Boolean? = false + private var onScrollEnd: () -> Unit = {} + + val scope = CoroutineScope(Dispatchers.IO) + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) arguments?.let { @@ -73,11 +84,10 @@ class ChannelFragment : BaseFragment() { if (binding.channelScrollView.getChildAt(0).bottom == (binding.channelScrollView.height + binding.channelScrollView.scrollY) ) { - // scroll view is at bottom - if (nextPage != null && !isLoading) { - isLoading = true - binding.channelRefresh.isRefreshing = true - fetchChannelNextPage() + try { + onScrollEnd.invoke() + } catch (e: Exception) { + Log.e("tabs failed", e.toString()) } } } @@ -103,6 +113,14 @@ class ChannelFragment : BaseFragment() { // needed if the channel gets loaded by the ID channelId = response.id + onScrollEnd = { + if (nextPage != null && !isLoading) { + isLoading = true + binding.channelRefresh.isRefreshing = true + fetchChannelNextPage() + } + } + // fetch and update the subscription status isSubscribed = SubscriptionHelper.isSubscribed(channelId!!) if (isSubscribed == null) return@launchWhenCreated @@ -166,17 +184,68 @@ class ChannelFragment : BaseFragment() { // recyclerview of the videos by the channel channelAdapter = ChannelAdapter( - response.relatedStreams!!.toMutableList(), + response.relatedStreams.orEmpty().toMutableList(), childFragmentManager ) binding.channelRecView.adapter = channelAdapter } - response.tabs?.forEach { - try { - RetrofitInstance.api.getChannelTab(it.data!!).toString() + binding.videos.setOnClickListener { + binding.channelRecView.adapter = channelAdapter + } + + response.tabs?.firstOrNull { it.name == "Playlists" }?.let { + setupTab(binding.playlists, it) + } + + response.tabs?.firstOrNull { it.name == "Channels" }?.let { + setupTab(binding.channels, it) + } + + response.tabs?.firstOrNull { it.name == "Livestreams" }?.let { + setupTab(binding.livestreams, it) + } + + response.tabs?.firstOrNull { it.name == "Shorts" }?.let { + setupTab(binding.shorts, it) + } + } + } + + private fun setupTab(chip: Chip, tab: ChannelTab) { + chip.visibility = View.VISIBLE + chip.setOnClickListener { + binding.tabChips.children.forEach { + if (it != chip) it.isSelected = false + } + scope.launch { + val response = try { + RetrofitInstance.api.getChannelTab(tab.data!!) } catch (e: Exception) { - Log.e("error", e.toString()) + return@launch + } + + val adapter = SearchAdapter( + response.content.toMutableList(), + childFragmentManager + ) + + runOnUiThread { + binding.channelRecView.adapter = adapter + } + + onScrollEnd = { + if (response.nextpage != null) { + scope.launch { + val newContent = try { + RetrofitInstance.api.getChannelTab(tab.data, response.nextpage) + } catch (e: Exception) { + e.printStackTrace() + null + } + newContent?.content?.let { adapter.updateItems(it) } + } + } } } } diff --git a/app/src/main/res/layout/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index 70bdf6509..6d4889444 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -115,6 +115,47 @@ android:maxLines="2" android:padding="10dp" /> + + + + + + + + + + + + + + + + + + Queue Markers Mark the segments on the time bar. + Livestreams Download Service diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml index a1858f15e..e5837b1e8 100644 --- a/app/src/main/res/values/style.xml +++ b/app/src/main/res/values/style.xml @@ -179,4 +179,13 @@ slide + + \ No newline at end of file From 8119462cb753fb91580675bc585f6428874dd644 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 12:16:48 +0200 Subject: [PATCH 084/516] Fixed minor bugs and improved Chip UI --- .../com/github/libretube/ui/fragments/ChannelFragment.kt | 8 ++++++-- app/src/main/res/layout/fragment_channel.xml | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index 5e94096eb..9ddb36bc3 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -216,7 +216,7 @@ class ChannelFragment : BaseFragment() { chip.visibility = View.VISIBLE chip.setOnClickListener { binding.tabChips.children.forEach { - if (it != chip) it.isSelected = false + if (it != chip) (it as Chip).isChecked = false } scope.launch { val response = try { @@ -243,7 +243,11 @@ class ChannelFragment : BaseFragment() { e.printStackTrace() null } - newContent?.content?.let { adapter.updateItems(it) } + runOnUiThread { + newContent?.content?.let { + adapter.updateItems(it) + } + } } } } diff --git a/app/src/main/res/layout/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index 6d4889444..ab26d98aa 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -116,19 +116,20 @@ android:padding="10dp" /> From 05ab99e518899f663323a7673ba8fd3764f23d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Sat, 29 Oct 2022 08:05:42 +0000 Subject: [PATCH 085/516] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegi?= =?UTF-8?q?an=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 78.7% (282 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/nb_NO/ --- app/src/main/res/values-nb-rNO/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index cf9ea5e76..0f028c3c4 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -356,4 +356,6 @@ Lagt til på spillelisten Vis mer Tidskode + Markører + Marker segmenter i forløpsindikatoren. \ No newline at end of file From 988781e64721aba326bb000302ccb1bdac8c8dfc Mon Sep 17 00:00:00 2001 From: Rex_sa Date: Fri, 28 Oct 2022 22:54:10 +0000 Subject: [PATCH 086/516] Translated using Weblate (Arabic) Currently translated at 100.0% (358 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/ar/ --- app/src/main/res/values-ar/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 6860a26e8..5a5332cfd 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -125,7 +125,7 @@ %1$s مشاهدة الإفتراضي ابحث عن الإصدار الجديد - انقر لمعرفة ما إذا كان التطبيق محدثا أم لا. + التحقق من وجود تحديث يتم حاليا تشغيل أحدث إصدار. انت تقوم الان بتشغيل أحدث إصدار. الاسم @@ -356,4 +356,6 @@ تمت الإضافة إلى قائمة التشغيل تشغيل قائمة الانتظار الانتظار + العلامات + وضع علامة على الأجزاء في شريط الوقت. \ No newline at end of file From 56d2bd92a797a2a1cadff91fe392eaac26ccec50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=9E=C4=85me=20=C7=BEver!?= Date: Sat, 29 Oct 2022 06:23:12 +0000 Subject: [PATCH 087/516] Translated using Weblate (Persian) Currently translated at 23.1% (83 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/fa/ --- app/src/main/res/values-fa/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index 913bf5408..10d22cc12 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -1,6 +1,6 @@ - کیفیت: + کیفیت مشترک شدن ذخیره نام کاربری @@ -24,7 +24,7 @@ دانلود شکست خورد! باز کردن در VLC خطای شبکه! - انتخاب + انتخاب کنید … لطفا وارد شوید و دوباره امتحان کنید! منطقه ورود/ثبت‌نام @@ -35,7 +35,7 @@ دانلود دیگری در جریان است، لطفا صبر کنید تا دانلود کامل شود! این ویدئو را نمی‌توان دانلود کرد! سرور دچار مشکل شده. شاید بهترست نمونه دیگری را امتحان کنید؟ - مشکلی پیش آمده! + مشکلی پیش آمده است! این مربوط به حساب پایپ است ابعاد ویدئو نام‌کاربری و رمز‌عبور نمی‌تواند خالی باشد! @@ -43,7 +43,7 @@ نمی توانید در VLC ویدئو را ببینید. لطفا مطمئن شوید که برنامه VLC را نصب کرده باشید انتخاب تعداد ستون ها حذف لیست پخش - "لیست پخش حذف شود؟" + لیست پخش حذف شود؟ ساخت لیست پخش فهرست پخش ساخته شد نام فهرست پخش From 356286f4770b985f73b61119a601dad7c7f4b608 Mon Sep 17 00:00:00 2001 From: Linerly Date: Fri, 28 Oct 2022 23:09:52 +0000 Subject: [PATCH 088/516] Translated using Weblate (Indonesian) Currently translated at 100.0% (358 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/id/ --- app/src/main/res/values-in/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 14a8c2e37..b68d37155 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -236,7 +236,7 @@ Temukan versi baru Berjalan pada versi terkini. Anda menjalankan versi yang terkini. - Ketuk untuk mengetahui jika aplikasi ini sudah yang terkini. + Periksa untuk pembaruan Pemain Atur aplikasi sesuai rasa Anda. Unduhan dan pengaturan ulang @@ -356,4 +356,6 @@ Ditambahkan ke daftar putar Antrean main Antrean + Tandai segmen pada bilah waktu. + Penanda \ No newline at end of file From ed1a49a6527d10a69ee75a76fbe44d3cb5c0ebb0 Mon Sep 17 00:00:00 2001 From: Nizami Date: Sat, 29 Oct 2022 05:05:40 +0000 Subject: [PATCH 089/516] Translated using Weblate (Turkish) Currently translated at 99.7% (357 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/tr/ --- app/src/main/res/values-tr/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 85dd09854..52245626b 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -127,7 +127,7 @@ İndirilen medyanın depolandığı yer. Katkı Bağış - Uygulamanın güncel olup olmadığını öğrenmek için tıklayın. + Güncellemeleri kontrol et En son sürümü çalıştırıyor. En son sürümü çalıştırıyorsunuz. Oynatma hızı @@ -356,4 +356,6 @@ Oynatma listesine eklendi Sıra Oynatma sırası + İşaretçiler + Segmentleri zaman çubuğunda işaretleyin. \ No newline at end of file From 7b957c3dfabeec76d2ad219582357f3221ccb383 Mon Sep 17 00:00:00 2001 From: Nizami Date: Sat, 29 Oct 2022 05:02:51 +0000 Subject: [PATCH 090/516] Translated using Weblate (Azerbaijani) Currently translated at 100.0% (358 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/az/ --- app/src/main/res/values-az/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index a8ef59196..688f02d15 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -134,7 +134,7 @@ Oynadıcı Tətbiqi zövqünüzə uyğunlaşdırın. Endirmələr və sıfırlama - Tətbiqin güncəl olduğunu öyrənmək üçün klikləyin. + Yeniləməni yoxla Ən son versiyanı işlədirsiniz. Canlı Müəlliflər @@ -356,4 +356,6 @@ Pleylistə əlavə edildi Oynatma növbəsi Növbə + Göstəricilər + Zaman çubuğunda seqmentləri göstər. \ No newline at end of file From 283bd897ce931842ef9482664d15a2bba19fd0e0 Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 29 Oct 2022 00:13:26 +0000 Subject: [PATCH 091/516] Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (358 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/zh_Hans/ --- app/src/main/res/values-zh-rCN/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index c3ab6ee41..857186030 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -122,7 +122,7 @@ 如果同时下载了音频与视频,则转换成视频文件。 下载到 检测新版本 - 单击检查应用是否是最新版。 + 检查更新 预览/回放 视频格式 外观 @@ -356,4 +356,6 @@ 已添加到播放列表 播放队列 队列 + 标记 + 在时间栏上标记段。 \ No newline at end of file From 1bac49251a9bda465c3483cf89e5d31d95208747 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Fri, 28 Oct 2022 20:13:36 +0000 Subject: [PATCH 092/516] Translated using Weblate (Ukrainian) Currently translated at 100.0% (358 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/uk/ --- app/src/main/res/values-uk/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index d44e87c00..2dfb734d2 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -131,7 +131,7 @@ Формат відео Внесок Шукати нову версію - Натисніть для перевірки чи додаток оновлений. + Перевірити наявність оновлень Це остання версія. Швидкість відтворення Програвач @@ -356,4 +356,6 @@ Додано в добірку Черга відтворення Черга + Маркери + Позначте відтинки на панелі часу. \ No newline at end of file From 2abe6595230afb369533bf0cf3dcdba1ebcc9c9e Mon Sep 17 00:00:00 2001 From: Gediminas Murauskas Date: Fri, 28 Oct 2022 20:16:36 +0000 Subject: [PATCH 093/516] Translated using Weblate (Lithuanian) Currently translated at 100.0% (358 of 358 strings) Translation: LibreTube/LibreTube Translate-URL: https://hosted.weblate.org/projects/libretube/libretube/lt/ --- app/src/main/res/values-lt/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 6fe26ac61..5c2c058f4 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -70,7 +70,7 @@ Kur saugoma atsisiųsta medija. Paaukoti Ieškoti naujos versijos - Spustelėkite, kad sužinotumėte, ar programėlė atnaujinta. + Tikrinti, ar yra atnaujinimų Įdiegta naujausia versija. Naudojate naujausią versiją. Atkūrimo greitis @@ -356,4 +356,6 @@ Segmentams, kuriuose išsamiai nupasakojamas būsimas šio ar būsimų serijos vaizdo įrašų turinys, bet nepateikiama papildomos informacijos. Jei joje yra klipų, kurie rodomi tik čia, labai tikėtina, kad tai netinkama kategorija. Viliojanti violetinė Vaizdo įrašo rezoliucija + Žymekliai + Žymėti segmentus laiko juostoje. \ No newline at end of file From 6644983154468cdb8661eef14c54fb7e9746297a Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 15:11:11 +0200 Subject: [PATCH 094/516] Improve double tap behavior --- .../libretube/util/DoubleTapListener.kt | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/DoubleTapListener.kt b/app/src/main/java/com/github/libretube/util/DoubleTapListener.kt index 5a96b4539..b9a6ee815 100644 --- a/app/src/main/java/com/github/libretube/util/DoubleTapListener.kt +++ b/app/src/main/java/com/github/libretube/util/DoubleTapListener.kt @@ -3,40 +3,49 @@ package com.github.libretube.util import android.os.Handler import android.os.Looper import android.os.SystemClock +import android.util.Log import android.view.View abstract class DoubleTapListener : View.OnClickListener { - private val maximumTimeDifference = 300L private val handler = Handler(Looper.getMainLooper()) - private var isSingleEvent = false - private var timeStampLastClick = 0L - private var timeStampLastDoubleClick = 0L - - override fun onClick(v: View?) { - if (SystemClock.elapsedRealtime() - timeStampLastClick < maximumTimeDifference) { - isSingleEvent = false - handler.removeCallbacks(runnable) - timeStampLastDoubleClick = SystemClock.elapsedRealtime() - onDoubleClick() - return - } - isSingleEvent = true - handler.removeCallbacks(runnable) - handler.postDelayed(runnable, maximumTimeDifference) - timeStampLastClick = SystemClock.elapsedRealtime() - } + private var lastClick = 0L + private var lastDoubleClick = 0L abstract fun onDoubleClick() abstract fun onSingleClick() - private val runnable = Runnable { - if (!isSingleEvent || - SystemClock.elapsedRealtime() - timeStampLastDoubleClick < maximumTimeDifference - ) { - return@Runnable + override fun onClick(v: View?) { + if (isSecondClick()) { + handler.removeCallbacks(runnable) + lastDoubleClick = elapsedTime() + onDoubleClick() + } else { + if (recentDoubleClick()) return + handler.removeCallbacks(runnable) + handler.postDelayed(runnable, MAX_TIME_DIFF) + lastClick = elapsedTime() } + } + + private val runnable = Runnable { + if (isSecondClick()) return@Runnable + Log.e("single", "single") onSingleClick() } + + private fun isSecondClick(): Boolean { + return elapsedTime() - lastClick < MAX_TIME_DIFF + } + + private fun recentDoubleClick(): Boolean { + return elapsedTime() - lastDoubleClick < MAX_TIME_DIFF + } + + fun elapsedTime() = SystemClock.elapsedRealtime() + + companion object { + private const val MAX_TIME_DIFF = 400L + } } From ae3f48fc45b8f18ecf7cb14f69f261b03fdad473 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 15:16:54 +0200 Subject: [PATCH 095/516] player fragment cleanup --- .../libretube/ui/fragments/PlayerFragment.kt | 142 +++++++++--------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index c91f3c5e4..a2a1a2562 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -105,7 +105,7 @@ import java.io.IOException import java.util.concurrent.Executors import kotlin.math.abs -class PlayerFragment : BaseFragment() { +class PlayerFragment : BaseFragment(), PlayerOptionsInterface { lateinit var binding: FragmentPlayerBinding private lateinit var playerBinding: ExoStyledPlayerControlViewBinding @@ -296,76 +296,6 @@ class PlayerFragment : BaseFragment() { } } - private val onlinePlayerOptionsInterface = object : PlayerOptionsInterface { - override fun onCaptionClicked() { - if (!this@PlayerFragment::streams.isInitialized || - streams.subtitles == null || - streams.subtitles!!.isEmpty() - ) { - Toast.makeText(context, R.string.no_subtitles_available, Toast.LENGTH_SHORT).show() - return - } - - val subtitlesNamesList = mutableListOf(context?.getString(R.string.none)!!) - val subtitleCodesList = mutableListOf("") - streams.subtitles!!.forEach { - subtitlesNamesList += it.name!! - subtitleCodesList += it.code!! - } - - BottomSheet() - .setSimpleItems(subtitlesNamesList) { index -> - val newParams = if (index != 0) { - // caption selected - - // get the caption language code - val captionLanguageCode = subtitleCodesList[index] - - // select the new caption preference - trackSelector.buildUponParameters() - .setPreferredTextLanguage(captionLanguageCode) - .setPreferredTextRoleFlags(C.ROLE_FLAG_CAPTION) - } else { - // none selected - // disable captions - trackSelector.buildUponParameters() - .setPreferredTextLanguage("") - } - - // set the new caption language - trackSelector.setParameters(newParams) - } - .show(childFragmentManager) - } - - override fun onQualityClicked() { - // get the available resolutions - val (videosNameArray, videosUrlArray) = getAvailableResolutions() - - // Dialog for quality selection - val lastPosition = exoPlayer.currentPosition - BottomSheet() - .setSimpleItems( - videosNameArray.toList() - ) { which -> - if ( - videosNameArray[which] == getString(R.string.hls) || - videosNameArray[which] == "LBRY HLS" - ) { - // set the progressive media source - setHLSMediaSource(videosUrlArray[which]) - } else { - val videoUri = videosUrlArray[which] - val audioUrl = - PlayerHelper.getAudioSource(requireContext(), streams.audioStreams!!) - setMediaSource(videoUri, audioUrl) - } - exoPlayer.seekTo(lastPosition) - } - .show(childFragmentManager) - } - } - // actions that don't depend on video information private fun initializeOnClickActions() { binding.closeImageView.setOnClickListener { @@ -814,7 +744,7 @@ class PlayerFragment : BaseFragment() { // initialize the player view actions binding.player.initialize( childFragmentManager, - onlinePlayerOptionsInterface, + this, doubleTapOverlayBinding, trackSelector ) @@ -1389,6 +1319,74 @@ class PlayerFragment : BaseFragment() { } } + override fun onCaptionClicked() { + if (!this@PlayerFragment::streams.isInitialized || + streams.subtitles == null || + streams.subtitles!!.isEmpty() + ) { + Toast.makeText(context, R.string.no_subtitles_available, Toast.LENGTH_SHORT).show() + return + } + + val subtitlesNamesList = mutableListOf(context?.getString(R.string.none)!!) + val subtitleCodesList = mutableListOf("") + streams.subtitles!!.forEach { + subtitlesNamesList += it.name!! + subtitleCodesList += it.code!! + } + + BottomSheet() + .setSimpleItems(subtitlesNamesList) { index -> + val newParams = if (index != 0) { + // caption selected + + // get the caption language code + val captionLanguageCode = subtitleCodesList[index] + + // select the new caption preference + trackSelector.buildUponParameters() + .setPreferredTextLanguage(captionLanguageCode) + .setPreferredTextRoleFlags(C.ROLE_FLAG_CAPTION) + } else { + // none selected + // disable captions + trackSelector.buildUponParameters() + .setPreferredTextLanguage("") + } + + // set the new caption language + trackSelector.setParameters(newParams) + } + .show(childFragmentManager) + } + + override fun onQualityClicked() { + // get the available resolutions + val (videosNameArray, videosUrlArray) = getAvailableResolutions() + + // Dialog for quality selection + val lastPosition = exoPlayer.currentPosition + BottomSheet() + .setSimpleItems( + videosNameArray.toList() + ) { which -> + if ( + videosNameArray[which] == getString(R.string.hls) || + videosNameArray[which] == "LBRY HLS" + ) { + // set the progressive media source + setHLSMediaSource(videosUrlArray[which]) + } else { + val videoUri = videosUrlArray[which] + val audioUrl = + PlayerHelper.getAudioSource(requireContext(), streams.audioStreams!!) + setMediaSource(videoUri, audioUrl) + } + exoPlayer.seekTo(lastPosition) + } + .show(childFragmentManager) + } + override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) { super.onPictureInPictureModeChanged(isInPictureInPictureMode) if (isInPictureInPictureMode) { From c8c2ab02e21fb9ef06d9fbfedf57d261974ffd26 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 15:33:06 +0200 Subject: [PATCH 096/516] player view cleanup --- ...onsInterface.kt => OnlinePlayerOptions.kt} | 4 +- .../models/interfaces/PlayerOptions.kt | 11 ++ .../github/libretube/obj/BottomSheetItem.kt | 3 +- .../ui/adapters/BottomSheetAdapter.kt | 1 + .../libretube/ui/fragments/PlayerFragment.kt | 6 +- .../github/libretube/ui/views/BottomSheet.kt | 8 +- .../libretube/ui/views/CustomExoPlayerView.kt | 156 +++++++++--------- 7 files changed, 102 insertions(+), 87 deletions(-) rename app/src/main/java/com/github/libretube/models/interfaces/{PlayerOptionsInterface.kt => OnlinePlayerOptions.kt} (55%) create mode 100644 app/src/main/java/com/github/libretube/models/interfaces/PlayerOptions.kt diff --git a/app/src/main/java/com/github/libretube/models/interfaces/PlayerOptionsInterface.kt b/app/src/main/java/com/github/libretube/models/interfaces/OnlinePlayerOptions.kt similarity index 55% rename from app/src/main/java/com/github/libretube/models/interfaces/PlayerOptionsInterface.kt rename to app/src/main/java/com/github/libretube/models/interfaces/OnlinePlayerOptions.kt index 66d3d87d9..10a354921 100644 --- a/app/src/main/java/com/github/libretube/models/interfaces/PlayerOptionsInterface.kt +++ b/app/src/main/java/com/github/libretube/models/interfaces/OnlinePlayerOptions.kt @@ -1,7 +1,7 @@ package com.github.libretube.models.interfaces -interface PlayerOptionsInterface { - fun onCaptionClicked() +interface OnlinePlayerOptions { + fun onCaptionsClicked() fun onQualityClicked() } diff --git a/app/src/main/java/com/github/libretube/models/interfaces/PlayerOptions.kt b/app/src/main/java/com/github/libretube/models/interfaces/PlayerOptions.kt new file mode 100644 index 000000000..fe2a5db67 --- /dev/null +++ b/app/src/main/java/com/github/libretube/models/interfaces/PlayerOptions.kt @@ -0,0 +1,11 @@ +package com.github.libretube.models.interfaces + +interface PlayerOptions { + fun onAutoplayClicked() + + fun onPlaybackSpeedClicked() + + fun onResizeModeClicked() + + fun onRepeatModeClicked() +} diff --git a/app/src/main/java/com/github/libretube/obj/BottomSheetItem.kt b/app/src/main/java/com/github/libretube/obj/BottomSheetItem.kt index d9614e5f8..dad4c43f8 100644 --- a/app/src/main/java/com/github/libretube/obj/BottomSheetItem.kt +++ b/app/src/main/java/com/github/libretube/obj/BottomSheetItem.kt @@ -3,5 +3,6 @@ package com.github.libretube.obj data class BottomSheetItem( val title: String, val drawable: Int? = null, - val currentValue: String? = null + val currentValue: String? = null, + val onClick: () -> Unit = {} ) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt index e694e8f5a..3b1b92a57 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt @@ -34,6 +34,7 @@ class BottomSheetAdapter( } root.setOnClickListener { + item.onClick.invoke() listener.invoke(position) } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index a2a1a2562..231a8f055 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -56,7 +56,7 @@ import com.github.libretube.extensions.query import com.github.libretube.extensions.toID import com.github.libretube.extensions.toStreamItem import com.github.libretube.models.PlayerViewModel -import com.github.libretube.models.interfaces.PlayerOptionsInterface +import com.github.libretube.models.interfaces.OnlinePlayerOptions import com.github.libretube.services.BackgroundMode import com.github.libretube.services.DownloadService import com.github.libretube.ui.activities.MainActivity @@ -105,7 +105,7 @@ import java.io.IOException import java.util.concurrent.Executors import kotlin.math.abs -class PlayerFragment : BaseFragment(), PlayerOptionsInterface { +class PlayerFragment : BaseFragment(), OnlinePlayerOptions { lateinit var binding: FragmentPlayerBinding private lateinit var playerBinding: ExoStyledPlayerControlViewBinding @@ -1319,7 +1319,7 @@ class PlayerFragment : BaseFragment(), PlayerOptionsInterface { } } - override fun onCaptionClicked() { + override fun onCaptionsClicked() { if (!this@PlayerFragment::streams.isInitialized || streams.subtitles == null || streams.subtitles!!.isEmpty() diff --git a/app/src/main/java/com/github/libretube/ui/views/BottomSheet.kt b/app/src/main/java/com/github/libretube/ui/views/BottomSheet.kt index 3fd8268cf..af1890c2e 100644 --- a/app/src/main/java/com/github/libretube/ui/views/BottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/views/BottomSheet.kt @@ -32,18 +32,18 @@ open class BottomSheet : BottomSheetDialogFragment() { binding.optionsRecycler.adapter = BottomSheetAdapter(items, listener) } - fun setItems(items: List, listener: (index: Int) -> Unit) = apply { + fun setItems(items: List, listener: ((index: Int) -> Unit)?) = apply { this.items = items this.listener = { index -> - listener.invoke(index) + listener?.invoke(index) dialog?.dismiss() } } - fun setSimpleItems(titles: List, listener: (index: Int) -> Unit) = apply { + fun setSimpleItems(titles: List, listener: ((index: Int) -> Unit)?) = apply { this.items = titles.map { BottomSheetItem(it) } this.listener = { index -> - listener.invoke(index) + listener?.invoke(index) dialog?.dismiss() } } diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index f1a887f41..bebb7d4e7 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -14,7 +14,8 @@ import com.github.libretube.databinding.DoubleTapOverlayBinding import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding import com.github.libretube.extensions.toDp import com.github.libretube.models.interfaces.DoubleTapInterface -import com.github.libretube.models.interfaces.PlayerOptionsInterface +import com.github.libretube.models.interfaces.OnlinePlayerOptions +import com.github.libretube.models.interfaces.PlayerOptions import com.github.libretube.obj.BottomSheetItem import com.github.libretube.ui.activities.MainActivity import com.github.libretube.ui.sheets.PlaybackSpeedSheet @@ -30,7 +31,7 @@ import com.google.android.exoplayer2.util.RepeatModeUtil internal class CustomExoPlayerView( context: Context, attributeSet: AttributeSet? = null -) : StyledPlayerView(context, attributeSet) { +) : StyledPlayerView(context, attributeSet), PlayerOptions { val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this) private var doubleTapOverlayBinding: DoubleTapOverlayBinding? = null @@ -38,7 +39,7 @@ internal class CustomExoPlayerView( * Objects from the parent fragment */ private var doubleTapListener: DoubleTapInterface? = null - private var playerOptionsInterface: PlayerOptionsInterface? = null + private var playerOptionsInterface: OnlinePlayerOptions? = null private lateinit var childFragmentManager: FragmentManager private var trackSelector: TrackSelector? = null @@ -72,7 +73,7 @@ internal class CustomExoPlayerView( fun initialize( childFragmentManager: FragmentManager, - playerViewInterface: PlayerOptionsInterface?, + playerViewInterface: OnlinePlayerOptions?, doubleTapOverlayBinding: DoubleTapOverlayBinding, trackSelector: TrackSelector? ) { @@ -136,78 +137,79 @@ internal class CustomExoPlayerView( private fun initializeAdvancedOptions(context: Context) { binding.toggleOptions.setOnClickListener { - val bottomSheetFragment = BottomSheet().apply { - val items = mutableListOf( - BottomSheetItem( - context.getString(R.string.player_autoplay), - R.drawable.ic_play, - if (autoplayEnabled) { - context.getString(R.string.enabled) - } else { - context.getString(R.string.disabled) - } - ), - BottomSheetItem( - context.getString(R.string.repeat_mode), - R.drawable.ic_repeat, - if (player?.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) { - context.getString(R.string.repeat_mode_none) - } else { - context.getString(R.string.repeat_mode_current) - } - ), - BottomSheetItem( - context.getString(R.string.player_resize_mode), - R.drawable.ic_aspect_ratio, - when (resizeMode) { - AspectRatioFrameLayout.RESIZE_MODE_FIT -> context.getString(R.string.resize_mode_fit) - AspectRatioFrameLayout.RESIZE_MODE_FILL -> context.getString(R.string.resize_mode_fill) - else -> context.getString(R.string.resize_mode_zoom) - } - ), - BottomSheetItem( - context.getString(R.string.playback_speed), - R.drawable.ic_speed, - "${ - player?.playbackParameters?.speed - .toString() - .replace(".0", "") - }x" - ) - ) - - if (playerOptionsInterface != null) { - items.add( - BottomSheetItem( - context.getString(R.string.quality), - R.drawable.ic_hd, - "${player?.videoSize?.height}p" - ) - ) - items.add( - BottomSheetItem( - context.getString(R.string.captions), - R.drawable.ic_caption, - if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) { - trackSelector!!.parameters.preferredTextLanguages[0] - } else { - context.getString(R.string.none) - } - ) - ) - } - - setItems(items) { index -> - when (index) { - 0 -> onAutoplayClicked() - 1 -> onRepeatModeClicked() - 2 -> onResizeModeClicked() - 3 -> onPlaybackSpeedClicked() - 4 -> playerOptionsInterface?.onQualityClicked() - 5 -> playerOptionsInterface?.onCaptionClicked() + val items = mutableListOf( + BottomSheetItem( + context.getString(R.string.player_autoplay), + R.drawable.ic_play, + if (autoplayEnabled) { + context.getString(R.string.enabled) + } else { + context.getString(R.string.disabled) } + ) { + onAutoplayClicked() + }, + BottomSheetItem( + context.getString(R.string.repeat_mode), + R.drawable.ic_repeat, + if (player?.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) { + context.getString(R.string.repeat_mode_none) + } else { + context.getString(R.string.repeat_mode_current) + } + ) { + onRepeatModeClicked() + }, + BottomSheetItem( + context.getString(R.string.player_resize_mode), + R.drawable.ic_aspect_ratio, + when (resizeMode) { + AspectRatioFrameLayout.RESIZE_MODE_FIT -> context.getString(R.string.resize_mode_fit) + AspectRatioFrameLayout.RESIZE_MODE_FILL -> context.getString(R.string.resize_mode_fill) + else -> context.getString(R.string.resize_mode_zoom) + } + ) { + onResizeModeClicked() + }, + BottomSheetItem( + context.getString(R.string.playback_speed), + R.drawable.ic_speed, + "${ + player?.playbackParameters?.speed + .toString() + .replace(".0", "") + }x" + ) { + onPlaybackSpeedClicked() } + ) + + if (playerOptionsInterface != null) { + items.add( + BottomSheetItem( + context.getString(R.string.quality), + R.drawable.ic_hd, + "${player?.videoSize?.height}p" + ) { + playerOptionsInterface?.onQualityClicked() + } + ) + items.add( + BottomSheetItem( + context.getString(R.string.captions), + R.drawable.ic_caption, + if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) { + trackSelector!!.parameters.preferredTextLanguages[0] + } else { + context.getString(R.string.none) + } + ) { + playerOptionsInterface?.onCaptionsClicked() + } + ) } + + val bottomSheetFragment = BottomSheet().setItems(items, null) bottomSheetFragment.show(childFragmentManager, null) } } @@ -307,7 +309,7 @@ internal class CustomExoPlayerView( } } - private fun onAutoplayClicked() { + override fun onAutoplayClicked() { // autoplay options dialog BottomSheet() .setSimpleItems( @@ -324,11 +326,11 @@ internal class CustomExoPlayerView( .show(childFragmentManager) } - private fun onPlaybackSpeedClicked() { + override fun onPlaybackSpeedClicked() { player?.let { PlaybackSpeedSheet(it).show(childFragmentManager) } } - private fun onResizeModeClicked() { + override fun onResizeModeClicked() { // switching between original aspect ratio (black bars) and zoomed to fill device screen val aspectRatioModeNames = context.resources?.getStringArray(R.array.resizeMode) ?.toList().orEmpty() @@ -346,7 +348,7 @@ internal class CustomExoPlayerView( .show(childFragmentManager) } - private fun onRepeatModeClicked() { + override fun onRepeatModeClicked() { val repeatModeNames = listOf( context.getString(R.string.repeat_mode_none), context.getString(R.string.repeat_mode_current) From e4194dfa9028a23dbfc643b62b45ac0494150b63 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 15:41:27 +0200 Subject: [PATCH 097/516] Move the playlist order to the instance prefs --- app/src/main/res/xml/appearance_settings.xml | 8 ++++++++ app/src/main/res/xml/instance_settings.xml | 12 ------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml index f7faed2a2..d46fadb98 100644 --- a/app/src/main/res/xml/appearance_settings.xml +++ b/app/src/main/res/xml/appearance_settings.xml @@ -106,6 +106,14 @@ app:key="trending_layout" app:title="@string/trending_layout" /> + + \ No newline at end of file diff --git a/app/src/main/res/xml/instance_settings.xml b/app/src/main/res/xml/instance_settings.xml index 29ab5da02..40fc7824e 100644 --- a/app/src/main/res/xml/instance_settings.xml +++ b/app/src/main/res/xml/instance_settings.xml @@ -71,16 +71,4 @@ - - - - - - \ No newline at end of file From c8d8fdbe41eac4953603243a71edece1813f94fc Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 29 Oct 2022 16:25:15 +0200 Subject: [PATCH 098/516] Channel tab fixes --- .../libretube/ui/fragments/ChannelFragment.kt | 58 ++++++++++++------- .../main/res/layout/dialog_addtoplaylist.xml | 6 +- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index ed1cfeabf..6d0c6fe4e 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -44,7 +44,7 @@ class ChannelFragment : BaseFragment() { private var onScrollEnd: () -> Unit = {} - val scope = CoroutineScope(Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.IO) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -115,11 +115,7 @@ class ChannelFragment : BaseFragment() { val shareData = ShareData(currentChannel = response.name) onScrollEnd = { - if (nextPage != null && !isLoading) { - isLoading = true - binding.channelRefresh.isRefreshing = true - fetchChannelNextPage() - } + fetchChannelNextPage() } // fetch and update the subscription status @@ -197,6 +193,12 @@ class ChannelFragment : BaseFragment() { binding.videos.setOnClickListener { binding.channelRecView.adapter = channelAdapter + onScrollEnd = { + fetchChannelNextPage() + } + binding.tabChips.children.forEach { child -> + if (child != it) (child as Chip).isChecked = false + } } response.tabs?.firstOrNull { it.name == "Playlists" }?.let { @@ -239,20 +241,11 @@ class ChannelFragment : BaseFragment() { binding.channelRecView.adapter = adapter } + var tabNextPage = response.nextpage onScrollEnd = { - if (response.nextpage != null) { - scope.launch { - val newContent = try { - RetrofitInstance.api.getChannelTab(tab.data, response.nextpage) - } catch (e: Exception) { - e.printStackTrace() - null - } - runOnUiThread { - newContent?.content?.let { - adapter.updateItems(it) - } - } + tabNextPage?.let { + fetchTabNextPage(it, tab, adapter) { nextPage -> + tabNextPage = nextPage } } } @@ -262,12 +255,15 @@ class ChannelFragment : BaseFragment() { private fun fetchChannelNextPage() { fun run() { + if (nextPage == null || isLoading) return + isLoading = true + binding.channelRefresh.isRefreshing = true + lifecycleScope.launchWhenCreated { val response = try { RetrofitInstance.api.getChannelNextPage(channelId!!, nextPage!!) } catch (e: IOException) { binding.channelRefresh.isRefreshing = false - println(e) Log.e(TAG(), "IOException, you might not have internet connection") return@launchWhenCreated } catch (e: HttpException) { @@ -283,4 +279,26 @@ class ChannelFragment : BaseFragment() { } run() } + + private fun fetchTabNextPage( + nextPage: String, + tab: ChannelTab, + adapter: SearchAdapter, + onNewNextPage: (String?) -> Unit + ) { + scope.launch { + val newContent = try { + RetrofitInstance.api.getChannelTab(tab.data ?: "", nextPage) + } catch (e: Exception) { + e.printStackTrace() + null + } + onNewNextPage.invoke(newContent?.nextpage) + runOnUiThread { + newContent?.content?.let { + adapter.updateItems(it) + } + } + } + } } diff --git a/app/src/main/res/layout/dialog_addtoplaylist.xml b/app/src/main/res/layout/dialog_addtoplaylist.xml index 31d353893..eae3855cb 100644 --- a/app/src/main/res/layout/dialog_addtoplaylist.xml +++ b/app/src/main/res/layout/dialog_addtoplaylist.xml @@ -1,5 +1,6 @@ @@ -18,7 +19,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" - android:padding="8dp" /> + android:paddingVertical="8dp" + android:paddingStart="8dp" + android:paddingEnd="40dp" + tools:ignore="RtlSymmetry" />