Hmm somethings are changed
This commit is contained in:
parent
8dfb0dc8dd
commit
423b26be66
76 changed files with 410 additions and 234 deletions
|
@ -22,7 +22,7 @@ object ATH {
|
|||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
fun didThemeValuesChange(context: Context, since: Long): Boolean {
|
||||
return ThemeStore.isConfigured(context) && ThemeStore.prefs(context).getLong(ThemeStore.VALUES_CHANGED, -1) > since
|
||||
return ThemeStore.isConfigured(context) && ThemeStore.prefs(context).getLong(ThemeStorePrefKeys.VALUES_CHANGED, -1) > since
|
||||
}
|
||||
|
||||
fun setStatusbarColorAuto(activity: Activity) {
|
||||
|
@ -105,7 +105,7 @@ object ATH {
|
|||
// Task description requires fully opaque color
|
||||
colorFinal = ColorUtil.stripAlpha(colorFinal)
|
||||
// Sets color of entry in the system recents page
|
||||
activity.setTaskDescription(ActivityManager.TaskDescription(activity.title as String, null, colorFinal))
|
||||
activity.setTaskDescription(ActivityManager.TaskDescription(activity.title as String?, null, colorFinal))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
}
|
||||
|
||||
@CheckResult
|
||||
protected fun prefs(context: Context): SharedPreferences {
|
||||
fun prefs(context: Context): SharedPreferences {
|
||||
return context.getSharedPreferences(ThemeStorePrefKeys.CONFIG_PREFS_KEY_DEFAULT, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.preference.CheckBoxPreference
|
||||
import android.preference.Preference
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.CheckBox
|
||||
|
||||
import code.name.monkey.appthemehelper.ATH
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
|
@ -17,12 +14,25 @@ import code.name.monkey.appthemehelper.ThemeStore
|
|||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATECheckBoxPreference @TargetApi(Build.VERSION_CODES.LOLLIPOP) constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : CheckBoxPreference(context, attrs, defStyleAttr, defStyleRes) {
|
||||
class ATECheckBoxPreference : CheckBoxPreference {
|
||||
|
||||
init {
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom
|
||||
|
||||
|
|
|
@ -4,23 +4,34 @@ import android.content.Context
|
|||
import android.preference.Preference
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEColorPreference(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : Preference(context, attrs, defStyleAttr) {
|
||||
class ATEColorPreference : Preference {
|
||||
|
||||
private var mView: View? = null
|
||||
private var color: Int = 0
|
||||
private var border: Int = 0
|
||||
|
||||
init {
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom
|
||||
widgetLayoutResource = R.layout.ate_preference_color
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import com.afollestad.materialdialogs.prefs.MaterialDialogPreference
|
||||
|
||||
|
@ -8,12 +9,25 @@ import com.afollestad.materialdialogs.prefs.MaterialDialogPreference
|
|||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEDialogPreference(context: Context) : MaterialDialogPreference(context) {
|
||||
class ATEDialogPreference : MaterialDialogPreference {
|
||||
|
||||
init {
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom
|
||||
}
|
||||
|
|
|
@ -8,12 +8,25 @@ import com.afollestad.materialdialogs.prefs.MaterialEditTextPreference
|
|||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEEditTextPreference(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : MaterialEditTextPreference(context, attrs, defStyleAttr, defStyleRes) {
|
||||
class ATEEditTextPreference : MaterialEditTextPreference {
|
||||
|
||||
init {
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
layoutResource = code.name.monkey.appthemehelper.R.layout.ate_preference_custom
|
||||
}
|
||||
|
|
|
@ -2,16 +2,27 @@ package code.name.monkey.appthemehelper.common.prefs
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
|
||||
import com.afollestad.materialdialogs.prefs.MaterialListPreference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import com.afollestad.materialdialogs.prefs.MaterialListPreference
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEMultiSelectPreference(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : MaterialListPreference(context, attrs, defStyleAttr, defStyleRes) {
|
||||
class ATEMultiSelectPreference : MaterialListPreference {
|
||||
|
||||
init {
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,32 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.preference.Preference
|
||||
import android.util.AttributeSet
|
||||
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEPreference @TargetApi(Build.VERSION_CODES.LOLLIPOP) constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : Preference(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
init {
|
||||
init(context, attrs)
|
||||
class ATEPreference : Preference {
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init(context: Context, attrs: AttributeSet?) {
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom
|
||||
}
|
||||
}
|
|
@ -1,16 +1,28 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.preference.PreferenceCategory
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
|
||||
class ATEPreferenceCategory @TargetApi(Build.VERSION_CODES.LOLLIPOP) constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) {
|
||||
class ATEPreferenceCategory : PreferenceCategory {
|
||||
constructor(context: Context) : super(context) {
|
||||
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
}
|
||||
|
||||
override fun onBindView(view: View) {
|
||||
super.onBindView(view)
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import android.util.AttributeSet
|
||||
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
|
||||
|
@ -15,23 +12,22 @@ import code.name.monkey.appthemehelper.R
|
|||
class ATECheckBoxPreference : CheckBoxPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init(context, null)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init(context: Context, attrs: AttributeSet?) {
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
widgetLayoutResource = R.layout.ate_preference_checkbox
|
||||
}
|
||||
|
|
|
@ -13,22 +13,22 @@ import code.name.monkey.appthemehelper.R
|
|||
open class ATEDialogPreference : DialogPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init(context, null)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init(context: Context, attrs: AttributeSet?) {
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
}
|
||||
}
|
|
@ -10,25 +10,26 @@ import code.name.monkey.appthemehelper.R
|
|||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEEditTextPreference : EditTextPreference {
|
||||
class ATEEditTextPreference : EditTextPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init(context, null)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init(context: Context, attrs: AttributeSet?) {
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,22 +12,22 @@ import code.name.monkey.appthemehelper.R
|
|||
class ATEListPreference : ListPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init(context, null)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init(context: Context, attrs: AttributeSet?) {
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
if (summary == null || summary.toString().trim { it <= ' ' }.isEmpty())
|
||||
summary = "%s"
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.preference.Preference
|
||||
import android.util.AttributeSet
|
||||
|
||||
import androidx.preference.Preference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
/**
|
||||
|
@ -14,23 +11,23 @@ import code.name.monkey.appthemehelper.R
|
|||
class ATEPreference : Preference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init(context, null)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init(context: Context, attrs: AttributeSet?) {
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
}
|
||||
}
|
|
@ -1,42 +1,39 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import android.util.AttributeSet
|
||||
import android.widget.TextView
|
||||
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
|
||||
class ATEPreferenceCategory : PreferenceCategory {
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init(context, attrs)
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init(context, attrs)
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init(context, attrs)
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
val mTitle = holder.itemView as TextView
|
||||
mTitle.setTextColor(ThemeStore.accentColor(context))
|
||||
}
|
||||
|
||||
private fun init(context: Context, attrs: AttributeSet?) {
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_category
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,37 @@ package code.name.monkey.appthemehelper.common.prefs.supportv7
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
|
||||
import android.widget.SeekBar
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import androidx.preference.SeekBarPreference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
|
||||
class ATESeekBarPreference(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : SeekBarPreference(context, attrs, defStyleAttr, defStyleRes)
|
||||
class ATESeekBarPreference : SeekBarPreference {
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(view: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(view)
|
||||
val seekBar = view.findViewById(R.id.seekbar) as SeekBar
|
||||
TintHelper.setTintAuto(seekBar, ThemeStore.accentColor(context), true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ object ATHUtil {
|
|||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun resolveColor(context: Context, @AttrRes attr: Int, fallback: Int = 0): Int {
|
||||
val a = context.theme.obtainStyledAttributes(intArrayOf(attr))
|
||||
fun resolveColor(context: Context?, @AttrRes attr: Int, fallback: Int = 0): Int {
|
||||
val a = context!!.theme.obtainStyledAttributes(intArrayOf(attr))
|
||||
try {
|
||||
return a.getColor(0, fallback)
|
||||
} finally {
|
||||
|
|
|
@ -12,33 +12,33 @@ object MaterialValueHelper {
|
|||
|
||||
@SuppressLint("PrivateResource")
|
||||
@ColorInt
|
||||
fun getPrimaryTextColor(context: Context, dark: Boolean): Int {
|
||||
fun getPrimaryTextColor(context: Context?, dark: Boolean): Int {
|
||||
return if (dark) {
|
||||
ContextCompat.getColor(context, R.color.primary_text_default_material_light)
|
||||
} else ContextCompat.getColor(context, R.color.primary_text_default_material_dark)
|
||||
ContextCompat.getColor(context!!, R.color.primary_text_default_material_light)
|
||||
} else ContextCompat.getColor(context!!, R.color.primary_text_default_material_dark)
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateResource")
|
||||
@ColorInt
|
||||
fun getSecondaryTextColor(context: Context, dark: Boolean): Int {
|
||||
fun getSecondaryTextColor(context: Context?, dark: Boolean): Int {
|
||||
return if (dark) {
|
||||
ContextCompat.getColor(context, R.color.secondary_text_default_material_light)
|
||||
} else ContextCompat.getColor(context, R.color.secondary_text_default_material_dark)
|
||||
ContextCompat.getColor(context!!, R.color.secondary_text_default_material_light)
|
||||
} else ContextCompat.getColor(context!!, R.color.secondary_text_default_material_dark)
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateResource")
|
||||
@ColorInt
|
||||
fun getPrimaryDisabledTextColor(context: Context, dark: Boolean): Int {
|
||||
fun getPrimaryDisabledTextColor(context: Context?, dark: Boolean): Int {
|
||||
return if (dark) {
|
||||
ContextCompat.getColor(context, R.color.primary_text_disabled_material_light)
|
||||
} else ContextCompat.getColor(context, R.color.primary_text_disabled_material_dark)
|
||||
ContextCompat.getColor(context!!, R.color.primary_text_disabled_material_light)
|
||||
} else ContextCompat.getColor(context!!, R.color.primary_text_disabled_material_dark)
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateResource")
|
||||
@ColorInt
|
||||
fun getSecondaryDisabledTextColor(context: Context, dark: Boolean): Int {
|
||||
fun getSecondaryDisabledTextColor(context: Context?, dark: Boolean): Int {
|
||||
return if (dark) {
|
||||
ContextCompat.getColor(context, R.color.secondary_text_disabled_material_light)
|
||||
} else ContextCompat.getColor(context, R.color.secondary_text_disabled_material_dark)
|
||||
ContextCompat.getColor(context!!, R.color.secondary_text_disabled_material_light)
|
||||
} else ContextCompat.getColor(context!!, R.color.secondary_text_disabled_material_dark)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue