pull/32/head
kunfei 5 years ago
parent 162bd16922
commit 91eff38e8b
  1. 26
      app/src/main/java/io/legado/app/lib/theme/TintHelper.kt
  2. 3
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -332,11 +332,11 @@ object TintHelper {
compatSwitch: Boolean, compatSwitch: Boolean,
useDarker: Boolean useDarker: Boolean
): Drawable? { ): Drawable? {
var tint = tint var tint1 = tint
if (useDarker) { if (useDarker) {
tint = ColorUtils.shiftColor(tint, 1.1f) tint1 = ColorUtils.shiftColor(tint1, 1.1f)
} }
tint = ColorUtils.adjustAlpha(tint, if (compatSwitch && !thumb) 0.5f else 1.0f) tint1 = ColorUtils.adjustAlpha(tint1, if (compatSwitch && !thumb) 0.5f else 1.0f)
val disabled: Int val disabled: Int
var normal: Int var normal: Int
if (thumb) { if (thumb) {
@ -375,7 +375,7 @@ object TintHelper {
intArrayOf(android.R.attr.state_enabled, android.R.attr.state_activated), intArrayOf(android.R.attr.state_enabled, android.R.attr.state_activated),
intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked) intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked)
), ),
intArrayOf(disabled, normal, tint, tint) intArrayOf(disabled, normal, tint1, tint1)
) )
return createTintedDrawable(from, sl) return createTintedDrawable(from, sl)
} }
@ -414,20 +414,20 @@ object TintHelper {
// This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise. // This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise.
@CheckResult @CheckResult
fun createTintedDrawable(drawable: Drawable?, @ColorInt color: Int): Drawable? { fun createTintedDrawable(drawable: Drawable?, @ColorInt color: Int): Drawable? {
var drawable: Drawable? = drawable ?: return null var drawable1: Drawable? = drawable ?: return null
drawable = DrawableCompat.wrap(drawable!!.mutate()) drawable1 = DrawableCompat.wrap(drawable1!!.mutate())
DrawableCompat.setTintMode(drawable!!, PorterDuff.Mode.SRC_IN) DrawableCompat.setTintMode(drawable1!!, PorterDuff.Mode.SRC_IN)
DrawableCompat.setTint(drawable, color) DrawableCompat.setTint(drawable1, color)
return drawable return drawable1
} }
// This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise. // This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise.
@CheckResult @CheckResult
fun createTintedDrawable(drawable: Drawable?, sl: ColorStateList): Drawable? { fun createTintedDrawable(drawable: Drawable?, sl: ColorStateList): Drawable? {
var drawable: Drawable? = drawable ?: return null var drawable1: Drawable? = drawable ?: return null
drawable = DrawableCompat.wrap(drawable!!.mutate()) drawable1 = DrawableCompat.wrap(drawable1!!.mutate())
DrawableCompat.setTintList(drawable!!, sl) DrawableCompat.setTintList(drawable1!!, sl)
return drawable return drawable1
} }
fun setCursorTint(editText: EditText, @ColorInt color: Int) { fun setCursorTint(editText: EditText, @ColorInt color: Int) {

@ -14,6 +14,7 @@ import kotlinx.coroutines.Deferred
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import retrofit2.Response import retrofit2.Response
import java.net.URLEncoder import java.net.URLEncoder
import java.util.* import java.util.*
@ -148,7 +149,7 @@ class AnalyzeUrl(
Method.POST -> { Method.POST -> {
bodyTxt?.let { bodyTxt?.let {
if (it.isJson()) { if (it.isJson()) {
body = RequestBody.create(jsonType, it) body = it.toRequestBody(jsonType)
} else { } else {
analyzeFields(it) analyzeFields(it)
} }

Loading…
Cancel
Save