From 23f1da85305902c2d453cab59eaadceeda79fc51 Mon Sep 17 00:00:00 2001 From: brahmkshatriya <69040506+brahmkshatriya@users.noreply.github.com> Date: Wed, 11 Dec 2024 03:31:43 +0530 Subject: [PATCH] Add predictive back animation for all fragments --- app/build.gradle.kts | 20 +++++----- .../echo/download/DownloadReceiver.kt | 40 ------------------- 2 files changed, 9 insertions(+), 51 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 038a9c79..1a4ce7b5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -48,25 +48,25 @@ dependencies { implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.constraintlayout:constraintlayout:2.2.0") implementation("androidx.recyclerview:recyclerview:1.3.2") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation("androidx.fragment:fragment-ktx:1.6.2") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.6") - implementation("androidx.paging:paging-common-ktx:3.3.2") - implementation("androidx.paging:paging-runtime-ktx:3.3.2") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7") + implementation("androidx.paging:paging-common-ktx:3.3.4") + implementation("androidx.paging:paging-runtime-ktx:3.3.4") implementation("androidx.preference:preference-ktx:1.2.1") implementation("androidx.room:room-runtime:2.6.1") implementation("androidx.room:room-ktx:2.6.1") ksp("androidx.room:room-compiler:2.6.1") - implementation("androidx.media3:media3-exoplayer:1.4.1") - implementation("androidx.media3:media3-session:1.4.1") - implementation("androidx.media3:media3-ui:1.4.1") - implementation("androidx.media3:media3-exoplayer-dash:1.4.1") - implementation("androidx.media3:media3-exoplayer-hls:1.4.1") + implementation("androidx.media3:media3-exoplayer:1.5.0") + implementation("androidx.media3:media3-session:1.5.0") + implementation("androidx.media3:media3-ui:1.5.0") + implementation("androidx.media3:media3-exoplayer-dash:1.5.0") + implementation("androidx.media3:media3-exoplayer-hls:1.5.0") implementation("androidx.core:core-splashscreen:1.0.1") implementation("androidx.palette:palette-ktx:1.0.0") @@ -86,8 +86,6 @@ dependencies { implementation("com.flaviofaria:kenburnsview:1.0.7") implementation("com.github.paramsen:noise:2.0.0") - implementation("com.github.Kyant0:taglib:1.0.0-alpha22") - testImplementation("org.jetbrains.kotlin:kotlin-reflect:1.9.24") testImplementation("junit:junit:4.13.2") } diff --git a/app/src/main/java/dev/brahmkshatriya/echo/download/DownloadReceiver.kt b/app/src/main/java/dev/brahmkshatriya/echo/download/DownloadReceiver.kt index 02e3074b..0f68b762 100644 --- a/app/src/main/java/dev/brahmkshatriya/echo/download/DownloadReceiver.kt +++ b/app/src/main/java/dev/brahmkshatriya/echo/download/DownloadReceiver.kt @@ -4,25 +4,17 @@ import android.app.DownloadManager import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import android.graphics.Bitmap import android.media.MediaScannerConnection import android.net.Uri -import android.os.ParcelFileDescriptor import android.webkit.MimeTypeMap -import com.kyant.taglib.Metadata -import com.kyant.taglib.Picture -import com.kyant.taglib.PropertyMap -import com.kyant.taglib.TagLib import dagger.hilt.android.AndroidEntryPoint import dev.brahmkshatriya.echo.EchoDatabase import dev.brahmkshatriya.echo.common.models.Track import dev.brahmkshatriya.echo.db.DownloadDao import dev.brahmkshatriya.echo.utils.getFromCache -import dev.brahmkshatriya.echo.utils.loadBitmap import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext -import java.io.ByteArrayOutputStream import java.io.File import javax.inject.Inject @@ -58,7 +50,6 @@ class DownloadReceiver : BroadcastReceiver() { val file = File(Uri.parse(fileUri).path!!) val newFile = File("${file.absolutePath}.$extension") file.renameTo(newFile) - context.applyTags(newFile, track) MediaScannerConnection.scanFile( context, arrayOf(newFile.toString()), null, null ) @@ -70,35 +61,4 @@ class DownloadReceiver : BroadcastReceiver() { } } } - - companion object { - fun Context.applyTags( - newFile: File, track - : Track - ) { - val fd = ParcelFileDescriptor.open( - newFile, ParcelFileDescriptor.MODE_READ_WRITE - ) - - val metadata = TagLib.getMetadata(fd = fd.dup().detachFd(), readPictures = true) - ?: Metadata(PropertyMap(), arrayOf()) - val artwork = runBlocking { track.cover.loadBitmap(this@applyTags) }?.let { - val stream = ByteArrayOutputStream() - it.compress(Bitmap.CompressFormat.PNG, 100, stream) - Picture(stream.toByteArray(), "Back Cover", "Back Cover", "image/png") - } - - artwork?.let { TagLib.savePictures(fd.dup().detachFd(), arrayOf(it)) } - val props = metadata.propertyMap.apply { - set("TITLE", arrayOf(track.title)) - set("ARTIST", arrayOf(track.artists.joinToString(", ") { it.name })) - track.album?.run { - set("ALBUM", arrayOf(title)) - set("ALBUMARTIST", arrayOf(artists.joinToString(", ") { it.name })) - releaseDate?.let { set("DATE", arrayOf(it)) } - } - } - TagLib.savePropertyMap(fd.dup().detachFd(), props) - } - } } \ No newline at end of file