diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8349fcf..f1fad0c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,7 +23,7 @@ android { defaultConfig { applicationId = "io.github.shadow578.yodel" - minSdk = 23 + minSdk = 24 targetSdk = 33 compileSdk = 33 versionCode = 5 @@ -111,10 +111,9 @@ dependencies { kapt("androidx.room:room-compiler:2.5.0") // youtube-dl - //TODO: currently uses the latest version available. This makes the build unstable! - implementation("com.github.yausername.youtubedl-android:library:master-SNAPSHOT") - implementation("com.github.yausername.youtubedl-android:ffmpeg:master-SNAPSHOT") - implementation("com.github.yausername.youtubedl-android:aria2c:master-SNAPSHOT") + implementation("io.github.junkfood02.youtubedl-android:library:0.17.1") + implementation("io.github.junkfood02.youtubedl-android:ffmpeg:0.17.1") + implementation("io.github.junkfood02.youtubedl-android:aria2c:0.17.1") // id3v2 tagging implementation("com.mpatric:mp3agic:0.9.1") diff --git a/app/src/main/kotlin/io/github/shadow578/yodel/downloader/DownloadService.kt b/app/src/main/kotlin/io/github/shadow578/yodel/downloader/DownloadService.kt index f9989a4..5545318 100644 --- a/app/src/main/kotlin/io/github/shadow578/yodel/downloader/DownloadService.kt +++ b/app/src/main/kotlin/io/github/shadow578/yodel/downloader/DownloadService.kt @@ -1,13 +1,16 @@ package io.github.shadow578.yodel.downloader +import android.Manifest import android.app.Notification import android.app.PendingIntent import android.content.Context import android.content.Intent +import android.content.pm.PackageManager import android.graphics.Bitmap import android.graphics.BitmapFactory import android.os.Build import androidx.annotation.StringRes +import androidx.core.app.ActivityCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.documentfile.provider.DocumentFile @@ -616,6 +619,10 @@ class DownloaderService : LifecycleService() { private fun updateNotification(newNotification: Notification) { if (isInForeground) { // already in foreground, update the notification + if (ActivityCompat.checkSelfPermission(this,Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + // TODO: handle this gracefully + return + } notificationManager.notify(PROGRESS_NOTIFICATION_ID, newNotification) } else { // create foreground notification @@ -745,7 +752,10 @@ class DownloaderService : LifecycleService() { // send the notification with a randomized id // this way, we can have multiple notifications (for multiple errors) - notificationManager.notify(notificationId, notification.build()) + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { + // TODO: handle this gracefully + notificationManager.notify(notificationId, notification.build()) + } } //endregion diff --git a/app/src/main/kotlin/io/github/shadow578/yodel/downloader/wrapper/YoutubeDLWrapper.kt b/app/src/main/kotlin/io/github/shadow578/yodel/downloader/wrapper/YoutubeDLWrapper.kt index 2d69627..81a0921 100644 --- a/app/src/main/kotlin/io/github/shadow578/yodel/downloader/wrapper/YoutubeDLWrapper.kt +++ b/app/src/main/kotlin/io/github/shadow578/yodel/downloader/wrapper/YoutubeDLWrapper.kt @@ -216,11 +216,11 @@ class YoutubeDLWrapper( * @throws InterruptedException by [YoutubeDL.execute] call */ @Throws(YoutubeDLException::class, InterruptedException::class) - fun download(progressCallback: DownloadProgressCallback?): YoutubeDLResponse { + fun download(progressCallback: ((Float, Long, String) -> Unit)?): YoutubeDLResponse { check(initialized) { "youtube-dl was not initialized! call YoutubeDLWrapper.init() first!" } Timber.i("downloading $videoUrl") - val response = YoutubeDL.getInstance().execute(request, progressCallback) + val response = YoutubeDL.getInstance().execute(request, callback=progressCallback) if (printOutput) { Timber.i(response.toPrettyString()) print(response)