Misc updates
This commit is contained in:
1 parent
20c1b7acdb
commit
56f9138db4
9 files changed
+24
-19
No files matched your search
@@ -5,6 +5,7 @@ import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.MapColumn
|
||||
import androidx.room.Query
|
||||
import androidx.room.RoomWarnings
|
||||
import androidx.room.Transaction
|
||||
import androidx.room.Update
|
||||
import androidx.room.Upsert
|
||||
@@ -12,11 +13,12 @@ import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface DownloadsDao {
|
||||
@Suppress("ktlint:standard:annotation")
|
||||
// https://issuetracker.google.com/327583152
|
||||
@Suppress("ktlint:standard:annotation", RoomWarnings.UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE)
|
||||
@Query("SELECT LABEL, COUNT(*) AS COUNT FROM DOWNLOADS LEFT JOIN DOWNLOAD_LABELS USING(LABEL) GROUP BY LABEL")
|
||||
fun countByLabel(): Flow<Map<@MapColumn("LABEL") String?, @MapColumn("COUNT") Int>>
|
||||
|
||||
@Suppress("ktlint:standard:annotation")
|
||||
@Suppress("ktlint:standard:annotation", RoomWarnings.UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE)
|
||||
@Query("SELECT ARTIST, COUNT(*) AS COUNT FROM DOWNLOADS LEFT JOIN DOWNLOAD_ARTISTS USING(GID) GROUP BY ARTIST ORDER BY COUNT DESC, ARTIST")
|
||||
fun countByArtist(): Flow<Map<@MapColumn("ARTIST") String?, @MapColumn("COUNT") Int>>
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ fun openBrowser(url: String) {
|
||||
if (url.isEmpty()) return
|
||||
try {
|
||||
intent.launchUrl(ctx, url.toUri())
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
Toast.makeText(ctx, R.string.no_browser_installed, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ fun FabLayout(
|
||||
}
|
||||
}
|
||||
onExpandChanged(false)
|
||||
} catch (e: CancellationException) {
|
||||
} catch (_: CancellationException) {
|
||||
launch { state.expand() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ suspend fun save(page: Page) {
|
||||
try {
|
||||
ctx.contentResolver.delete(imageUri, null, null)
|
||||
} catch (e: Exception) {
|
||||
e.logcat(e)
|
||||
logcat("SavePage", e)
|
||||
}
|
||||
snackbar(cannotSave)
|
||||
} else if (isAtLeastQ) {
|
||||
|
||||
@@ -249,7 +249,7 @@ fun AnimatedVisibilityScope.GalleryDetailScreen(args: GalleryDetailScreenArgs, n
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.clear_image_cache_confirm))
|
||||
}
|
||||
(0..<gd.pages).forEach {
|
||||
repeat(gd.pages) {
|
||||
val key = getImageKey(gd.gid, it)
|
||||
imageCache.remove(key)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ fun animateFloatMergePredictiveBackAsState(
|
||||
animatable.snapTo(transformed)
|
||||
}
|
||||
onBack()
|
||||
} catch (e: CancellationException) {
|
||||
} catch (_: CancellationException) {
|
||||
channel.trySend(0f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@ import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.InternalAPI
|
||||
import io.ktor.utils.io.rethrowCloseCauseIfNeeded
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
import kotlin.math.ln
|
||||
import kotlin.math.pow
|
||||
import okio.Path
|
||||
|
||||
object FileUtils {
|
||||
@@ -38,15 +35,15 @@ object FileUtils {
|
||||
* @param bytes the bytes to convert
|
||||
* @return the human readable string
|
||||
*/
|
||||
// http://stackoverflow.com/questions/3758606/
|
||||
fun humanReadableByteCount(bytes: Long): String {
|
||||
if (bytes < 1024) return "$bytes B"
|
||||
val exp = (ln(bytes.toDouble()) / ln(1024f)).toInt()
|
||||
return "%.1f %sB".format(
|
||||
Locale.US,
|
||||
bytes / 1024.toDouble().pow(exp.toDouble()),
|
||||
("KMGTPE")[exp - 1].toString() + "i",
|
||||
)
|
||||
val units = "KMGTPE"
|
||||
var exp = -1
|
||||
var result = bytes.toDouble()
|
||||
while (result >= 1024.0 && exp < units.length - 1) {
|
||||
exp++
|
||||
result /= 1024.0
|
||||
}
|
||||
return if (exp == -1) "$bytes B" else "%.1f %siB".format(result, units[exp])
|
||||
}
|
||||
|
||||
fun cleanupDirectory(dir: File?, maxFiles: Int = 10) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||
// https://kotlinlang.org/docs/gradle-compiler-options.html#all-compiler-options
|
||||
internal fun KotlinCommonCompilerOptions.configureKotlin() {
|
||||
progressiveMode = true
|
||||
allWarningsAsErrors = true
|
||||
optIn.addAll(
|
||||
"kotlin.ExperimentalStdlibApi",
|
||||
"kotlin.concurrent.atomics.ExperimentalAtomicApi",
|
||||
|
||||
+6
-1
@@ -18,9 +18,14 @@ org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.configuration-cache=true
|
||||
|
||||
# TODO: These will become default in AGP 9.0
|
||||
android.useAndroidX=true
|
||||
android.enableAppCompileTimeRClass=true
|
||||
android.r8.integratedResourceShrinking=true
|
||||
android.defaults.buildfeatures.resvalues=false
|
||||
android.defaults.buildfeatures.shaders=false
|
||||
android.r8.optimizedResourceShrinking=true
|
||||
android.r8.strictFullModeForKeepRules=true
|
||||
|
||||
# https://github.com/google/ksp/issues/2375
|
||||
ksp.version.check=false
|
||||
Reference in new issue
Block a user