mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 04:28:55 +01:00
Rewrote Theme
This commit is contained in:
@@ -40,7 +40,7 @@ inline fun Context.notification(func: NotificationCompat.Builder.() -> Unit): No
|
||||
/**
|
||||
* Property to get the notification manager from the context.
|
||||
*/
|
||||
val Context.notificationManager : NotificationManager
|
||||
val Context.notificationManager: NotificationManager
|
||||
get() = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
/**
|
||||
@@ -48,4 +48,4 @@ val Context.notificationManager : NotificationManager
|
||||
* @return the alarm manager.
|
||||
*/
|
||||
val Context.alarmManager: AlarmManager
|
||||
get() = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
get() = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.util
|
||||
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.graphics.drawable.DrawableCompat
|
||||
import android.widget.ImageView
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,9 @@ import android.widget.ImageView
|
||||
*/
|
||||
fun ImageView.setDrawableCompat(@DrawableRes drawable: Int?) {
|
||||
if (drawable != null) {
|
||||
setImageDrawable(ContextCompat.getDrawable(context, drawable))
|
||||
var drawable = ContextCompat.getDrawable(context, drawable)
|
||||
DrawableCompat.setTint(drawable,this.context.theme.getResourceColor(android.R.attr.textColorHint))
|
||||
setImageDrawable(drawable)
|
||||
} else {
|
||||
setImageResource(android.R.color.transparent)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.support.annotation.StringRes
|
||||
|
||||
fun Resources.Theme.getResourceColor(@StringRes resource: Int) : Int {
|
||||
val typedArray = this.obtainStyledAttributes(intArrayOf(resource))
|
||||
val attrValue = typedArray.getColor(0, 0)
|
||||
typedArray.recycle()
|
||||
return attrValue
|
||||
}
|
||||
|
||||
fun Resources.Theme.getResourceDrawable(@StringRes resource: Int) : Drawable {
|
||||
val typedArray = this.obtainStyledAttributes(intArrayOf(resource))
|
||||
val attrValue = typedArray.getDrawable(0)
|
||||
typedArray.recycle()
|
||||
return attrValue
|
||||
}
|
||||
Reference in New Issue
Block a user