Bump dependencies + linting

This commit is contained in:
arkon
2022-09-10 23:57:03 -04:00
parent 5b474e96b7
commit cd3cb72b65
33 changed files with 195 additions and 104 deletions

View File

@@ -111,8 +111,11 @@ object Migrations {
// Migrate library filters to tri-state versions
fun convertBooleanPrefToTriState(key: String): Int {
val oldPrefValue = prefs.getBoolean(key, false)
return if (oldPrefValue) ExtendedNavigationView.Item.TriStateGroup.State.INCLUDE.value
else ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value
return if (oldPrefValue) {
ExtendedNavigationView.Item.TriStateGroup.State.INCLUDE.value
} else {
ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value
}
}
prefs.edit {
putInt(PreferenceKeys.filterDownloaded, convertBooleanPrefToTriState("pref_filter_downloaded_key"))

View File

@@ -44,8 +44,11 @@ class BackupFileValidator(
.filter { sourceManager.get(it.key) == null }
.values.map {
val id = it.toLongOrNull()
if (id == null) it
else sourceManager.getOrStub(id).toString()
if (id == null) {
it
} else {
sourceManager.getOrStub(id).toString()
}
}
.distinct()
.sorted()

View File

@@ -11,7 +11,8 @@ data class BackupTracking(
@ProtoNumber(1) var syncId: Int,
// LibraryId is not null in 1.x
@ProtoNumber(2) var libraryId: Long,
@Deprecated("Use mediaId instead", level = DeprecationLevel.WARNING) @ProtoNumber(3)
@Deprecated("Use mediaId instead", level = DeprecationLevel.WARNING)
@ProtoNumber(3)
var mediaIdInt: Int = 0,
// trackingUrl is called mediaUrl in 1.x
@ProtoNumber(4) var trackingUrl: String = "",

View File

@@ -30,29 +30,37 @@ class BangumiInterceptor(val bangumi: Bangumi) : Interceptor {
}
}
val authRequest = if (originalRequest.method == "GET") originalRequest.newBuilder()
.header("User-Agent", "Tachiyomi")
.url(
originalRequest.url.newBuilder()
.addQueryParameter("access_token", currAuth.access_token).build(),
)
.build() else originalRequest.newBuilder()
.post(addToken(currAuth.access_token, originalRequest.body as FormBody))
.header("User-Agent", "Tachiyomi")
.build()
val authRequest = if (originalRequest.method == "GET") {
originalRequest.newBuilder()
.header("User-Agent", "Tachiyomi")
.url(
originalRequest.url.newBuilder()
.addQueryParameter("access_token", currAuth.access_token).build(),
)
.build()
} else {
originalRequest.newBuilder()
.post(addToken(currAuth.access_token, originalRequest.body as FormBody))
.header("User-Agent", "Tachiyomi")
.build()
}
return chain.proceed(authRequest)
}
fun newAuth(oauth: OAuth?) {
this.oauth = if (oauth == null) null else OAuth(
oauth.access_token,
oauth.token_type,
System.currentTimeMillis() / 1000,
oauth.expires_in,
oauth.refresh_token,
this.oauth?.user_id,
)
this.oauth = if (oauth == null) {
null
} else {
OAuth(
oauth.access_token,
oauth.token_type,
System.currentTimeMillis() / 1000,
oauth.expires_in,
oauth.refresh_token,
this.oauth?.user_id,
)
}
bangumi.saveToken(oauth)
}

View File

@@ -41,8 +41,11 @@ class KomgaApi(private val client: OkHttpClient) {
val progress = client
.newCall(GET("${url.replace("/api/v1/series/", "/api/v2/series/")}/read-progress/tachiyomi"))
.await().let {
if (url.contains("/api/v1/series/")) it.parseAs<ReadProgressV2Dto>()
else it.parseAs<ReadProgressDto>().toV2()
if (url.contains("/api/v1/series/")) {
it.parseAs<ReadProgressV2Dto>()
} else {
it.parseAs<ReadProgressDto>().toV2()
}
}
track.apply {

View File

@@ -29,14 +29,18 @@ internal class ExtensionGithubApi {
suspend fun findExtensions(): List<Extension.Available> {
return withIOContext {
val githubResponse = if (requiresFallbackSource) null else try {
networkService.client
.newCall(GET("${REPO_URL_PREFIX}index.min.json"))
.await()
} catch (e: Throwable) {
logcat(LogPriority.ERROR, e) { "Failed to get extensions from GitHub" }
requiresFallbackSource = true
val githubResponse = if (requiresFallbackSource) {
null
} else {
try {
networkService.client
.newCall(GET("${REPO_URL_PREFIX}index.min.json"))
.await()
} catch (e: Throwable) {
logcat(LogPriority.ERROR, e) { "Failed to get extensions from GitHub" }
requiresFallbackSource = true
null
}
}
val response = githubResponse ?: run {

View File

@@ -50,11 +50,13 @@ internal class ExtensionInstallReceiver(private val listener: Listener) :
when (intent.action) {
Intent.ACTION_PACKAGE_ADDED -> {
if (!isReplacing(intent)) launchNow {
when (val result = getExtensionFromIntent(context, intent)) {
is LoadResult.Success -> listener.onExtensionInstalled(result.extension)
is LoadResult.Untrusted -> listener.onExtensionUntrusted(result.extension)
else -> {}
if (!isReplacing(intent)) {
launchNow {
when (val result = getExtensionFromIntent(context, intent)) {
is LoadResult.Success -> listener.onExtensionInstalled(result.extension)
is LoadResult.Untrusted -> listener.onExtensionUntrusted(result.extension)
else -> {}
}
}
}
}

View File

@@ -238,7 +238,9 @@ class UpdatesGridGlanceWidget : GlanceAppWidget() {
.let {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
it.transformations(RoundedCornersTransformation(roundPx))
} else it // Handled by system
} else {
it // Handled by system
}
}
.build()
Pair(updatesView.mangaId, app.imageLoader.executeBlocking(request).drawable?.toBitmap())

View File

@@ -74,10 +74,12 @@ internal class RateLimitInterceptor(
throw IOException("Canceled")
} else if (hasRemovedExpired) {
break
} else try { // wait for the first entry to expire, or notified by cached response
(requestQueue as Object).wait(requestQueue.first - periodStart)
} catch (_: InterruptedException) {
continue
} else {
try { // wait for the first entry to expire, or notified by cached response
(requestQueue as Object).wait(requestQueue.first - periodStart)
} catch (_: InterruptedException) {
continue
}
}
}

View File

@@ -50,7 +50,7 @@ private var lockState = LockState.INACTIVE
private enum class LockState {
INACTIVE,
PENDING,
ACTIVE
ACTIVE,
}
class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObserver {

View File

@@ -167,8 +167,11 @@ class SearchPresenter(
val service = enhancedServices
.firstOrNull { it.isTrackFrom(updatedTrack, prevManga, prevSource) }
if (service != null) service.migrateTrack(updatedTrack, manga, source)
else updatedTrack
if (service != null) {
service.migrateTrack(updatedTrack, manga, source)
} else {
updatedTrack
}
}
insertTrack.awaitAll(tracks)
}

View File

@@ -190,32 +190,44 @@ class LibraryPresenter(
else -> downloadManager.getDownloadCount(item.manga.toDomainManga()!!) > 0
}
return@downloaded if (downloadedOnly || filterDownloaded == State.INCLUDE.value) isDownloaded
else !isDownloaded
return@downloaded if (downloadedOnly || filterDownloaded == State.INCLUDE.value) {
isDownloaded
} else {
!isDownloaded
}
}
val filterFnUnread: (LibraryItem) -> Boolean = unread@{ item ->
if (filterUnread == State.IGNORE.value) return@unread true
val isUnread = item.manga.unreadCount != 0
return@unread if (filterUnread == State.INCLUDE.value) isUnread
else !isUnread
return@unread if (filterUnread == State.INCLUDE.value) {
isUnread
} else {
!isUnread
}
}
val filterFnStarted: (LibraryItem) -> Boolean = started@{ item ->
if (filterStarted == State.IGNORE.value) return@started true
val hasStarted = item.manga.hasStarted
return@started if (filterStarted == State.INCLUDE.value) hasStarted
else !hasStarted
return@started if (filterStarted == State.INCLUDE.value) {
hasStarted
} else {
!hasStarted
}
}
val filterFnCompleted: (LibraryItem) -> Boolean = completed@{ item ->
if (filterCompleted == State.IGNORE.value) return@completed true
val isCompleted = item.manga.status == SManga.COMPLETED
return@completed if (filterCompleted == State.INCLUDE.value) isCompleted
else !isCompleted
return@completed if (filterCompleted == State.INCLUDE.value) {
isCompleted
} else {
!isCompleted
}
}
val filterFnTracking: (LibraryItem) -> Boolean = tracking@{ item ->

View File

@@ -305,7 +305,8 @@ class MangaController : FullComposeController<MangaPresenter> {
previousController.search(query)
}
is UpdatesController,
is HistoryController, -> {
is HistoryController,
-> {
// Manually navigate to LibraryController
router.handleBack()
(router.activity as MainActivity).setSelectedNavItem(R.id.nav_library)

View File

@@ -151,7 +151,9 @@ class HttpPageLoader(
.mapNotNull {
if (it.status == Page.QUEUE) {
PriorityPage(it, 0).apply { queue.offer(this) }
} else null
} else {
null
}
}
}

View File

@@ -12,7 +12,8 @@ enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val str
REVERSE_PORTRAIT(6, ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT, R.string.rotation_reverse_portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000030),
LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_landscape, R.drawable.ic_stay_current_landscape_24dp, 0x00000018),
LOCKED_PORTRAIT(4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.rotation_force_portrait, R.drawable.ic_screen_lock_portrait_24dp, 0x00000020),
LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.rotation_force_landscape, R.drawable.ic_screen_lock_landscape_24dp, 0x00000028);
LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.rotation_force_landscape, R.drawable.ic_screen_lock_landscape_24dp, 0x00000028),
;
companion object {
const val MASK = 0x00000038

View File

@@ -171,7 +171,8 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
val placeAtIndex = when (viewer) {
is L2RPagerViewer,
is VerticalPagerViewer, -> currentIndex + 1
is VerticalPagerViewer,
-> currentIndex + 1
else -> currentIndex
}

View File

@@ -33,11 +33,13 @@ private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutin
}
override fun onCompleted() {
if (cont.isActive) cont.resumeWithException(
IllegalStateException(
"Should have invoked onNext",
),
)
if (cont.isActive) {
cont.resumeWithException(
IllegalStateException(
"Should have invoked onNext",
),
)
}
}
override fun onError(e: Throwable) {

View File

@@ -117,7 +117,7 @@ open class ExtendedNavigationView @JvmOverloads constructor(
enum class State(val value: Int) {
IGNORE(0),
INCLUDE(1),
EXCLUDE(2)
EXCLUDE(2),
}
override fun getStateDrawable(context: Context): Drawable? {

View File

@@ -46,7 +46,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
} else {
event.x > handle.width + ViewCompat.getPaddingStart(handle)
}
) return false
) {
return false
}
// end
if (ignoreTouchesOutsideHandle &&

View File

@@ -39,7 +39,9 @@ class TachiyomiChangeHandlerFrameLayout(
behavior.apply {
shouldHeaderOverlap = overlapHeader
}
} else null
} else {
null
}
if (!enable) {
// The behavior doesn't reset translationY when shouldHeaderOverlap is false
translationY = 0F

View File

@@ -48,7 +48,9 @@ class TachiyomiSearchView @JvmOverloads constructor(
clearFocus()
listener?.onQueryTextSubmit(query.toString())
true
} else false
} else {
false
}
}
}