Rewrote Theme

This commit is contained in:
NoodleMage
2016-03-12 14:22:40 +01:00
committed by NoodleMage
parent 98d420d5aa
commit 5ef5f9b45f
112 changed files with 1078 additions and 1536 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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
}