Update dependencies
This commit is contained in:
@@ -6,7 +6,7 @@ import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.room.Room
|
||||
import coil.Coil
|
||||
import coil.ComponentRegistry
|
||||
import coil.ImageLoaderBuilder
|
||||
import coil.ImageLoader
|
||||
import coil.util.CoilUtils
|
||||
import com.chuckerteam.chucker.api.ChuckerCollector
|
||||
import com.chuckerteam.chucker.api.ChuckerInterceptor
|
||||
@@ -14,6 +14,7 @@ import okhttp3.OkHttpClient
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.android.ext.koin.androidLogger
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.core.logger.Level
|
||||
import org.koin.dsl.module
|
||||
import org.koitharu.kotatsu.core.db.DatabasePrePopulateCallback
|
||||
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||
@@ -73,7 +74,7 @@ class KotatsuApp : Application() {
|
||||
|
||||
private fun initKoin() {
|
||||
startKoin {
|
||||
androidLogger()
|
||||
androidLogger(Level.ERROR)
|
||||
androidContext(applicationContext)
|
||||
modules(
|
||||
module {
|
||||
@@ -101,7 +102,7 @@ class KotatsuApp : Application() {
|
||||
|
||||
private fun initCoil() {
|
||||
Coil.setImageLoader(
|
||||
ImageLoaderBuilder(applicationContext)
|
||||
ImageLoader.Builder(applicationContext)
|
||||
.okHttpClient(
|
||||
okHttp()
|
||||
.cache(CoilUtils.createDefaultCache(applicationContext))
|
||||
|
||||
@@ -4,19 +4,19 @@ import androidx.room.*
|
||||
import org.koitharu.kotatsu.core.db.entity.TagEntity
|
||||
|
||||
@Dao
|
||||
interface TagsDao {
|
||||
abstract class TagsDao {
|
||||
|
||||
@Query("SELECT * FROM tags")
|
||||
suspend fun getAllTags(): List<TagEntity>
|
||||
abstract suspend fun getAllTags(): List<TagEntity>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
suspend fun insert(tag: TagEntity): Long
|
||||
abstract suspend fun insert(tag: TagEntity): Long
|
||||
|
||||
@Update(onConflict = OnConflictStrategy.IGNORE)
|
||||
suspend fun update(tag: TagEntity): Int
|
||||
abstract suspend fun update(tag: TagEntity): Int
|
||||
|
||||
@Transaction
|
||||
suspend fun upsert(tags: Iterable<TagEntity>) {
|
||||
open suspend fun upsert(tags: Iterable<TagEntity>) {
|
||||
tags.forEach { tag ->
|
||||
if (update(tag) <= 0) {
|
||||
insert(tag)
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.koitharu.kotatsu.core.local
|
||||
|
||||
import android.net.Uri
|
||||
import android.webkit.MimeTypeMap
|
||||
import coil.bitmappool.BitmapPool
|
||||
import coil.bitmap.BitmapPool
|
||||
import coil.decode.DataSource
|
||||
import coil.decode.Options
|
||||
import coil.fetch.FetchResult
|
||||
|
||||
@@ -131,7 +131,7 @@ abstract class ChanRepository(loaderContext: MangaLoaderContext) : RemoteMangaRe
|
||||
override fun onCreatePreferences() = setOf(R.string.key_parser_domain)
|
||||
|
||||
private fun getSortKey(sortOrder: SortOrder?) =
|
||||
when (sortOrder ?: sortOrders.minBy { it.ordinal }) {
|
||||
when (sortOrder ?: sortOrders.minByOrNull { it.ordinal }) {
|
||||
SortOrder.ALPHABETICAL -> "catalog"
|
||||
SortOrder.POPULARITY -> "mostfavorites"
|
||||
SortOrder.NEWEST -> "manga/new"
|
||||
@@ -139,7 +139,7 @@ abstract class ChanRepository(loaderContext: MangaLoaderContext) : RemoteMangaRe
|
||||
}
|
||||
|
||||
private fun getSortKey2(sortOrder: SortOrder?) =
|
||||
when (sortOrder ?: sortOrders.minBy { it.ordinal }) {
|
||||
when (sortOrder ?: sortOrders.minByOrNull { it.ordinal }) {
|
||||
SortOrder.ALPHABETICAL -> "abcasc"
|
||||
SortOrder.POPULARITY -> "favdesc"
|
||||
SortOrder.NEWEST -> "datedesc"
|
||||
|
||||
@@ -165,7 +165,7 @@ abstract class GroupleRepository(loaderContext: MangaLoaderContext) :
|
||||
override fun onCreatePreferences() = setOf(R.string.key_parser_domain)
|
||||
|
||||
private fun getSortKey(sortOrder: SortOrder?) =
|
||||
when (sortOrder ?: sortOrders.minBy { it.ordinal }) {
|
||||
when (sortOrder ?: sortOrders.minByOrNull { it.ordinal }) {
|
||||
SortOrder.ALPHABETICAL -> "name"
|
||||
SortOrder.POPULARITY -> "rate"
|
||||
SortOrder.UPDATED -> "updated"
|
||||
|
||||
@@ -6,7 +6,7 @@ import androidx.core.net.toUri
|
||||
import androidx.core.text.parseAsHtml
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import coil.api.load
|
||||
import coil.load
|
||||
import com.google.android.material.chip.Chip
|
||||
import kotlinx.android.synthetic.main.fragment_details.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
@@ -13,7 +13,6 @@ import androidx.core.graphics.drawable.toBitmap
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
import org.koitharu.kotatsu.ui.details.MangaDetailsActivity
|
||||
import org.koitharu.kotatsu.utils.ext.clearActions
|
||||
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import android.webkit.MimeTypeMap
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import coil.Coil
|
||||
import coil.request.GetRequestBuilder
|
||||
import coil.request.ImageRequest
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import okhttp3.OkHttpClient
|
||||
@@ -89,7 +89,7 @@ class DownloadService : BaseService() {
|
||||
val repo = MangaProviderFactory.create(manga.source)
|
||||
val cover = safe {
|
||||
Coil.execute(
|
||||
GetRequestBuilder(this@DownloadService)
|
||||
ImageRequest.Builder(this@DownloadService)
|
||||
.data(manga.coverUrl)
|
||||
.build()
|
||||
).drawable
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.koitharu.kotatsu.ui.list
|
||||
|
||||
import android.view.ViewGroup
|
||||
import coil.api.clear
|
||||
import coil.api.load
|
||||
import coil.clear
|
||||
import coil.load
|
||||
import kotlinx.android.synthetic.main.item_manga_grid.*
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.koitharu.kotatsu.ui.list
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import coil.api.clear
|
||||
import coil.api.load
|
||||
import coil.clear
|
||||
import coil.load
|
||||
import kotlinx.android.synthetic.main.item_manga_list_details.*
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.koitharu.kotatsu.ui.list
|
||||
|
||||
import android.view.ViewGroup
|
||||
import coil.api.clear
|
||||
import coil.api.load
|
||||
import coil.clear
|
||||
import coil.load
|
||||
import kotlinx.android.synthetic.main.item_manga_list.*
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.koitharu.kotatsu.ui.list.feed
|
||||
|
||||
import android.text.format.DateUtils
|
||||
import android.view.ViewGroup
|
||||
import coil.api.clear
|
||||
import coil.api.load
|
||||
import coil.clear
|
||||
import coil.load
|
||||
import kotlinx.android.synthetic.main.item_tracklog.*
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.TrackingLogItem
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.koitharu.kotatsu.ui.reader.thumbnails
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.net.toUri
|
||||
import coil.Coil
|
||||
import coil.request.GetRequestBuilder
|
||||
import coil.request.ImageRequest
|
||||
import coil.size.PixelSize
|
||||
import coil.size.Size
|
||||
import kotlinx.android.synthetic.main.item_page_thumb.*
|
||||
@@ -18,7 +18,7 @@ class PageThumbnailHolder(parent: ViewGroup, private val scope: CoroutineScope)
|
||||
BaseViewHolder<MangaPage, PagesCache>(parent, R.layout.item_page_thumb) {
|
||||
|
||||
private var job: Job? = null
|
||||
private val thumbSize: Size
|
||||
private val thumbSize: Size
|
||||
|
||||
init {
|
||||
val width = itemView.context.resources.getDimensionPixelSize(R.dimen.preferred_grid_width)
|
||||
@@ -38,10 +38,12 @@ class PageThumbnailHolder(parent: ViewGroup, private val scope: CoroutineScope)
|
||||
val pageUrl = MangaProviderFactory.create(data.source).getPageFullUrl(data)
|
||||
extra[pageUrl]?.toUri()?.toString() ?: pageUrl
|
||||
}
|
||||
val drawable = Coil.execute(GetRequestBuilder(context)
|
||||
.data(url)
|
||||
.size(thumbSize)
|
||||
.build()).drawable
|
||||
val drawable = Coil.execute(
|
||||
ImageRequest.Builder(context)
|
||||
.data(url)
|
||||
.size(thumbSize)
|
||||
.build()
|
||||
).drawable
|
||||
withContext(Dispatchers.Main) {
|
||||
imageView_thumb.setImageDrawable(drawable)
|
||||
}
|
||||
|
||||
@@ -67,10 +67,15 @@ class AppUpdateChecker(private val activity: ComponentActivity) : KoinComponent
|
||||
.setTitle(R.string.app_update_available)
|
||||
.setMessage(buildString {
|
||||
append(activity.getString(R.string.new_version_s, version.name))
|
||||
appendln()
|
||||
append(activity.getString(R.string.size_s, FileSizeUtils.formatBytes(activity, version.apkSize)))
|
||||
appendln()
|
||||
appendln()
|
||||
appendLine()
|
||||
append(
|
||||
activity.getString(
|
||||
R.string.size_s,
|
||||
FileSizeUtils.formatBytes(activity, version.apkSize)
|
||||
)
|
||||
)
|
||||
appendLine()
|
||||
appendLine()
|
||||
append(version.description)
|
||||
})
|
||||
.setPositiveButton(R.string.download) { _, _ ->
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.work.*
|
||||
import coil.Coil
|
||||
import coil.request.GetRequestBuilder
|
||||
import coil.request.ImageRequest
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.core.KoinComponent
|
||||
@@ -143,7 +143,7 @@ class TrackWorker(context: Context, workerParams: WorkerParameters) :
|
||||
setNumber(newChapters.size)
|
||||
setLargeIcon(
|
||||
Coil.execute(
|
||||
GetRequestBuilder(applicationContext)
|
||||
ImageRequest.Builder(applicationContext)
|
||||
.data(manga.coverUrl)
|
||||
.build()
|
||||
).toBitmapOrNull()
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.content.Intent
|
||||
import android.widget.RemoteViews
|
||||
import android.widget.RemoteViewsService
|
||||
import coil.Coil
|
||||
import coil.request.GetRequestBuilder
|
||||
import coil.request.ImageRequest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
@@ -38,9 +38,11 @@ class RecentListFactory(private val context: Context) : RemoteViewsService.Remot
|
||||
val item = dataSet[position]
|
||||
try {
|
||||
val cover = runBlocking {
|
||||
Coil.execute(GetRequestBuilder(context)
|
||||
.data(item.coverUrl)
|
||||
.build()).requireBitmap()
|
||||
Coil.execute(
|
||||
ImageRequest.Builder(context)
|
||||
.data(item.coverUrl)
|
||||
.build()
|
||||
).requireBitmap()
|
||||
}
|
||||
views.setImageViewBitmap(R.id.imageView_cover, cover)
|
||||
} catch (e: IOException) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.content.Intent
|
||||
import android.widget.RemoteViews
|
||||
import android.widget.RemoteViewsService
|
||||
import coil.Coil
|
||||
import coil.request.GetRequestBuilder
|
||||
import coil.request.ImageRequest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
@@ -49,9 +49,11 @@ class ShelfListFactory(private val context: Context, widgetId: Int) : RemoteView
|
||||
views.setTextViewText(R.id.textView_title, item.title)
|
||||
try {
|
||||
val cover = runBlocking {
|
||||
Coil.execute(GetRequestBuilder(context)
|
||||
.data(item.coverUrl)
|
||||
.build()).requireBitmap()
|
||||
Coil.execute(
|
||||
ImageRequest.Builder(context)
|
||||
.data(item.coverUrl)
|
||||
.build()
|
||||
).requireBitmap()
|
||||
}
|
||||
views.setImageViewBitmap(R.id.imageView_cover, cover)
|
||||
} catch (e: IOException) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.core.content.pm.ShortcutInfoCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import coil.Coil
|
||||
import coil.request.GetRequestBuilder
|
||||
import coil.request.ImageRequest
|
||||
import coil.size.PixelSize
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -40,7 +40,7 @@ class MangaShortcut(private val manga: Manga) {
|
||||
}
|
||||
builder.setRank(1)
|
||||
if (shortcuts.isNotEmpty() && shortcuts.size >= limit) {
|
||||
manager.removeDynamicShortcuts(listOf(shortcuts.minBy { it.rank }!!.id))
|
||||
manager.removeDynamicShortcuts(listOf(shortcuts.minByOrNull { it.rank }!!.id))
|
||||
}
|
||||
manager.addDynamicShortcuts(listOf(builder.build().toShortcutInfo()))
|
||||
}
|
||||
@@ -66,9 +66,11 @@ class MangaShortcut(private val manga: Manga) {
|
||||
val icon = safe {
|
||||
val size = getIconSize(context)
|
||||
withContext(Dispatchers.IO) {
|
||||
val bmp = Coil.execute(GetRequestBuilder(context)
|
||||
.data(manga.coverUrl)
|
||||
.build()).requireBitmap()
|
||||
val bmp = Coil.execute(
|
||||
ImageRequest.Builder(context)
|
||||
.data(manga.coverUrl)
|
||||
.build()
|
||||
).requireBitmap()
|
||||
ThumbnailUtils.extractThumbnail(bmp, size.width, size.height, 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@ package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import coil.request.ErrorResult
|
||||
import coil.request.RequestResult
|
||||
import coil.request.ImageResult
|
||||
import coil.request.SuccessResult
|
||||
|
||||
fun RequestResult.requireBitmap() = when(this) {
|
||||
fun ImageResult.requireBitmap() = when (this) {
|
||||
is SuccessResult -> drawable.toBitmap()
|
||||
is ErrorResult -> throw throwable
|
||||
}
|
||||
|
||||
fun RequestResult.toBitmapOrNull() = when(this) {
|
||||
fun ImageResult.toBitmapOrNull() = when (this) {
|
||||
is SuccessResult -> try {
|
||||
drawable.toBitmap()
|
||||
} catch (_: Throwable) {
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.core.app.NotificationCompat
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
fun NotificationCompat.Builder.clearActions(): NotificationCompat.Builder {
|
||||
safe {
|
||||
mActions.clear()
|
||||
}
|
||||
return this
|
||||
}
|
||||
Reference in New Issue
Block a user