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
19 changed files with 144 additions and 163 deletions

View File

@@ -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<Int> {
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