pull/1395/head
gedoor 3 years ago
parent 76cb917530
commit 57ef8d9b73
  1. 17
      app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt

@ -2,7 +2,6 @@
package io.legado.app.lib.theme package io.legado.app.lib.theme
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
@ -15,7 +14,6 @@ import io.legado.app.utils.dp
/** /**
* @author Karim Abou Zeid (kabouzeid) * @author Karim Abou Zeid (kabouzeid)
*/ */
@SuppressLint("PrivateResource")
@ColorInt @ColorInt
fun Context.getPrimaryTextColor(dark: Boolean): Int { fun Context.getPrimaryTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
@ -23,28 +21,31 @@ fun Context.getPrimaryTextColor(dark: Boolean): Int {
} else ContextCompat.getColor(this, R.color.primary_text_default_material_dark) } else ContextCompat.getColor(this, R.color.primary_text_default_material_dark)
} }
@SuppressLint("PrivateResource")
@ColorInt @ColorInt
fun Context.getSecondaryTextColor(dark: Boolean): Int { fun Context.getSecondaryTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, R.color.secondary_text_default_material_light) ContextCompat.getColor(this, R.color.secondary_text_default_material_light)
} else ContextCompat.getColor(this, R.color.secondary_text_default_material_dark) } else {
ContextCompat.getColor(this, R.color.secondary_text_default_material_dark)
}
} }
@SuppressLint("PrivateResource")
@ColorInt @ColorInt
fun Context.getPrimaryDisabledTextColor(dark: Boolean): Int { fun Context.getPrimaryDisabledTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, R.color.primary_text_disabled_material_light) ContextCompat.getColor(this, R.color.primary_text_disabled_material_light)
} else ContextCompat.getColor(this, R.color.primary_text_disabled_material_dark) } else {
ContextCompat.getColor(this, R.color.primary_text_disabled_material_dark)
}
} }
@SuppressLint("PrivateResource")
@ColorInt @ColorInt
fun Context.getSecondaryDisabledTextColor(dark: Boolean): Int { fun Context.getSecondaryDisabledTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, R.color.secondary_text_disabled_material_light) ContextCompat.getColor(this, R.color.secondary_text_disabled_material_light)
} else ContextCompat.getColor(this, R.color.secondary_text_disabled_material_dark) } else {
ContextCompat.getColor(this, R.color.secondary_text_disabled_material_dark)
}
} }
val Context.primaryColor: Int val Context.primaryColor: Int

Loading…
Cancel
Save