From b40af7c3c6beb2a28c1ec3104cc8cbd9f6a4a04e Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 17 Apr 2021 19:05:35 -0400 Subject: [PATCH] Minor cleanup --- README.md | 2 +- .../migration/search/SearchPresenter.kt | 2 +- .../ui/browse/source/SourceHolder.kt | 5 ++-- .../eu/kanade/tachiyomi/util/CrashLogUtil.kt | 3 --- .../util/chapter/ChapterSourceSync.kt | 2 ++ .../util/chapter/NoChaptersException.kt | 3 --- .../util/view/ImageViewExtensions.kt | 6 +++-- .../materialdialogs/QuadStateCheckBox.kt | 23 +++++-------------- 8 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/util/chapter/NoChaptersException.kt diff --git a/README.md b/README.md index 88eb718a29..1662f2c70b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Tachiyomi is a free and open source manga reader for Android 5.0 and above. ## Features Features include: -* Online reading from sources such as MangaDex, MangaSee, Mangakakalot, [and more](https://github.com/tachiyomiorg/tachiyomi-extensions) +* Online reading from [a variety of sources](https://github.com/tachiyomiorg/tachiyomi-extensions) * Local reading of downloaded manga * A configurable reader with multiple viewers, reading directions and other settings. * [MyAnimeList](https://myanimelist.net/), [AniList](https://anilist.co/), [Kitsu](https://kitsu.io/), [Shikimori](https://shikimori.one), and [Bangumi](https://bgm.tv/) support diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt index 330ee1e042..204f6cbecd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt @@ -104,7 +104,7 @@ class SearchPresenter( val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking() val maxChapterRead = prevMangaChapters .filter { it.read } - .maxByOrNull { it.chapter_number }?.chapter_number + .maxOfOrNull { it.chapter_number } if (maxChapterRead != null) { val dbChapters = db.getChapters(manga).executeAsBlocking() for (chapter in dbChapters) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceHolder.kt index 4cafa15e33..0f05512e0e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceHolder.kt @@ -8,7 +8,6 @@ import eu.kanade.tachiyomi.databinding.SourceMainControllerCardItemBinding import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.icon import eu.kanade.tachiyomi.util.system.LocaleHelper -import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.setVectorCompat class SourceHolder(private val view: View, val adapter: SourceAdapter) : @@ -46,9 +45,9 @@ class SourceHolder(private val view: View, val adapter: SourceAdapter) : binding.pin.isVisible = true if (item.isPinned) { - binding.pin.setVectorCompat(R.drawable.ic_push_pin_24dp, view.context.getResourceColor(R.attr.colorAccent)) + binding.pin.setVectorCompat(R.drawable.ic_push_pin_24dp, R.attr.colorAccent) } else { - binding.pin.setVectorCompat(R.drawable.ic_push_pin_outline_24dp, view.context.getResourceColor(android.R.attr.textColorHint)) + binding.pin.setVectorCompat(R.drawable.ic_push_pin_outline_24dp, android.R.attr.textColorHint) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt index 8b32ec43cb..16367fd7df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt @@ -54,15 +54,12 @@ class CrashLogUtil(private val context: Context) { with(notificationBuilder) { setContentTitle(context.getString(R.string.crash_log_saved)) - // Clear old actions if they exist clearActions() - addAction( R.drawable.ic_folder_24dp, context.getString(R.string.action_open_log), NotificationReceiver.openErrorLogPendingActivity(context, uri) ) - addAction( R.drawable.ic_share_24dp, context.getString(R.string.action_share), diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt index 308ba27fa1..5639433704 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt @@ -157,3 +157,5 @@ private fun shouldUpdateDbChapter(dbChapter: Chapter, sourceChapter: SChapter): dbChapter.date_upload != sourceChapter.date_upload || dbChapter.chapter_number != sourceChapter.chapter_number } + +class NoChaptersException : Exception() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/NoChaptersException.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/NoChaptersException.kt deleted file mode 100644 index 1801792481..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/NoChaptersException.kt +++ /dev/null @@ -1,3 +0,0 @@ -package eu.kanade.tachiyomi.util.chapter - -class NoChaptersException : Exception() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt index 9c3372b154..dfeb7281e6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ImageViewExtensions.kt @@ -1,19 +1,21 @@ package eu.kanade.tachiyomi.util.view import android.widget.ImageView +import androidx.annotation.AttrRes import androidx.annotation.DrawableRes import androidx.appcompat.content.res.AppCompatResources +import eu.kanade.tachiyomi.util.system.getResourceColor /** * Set a vector on a [ImageView]. * * @param drawable id of drawable resource */ -fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) { +fun ImageView.setVectorCompat(@DrawableRes drawable: Int, @AttrRes tint: Int? = null) { val vector = AppCompatResources.getDrawable(context, drawable) if (tint != null) { vector?.mutate() - vector?.setTint(tint) + vector?.setTint(context.getResourceColor(tint)) } setImageDrawable(vector) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/QuadStateCheckBox.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/QuadStateCheckBox.kt index 5dd19a1419..b01d224374 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/QuadStateCheckBox.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/QuadStateCheckBox.kt @@ -1,13 +1,10 @@ package eu.kanade.tachiyomi.widget.materialdialogs import android.content.Context -import android.graphics.drawable.Drawable import android.util.AttributeSet -import androidx.annotation.AttrRes -import androidx.appcompat.content.res.AppCompatResources import androidx.appcompat.widget.AppCompatImageView import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.util.system.getResourceColor +import eu.kanade.tachiyomi.util.view.setVectorCompat class QuadStateCheckBox @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : AppCompatImageView(context, attrs) { @@ -19,19 +16,11 @@ class QuadStateCheckBox @JvmOverloads constructor(context: Context, attrs: Attri } private fun updateDrawable() { - val drawable = when (state) { - State.UNCHECKED -> tintVector(context, R.drawable.ic_check_box_outline_blank_24dp, R.attr.colorControlNormal) - State.INDETERMINATE -> tintVector(context, R.drawable.ic_indeterminate_check_box_24dp) - State.CHECKED -> tintVector(context, R.drawable.ic_check_box_24dp) - State.INVERSED -> tintVector(context, R.drawable.ic_check_box_x_24dp) - } - - setImageDrawable(drawable) - } - - private fun tintVector(context: Context, resId: Int, @AttrRes colorAttrRes: Int = R.attr.colorAccent): Drawable { - return AppCompatResources.getDrawable(context, resId)!!.apply { - setTint(context.getResourceColor(colorAttrRes)) + when (state) { + State.UNCHECKED -> setVectorCompat(R.drawable.ic_check_box_outline_blank_24dp, R.attr.colorControlNormal) + State.INDETERMINATE -> setVectorCompat(R.drawable.ic_indeterminate_check_box_24dp, R.attr.colorAccent) + State.CHECKED -> setVectorCompat(R.drawable.ic_check_box_24dp, R.attr.colorAccent) + State.INVERSED -> setVectorCompat(R.drawable.ic_check_box_x_24dp, R.attr.colorAccent) } }