Twidere-App-Android-Twitter.../twidere/src/main/kotlin/org/mariotaku/twidere/preference/TintedPreferenceCategory.kt

27 lines
959 B
Kotlin
Raw Normal View History

2017-02-05 06:03:18 +01:00
package org.mariotaku.twidere.preference
import android.content.Context
import android.support.v7.preference.PreferenceCategory
import android.support.v7.preference.PreferenceViewHolder
import android.util.AttributeSet
import android.widget.TextView
import org.mariotaku.chameleon.Chameleon
import org.mariotaku.chameleon.ChameleonUtils
2017-04-02 09:59:09 +02:00
import org.mariotaku.twidere.util.ThemeUtils
2017-02-05 06:03:18 +01:00
/**
* Created by mariotaku on 2017/2/5.
*/
open class TintedPreferenceCategory(context: Context, attrs: AttributeSet? = null) : PreferenceCategory(context, attrs) {
2017-04-02 09:59:09 +02:00
2017-02-05 06:03:18 +01:00
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val theme = Chameleon.getOverrideTheme(context, ChameleonUtils.getActivity(context))
val textView = holder.findViewById(android.R.id.title) as? TextView
2017-04-02 09:59:09 +02:00
textView?.setTextColor(ThemeUtils.getOptimalAccentColor(theme.colorAccent,
theme.colorForeground))
2017-02-05 06:03:18 +01:00
}
2017-04-02 09:59:09 +02:00
2017-02-05 06:03:18 +01:00
}