From 5f7e34b6a1cbda755db6f943a87da16cfc51e6e4 Mon Sep 17 00:00:00 2001 From: Taco Date: Tue, 26 Jan 2021 09:02:53 -0500 Subject: [PATCH] Update Okio, use more KTX stuff (#4353) * Update Okio to 2.10.0 * Use some more KTX extensions --- app/build.gradle.kts | 2 +- .../database/mappers/CategoryTypeMapping.kt | 15 +++--- .../database/mappers/ChapterTypeMapping.kt | 31 +++++------ .../database/mappers/HistoryTypeMapping.kt | 15 +++--- .../mappers/MangaCategoryTypeMapping.kt | 13 ++--- .../data/database/mappers/MangaTypeMapping.kt | 41 +++++++------- .../data/database/mappers/TrackTypeMapping.kt | 33 ++++++------ .../resolvers/ChapterBackupPutResolver.kt | 13 ++--- .../resolvers/ChapterProgressPutResolver.kt | 13 ++--- .../ChapterSourceOrderPutResolver.kt | 9 ++-- .../resolvers/HistoryLastReadPutResolver.kt | 9 ++-- .../MangaCoverLastModifiedPutResolver.kt | 9 ++-- .../resolvers/MangaFavoritePutResolver.kt | 9 ++-- .../resolvers/MangaFlagsPutResolver.kt | 9 ++-- .../resolvers/MangaLastUpdatedPutResolver.kt | 9 ++-- .../resolvers/MangaTitlePutResolver.kt | 9 ++-- .../resolvers/MangaViewerPutResolver.kt | 9 ++-- .../ui/reader/ReaderColorFilterSheet.kt | 53 ++++--------------- .../util/system/ContextExtensions.kt | 6 +-- 19 files changed, 144 insertions(+), 163 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9816315e3e..546066fed5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -157,7 +157,7 @@ dependencies { implementation("com.squareup.okhttp3:okhttp:$okhttpVersion") implementation("com.squareup.okhttp3:logging-interceptor:$okhttpVersion") implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttpVersion") - implementation("com.squareup.okio:okio:2.9.0") + implementation("com.squareup.okio:okio:2.10.0") // TLS 1.3 support for Android < 10 implementation("org.conscrypt:conscrypt-android:2.5.1") diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt index 4cf2d1eea6..b08dd31dc0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.data.database.mappers -import android.content.ContentValues import android.database.Cursor +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver @@ -35,12 +35,13 @@ class CategoryPutResolver : DefaultPutResolver() { .whereArgs(obj.id) .build() - override fun mapToContentValues(obj: Category) = ContentValues(4).apply { - put(COL_ID, obj.id) - put(COL_NAME, obj.name) - put(COL_ORDER, obj.order) - put(COL_FLAGS, obj.flags) - } + override fun mapToContentValues(obj: Category) = + contentValuesOf( + COL_ID to obj.id, + COL_NAME to obj.name, + COL_ORDER to obj.order, + COL_FLAGS to obj.flags + ) } class CategoryGetResolver : DefaultGetResolver() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt index 9d5810e012..c663d2f2f3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.data.database.mappers -import android.content.ContentValues import android.database.Cursor +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver @@ -43,20 +43,21 @@ class ChapterPutResolver : DefaultPutResolver() { .whereArgs(obj.id) .build() - override fun mapToContentValues(obj: Chapter) = ContentValues(11).apply { - put(COL_ID, obj.id) - put(COL_MANGA_ID, obj.manga_id) - put(COL_URL, obj.url) - put(COL_NAME, obj.name) - put(COL_READ, obj.read) - put(COL_SCANLATOR, obj.scanlator) - put(COL_BOOKMARK, obj.bookmark) - put(COL_DATE_FETCH, obj.date_fetch) - put(COL_DATE_UPLOAD, obj.date_upload) - put(COL_LAST_PAGE_READ, obj.last_page_read) - put(COL_CHAPTER_NUMBER, obj.chapter_number) - put(COL_SOURCE_ORDER, obj.source_order) - } + override fun mapToContentValues(obj: Chapter) = + contentValuesOf( + COL_ID to obj.id, + COL_MANGA_ID to obj.manga_id, + COL_URL to obj.url, + COL_NAME to obj.name, + COL_READ to obj.read, + COL_SCANLATOR to obj.scanlator, + COL_BOOKMARK to obj.bookmark, + COL_DATE_FETCH to obj.date_fetch, + COL_DATE_UPLOAD to obj.date_upload, + COL_LAST_PAGE_READ to obj.last_page_read, + COL_CHAPTER_NUMBER to obj.chapter_number, + COL_SOURCE_ORDER to obj.source_order + ) } class ChapterGetResolver : DefaultGetResolver() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt index e3da101695..d5cce7312a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.data.database.mappers -import android.content.ContentValues import android.database.Cursor +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver @@ -35,12 +35,13 @@ open class HistoryPutResolver : DefaultPutResolver() { .whereArgs(obj.id) .build() - override fun mapToContentValues(obj: History) = ContentValues(4).apply { - put(COL_ID, obj.id) - put(COL_CHAPTER_ID, obj.chapter_id) - put(COL_LAST_READ, obj.last_read) - put(COL_TIME_READ, obj.time_read) - } + override fun mapToContentValues(obj: History) = + contentValuesOf( + COL_ID to obj.id, + COL_CHAPTER_ID to obj.chapter_id, + COL_LAST_READ to obj.last_read, + COL_TIME_READ to obj.time_read + ) } class HistoryGetResolver : DefaultGetResolver() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt index 24fff124cd..f5e5843337 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.data.database.mappers -import android.content.ContentValues import android.database.Cursor +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver @@ -33,11 +33,12 @@ class MangaCategoryPutResolver : DefaultPutResolver() { .whereArgs(obj.id) .build() - override fun mapToContentValues(obj: MangaCategory) = ContentValues(3).apply { - put(COL_ID, obj.id) - put(COL_MANGA_ID, obj.manga_id) - put(COL_CATEGORY_ID, obj.category_id) - } + override fun mapToContentValues(obj: MangaCategory) = + contentValuesOf( + COL_ID to obj.id, + COL_MANGA_ID to obj.manga_id, + COL_CATEGORY_ID to obj.category_id + ) } class MangaCategoryGetResolver : DefaultGetResolver() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt index 34fcf560c0..37ea8cb297 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.data.database.mappers -import android.content.ContentValues import android.database.Cursor +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver @@ -48,25 +48,26 @@ class MangaPutResolver : DefaultPutResolver() { .whereArgs(obj.id) .build() - override fun mapToContentValues(obj: Manga) = ContentValues(17).apply { - put(COL_ID, obj.id) - put(COL_SOURCE, obj.source) - put(COL_URL, obj.url) - put(COL_ARTIST, obj.artist) - put(COL_AUTHOR, obj.author) - put(COL_DESCRIPTION, obj.description) - put(COL_GENRE, obj.genre) - put(COL_TITLE, obj.title) - put(COL_STATUS, obj.status) - put(COL_THUMBNAIL_URL, obj.thumbnail_url) - put(COL_FAVORITE, obj.favorite) - put(COL_LAST_UPDATE, obj.last_update) - put(COL_INITIALIZED, obj.initialized) - put(COL_VIEWER, obj.viewer) - put(COL_CHAPTER_FLAGS, obj.chapter_flags) - put(COL_COVER_LAST_MODIFIED, obj.cover_last_modified) - put(COL_DATE_ADDED, obj.date_added) - } + override fun mapToContentValues(obj: Manga) = + contentValuesOf( + COL_ID to obj.id, + COL_SOURCE to obj.source, + COL_URL to obj.url, + COL_ARTIST to obj.artist, + COL_AUTHOR to obj.author, + COL_DESCRIPTION to obj.description, + COL_GENRE to obj.genre, + COL_TITLE to obj.title, + COL_STATUS to obj.status, + COL_THUMBNAIL_URL to obj.thumbnail_url, + COL_FAVORITE to obj.favorite, + COL_LAST_UPDATE to obj.last_update, + COL_INITIALIZED to obj.initialized, + COL_VIEWER to obj.viewer, + COL_CHAPTER_FLAGS to obj.chapter_flags, + COL_COVER_LAST_MODIFIED to obj.cover_last_modified, + COL_DATE_ADDED to obj.date_added + ) } interface BaseMangaGetResolver { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt index 94de567ad5..1ab6f811c2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.data.database.mappers -import android.content.ContentValues import android.database.Cursor +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver @@ -44,21 +44,22 @@ class TrackPutResolver : DefaultPutResolver() { .whereArgs(obj.id) .build() - override fun mapToContentValues(obj: Track) = ContentValues(10).apply { - put(COL_ID, obj.id) - put(COL_MANGA_ID, obj.manga_id) - put(COL_SYNC_ID, obj.sync_id) - put(COL_MEDIA_ID, obj.media_id) - put(COL_LIBRARY_ID, obj.library_id) - put(COL_TITLE, obj.title) - put(COL_LAST_CHAPTER_READ, obj.last_chapter_read) - put(COL_TOTAL_CHAPTERS, obj.total_chapters) - put(COL_STATUS, obj.status) - put(COL_TRACKING_URL, obj.tracking_url) - put(COL_SCORE, obj.score) - put(COL_START_DATE, obj.started_reading_date) - put(COL_FINISH_DATE, obj.finished_reading_date) - } + override fun mapToContentValues(obj: Track) = + contentValuesOf( + COL_ID to obj.id, + COL_MANGA_ID to obj.manga_id, + COL_SYNC_ID to obj.sync_id, + COL_MEDIA_ID to obj.media_id, + COL_LIBRARY_ID to obj.library_id, + COL_TITLE to obj.title, + COL_LAST_CHAPTER_READ to obj.last_chapter_read, + COL_TOTAL_CHAPTERS to obj.total_chapters, + COL_STATUS to obj.status, + COL_TRACKING_URL to obj.tracking_url, + COL_SCORE to obj.score, + COL_START_DATE to obj.started_reading_date, + COL_FINISH_DATE to obj.finished_reading_date + ) } class TrackGetResolver : DefaultGetResolver() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterBackupPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterBackupPutResolver.kt index 20008e0748..76516139fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterBackupPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterBackupPutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,9 +25,10 @@ class ChapterBackupPutResolver : PutResolver() { .whereArgs(chapter.url) .build() - fun mapToContentValues(chapter: Chapter) = ContentValues(3).apply { - put(ChapterTable.COL_READ, chapter.read) - put(ChapterTable.COL_BOOKMARK, chapter.bookmark) - put(ChapterTable.COL_LAST_PAGE_READ, chapter.last_page_read) - } + fun mapToContentValues(chapter: Chapter) = + contentValuesOf( + ChapterTable.COL_READ to chapter.read, + ChapterTable.COL_BOOKMARK to chapter.bookmark, + ChapterTable.COL_LAST_PAGE_READ to chapter.last_page_read + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt index b2800551f8..949dcafd7e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,9 +25,10 @@ class ChapterProgressPutResolver : PutResolver() { .whereArgs(chapter.id) .build() - fun mapToContentValues(chapter: Chapter) = ContentValues(3).apply { - put(ChapterTable.COL_READ, chapter.read) - put(ChapterTable.COL_BOOKMARK, chapter.bookmark) - put(ChapterTable.COL_LAST_PAGE_READ, chapter.last_page_read) - } + fun mapToContentValues(chapter: Chapter) = + contentValuesOf( + ChapterTable.COL_READ to chapter.read, + ChapterTable.COL_BOOKMARK to chapter.bookmark, + ChapterTable.COL_LAST_PAGE_READ to chapter.last_page_read + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt index fa0f3514c8..9814e9dc5a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,7 +25,8 @@ class ChapterSourceOrderPutResolver : PutResolver() { .whereArgs(chapter.url, chapter.manga_id) .build() - fun mapToContentValues(chapter: Chapter) = ContentValues(1).apply { - put(ChapterTable.COL_SOURCE_ORDER, chapter.source_order) - } + fun mapToContentValues(chapter: Chapter) = + contentValuesOf( + ChapterTable.COL_SOURCE_ORDER to chapter.source_order + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt index 32f73c0097..07b883b455 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues import androidx.annotation.NonNull +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.queries.Query @@ -57,7 +57,8 @@ class HistoryLastReadPutResolver : HistoryPutResolver() { * Create content query * @param history object */ - fun mapToUpdateContentValues(history: History) = ContentValues(1).apply { - put(HistoryTable.COL_LAST_READ, history.last_read) - } + fun mapToUpdateContentValues(history: History) = + contentValuesOf( + HistoryTable.COL_LAST_READ to history.last_read + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaCoverLastModifiedPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaCoverLastModifiedPutResolver.kt index 98d6ba4a23..0db595e429 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaCoverLastModifiedPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaCoverLastModifiedPutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,7 +25,8 @@ class MangaCoverLastModifiedPutResolver : PutResolver() { .whereArgs(manga.id) .build() - fun mapToContentValues(manga: Manga) = ContentValues(1).apply { - put(MangaTable.COL_COVER_LAST_MODIFIED, manga.cover_last_modified) - } + fun mapToContentValues(manga: Manga) = + contentValuesOf( + MangaTable.COL_COVER_LAST_MODIFIED to manga.cover_last_modified + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFavoritePutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFavoritePutResolver.kt index 5c948a2c8e..29f93a19be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFavoritePutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFavoritePutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,7 +25,8 @@ class MangaFavoritePutResolver : PutResolver() { .whereArgs(manga.id) .build() - fun mapToContentValues(manga: Manga) = ContentValues(1).apply { - put(MangaTable.COL_FAVORITE, manga.favorite) - } + fun mapToContentValues(manga: Manga) = + contentValuesOf( + MangaTable.COL_FAVORITE to manga.favorite + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt index 2a8e083838..b342e35bb4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -35,7 +35,8 @@ class MangaFlagsPutResolver(private val updateAll: Boolean = false) : PutResolve } } - fun mapToContentValues(manga: Manga) = ContentValues(1).apply { - put(MangaTable.COL_CHAPTER_FLAGS, manga.chapter_flags) - } + fun mapToContentValues(manga: Manga) = + contentValuesOf( + MangaTable.COL_CHAPTER_FLAGS to manga.chapter_flags + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaLastUpdatedPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaLastUpdatedPutResolver.kt index 6b33ed2554..5cd673c6e3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaLastUpdatedPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaLastUpdatedPutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,7 +25,8 @@ class MangaLastUpdatedPutResolver : PutResolver() { .whereArgs(manga.id) .build() - fun mapToContentValues(manga: Manga) = ContentValues(1).apply { - put(MangaTable.COL_LAST_UPDATE, manga.last_update) - } + fun mapToContentValues(manga: Manga) = + contentValuesOf( + MangaTable.COL_LAST_UPDATE to manga.last_update + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaTitlePutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaTitlePutResolver.kt index cb29c26d95..64323d2769 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaTitlePutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaTitlePutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,7 +25,8 @@ class MangaTitlePutResolver : PutResolver() { .whereArgs(manga.id) .build() - fun mapToContentValues(manga: Manga) = ContentValues(1).apply { - put(MangaTable.COL_TITLE, manga.title) - } + fun mapToContentValues(manga: Manga) = + contentValuesOf( + MangaTable.COL_TITLE to manga.title + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaViewerPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaViewerPutResolver.kt index 13005d24c2..5f465eb308 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaViewerPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaViewerPutResolver.kt @@ -1,6 +1,6 @@ package eu.kanade.tachiyomi.data.database.resolvers -import android.content.ContentValues +import androidx.core.content.contentValuesOf import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResult @@ -25,7 +25,8 @@ class MangaViewerPutResolver : PutResolver() { .whereArgs(manga.id) .build() - fun mapToContentValues(manga: Manga) = ContentValues(1).apply { - put(MangaTable.COL_VIEWER, manga.viewer) - } + fun mapToContentValues(manga: Manga) = + contentValuesOf( + MangaTable.COL_VIEWER to manga.viewer + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt index 04efa20d20..287b21f441 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader import android.view.ViewGroup import android.widget.SeekBar import androidx.annotation.ColorInt +import androidx.core.graphics.* import androidx.lifecycle.lifecycleScope import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog @@ -156,16 +157,16 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet * @param color integer containing color information */ fun setValues(color: Int): Array { - val alpha = getAlphaFromColor(color) - val red = getRedFromColor(color) - val green = getGreenFromColor(color) - val blue = getBlueFromColor(color) + val alpha = color.alpha + val red = color.red + val green = color.green + val blue = color.blue // Initialize values - binding.txtColorFilterAlphaValue.text = alpha.toString() - binding.txtColorFilterRedValue.text = red.toString() - binding.txtColorFilterGreenValue.text = green.toString() - binding.txtColorFilterBlueValue.text = blue.toString() + binding.txtColorFilterAlphaValue.text = "$alpha" + binding.txtColorFilterRedValue.text = "$red" + binding.txtColorFilterGreenValue.text = "$green" + binding.txtColorFilterBlueValue.text = "$blue" return arrayOf(alpha, red, green, blue) } @@ -232,42 +233,6 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet preferences.colorFilterValue().set(updatedColor) } - /** - * Returns the alpha value from the Color Hex - * @param color color hex as int - * @return alpha of color - */ - private fun getAlphaFromColor(color: Int): Int { - return color shr 24 and 0xFF - } - - /** - * Returns the red value from the Color Hex - * @param color color hex as int - * @return red of color - */ - private fun getRedFromColor(color: Int): Int { - return color shr 16 and 0xFF - } - - /** - * Returns the green value from the Color Hex - * @param color color hex as int - * @return green of color - */ - private fun getGreenFromColor(color: Int): Int { - return color shr 8 and 0xFF - } - - /** - * Returns the blue value from the Color Hex - * @param color color hex as int - * @return blue of color - */ - private fun getBlueFromColor(color: Int): Int { - return color and 0xFF - } - private companion object { /** Integer mask of alpha value **/ const val ALPHA_MASK: Long = 0xFF000000 diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index 5d5a0dbfc6..d5c44caf1d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -154,19 +154,19 @@ val Resources.isLTR * Property to get the notification manager from the context. */ val Context.notificationManager: NotificationManager - get() = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + get() = getSystemService()!! /** * Property to get the connectivity manager from the context. */ val Context.connectivityManager: ConnectivityManager - get() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + get() = getSystemService()!! /** * Property to get the power manager from the context. */ val Context.powerManager: PowerManager - get() = getSystemService(Context.POWER_SERVICE) as PowerManager + get() = getSystemService()!! /** * Convenience method to acquire a partial wake lock.