mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
Replace Timber with Square Logcat and make logging configurable (#6062)
* Replace Timber with Square Logcat * Configurable logger
This commit is contained in:
@@ -10,10 +10,10 @@ import androidx.viewbinding.ViewBinding
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.ControllerChangeType
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import timber.log.Timber
|
||||
|
||||
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) : Controller(bundle) {
|
||||
|
||||
@@ -31,20 +31,20 @@ abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) : Contro
|
||||
|
||||
override fun preCreateView(controller: Controller) {
|
||||
viewScope = MainScope()
|
||||
Timber.d("Create view for ${controller.instance()}")
|
||||
logcat { "Create view for ${controller.instance()}" }
|
||||
}
|
||||
|
||||
override fun preAttach(controller: Controller, view: View) {
|
||||
Timber.d("Attach view for ${controller.instance()}")
|
||||
logcat { "Attach view for ${controller.instance()}" }
|
||||
}
|
||||
|
||||
override fun preDetach(controller: Controller, view: View) {
|
||||
Timber.d("Detach view for ${controller.instance()}")
|
||||
logcat { "Detach view for ${controller.instance()}" }
|
||||
}
|
||||
|
||||
override fun preDestroyView(controller: Controller, view: View) {
|
||||
viewScope.cancel()
|
||||
Timber.d("Destroy view for ${controller.instance()}")
|
||||
logcat { "Destroy view for ${controller.instance()}" }
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -27,8 +27,9 @@ import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.getPreferenceKey
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.widget.TachiyomiTextInputEditText.Companion.setIncognito
|
||||
import timber.log.Timber
|
||||
import logcat.LogPriority
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
class SourcePreferencesController(bundle: Bundle? = null) :
|
||||
@@ -77,7 +78,7 @@ class SourcePreferencesController(bundle: Bundle? = null) :
|
||||
try {
|
||||
addPreferencesForSource(screen, source)
|
||||
} catch (e: AbstractMethodError) {
|
||||
Timber.e("Source did not implement [addPreferencesForSource]: ${source.name}")
|
||||
logcat(LogPriority.ERROR) { "Source did not implement [addPreferencesForSource]: ${source.name}" }
|
||||
}
|
||||
|
||||
manager.setPreferences(screen)
|
||||
|
||||
@@ -42,6 +42,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.more.MoreController
|
||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.system.connectivityManager
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.inflate
|
||||
@@ -54,7 +55,7 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import timber.log.Timber
|
||||
import logcat.LogPriority
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
@@ -405,7 +406,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
* @param error the error received.
|
||||
*/
|
||||
fun onAddPageError(error: Throwable) {
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
val adapter = adapter ?: return
|
||||
adapter.onLoadMoreComplete(null)
|
||||
hideProgressBar()
|
||||
|
||||
@@ -37,6 +37,7 @@ import eu.kanade.tachiyomi.util.chapter.syncChaptersWithTrackServiceTwoWay
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -44,10 +45,10 @@ import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import logcat.LogPriority
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Date
|
||||
@@ -155,7 +156,7 @@ open class BrowseSourcePresenter(
|
||||
view.onAddPage(page, mangas)
|
||||
},
|
||||
{ _, error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -221,7 +222,7 @@ open class BrowseSourcePresenter(
|
||||
view?.onMangaInitialized(it)
|
||||
}
|
||||
}
|
||||
.catch { e -> Timber.e(e) }
|
||||
.catch { e -> logcat(LogPriority.ERROR, e) }
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@@ -239,7 +240,7 @@ open class BrowseSourcePresenter(
|
||||
manga.initialized = true
|
||||
db.insertManga(manga).executeAsBlocking()
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
return manga
|
||||
}
|
||||
@@ -282,7 +283,7 @@ open class BrowseSourcePresenter(
|
||||
syncChaptersWithTrackServiceTwoWay(db, db.getChapters(manga).executeAsBlocking(), track, service as TrackService)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e, "Could not match manga: ${manga.title} with service $service")
|
||||
logcat(LogPriority.WARN, e) { "Could not match manga: ${manga.title} with service $service" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@ import eu.kanade.tachiyomi.source.model.toSManga
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter
|
||||
import eu.kanade.tachiyomi.util.lang.runAsObservable
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import logcat.LogPriority
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import rx.subjects.PublishSubject
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@@ -198,7 +199,7 @@ open class GlobalSearchPresenter(
|
||||
view.setItems(manga)
|
||||
},
|
||||
{ _, error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -233,7 +234,7 @@ open class GlobalSearchPresenter(
|
||||
view?.onMangaInitialized(source, manga)
|
||||
},
|
||||
{ error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,10 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import logcat.LogPriority
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,7 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map { it.map(::DownloadItem) }
|
||||
.subscribeLatestCache(DownloadController::onNextDownloads) { _, error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +61,14 @@ import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.isTablet
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.setNavigationBarTransparentCompat
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import timber.log.Timber
|
||||
import logcat.LogPriority
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -340,7 +341,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
NewUpdateDialogController(result).showDialog(router)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -356,7 +357,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
val pendingUpdates = ExtensionGithubApi().checkForUpdates(this@MainActivity)
|
||||
preferences.extensionUpdatesCount().set(pendingUpdates.size)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ import eu.kanade.tachiyomi.util.hasCustomCover
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toShareIntent
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.getCoordinates
|
||||
@@ -95,9 +96,9 @@ import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.widget.materialdialogs.QuadStateTextView
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import logcat.LogPriority
|
||||
import reactivecircus.flowbinding.recyclerview.scrollStateChanges
|
||||
import reactivecircus.flowbinding.swiperefreshlayout.refreshes
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@@ -595,7 +596,9 @@ class MangaController :
|
||||
presenter.registerTracking(track, service as TrackService)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e, "Could not match manga: ${manga.title} with service $service")
|
||||
logcat(LogPriority.WARN, e) {
|
||||
"Could not match manga: ${manga.title} with service $service"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -767,7 +770,7 @@ class MangaController :
|
||||
startActivity(uri.toShareIntent(activity))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
logcat(LogPriority.ERROR, e)
|
||||
activity?.toast(R.string.error_sharing_cover)
|
||||
}
|
||||
}
|
||||
@@ -780,7 +783,7 @@ class MangaController :
|
||||
activity.toast(R.string.cover_saved)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
logcat(LogPriority.ERROR, e)
|
||||
activity?.toast(R.string.error_saving_cover)
|
||||
}
|
||||
}
|
||||
@@ -836,7 +839,7 @@ class MangaController :
|
||||
|
||||
fun onSetCoverError(error: Throwable) {
|
||||
activity?.toast(R.string.notification_cover_update_failed)
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1177,7 +1180,7 @@ class MangaController :
|
||||
}
|
||||
|
||||
fun onChaptersDeletedError(error: Throwable) {
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
|
||||
override fun startDownloadNow(position: Int) {
|
||||
@@ -1231,7 +1234,7 @@ class MangaController :
|
||||
}
|
||||
|
||||
fun onTrackingRefreshError(error: Throwable) {
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
activity?.toast(error.message)
|
||||
}
|
||||
|
||||
@@ -1240,7 +1243,7 @@ class MangaController :
|
||||
}
|
||||
|
||||
fun onTrackingSearchResultsError(error: Throwable) {
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
getTrackingSearchDialog()?.onSearchResultsError(error.message)
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.storage.getPicturesDir
|
||||
import eu.kanade.tachiyomi.util.storage.getTempShareDir
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.updateCoverLastModified
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
||||
@@ -50,11 +51,11 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import logcat.LogPriority
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
@@ -128,7 +129,9 @@ class MangaPresenter(
|
||||
|
||||
getTrackingObservable()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeLatestCache(MangaController::onTrackingCount) { _, error -> Timber.e(error) }
|
||||
.subscribeLatestCache(MangaController::onTrackingCount) { _, error ->
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
|
||||
// Prepare the relay.
|
||||
chaptersRelay.flatMap { applyChapterFilters(it) }
|
||||
@@ -138,7 +141,7 @@ class MangaPresenter(
|
||||
filteredAndSortedChapters = chapters
|
||||
view?.onNextChapters(chapters)
|
||||
},
|
||||
{ _, error -> Timber.e(error) }
|
||||
{ _, error -> logcat(LogPriority.ERROR, error) }
|
||||
)
|
||||
|
||||
// Manga info - end
|
||||
@@ -428,7 +431,7 @@ class MangaPresenter(
|
||||
view.onChapterDownloadUpdate(it)
|
||||
},
|
||||
{ _, error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -439,7 +442,7 @@ class MangaPresenter(
|
||||
.filter { download -> download.manga.id == manga.id }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@ import eu.kanade.tachiyomi.util.preference.onClick
|
||||
import eu.kanade.tachiyomi.util.preference.preference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import timber.log.Timber
|
||||
import logcat.LogPriority
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
@@ -112,7 +113,7 @@ class AboutController : SettingsController(), NoAppBarElevationController {
|
||||
}
|
||||
} catch (error: Exception) {
|
||||
activity?.toast(error.message)
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import eu.kanade.tachiyomi.util.system.createReaderThemeContext
|
||||
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
||||
import eu.kanade.tachiyomi.util.system.isNightMode
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.popupMenu
|
||||
import eu.kanade.tachiyomi.util.view.setTooltip
|
||||
@@ -79,8 +80,8 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.merge
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import logcat.LogPriority
|
||||
import nucleus.factory.RequiresPresenter
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import kotlin.math.abs
|
||||
@@ -620,7 +621,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
readingModeToast?.cancel()
|
||||
readingModeToast = toast(strings[mode])
|
||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
||||
Timber.e("Unknown reading mode: $mode")
|
||||
logcat(LogPriority.ERROR) { "Unknown reading mode: $mode" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +661,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
* this case the activity is closed and a toast is shown to the user.
|
||||
*/
|
||||
fun setInitialChapterError(error: Throwable) {
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
finish()
|
||||
toast(error.message)
|
||||
}
|
||||
@@ -822,7 +823,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
toast(R.string.picture_saved)
|
||||
}
|
||||
is ReaderPresenter.SaveImageResult.Error -> {
|
||||
Timber.e(result.error)
|
||||
logcat(LogPriority.ERROR, result.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,14 +34,15 @@ import eu.kanade.tachiyomi.util.storage.getPicturesDir
|
||||
import eu.kanade.tachiyomi.util.storage.getTempShareDir
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.system.isOnline
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.updateCoverLastModified
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import logcat.LogPriority
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
@@ -301,7 +302,7 @@ class ReaderPresenter(
|
||||
private fun loadNewChapter(chapter: ReaderChapter) {
|
||||
val loader = loader ?: return
|
||||
|
||||
Timber.d("Loading ${chapter.chapter.url}")
|
||||
logcat { "Loading ${chapter.chapter.url}" }
|
||||
|
||||
activeChapterSubscription?.unsubscribe()
|
||||
activeChapterSubscription = getLoadObservable(loader, chapter)
|
||||
@@ -319,7 +320,7 @@ class ReaderPresenter(
|
||||
private fun loadAdjacent(chapter: ReaderChapter) {
|
||||
val loader = loader ?: return
|
||||
|
||||
Timber.d("Loading adjacent ${chapter.chapter.url}")
|
||||
logcat { "Loading adjacent ${chapter.chapter.url}" }
|
||||
|
||||
activeChapterSubscription?.unsubscribe()
|
||||
activeChapterSubscription = getLoadObservable(loader, chapter)
|
||||
@@ -344,7 +345,7 @@ class ReaderPresenter(
|
||||
return
|
||||
}
|
||||
|
||||
Timber.d("Preloading ${chapter.chapter.url}")
|
||||
logcat { "Preloading ${chapter.chapter.url}" }
|
||||
|
||||
val loader = loader ?: return
|
||||
|
||||
@@ -383,7 +384,7 @@ class ReaderPresenter(
|
||||
}
|
||||
|
||||
if (selectedChapter != currentChapters.currChapter) {
|
||||
Timber.d("Setting ${selectedChapter.chapter.url} as active")
|
||||
logcat { "Setting ${selectedChapter.chapter.url} as active" }
|
||||
onChapterChanged(currentChapters.currChapter)
|
||||
loadNewChapter(selectedChapter)
|
||||
}
|
||||
@@ -549,7 +550,7 @@ class ReaderPresenter(
|
||||
manga.orientationType = rotationType
|
||||
db.updateViewerFlags(manga).executeAsBlocking()
|
||||
|
||||
Timber.i("Manga orientation is ${manga.orientationType}")
|
||||
logcat(LogPriority.INFO) { "Manga orientation is ${manga.orientationType}" }
|
||||
|
||||
Observable.timer(250, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
||||
.subscribeFirst({ view, _ ->
|
||||
@@ -734,7 +735,7 @@ class ReaderPresenter(
|
||||
}
|
||||
.awaitAll()
|
||||
.mapNotNull { it.exceptionOrNull() }
|
||||
.forEach { Timber.w(it) }
|
||||
.forEach { logcat(LogPriority.INFO, it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import rx.Completable
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Loader used to retrieve the [PageLoader] for a given chapter.
|
||||
@@ -37,7 +37,7 @@ class ChapterLoader(
|
||||
.doOnNext { chapter.state = ReaderChapter.State.Loading }
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMap { readerChapter ->
|
||||
Timber.d("Loading pages for ${chapter.chapter.name}")
|
||||
logcat { "Loading pages for ${chapter.chapter.name}" }
|
||||
|
||||
val loader = getPageLoader(readerChapter)
|
||||
chapter.pageLoader = loader
|
||||
|
||||
@@ -6,13 +6,14 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import logcat.LogPriority
|
||||
import rx.Completable
|
||||
import rx.Observable
|
||||
import rx.schedulers.Schedulers
|
||||
import rx.subjects.PublishSubject
|
||||
import rx.subjects.SerializedSubject
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.concurrent.PriorityBlockingQueue
|
||||
@@ -51,7 +52,7 @@ class HttpPageLoader(
|
||||
},
|
||||
{ error ->
|
||||
if (error !is InterruptedException) {
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.ui.reader.model
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.ui.reader.loader.PageLoader
|
||||
import timber.log.Timber
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
|
||||
data class ReaderChapter(val chapter: Chapter) {
|
||||
|
||||
@@ -36,7 +36,7 @@ data class ReaderChapter(val chapter: Chapter) {
|
||||
references--
|
||||
if (references == 0) {
|
||||
if (pageLoader != null) {
|
||||
Timber.d("Recycling chapter ${chapter.name}")
|
||||
logcat { "Recycling chapter ${chapter.name}" }
|
||||
}
|
||||
pageLoader?.recycle()
|
||||
pageLoader = null
|
||||
|
||||
@@ -17,9 +17,9 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation.NavigationRegion
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import timber.log.Timber
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
@@ -194,7 +194,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
*/
|
||||
private fun onReaderPageSelected(page: ReaderPage, allowPreload: Boolean) {
|
||||
val pages = page.chapter.pages ?: return
|
||||
Timber.d("onReaderPageSelected: ${page.number}/${pages.size}")
|
||||
logcat { "onReaderPageSelected: ${page.number}/${pages.size}" }
|
||||
activity.onPageSelected(page)
|
||||
|
||||
// Skip preload on inserts it causes unwanted page jumping
|
||||
@@ -205,7 +205,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
// Preload next chapter once we're within the last 5 pages of the current chapter
|
||||
val inPreloadRange = pages.size - page.number < 5
|
||||
if (inPreloadRange && allowPreload && page.chapter == adapter.currentChapter) {
|
||||
Timber.d("Request preload next chapter because we're at page ${page.number} of ${pages.size}")
|
||||
logcat { "Request preload next chapter because we're at page ${page.number} of ${pages.size}" }
|
||||
adapter.nextTransition?.to?.let {
|
||||
activity.requestPreloadChapter(it)
|
||||
}
|
||||
@@ -217,10 +217,10 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
* preload of the destination chapter of the transition.
|
||||
*/
|
||||
private fun onTransitionSelected(transition: ChapterTransition) {
|
||||
Timber.d("onTransitionSelected: $transition")
|
||||
logcat { "onTransitionSelected: $transition" }
|
||||
val toChapter = transition.to
|
||||
if (toChapter != null) {
|
||||
Timber.d("Request preload destination chapter because we're on the transition")
|
||||
logcat { "Request preload destination chapter because we're on the transition" }
|
||||
activity.requestPreloadChapter(toChapter)
|
||||
} else if (transition is ChapterTransition.Next) {
|
||||
// No more chapters, show menu because the user is probably going to close the reader
|
||||
@@ -244,13 +244,13 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
* Sets the active [chapters] on this pager.
|
||||
*/
|
||||
private fun setChaptersInternal(chapters: ViewerChapters) {
|
||||
Timber.d("setChaptersInternal")
|
||||
logcat { "setChaptersInternal" }
|
||||
val forceTransition = config.alwaysShowChapterTransition || adapter.items.getOrNull(pager.currentItem) is ChapterTransition
|
||||
adapter.setChapters(chapters, forceTransition)
|
||||
|
||||
// Layout the pager once a chapter is being set
|
||||
if (pager.isGone) {
|
||||
Timber.d("Pager first layout")
|
||||
logcat { "Pager first layout" }
|
||||
val pages = chapters.currChapter.pages ?: return
|
||||
moveToPage(pages[min(chapters.currChapter.requestedPage, pages.lastIndex)])
|
||||
pager.isVisible = true
|
||||
@@ -261,7 +261,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
* Tells this viewer to move to the given [page].
|
||||
*/
|
||||
override fun moveToPage(page: ReaderPage) {
|
||||
Timber.d("moveToPage ${page.number}")
|
||||
logcat { "moveToPage ${page.number}" }
|
||||
val position = adapter.items.indexOf(page)
|
||||
if (position != -1) {
|
||||
val currentPosition = pager.currentItem
|
||||
@@ -271,7 +271,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
onPageChange(position)
|
||||
}
|
||||
} else {
|
||||
Timber.d("Page $page not found in adapter")
|
||||
logcat { "Page $page not found in adapter" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.hasMissingChapters
|
||||
import eu.kanade.tachiyomi.util.system.createReaderThemeContext
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Pager adapter used by this [viewer] to where [ViewerChapters] updates are posted.
|
||||
@@ -152,7 +152,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
||||
if (position != -1) {
|
||||
return position
|
||||
} else {
|
||||
Timber.d("Position for ${view.item} not found")
|
||||
logcat { "Position for ${view.item} not found" }
|
||||
}
|
||||
}
|
||||
return POSITION_NONE
|
||||
|
||||
@@ -18,10 +18,10 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation.NavigationRegion
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import kotlin.math.max
|
||||
@@ -195,17 +195,17 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
*/
|
||||
private fun onPageSelected(page: ReaderPage, allowPreload: Boolean) {
|
||||
val pages = page.chapter.pages ?: return
|
||||
Timber.d("onPageSelected: ${page.number}/${pages.size}")
|
||||
logcat { "onPageSelected: ${page.number}/${pages.size}" }
|
||||
activity.onPageSelected(page)
|
||||
|
||||
// Preload next chapter once we're within the last 5 pages of the current chapter
|
||||
val inPreloadRange = pages.size - page.number < 5
|
||||
if (inPreloadRange && allowPreload && page.chapter == adapter.currentChapter) {
|
||||
Timber.d("Request preload next chapter because we're at page ${page.number} of ${pages.size}")
|
||||
logcat { "Request preload next chapter because we're at page ${page.number} of ${pages.size}" }
|
||||
val nextItem = adapter.items.getOrNull(adapter.items.size - 1)
|
||||
val transitionChapter = (nextItem as? ChapterTransition.Next)?.to ?: (nextItem as?ReaderPage)?.chapter
|
||||
if (transitionChapter != null) {
|
||||
Timber.d("Requesting to preload chapter ${transitionChapter.chapter.chapter_number}")
|
||||
logcat { "Requesting to preload chapter ${transitionChapter.chapter.chapter_number}" }
|
||||
activity.requestPreloadChapter(transitionChapter)
|
||||
}
|
||||
}
|
||||
@@ -216,10 +216,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
* preload of the destination chapter of the transition.
|
||||
*/
|
||||
private fun onTransitionSelected(transition: ChapterTransition) {
|
||||
Timber.d("onTransitionSelected: $transition")
|
||||
logcat { "onTransitionSelected: $transition" }
|
||||
val toChapter = transition.to
|
||||
if (toChapter != null) {
|
||||
Timber.d("Request preload destination chapter because we're on the transition")
|
||||
logcat { "Request preload destination chapter because we're on the transition" }
|
||||
activity.requestPreloadChapter(toChapter)
|
||||
} else if (transition is ChapterTransition.Next) {
|
||||
// No more chapters, show menu because the user is probably going to close the reader
|
||||
@@ -231,12 +231,12 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
* Tells this viewer to set the given [chapters] as active.
|
||||
*/
|
||||
override fun setChapters(chapters: ViewerChapters) {
|
||||
Timber.d("setChapters")
|
||||
logcat { "setChapters" }
|
||||
val forceTransition = config.alwaysShowChapterTransition || currentPage is ChapterTransition
|
||||
adapter.setChapters(chapters, forceTransition)
|
||||
|
||||
if (recycler.isGone) {
|
||||
Timber.d("Recycler first layout")
|
||||
logcat { "Recycler first layout" }
|
||||
val pages = chapters.currChapter.pages ?: return
|
||||
moveToPage(pages[min(chapters.currChapter.requestedPage, pages.lastIndex)])
|
||||
recycler.isVisible = true
|
||||
@@ -247,7 +247,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
* Tells this viewer to move to the given [page].
|
||||
*/
|
||||
override fun moveToPage(page: ReaderPage) {
|
||||
Timber.d("moveToPage")
|
||||
logcat { "moveToPage" }
|
||||
val position = adapter.items.indexOf(page)
|
||||
if (position != -1) {
|
||||
recycler.scrollToPosition(position)
|
||||
@@ -255,7 +255,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
onScrolled(pos = position)
|
||||
}
|
||||
} else {
|
||||
Timber.d("Page $page not found in adapter")
|
||||
logcat { "Page $page not found in adapter" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,14 @@ import eu.kanade.tachiyomi.ui.browse.source.browse.ProgressItem
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.onAnimationsFinished
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import logcat.LogPriority
|
||||
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
@@ -123,7 +124,7 @@ class HistoryController :
|
||||
fun onAddPageError(error: Throwable) {
|
||||
adapter?.onLoadMoreComplete(null)
|
||||
adapter?.endlessTargetCount = 1
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
|
||||
override fun onUpdateEmptyView(size: Int) {
|
||||
|
||||
@@ -25,14 +25,15 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.manga.chapter.base.BaseChaptersAdapter
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.onAnimationsFinished
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import logcat.LogPriority
|
||||
import reactivecircus.flowbinding.recyclerview.scrollStateChanges
|
||||
import reactivecircus.flowbinding.swiperefreshlayout.refreshes
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Fragment that shows recent chapters.
|
||||
@@ -300,7 +301,7 @@ class UpdatesController :
|
||||
* @param error error message
|
||||
*/
|
||||
fun onChaptersDeletedError(error: Throwable) {
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
|
||||
override fun downloadChapter(position: Int) {
|
||||
|
||||
@@ -11,10 +11,11 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.recent.DateSectionItem
|
||||
import eu.kanade.tachiyomi.util.lang.toDateKey
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import logcat.LogPriority
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.DateFormat
|
||||
import java.util.Calendar
|
||||
@@ -53,7 +54,7 @@ class UpdatesPresenter : BasePresenter<UpdatesController>() {
|
||||
view.onChapterDownloadUpdate(it)
|
||||
},
|
||||
{ _, error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -62,7 +63,7 @@ class UpdatesPresenter : BasePresenter<UpdatesController>() {
|
||||
.onBackpressureBuffer()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeLatestCache(UpdatesController::onChapterDownloadUpdate) { _, error ->
|
||||
Timber.e(error)
|
||||
logcat(LogPriority.ERROR, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseThemedActivity
|
||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.startAuthentication
|
||||
import timber.log.Timber
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import logcat.LogPriority
|
||||
import java.util.Date
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,7 @@ class UnlockActivity : BaseThemedActivity() {
|
||||
errString: CharSequence
|
||||
) {
|
||||
super.onAuthenticationError(activity, errorCode, errString)
|
||||
Timber.e(errString.toString())
|
||||
logcat(LogPriority.ERROR) { errString.toString() }
|
||||
finishAffinity()
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,18 @@ class SettingsAdvancedController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.verboseLogging
|
||||
titleRes = R.string.pref_verbose_logging
|
||||
summaryRes = R.string.pref_verbose_logging_summary
|
||||
defaultValue = false
|
||||
|
||||
onChange {
|
||||
activity?.toast(R.string.requires_app_restart)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.label_background_activity
|
||||
|
||||
|
||||
Reference in New Issue
Block a user