Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for jpegxl #142

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext {
jacocoVersion = "0.8.7"
androidXLifecycleVersion = "2.3.1"
glideVersion = '4.11.0'
androidXLifecycleVersion = "2.6.1"
glideVersion = '4.16.0'
fragment_version = "1.3.6"
roomVersion = "2.4.0"
billing_version = "6.0.1"
Expand Down Expand Up @@ -39,6 +39,7 @@ plugins {
id 'com.starter.easylauncher'
id 'com.mikepenz.aboutlibraries.plugin'
id 'org.jetbrains.kotlin.android'
id("com.google.devtools.ksp")
}

android {
Expand All @@ -47,12 +48,12 @@ android {
release
}

compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.amaze.fileutilities"
minSdk 21
targetSdk 33
targetSdk 34

Integer sudoVersionCode = 31
String versionNameText = "1.91"
Expand Down Expand Up @@ -220,7 +221,7 @@ android {
}

dependencies {
implementation 'androidx.core:core:1.7.0'
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.6.1'
Expand All @@ -231,12 +232,15 @@ dependencies {
implementation 'androidx.palette:palette:1.0.0'
//Glide: loads icons seemlessly
implementation "com.github.bumptech.glide:glide:$glideVersion"
ksp("com.github.bumptech.glide:ksp:$glideVersion")
implementation ("com.github.bumptech.glide:recyclerview-integration:$glideVersion") {
// Excludes the support library because it's already included by Glide.
transitive = false
}
implementation("com.github.bumptech.glide:compose:1.0.0-alpha.5")
playImplementation 'com.google.android.play:core-ktx:1.8.1'
kapt "com.github.bumptech.glide:compiler:$glideVersion"
implementation 'com.github.awxkee:avif-coder-glide:1.5.7'
// kapt "com.github.bumptech.glide:compiler:$glideVersion"
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk tools:overrideLibrary="linc.com.amplituda, me.zhanghai.android.fastscroll,
org.opencv, com.mikepenz.aboutlibraries, com.abedelazizshe.lightcompressorlibrary" />
org.opencv, com.mikepenz.aboutlibraries, com.abedelazizshe.lightcompressorlibrary,
com.awxkee.avif.glide, com.github.awxkee.avifcoil, com.github.awxkee.avifcoder, androidx.emoji2" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import com.amaze.fileutilities.utilis.ObtainableServiceBinder
import com.amaze.fileutilities.utilis.PreferencesConstants
import com.amaze.fileutilities.utilis.Utils
import com.amaze.fileutilities.utilis.getAppCommonSharedPreferences
import com.amaze.fileutilities.utilis.startServiceSafely
import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
Expand Down Expand Up @@ -89,7 +90,7 @@ class AudioPlayerService : Service(), ServiceOperationCallback, OnPlayerRepeatin
intent.putParcelableArrayListExtra(ARG_URI_LIST, ArrayList(uriList))
}
intent.action = action
context.startService(intent)
context.startServiceSafely(intent, ARG_URI_LIST)
}

fun sendCancelBroadcast(context: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ interface IAudioPlayerInterfaceHandler : OnPlaybackInfoUpdate, LifecycleOwner {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
// do nothing
Expand All @@ -274,15 +274,15 @@ interface IAudioPlayerInterfaceHandler : OnPlaybackInfoUpdate, LifecycleOwner {
}

override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
getContextWeakRef().get()?.let {
context ->
resource?.let {
resource.let {
getAudioPlayerHandlerViewModel().getPaletteColor(
it,
context.getColor(R.color.navy_blue_alt_3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ public class M3UWriter {

public static File write(File dir, MediaFileInfo.Playlist playlist, List<MediaFileInfo> songs)
throws IOException {
if (!dir.exists()) // noinspection ResultOfMethodCallIgnored
dir.mkdirs();
if (!dir.exists()) {
// noinspection ResultOfMethodCallIgnored
dir.mkdirs();
}
File file = new File(dir, playlist.getName().concat("." + EXTENSION));

if (songs.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import androidx.core.graphics.drawable.toBitmap
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.liveData
import androidx.lifecycle.switchMap
import androidx.lifecycle.viewModelScope
import com.abedelazizshe.lightcompressorlibrary.CompressionListener
import com.abedelazizshe.lightcompressorlibrary.VideoCompressor
Expand Down Expand Up @@ -305,7 +305,7 @@ class FilesViewModel(val applicationContext: Application) :
fun usedImagesSummaryTransformations():
LiveData<Pair<StorageSummary, ArrayList<MediaFileInfo>>?> {
if (usedImagesSummaryTransformations == null) {
usedImagesSummaryTransformations = Transformations.switchMap(internalStorageStats()) {
usedImagesSummaryTransformations = internalStorageStats().switchMap {
input ->
getImagesSummaryLiveData(input)
}
Expand All @@ -316,7 +316,7 @@ class FilesViewModel(val applicationContext: Application) :
fun usedAudiosSummaryTransformations():
LiveData<Pair<StorageSummary, ArrayList<MediaFileInfo>>?> {
if (usedAudiosSummaryTransformations == null) {
usedAudiosSummaryTransformations = Transformations.switchMap(internalStorageStats()) {
usedAudiosSummaryTransformations = internalStorageStats().switchMap {
input ->
getAudiosSummaryLiveData(input)
}
Expand All @@ -328,7 +328,7 @@ class FilesViewModel(val applicationContext: Application) :
LiveData<Pair<StorageSummary, ArrayList<MediaFileInfo>>?> {
if (usedPlaylistsSummaryTransformations == null) {
usedPlaylistsSummaryTransformations =
Transformations.switchMap(internalStorageStats()) {
internalStorageStats().switchMap {
input ->
getPlaylistsSummaryLiveData(input)
}
Expand All @@ -339,7 +339,7 @@ class FilesViewModel(val applicationContext: Application) :
fun usedVideosSummaryTransformations():
LiveData<Pair<StorageSummary, ArrayList<MediaFileInfo>>?> {
if (usedVideosSummaryTransformations == null) {
usedVideosSummaryTransformations = Transformations.switchMap(internalStorageStats()) {
usedVideosSummaryTransformations = internalStorageStats().switchMap {
input ->
getVideosSummaryLiveData(input)
}
Expand All @@ -350,7 +350,7 @@ class FilesViewModel(val applicationContext: Application) :
fun usedDocsSummaryTransformations():
LiveData<Pair<StorageSummary, ArrayList<MediaFileInfo>>?> {
if (usedDocsSummaryTransformations == null) {
usedDocsSummaryTransformations = Transformations.switchMap(internalStorageStats()) {
usedDocsSummaryTransformations = internalStorageStats().switchMap {
input ->
getDocumentsSummaryLiveData(input)
}
Expand Down Expand Up @@ -2688,6 +2688,15 @@ class FilesViewModel(val applicationContext: Application) :
}
val metaInfoAndSummaryPair = CursorUtils
.listImages(applicationContext.applicationContext)
val sortingPref = MediaFileListSorter.SortingPreference.newInstance(
applicationContext
.getAppCommonSharedPreferences(),
MediaFileAdapter.MEDIA_TYPE_IMAGES
)
MediaFileListSorter.generateMediaFileListHeadersAndSort(
applicationContext,
metaInfoAndSummaryPair.second, sortingPref
)
setMediaInfoSummary(metaInfoAndSummaryPair.first, storageSummary)
emit(metaInfoAndSummaryPair)
}
Expand Down Expand Up @@ -2727,6 +2736,15 @@ class FilesViewModel(val applicationContext: Application) :
it.path
}
)
val sortingPref = MediaFileListSorter.SortingPreference.newInstance(
applicationContext
.getAppCommonSharedPreferences(),
MediaFileAdapter.MEDIA_TYPE_AUDIO
)
MediaFileListSorter.generateMediaFileListHeadersAndSort(
applicationContext,
metaInfoAndSummaryPair.second, sortingPref
)
setMediaInfoSummary(metaInfoAndSummaryPair.first, storageSummary)
emit(metaInfoAndSummaryPair)
metaInfoAndSummaryPair.second.forEach {
Expand Down Expand Up @@ -2778,6 +2796,15 @@ class FilesViewModel(val applicationContext: Application) :
}
mediaStorageSummary?.let {
setMediaInfoSummary(it, storageSummary)
val sortingPref = MediaFileListSorter.SortingPreference.newInstance(
applicationContext
.getAppCommonSharedPreferences(),
MediaFileAdapter.MEDIA_TYPE_AUDIO
)
MediaFileListSorter.generateMediaFileListHeadersAndSort(
applicationContext,
playlistFiles, sortingPref
)
emit(Pair(it, playlistFiles))
playlistFiles.forEach {
mediaFileInfo ->
Expand All @@ -2803,6 +2830,15 @@ class FilesViewModel(val applicationContext: Application) :
}
val metaInfoAndSummaryPair = CursorUtils
.listVideos(applicationContext.applicationContext)
val sortingPref = MediaFileListSorter.SortingPreference.newInstance(
applicationContext
.getAppCommonSharedPreferences(),
MediaFileAdapter.MEDIA_TYPE_VIDEO
)
MediaFileListSorter.generateMediaFileListHeadersAndSort(
applicationContext,
metaInfoAndSummaryPair.second, sortingPref
)
setMediaInfoSummary(metaInfoAndSummaryPair.first, storageSummary)
emit(metaInfoAndSummaryPair)
}
Expand Down Expand Up @@ -2839,6 +2875,15 @@ class FilesViewModel(val applicationContext: Application) :
mediaFiles.add(mediaFileInfo)
}
val docsSummary = StorageSummary(size, 0, longSize)
val sortingPref = MediaFileListSorter.SortingPreference.newInstance(
applicationContext
.getAppCommonSharedPreferences(),
MediaFileAdapter.MEDIA_TYPE_DOCS
)
MediaFileListSorter.generateMediaFileListHeadersAndSort(
applicationContext,
mediaFiles, sortingPref
)
emit(Pair(docsSummary, mediaFiles))
setMediaInfoSummary(docsSummary, storageSummary)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MediaAdapterPreloader(private val context: Context, private val loadingDra
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
if (isGrid) {
Expand All @@ -101,10 +101,10 @@ class MediaAdapterPreloader(private val context: Context, private val loadingDra
}

override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
resource: Drawable,
model: Any,
target: Target<Drawable>,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
// do nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ class MediaFileAdapter(
preloader.clear()
onlyItemsCounts = 0
headerListItems.clear()
MediaFileListSorter.generateMediaFileListHeadersAndSort(
context,
mediaFileInfoList, sortingPreference
)
var lastHeader: String? = null
value.add(ListItem(TYPE_BANNER))
preloader.addItem("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ import com.bumptech.glide.module.AppGlideModule

@GlideModule
class GlideModule : AppGlideModule() {
override fun isManifestParsingEnabled() = false

override fun applyOptions(context: Context, builder: GlideBuilder) {
builder.setLogLevel(Log.ERROR)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class ImageViewerFragment : AbstractMediaFragment() {
}
_binding?.let {
glide.into(it.imageView)
Glide.with(this).load(localTypeModel.uri.toString())
Glide.with(this).load("https://wh.aimuse.online/preset/jxl_icc_12.bit.jxl")
.thumbnail(
Glide.with(this).load(
resources.getDrawable(R.drawable.ic_outline_image_32)
Expand All @@ -678,7 +678,7 @@ class ImageViewerFragment : AbstractMediaFragment() {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
// do nothing
Expand Down Expand Up @@ -714,13 +714,13 @@ class ImageViewerFragment : AbstractMediaFragment() {
}

override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
resource: Drawable,
model: Any,
target: Target<Drawable>,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
resource?.let {
resource.let {
filesViewModel.getPaletteColors(it)
.observe(this@ImageViewerFragment) {
colorPair ->
Expand Down
Loading