Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ffb91c2 authored by tibbi's avatar tibbi
Browse files

move the file compression format checker to a string extension

parent b6ea70f4
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
package com.simplemobiletools.commons.extensions

import android.content.Context
import android.graphics.Bitmap
import com.simplemobiletools.commons.models.FileDirItem
import java.io.File

@@ -17,12 +16,6 @@ fun File.isAudioSlow() = absolutePath.isAudioFast() || getMimeType().startsWith(

fun File.getMimeType() = absolutePath.getMimeType()

fun File.getCompressionFormat() = when (extension.toLowerCase()) {
    "png" -> Bitmap.CompressFormat.PNG
    "webp" -> Bitmap.CompressFormat.WEBP
    else -> Bitmap.CompressFormat.JPEG
}

fun File.getProperSize(countHiddenItems: Boolean): Long {
    return if (isDirectory) {
        getDirectorySize(this, countHiddenItems)
+7 −0
Original line number Diff line number Diff line
package com.simplemobiletools.commons.extensions

import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Point
import android.media.ExifInterface
@@ -58,6 +59,12 @@ fun String.isImageSlow() = isImageFast() || getMimeType().startsWith("image")
fun String.isVideoSlow() = isVideoFast() || getMimeType().startsWith("video")
fun String.isAudioSlow() = isAudioFast() || getMimeType().startsWith("audio")

fun String.getCompressionFormat() = when (getFilenameExtension().toLowerCase()) {
    "png" -> Bitmap.CompressFormat.PNG
    "webp" -> Bitmap.CompressFormat.WEBP
    else -> Bitmap.CompressFormat.JPEG
}

fun String.areDigitsOnly() = matches(Regex("[0-9]+"))

fun String.getExifProperties(exif: ExifInterface): String {