Update Okio, use more KTX stuff (#4353)

* Update Okio to 2.10.0

* Use some more KTX extensions
This commit is contained in:
Taco 2021-01-26 09:02:53 -05:00 committed by GitHub
parent 34cb24fe34
commit 5f7e34b6a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 144 additions and 163 deletions

View File

@ -157,7 +157,7 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:$okhttpVersion") implementation("com.squareup.okhttp3:okhttp:$okhttpVersion")
implementation("com.squareup.okhttp3:logging-interceptor:$okhttpVersion") implementation("com.squareup.okhttp3:logging-interceptor:$okhttpVersion")
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$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 // TLS 1.3 support for Android < 10
implementation("org.conscrypt:conscrypt-android:2.5.1") implementation("org.conscrypt:conscrypt-android:2.5.1")

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.data.database.mappers package eu.kanade.tachiyomi.data.database.mappers
import android.content.ContentValues
import android.database.Cursor import android.database.Cursor
import androidx.core.content.contentValuesOf
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping
import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver
import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver
@ -35,12 +35,13 @@ class CategoryPutResolver : DefaultPutResolver<Category>() {
.whereArgs(obj.id) .whereArgs(obj.id)
.build() .build()
override fun mapToContentValues(obj: Category) = ContentValues(4).apply { override fun mapToContentValues(obj: Category) =
put(COL_ID, obj.id) contentValuesOf(
put(COL_NAME, obj.name) COL_ID to obj.id,
put(COL_ORDER, obj.order) COL_NAME to obj.name,
put(COL_FLAGS, obj.flags) COL_ORDER to obj.order,
} COL_FLAGS to obj.flags
)
} }
class CategoryGetResolver : DefaultGetResolver<Category>() { class CategoryGetResolver : DefaultGetResolver<Category>() {

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.data.database.mappers package eu.kanade.tachiyomi.data.database.mappers
import android.content.ContentValues
import android.database.Cursor import android.database.Cursor
import androidx.core.content.contentValuesOf
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping
import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver
import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver
@ -43,20 +43,21 @@ class ChapterPutResolver : DefaultPutResolver<Chapter>() {
.whereArgs(obj.id) .whereArgs(obj.id)
.build() .build()
override fun mapToContentValues(obj: Chapter) = ContentValues(11).apply { override fun mapToContentValues(obj: Chapter) =
put(COL_ID, obj.id) contentValuesOf(
put(COL_MANGA_ID, obj.manga_id) COL_ID to obj.id,
put(COL_URL, obj.url) COL_MANGA_ID to obj.manga_id,
put(COL_NAME, obj.name) COL_URL to obj.url,
put(COL_READ, obj.read) COL_NAME to obj.name,
put(COL_SCANLATOR, obj.scanlator) COL_READ to obj.read,
put(COL_BOOKMARK, obj.bookmark) COL_SCANLATOR to obj.scanlator,
put(COL_DATE_FETCH, obj.date_fetch) COL_BOOKMARK to obj.bookmark,
put(COL_DATE_UPLOAD, obj.date_upload) COL_DATE_FETCH to obj.date_fetch,
put(COL_LAST_PAGE_READ, obj.last_page_read) COL_DATE_UPLOAD to obj.date_upload,
put(COL_CHAPTER_NUMBER, obj.chapter_number) COL_LAST_PAGE_READ to obj.last_page_read,
put(COL_SOURCE_ORDER, obj.source_order) COL_CHAPTER_NUMBER to obj.chapter_number,
} COL_SOURCE_ORDER to obj.source_order
)
} }
class ChapterGetResolver : DefaultGetResolver<Chapter>() { class ChapterGetResolver : DefaultGetResolver<Chapter>() {

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.data.database.mappers package eu.kanade.tachiyomi.data.database.mappers
import android.content.ContentValues
import android.database.Cursor import android.database.Cursor
import androidx.core.content.contentValuesOf
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping
import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver
import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver
@ -35,12 +35,13 @@ open class HistoryPutResolver : DefaultPutResolver<History>() {
.whereArgs(obj.id) .whereArgs(obj.id)
.build() .build()
override fun mapToContentValues(obj: History) = ContentValues(4).apply { override fun mapToContentValues(obj: History) =
put(COL_ID, obj.id) contentValuesOf(
put(COL_CHAPTER_ID, obj.chapter_id) COL_ID to obj.id,
put(COL_LAST_READ, obj.last_read) COL_CHAPTER_ID to obj.chapter_id,
put(COL_TIME_READ, obj.time_read) COL_LAST_READ to obj.last_read,
} COL_TIME_READ to obj.time_read
)
} }
class HistoryGetResolver : DefaultGetResolver<History>() { class HistoryGetResolver : DefaultGetResolver<History>() {

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.data.database.mappers package eu.kanade.tachiyomi.data.database.mappers
import android.content.ContentValues
import android.database.Cursor import android.database.Cursor
import androidx.core.content.contentValuesOf
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping
import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver
import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver
@ -33,11 +33,12 @@ class MangaCategoryPutResolver : DefaultPutResolver<MangaCategory>() {
.whereArgs(obj.id) .whereArgs(obj.id)
.build() .build()
override fun mapToContentValues(obj: MangaCategory) = ContentValues(3).apply { override fun mapToContentValues(obj: MangaCategory) =
put(COL_ID, obj.id) contentValuesOf(
put(COL_MANGA_ID, obj.manga_id) COL_ID to obj.id,
put(COL_CATEGORY_ID, obj.category_id) COL_MANGA_ID to obj.manga_id,
} COL_CATEGORY_ID to obj.category_id
)
} }
class MangaCategoryGetResolver : DefaultGetResolver<MangaCategory>() { class MangaCategoryGetResolver : DefaultGetResolver<MangaCategory>() {

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.data.database.mappers package eu.kanade.tachiyomi.data.database.mappers
import android.content.ContentValues
import android.database.Cursor import android.database.Cursor
import androidx.core.content.contentValuesOf
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping
import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver
import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver
@ -48,25 +48,26 @@ class MangaPutResolver : DefaultPutResolver<Manga>() {
.whereArgs(obj.id) .whereArgs(obj.id)
.build() .build()
override fun mapToContentValues(obj: Manga) = ContentValues(17).apply { override fun mapToContentValues(obj: Manga) =
put(COL_ID, obj.id) contentValuesOf(
put(COL_SOURCE, obj.source) COL_ID to obj.id,
put(COL_URL, obj.url) COL_SOURCE to obj.source,
put(COL_ARTIST, obj.artist) COL_URL to obj.url,
put(COL_AUTHOR, obj.author) COL_ARTIST to obj.artist,
put(COL_DESCRIPTION, obj.description) COL_AUTHOR to obj.author,
put(COL_GENRE, obj.genre) COL_DESCRIPTION to obj.description,
put(COL_TITLE, obj.title) COL_GENRE to obj.genre,
put(COL_STATUS, obj.status) COL_TITLE to obj.title,
put(COL_THUMBNAIL_URL, obj.thumbnail_url) COL_STATUS to obj.status,
put(COL_FAVORITE, obj.favorite) COL_THUMBNAIL_URL to obj.thumbnail_url,
put(COL_LAST_UPDATE, obj.last_update) COL_FAVORITE to obj.favorite,
put(COL_INITIALIZED, obj.initialized) COL_LAST_UPDATE to obj.last_update,
put(COL_VIEWER, obj.viewer) COL_INITIALIZED to obj.initialized,
put(COL_CHAPTER_FLAGS, obj.chapter_flags) COL_VIEWER to obj.viewer,
put(COL_COVER_LAST_MODIFIED, obj.cover_last_modified) COL_CHAPTER_FLAGS to obj.chapter_flags,
put(COL_DATE_ADDED, obj.date_added) COL_COVER_LAST_MODIFIED to obj.cover_last_modified,
} COL_DATE_ADDED to obj.date_added
)
} }
interface BaseMangaGetResolver { interface BaseMangaGetResolver {

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.data.database.mappers package eu.kanade.tachiyomi.data.database.mappers
import android.content.ContentValues
import android.database.Cursor import android.database.Cursor
import androidx.core.content.contentValuesOf
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping
import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver
import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver
@ -44,21 +44,22 @@ class TrackPutResolver : DefaultPutResolver<Track>() {
.whereArgs(obj.id) .whereArgs(obj.id)
.build() .build()
override fun mapToContentValues(obj: Track) = ContentValues(10).apply { override fun mapToContentValues(obj: Track) =
put(COL_ID, obj.id) contentValuesOf(
put(COL_MANGA_ID, obj.manga_id) COL_ID to obj.id,
put(COL_SYNC_ID, obj.sync_id) COL_MANGA_ID to obj.manga_id,
put(COL_MEDIA_ID, obj.media_id) COL_SYNC_ID to obj.sync_id,
put(COL_LIBRARY_ID, obj.library_id) COL_MEDIA_ID to obj.media_id,
put(COL_TITLE, obj.title) COL_LIBRARY_ID to obj.library_id,
put(COL_LAST_CHAPTER_READ, obj.last_chapter_read) COL_TITLE to obj.title,
put(COL_TOTAL_CHAPTERS, obj.total_chapters) COL_LAST_CHAPTER_READ to obj.last_chapter_read,
put(COL_STATUS, obj.status) COL_TOTAL_CHAPTERS to obj.total_chapters,
put(COL_TRACKING_URL, obj.tracking_url) COL_STATUS to obj.status,
put(COL_SCORE, obj.score) COL_TRACKING_URL to obj.tracking_url,
put(COL_START_DATE, obj.started_reading_date) COL_SCORE to obj.score,
put(COL_FINISH_DATE, obj.finished_reading_date) COL_START_DATE to obj.started_reading_date,
} COL_FINISH_DATE to obj.finished_reading_date
)
} }
class TrackGetResolver : DefaultGetResolver<Track>() { class TrackGetResolver : DefaultGetResolver<Track>() {

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,9 +25,10 @@ class ChapterBackupPutResolver : PutResolver<Chapter>() {
.whereArgs(chapter.url) .whereArgs(chapter.url)
.build() .build()
fun mapToContentValues(chapter: Chapter) = ContentValues(3).apply { fun mapToContentValues(chapter: Chapter) =
put(ChapterTable.COL_READ, chapter.read) contentValuesOf(
put(ChapterTable.COL_BOOKMARK, chapter.bookmark) ChapterTable.COL_READ to chapter.read,
put(ChapterTable.COL_LAST_PAGE_READ, chapter.last_page_read) ChapterTable.COL_BOOKMARK to chapter.bookmark,
} ChapterTable.COL_LAST_PAGE_READ to chapter.last_page_read
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,9 +25,10 @@ class ChapterProgressPutResolver : PutResolver<Chapter>() {
.whereArgs(chapter.id) .whereArgs(chapter.id)
.build() .build()
fun mapToContentValues(chapter: Chapter) = ContentValues(3).apply { fun mapToContentValues(chapter: Chapter) =
put(ChapterTable.COL_READ, chapter.read) contentValuesOf(
put(ChapterTable.COL_BOOKMARK, chapter.bookmark) ChapterTable.COL_READ to chapter.read,
put(ChapterTable.COL_LAST_PAGE_READ, chapter.last_page_read) ChapterTable.COL_BOOKMARK to chapter.bookmark,
} ChapterTable.COL_LAST_PAGE_READ to chapter.last_page_read
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,7 +25,8 @@ class ChapterSourceOrderPutResolver : PutResolver<Chapter>() {
.whereArgs(chapter.url, chapter.manga_id) .whereArgs(chapter.url, chapter.manga_id)
.build() .build()
fun mapToContentValues(chapter: Chapter) = ContentValues(1).apply { fun mapToContentValues(chapter: Chapter) =
put(ChapterTable.COL_SOURCE_ORDER, chapter.source_order) contentValuesOf(
} ChapterTable.COL_SOURCE_ORDER to chapter.source_order
)
} }

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.data.database.resolvers package eu.kanade.tachiyomi.data.database.resolvers
import android.content.ContentValues
import androidx.annotation.NonNull import androidx.annotation.NonNull
import androidx.core.content.contentValuesOf
import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
import com.pushtorefresh.storio.sqlite.queries.Query import com.pushtorefresh.storio.sqlite.queries.Query
@ -57,7 +57,8 @@ class HistoryLastReadPutResolver : HistoryPutResolver() {
* Create content query * Create content query
* @param history object * @param history object
*/ */
fun mapToUpdateContentValues(history: History) = ContentValues(1).apply { fun mapToUpdateContentValues(history: History) =
put(HistoryTable.COL_LAST_READ, history.last_read) contentValuesOf(
} HistoryTable.COL_LAST_READ to history.last_read
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,7 +25,8 @@ class MangaCoverLastModifiedPutResolver : PutResolver<Manga>() {
.whereArgs(manga.id) .whereArgs(manga.id)
.build() .build()
fun mapToContentValues(manga: Manga) = ContentValues(1).apply { fun mapToContentValues(manga: Manga) =
put(MangaTable.COL_COVER_LAST_MODIFIED, manga.cover_last_modified) contentValuesOf(
} MangaTable.COL_COVER_LAST_MODIFIED to manga.cover_last_modified
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,7 +25,8 @@ class MangaFavoritePutResolver : PutResolver<Manga>() {
.whereArgs(manga.id) .whereArgs(manga.id)
.build() .build()
fun mapToContentValues(manga: Manga) = ContentValues(1).apply { fun mapToContentValues(manga: Manga) =
put(MangaTable.COL_FAVORITE, manga.favorite) contentValuesOf(
} MangaTable.COL_FAVORITE to manga.favorite
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult 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 { fun mapToContentValues(manga: Manga) =
put(MangaTable.COL_CHAPTER_FLAGS, manga.chapter_flags) contentValuesOf(
} MangaTable.COL_CHAPTER_FLAGS to manga.chapter_flags
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,7 +25,8 @@ class MangaLastUpdatedPutResolver : PutResolver<Manga>() {
.whereArgs(manga.id) .whereArgs(manga.id)
.build() .build()
fun mapToContentValues(manga: Manga) = ContentValues(1).apply { fun mapToContentValues(manga: Manga) =
put(MangaTable.COL_LAST_UPDATE, manga.last_update) contentValuesOf(
} MangaTable.COL_LAST_UPDATE to manga.last_update
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,7 +25,8 @@ class MangaTitlePutResolver : PutResolver<Manga>() {
.whereArgs(manga.id) .whereArgs(manga.id)
.build() .build()
fun mapToContentValues(manga: Manga) = ContentValues(1).apply { fun mapToContentValues(manga: Manga) =
put(MangaTable.COL_TITLE, manga.title) contentValuesOf(
} MangaTable.COL_TITLE to manga.title
)
} }

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.data.database.resolvers 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.StorIOSQLite
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
import com.pushtorefresh.storio.sqlite.operations.put.PutResult import com.pushtorefresh.storio.sqlite.operations.put.PutResult
@ -25,7 +25,8 @@ class MangaViewerPutResolver : PutResolver<Manga>() {
.whereArgs(manga.id) .whereArgs(manga.id)
.build() .build()
fun mapToContentValues(manga: Manga) = ContentValues(1).apply { fun mapToContentValues(manga: Manga) =
put(MangaTable.COL_VIEWER, manga.viewer) contentValuesOf(
} MangaTable.COL_VIEWER to manga.viewer
)
} }

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.SeekBar import android.widget.SeekBar
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.core.graphics.*
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
@ -156,16 +157,16 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
* @param color integer containing color information * @param color integer containing color information
*/ */
fun setValues(color: Int): Array<Int> { fun setValues(color: Int): Array<Int> {
val alpha = getAlphaFromColor(color) val alpha = color.alpha
val red = getRedFromColor(color) val red = color.red
val green = getGreenFromColor(color) val green = color.green
val blue = getBlueFromColor(color) val blue = color.blue
// Initialize values // Initialize values
binding.txtColorFilterAlphaValue.text = alpha.toString() binding.txtColorFilterAlphaValue.text = "$alpha"
binding.txtColorFilterRedValue.text = red.toString() binding.txtColorFilterRedValue.text = "$red"
binding.txtColorFilterGreenValue.text = green.toString() binding.txtColorFilterGreenValue.text = "$green"
binding.txtColorFilterBlueValue.text = blue.toString() binding.txtColorFilterBlueValue.text = "$blue"
return arrayOf(alpha, red, green, blue) return arrayOf(alpha, red, green, blue)
} }
@ -232,42 +233,6 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
preferences.colorFilterValue().set(updatedColor) 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 { private companion object {
/** Integer mask of alpha value **/ /** Integer mask of alpha value **/
const val ALPHA_MASK: Long = 0xFF000000 const val ALPHA_MASK: Long = 0xFF000000

View File

@ -154,19 +154,19 @@ val Resources.isLTR
* Property to get the notification manager from the context. * Property to get the notification manager from the context.
*/ */
val Context.notificationManager: NotificationManager val Context.notificationManager: NotificationManager
get() = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager get() = getSystemService()!!
/** /**
* Property to get the connectivity manager from the context. * Property to get the connectivity manager from the context.
*/ */
val Context.connectivityManager: ConnectivityManager val Context.connectivityManager: ConnectivityManager
get() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager get() = getSystemService()!!
/** /**
* Property to get the power manager from the context. * Property to get the power manager from the context.
*/ */
val Context.powerManager: PowerManager val Context.powerManager: PowerManager
get() = getSystemService(Context.POWER_SERVICE) as PowerManager get() = getSystemService()!!
/** /**
* Convenience method to acquire a partial wake lock. * Convenience method to acquire a partial wake lock.