Fix some warnings

devel
Koitharu 7 months ago
parent 07af3ea703
commit ef3aa40acc
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -36,7 +36,7 @@ class TelegramBackupUploader @Inject constructor(
suspend fun uploadBackup(file: File) {
val requestBody = file.asRequestBody("application/zip".toMediaTypeOrNull())
val multipartBody = MultipartBody.Builder()
.setType(MultipartBody.Companion.FORM)
.setType(MultipartBody.FORM)
.addFormDataPart("chat_id", requireChatId())
.addFormDataPart("document", file.name, requestBody)
.build()

@ -798,7 +798,7 @@ class AppRouter private constructor(
else -> true
}
fun shortMangaUrl(mangaId: Long) = Uri.Builder()
fun shortMangaUrl(mangaId: Long): Uri = Uri.Builder()
.scheme("kotatsu")
.path("manga")
.appendQueryParameter("id", mangaId.toString())

@ -19,6 +19,7 @@ import coil3.request.Options
import coil3.size.pxOrElse
import coil3.toAndroidUri
import coil3.toBitmap
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.runInterruptible
import okio.FileSystem
@ -41,7 +42,6 @@ import org.koitharu.kotatsu.local.data.LocalStorageCache
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
import java.io.File
import javax.inject.Inject
import kotlin.coroutines.coroutineContext
import coil3.Uri as CoilUri
class FaviconFetcher(
@ -88,7 +88,7 @@ class FaviconFetcher(
var favicons = repository.getFavicons()
var lastError: Exception? = null
while (favicons.isNotEmpty()) {
coroutineContext.ensureActive()
currentCoroutineContext().ensureActive()
val icon = favicons.find(sizePx) ?: throwNSEE(lastError)
try {
val result = imageLoader.fetch(icon.url, options)

@ -1,13 +1,11 @@
package org.koitharu.kotatsu.details.domain
import android.util.Log
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.onEach
import org.koitharu.kotatsu.core.model.FavouriteCategory
import org.koitharu.kotatsu.core.model.isNsfw
import org.koitharu.kotatsu.core.prefs.AppSettings

@ -27,7 +27,7 @@ class ReadingTimeUseCase @Inject constructor(
// Impossible task, I guess. Good luck on this.
var averageTimeSec: Int = 20 /* pages */ * getSecondsPerPage(manga.id) * chapters.size
if (isOnHistoryBranch) {
averageTimeSec = (averageTimeSec * (1f - checkNotNull(history).percent)).roundToInt()
averageTimeSec = (averageTimeSec * (1f - history.percent)).roundToInt()
}
if (averageTimeSec < 60) {
return null

@ -2,7 +2,6 @@ package org.koitharu.kotatsu.details.ui
import android.app.assist.AssistContent
import android.content.Context
import android.os.Build
import android.os.Bundle
import android.text.SpannedString
import android.view.Gravity

@ -1,7 +1,6 @@
package org.koitharu.kotatsu.explore.ui.adapter
import android.view.View
import androidx.appcompat.widget.TooltipCompat
import androidx.core.content.ContextCompat
import androidx.core.text.bold
import androidx.core.text.buildSpannedString

@ -1,6 +1,5 @@
package org.koitharu.kotatsu.filter.ui.sheet
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View

@ -2,14 +2,12 @@ package org.koitharu.kotatsu.image.ui
import android.content.Context
import android.graphics.drawable.LayerDrawable
import android.os.Build
import android.util.AttributeSet
import android.view.Gravity
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver.OnPreDrawListener
import androidx.annotation.AttrRes
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.core.content.withStyledAttributes
import androidx.core.graphics.ColorUtils
@ -205,6 +203,7 @@ class CoverImageView @JvmOverloads constructor(
is HttpStatusException -> statusCode.toString()
is ContentUnavailableException,
is FileNotFoundException -> "404"
is TooManyRequestExceptions -> "429"
is ParseException -> "</>"
is UnsupportedSourceException -> "X"
@ -266,7 +265,7 @@ class CoverImageView @JvmOverloads constructor(
width = Dimension(height.px * view.aspectRationWidth / view.aspectRationHeight)
}
}
return Size(checkNotNull(width), checkNotNull(height))
return Size(width, height)
}
private fun getWidth() = getDimension(

@ -27,7 +27,6 @@ import org.koitharu.kotatsu.parsers.util.json.getLongOrDefault
import org.koitharu.kotatsu.parsers.util.json.getStringOrNull
import org.koitharu.kotatsu.parsers.util.json.mapJSONToSet
import org.koitharu.kotatsu.parsers.util.json.toStringSet
import org.koitharu.kotatsu.parsers.util.nullIfEmpty
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
import org.koitharu.kotatsu.parsers.util.toTitleCase
import java.io.File

@ -8,11 +8,9 @@ import android.graphics.Rect
import androidx.annotation.ColorInt
import androidx.core.graphics.alpha
import androidx.core.graphics.blue
import androidx.core.graphics.get
import androidx.core.graphics.green
import androidx.core.graphics.red
import com.davemorrissey.labs.subscaleview.ImageSource
import com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder
import com.davemorrissey.labs.subscaleview.decoder.SkiaPooledImageRegionDecoder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
@ -23,7 +21,6 @@ import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import org.koitharu.kotatsu.core.util.SynchronizedSieveCache
import org.koitharu.kotatsu.core.util.ext.use
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
@ -49,16 +46,16 @@ class EdgeDetector(private val context: Context) {
val fullBitmap = decoder.decodeRegion(
Rect(0, 0, size.x, size.y),
sampleSize
sampleSize,
)
try {
val edges = coroutineScope {
listOf(
async { detectLeftRightEdge(fullBitmap, size, sampleSize, isLeft = true) },
async { detectTopBottomEdge(fullBitmap, size, sampleSize, isTop = true) },
async { detectLeftRightEdge(fullBitmap, size, sampleSize, isLeft = false) },
async { detectTopBottomEdge(fullBitmap, size, sampleSize, isTop = false) },
async { detectLeftRightEdge(fullBitmap, size, sampleSize, isLeft = true) },
async { detectTopBottomEdge(fullBitmap, size, sampleSize, isTop = true) },
async { detectLeftRightEdge(fullBitmap, size, sampleSize, isLeft = false) },
async { detectTopBottomEdge(fullBitmap, size, sampleSize, isTop = false) },
).awaitAll()
}
var hasEdges = false

@ -183,7 +183,7 @@ class MALRepository @Inject constructor(
storage.clear()
}
private fun jsonToManga(json: JSONObject, sourceTitle: String): ScrobblerManga? {
private fun jsonToManga(json: JSONObject, sourceTitle: String): ScrobblerManga {
val node = json.getJSONObject("node")
val title = node.getString("title")
return ScrobblerManga(

@ -1,6 +1,5 @@
package org.koitharu.kotatsu.search.ui.suggestion.adapter
import androidx.appcompat.widget.TooltipCompat
import androidx.core.view.updatePadding
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView

@ -8,6 +8,7 @@ import androidx.core.net.toUri
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.isActive
@ -18,7 +19,6 @@ import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
import org.koitharu.kotatsu.core.util.ext.call
import org.koitharu.kotatsu.core.util.ext.requireValue
import javax.inject.Inject
import kotlin.coroutines.coroutineContext
@HiltViewModel
class AppUpdateViewModel @Inject constructor(
@ -79,7 +79,7 @@ class AppUpdateViewModel @Inject constructor(
private suspend fun observeDownload(id: Long) {
val query = DownloadManager.Query()
query.setFilterById(id)
while (coroutineContext.isActive) {
while (currentCoroutineContext().isActive) {
downloadManager.query(query).use { cursor ->
if (cursor.moveToFirst()) {
val bytesDownloaded = cursor.getLong(

@ -24,7 +24,7 @@ class DiscordSettingsFragment : BasePreferenceFragment(R.string.discord) {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_discord)
findPreference<EditTextPreference>(AppSettings.Companion.KEY_DISCORD_TOKEN)?.let { pref ->
findPreference<EditTextPreference>(AppSettings.KEY_DISCORD_TOKEN)?.let { pref ->
pref.dialogMessage = pref.context.getString(
R.string.discord_token_description,
pref.context.getString(R.string.sign_in),
@ -44,21 +44,21 @@ class DiscordSettingsFragment : BasePreferenceFragment(R.string.discord) {
}
override fun onDisplayPreferenceDialog(preference: Preference) {
if (preference is EditTextPreference && preference.key == AppSettings.Companion.KEY_DISCORD_TOKEN) {
if (parentFragmentManager.findFragmentByTag(TokenDialogFragment.Companion.DIALOG_FRAGMENT_TAG) != null) {
if (preference is EditTextPreference && preference.key == AppSettings.KEY_DISCORD_TOKEN) {
if (parentFragmentManager.findFragmentByTag(TokenDialogFragment.DIALOG_FRAGMENT_TAG) != null) {
return
}
val f = TokenDialogFragment.newInstance(preference.key)
@Suppress("DEPRECATION")
f.setTargetFragment(this, 0)
f.show(parentFragmentManager, TokenDialogFragment.Companion.DIALOG_FRAGMENT_TAG)
f.show(parentFragmentManager, TokenDialogFragment.DIALOG_FRAGMENT_TAG)
return
}
super.onDisplayPreferenceDialog(preference)
}
private fun bindTokenPreference(state: TokenState, token: String?) {
val pref = findPreference<EditTextPreference>(AppSettings.Companion.KEY_DISCORD_TOKEN) ?: return
val pref = findPreference<EditTextPreference>(AppSettings.KEY_DISCORD_TOKEN) ?: return
when (state) {
TokenState.EMPTY -> {
pref.icon = null

@ -34,7 +34,7 @@ class DiscordSettingsViewModel @Inject constructor(
TokenState.CHECKING to settings.discordToken,
)
private suspend fun checkToken(): Flow<Pair<TokenState, String?>> = flow {
private fun checkToken(): Flow<Pair<TokenState, String?>> = flow {
val token = settings.discordToken
if (!settings.isDiscordRpcEnabled) {
emit(

@ -46,7 +46,6 @@ import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.exceptions.CloudFlareException
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
import org.koitharu.kotatsu.core.exceptions.resolve.CaptchaHandler
import org.koitharu.kotatsu.core.model.distinctById
import org.koitharu.kotatsu.core.model.getLocale

@ -24,7 +24,6 @@ import org.koitharu.kotatsu.core.util.ext.checkNotificationPermission
import org.koitharu.kotatsu.core.util.ext.getQuantityStringSafe
import org.koitharu.kotatsu.core.util.ext.mangaSourceExtra
import org.koitharu.kotatsu.core.util.ext.toBitmapOrNull
import org.koitharu.kotatsu.parsers.model.ContentRating
import org.koitharu.kotatsu.parsers.model.Manga
import org.koitharu.kotatsu.parsers.model.MangaChapter
import javax.inject.Inject

@ -45,7 +45,7 @@
<item name="expandCollapseIndicator">@drawable/m3_split_button_chevron_avd</item>
<!-- Base attributes -->
<item name="android:windowLightStatusBar" tools:targetApi="M">@bool/light_status_bar</item>
<item name="android:windowLightStatusBar">@bool/light_status_bar</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@color/dim</item>
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>

@ -4,7 +4,6 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.koitharu.kotatsu.core.model.TestMangaSource
import org.koitharu.kotatsu.parsers.model.MangaParserSource
import org.koitharu.kotatsu.reader.ui.pager.ReaderPage
import kotlin.random.Random

Loading…
Cancel
Save