Skip to content
Merged
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
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ dependencies {
implementation libs.androidx.room.ktx
ksp libs.androidx.room.compiler

implementation platform(libs.okhttp.bom)
implementation libs.okhttp
implementation libs.okhttp.tls
implementation libs.okhttp.dnsoverhttps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package io.github.landwarderer.futon.core.util.ext

import android.os.Looper
import android.util.Log

fun Throwable.printStackTraceDebug() = printStackTrace()

fun Throwable.printStackTraceDebug(tag: String) = Log.e(tag, this.stackTraceToString())

fun Throwable.printStackTraceDebug(tag: String, source: String) = Log.e(tag, "source: $source", this)

fun assertNotInMainThread() = check(Looper.myLooper() != Looper.getMainLooper()) {
"Calling this from the main thread is prohibited"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.core.content.ContextCompat
import coil3.ImageLoader
import coil3.request.ImageRequest
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.runBlocking
import io.github.landwarderer.futon.R
import io.github.landwarderer.futon.alternatives.domain.AutoFixUseCase
import io.github.landwarderer.futon.alternatives.domain.AutoFixUseCase.NoAlternativesException
Expand All @@ -32,6 +31,7 @@ import io.github.landwarderer.futon.core.util.ext.toBitmapOrNull
import io.github.landwarderer.futon.core.util.ext.withPartialWakeLock
import io.github.landwarderer.futon.parsers.model.Manga
import io.github.landwarderer.futon.parsers.util.runCatchingCancellable
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
import androidx.appcompat.R as appcompatR

Expand Down Expand Up @@ -196,7 +196,7 @@ class AutoFixService : CoroutineIntentService() {
ContextCompat.startForegroundService(context, intent)
true
} catch (e: Exception) {
e.printStackTraceDebug()
e.printStackTraceDebug("AutoFixService::start")
false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object BackupUtils {
fun parseBackupDateTime(fileName: String): Date? = try {
dateTimeFormat.parse(fileName.substringAfterLast('_').substringBefore('.'))
} catch (e: ParseException) {
e.printStackTraceDebug()
e.printStackTraceDebug("BackupUtils::parseBackupDateTime")
null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import android.net.Uri
import androidx.annotation.CheckResult
import androidx.documentfile.provider.DocumentFile
import dagger.hilt.android.qualifiers.ApplicationContext
import io.github.landwarderer.futon.core.prefs.AppSettings
import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.parsers.util.runCatchingCancellable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runInterruptible
import okio.buffer
import okio.sink
import okio.source
import org.jetbrains.annotations.Blocking
import io.github.landwarderer.futon.core.prefs.AppSettings
import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.parsers.util.runCatchingCancellable
import java.io.File
import javax.inject.Inject

Expand All @@ -40,7 +40,7 @@ class ExternalBackupStorage @Inject constructor(
suspend fun listOrNull() = runCatchingCancellable {
list()
}.onFailure { e ->
e.printStackTraceDebug()
e.printStackTraceDebug("ExternalBackupStorage::listOrNull")
}.getOrNull()

suspend fun put(file: File): Uri = runInterruptible(Dispatchers.IO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.documentfile.provider.DocumentFile
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import io.github.landwarderer.futon.R
import io.github.landwarderer.futon.backups.data.BackupRepository
import io.github.landwarderer.futon.backups.ui.BaseBackupRestoreService
Expand All @@ -28,6 +23,11 @@ import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.core.util.ext.toUriOrNull
import io.github.landwarderer.futon.core.util.ext.withPartialWakeLock
import io.github.landwarderer.futon.core.util.progress.Progress
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.FileNotFoundException
import java.util.zip.ZipOutputStream
import javax.inject.Inject
Expand Down Expand Up @@ -124,7 +124,7 @@ class BackupService : BaseBackupRestoreService() {
ContextCompat.startForegroundService(context, intent)
true
} catch (e: Exception) {
e.printStackTraceDebug()
e.printStackTraceDebug("BackupService::start")
false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import androidx.annotation.CheckResult
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import io.github.landwarderer.futon.R
import io.github.landwarderer.futon.backups.data.BackupRepository
import io.github.landwarderer.futon.backups.domain.BackupSection
Expand All @@ -25,6 +22,9 @@ import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.core.util.ext.toUriOrNull
import io.github.landwarderer.futon.core.util.ext.withPartialWakeLock
import io.github.landwarderer.futon.core.util.progress.Progress
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import java.io.FileNotFoundException
import java.util.zip.ZipInputStream
import javax.inject.Inject
Expand Down Expand Up @@ -111,7 +111,7 @@ class RestoreService : BaseBackupRestoreService() {
ContextCompat.startForegroundService(context, intent)
true
} catch (e: Exception) {
e.printStackTraceDebug()
e.printStackTraceDebug("RestoreService::start")
false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import android.content.Context
import androidx.lifecycle.SavedStateHandle
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.runInterruptible
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream
import io.github.landwarderer.futon.backups.data.model.BackupIndex
import io.github.landwarderer.futon.backups.domain.BackupSection
import io.github.landwarderer.futon.core.nav.AppRouter
import io.github.landwarderer.futon.core.ui.BaseViewModel
import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.core.util.ext.toUriOrNull
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.runInterruptible
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream
import java.io.FileNotFoundException
import java.io.InputStream
import java.util.Date
Expand Down Expand Up @@ -107,6 +107,6 @@ class RestoreViewModel @Inject constructor(
val index = Json.decodeFromStream<List<BackupIndex>>(this)
Date(index.single().createdAt)
}.onFailure { e ->
e.printStackTraceDebug()
e.printStackTraceDebug("RestoreViewModel::InputStream")
}.getOrNull()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package io.github.landwarderer.futon.bookmarks.domain
import android.database.SQLException
import androidx.room.withTransaction
import dagger.Reusable
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import io.github.landwarderer.futon.bookmarks.data.BookmarkEntity
import io.github.landwarderer.futon.bookmarks.data.toBookmark
import io.github.landwarderer.futon.bookmarks.data.toBookmarks
Expand All @@ -17,6 +15,8 @@ import io.github.landwarderer.futon.core.ui.util.ReversibleHandle
import io.github.landwarderer.futon.core.util.ext.mapItems
import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.parsers.model.Manga
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject

@Reusable
Expand Down Expand Up @@ -94,7 +94,7 @@ class BookmarksRepository @Inject constructor(
try {
db.getBookmarksDao().insert(e)
} catch (e: SQLException) {
e.printStackTraceDebug()
e.printStackTraceDebug("BookmarksRepository::reverse")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.activity.result.contract.ActivityResultContract
import androidx.lifecycle.lifecycleScope
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import io.github.landwarderer.futon.R
import io.github.landwarderer.futon.core.exceptions.InteractiveActionRequiredException
import io.github.landwarderer.futon.core.nav.AppRouter
Expand All @@ -18,6 +17,7 @@ import io.github.landwarderer.futon.core.parser.ParserMangaRepository
import io.github.landwarderer.futon.core.util.ext.getDisplayMessage
import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.parsers.model.MangaSource
import kotlinx.coroutines.launch

@AndroidEntryPoint
class BrowserActivity : BaseBrowserActivity() {
Expand All @@ -29,7 +29,7 @@ class BrowserActivity : BaseBrowserActivity() {
try {
proxyProvider.applyWebViewConfig()
} catch (e: Exception) {
e.printStackTraceDebug()
e.printStackTraceDebug("BrowserActivity::onCreate2")
Snackbar.make(viewBinding.webView, e.getDisplayMessage(resources), Snackbar.LENGTH_LONG).show()
}
if (savedInstanceState == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import androidx.core.view.isInvisible
import androidx.lifecycle.lifecycleScope
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runInterruptible
import kotlinx.coroutines.yield
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import io.github.landwarderer.futon.R
import io.github.landwarderer.futon.browser.BaseBrowserActivity
import io.github.landwarderer.futon.core.exceptions.CloudFlareProtectedException
Expand All @@ -30,6 +24,12 @@ import io.github.landwarderer.futon.parsers.model.MangaSource
import io.github.landwarderer.futon.parsers.network.CloudFlareHelper
import io.github.landwarderer.futon.parsers.util.ifNullOrEmpty
import io.github.landwarderer.futon.parsers.util.runCatchingCancellable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runInterruptible
import kotlinx.coroutines.yield
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import javax.inject.Inject

@AndroidEntryPoint
Expand Down Expand Up @@ -110,7 +110,7 @@ class CloudFlareActivity : BaseBrowserActivity(), CloudFlareCallback {
runCatchingCancellable {
captchaHandler.discard(MangaSource(source))
}.onFailure {
it.printStackTraceDebug()
it.printStackTraceDebug("CloudFlareActivity::onCheckPassed")
}
}
finishAfterTransition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ErrorReporterReceiver : BroadcastReceiver() {
PendingIntentCompat.getBroadcast(context, 0, intent, 0, false)
}.onFailure { e ->
// probably cannot write exception as serializable
e.printStackTraceDebug()
e.printStackTraceDebug("ErrorReporterReceiver::getPendingIntentInternal")
}.getOrNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ import coil3.request.allowHardware
import coil3.request.lifecycle
import coil3.size.Scale
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import io.github.landwarderer.futon.R
import io.github.landwarderer.futon.core.LocalizedAppContext
import io.github.landwarderer.futon.core.db.MangaDatabase
Expand All @@ -58,6 +50,14 @@ import io.github.landwarderer.futon.parsers.model.MangaSource
import io.github.landwarderer.futon.parsers.network.CloudFlareHelper
import io.github.landwarderer.futon.parsers.util.mapToArray
import io.github.landwarderer.futon.parsers.util.runCatchingCancellable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import javax.inject.Inject
import javax.inject.Provider
import javax.inject.Singleton
Expand Down Expand Up @@ -256,7 +256,7 @@ class CaptchaHandler @Inject constructor(
.build(),
).toBitmapOrNull()
}.onFailure {
it.printStackTraceDebug()
it.printStackTraceDebug("CaptchaHandler::getFavicon")
}.getOrNull()

@AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package io.github.landwarderer.futon.core.github

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
import org.json.JSONObject
import io.github.landwarderer.futon.BuildConfig
import io.github.landwarderer.futon.R
import io.github.landwarderer.futon.core.network.BaseHttpClient
import io.github.landwarderer.futon.core.prefs.AppSettings
import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.parsers.util.await
import io.github.landwarderer.futon.parsers.util.runCatchingCancellable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
import org.json.JSONObject
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -72,7 +72,7 @@ class AppUpdateRepository @Inject constructor(
description = json.getString("body"),
)
}.onFailure {
it.printStackTraceDebug()
it.printStackTraceDebug("AppUpdateRepository::fetchUpdate")
}.onSuccess {
availableUpdate.value = it
}.getOrNull()
Expand All @@ -86,7 +86,7 @@ class AppUpdateRepository @Inject constructor(
.build()
okHttp.newCall(request).await().body?.string()
}.onFailure {
it.printStackTraceDebug()
it.printStackTraceDebug("AppUpdateRepository::fetchChangelog")
}.getOrNull()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.graphics.createBitmap
import com.davemorrissey.labs.subscaleview.decoder.ImageDecodeException
import okio.IOException
import okio.buffer
import okio.source
import org.aomedia.avif.android.AvifDecoder
import org.aomedia.avif.android.AvifDecoder.Info
import org.jetbrains.annotations.Blocking
import io.github.landwarderer.futon.core.util.MimeTypes
import io.github.landwarderer.futon.core.util.ext.MimeType
import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug
import io.github.landwarderer.futon.core.util.ext.readByteBuffer
import io.github.landwarderer.futon.core.util.ext.toByteBuffer
import io.github.landwarderer.futon.core.util.ext.toMimeTypeOrNull
import io.github.landwarderer.futon.parsers.util.runCatchingCancellable
import okio.IOException
import okio.buffer
import okio.source
import org.aomedia.avif.android.AvifDecoder
import org.aomedia.avif.android.AvifDecoder.Info
import org.jetbrains.annotations.Blocking
import java.io.File
import java.io.InputStream
import java.nio.ByteBuffer
Expand Down Expand Up @@ -67,7 +67,7 @@ object BitmapDecoderCompat {
BitmapRegionDecoder.newInstance(inoutStream, false)
}
} catch (e: IOException) {
e.printStackTraceDebug()
e.printStackTraceDebug("DecoderConfigListener::createRegionDecoder")
null
}

Expand Down
Loading
Loading