@ -332,11 +332,11 @@ object TintHelper {
compatSwitch : Boolean ,
compatSwitch : Boolean ,
useDarker : Boolean
useDarker : Boolean
) : Drawable ? {
) : Drawable ? {
var tint = tint
var tint1 = tint
if ( useDarker ) {
if ( useDarker ) {
tint = ColorUtils . shiftColor ( tint , 1.1f )
tint1 = ColorUtils . shiftColor ( tint1 , 1.1f )
}
}
tint = ColorUtils . adjustAlpha ( tint , if ( compatSwitch && ! thumb ) 0.5f else 1.0f )
tint1 = ColorUtils . adjustAlpha ( tint1 , if ( compatSwitch && ! thumb ) 0.5f else 1.0f )
val disabled : Int
val disabled : Int
var normal : Int
var normal : Int
if ( thumb ) {
if ( thumb ) {
@ -375,7 +375,7 @@ object TintHelper {
intArrayOf ( android . R . attr . state _enabled , android . R . attr . state _activated ) ,
intArrayOf ( android . R . attr . state _enabled , android . R . attr . state _activated ) ,
intArrayOf ( android . R . attr . state _enabled , android . R . attr . state _checked )
intArrayOf ( android . R . attr . state _enabled , android . R . attr . state _checked )
) ,
) ,
intArrayOf ( disabled , normal , tint , tint )
intArrayOf ( disabled , normal , tint1 , tint1 )
)
)
return createTintedDrawable ( from , sl )
return createTintedDrawable ( from , sl )
}
}
@ -414,20 +414,20 @@ object TintHelper {
// This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise.
// This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise.
@CheckResult
@CheckResult
fun createTintedDrawable ( drawable : Drawable ? , @ColorInt color : Int ) : Drawable ? {
fun createTintedDrawable ( drawable : Drawable ? , @ColorInt color : Int ) : Drawable ? {
var drawable : Drawable ? = drawable ?: return null
var drawable1 : Drawable ? = drawable ?: return null
drawable = DrawableCompat . wrap ( drawable !! . mutate ( ) )
drawable1 = DrawableCompat . wrap ( drawable1 !! . mutate ( ) )
DrawableCompat . setTintMode ( drawable !! , PorterDuff . Mode . SRC _IN )
DrawableCompat . setTintMode ( drawable1 !! , PorterDuff . Mode . SRC _IN )
DrawableCompat . setTint ( drawable , color )
DrawableCompat . setTint ( drawable1 , color )
return drawable
return drawable1
}
}
// This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise.
// This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise.
@CheckResult
@CheckResult
fun createTintedDrawable ( drawable : Drawable ? , sl : ColorStateList ) : Drawable ? {
fun createTintedDrawable ( drawable : Drawable ? , sl : ColorStateList ) : Drawable ? {
var drawable : Drawable ? = drawable ?: return null
var drawable1 : Drawable ? = drawable ?: return null
drawable = DrawableCompat . wrap ( drawable !! . mutate ( ) )
drawable1 = DrawableCompat . wrap ( drawable1 !! . mutate ( ) )
DrawableCompat . setTintList ( drawable !! , sl )
DrawableCompat . setTintList ( drawable1 !! , sl )
return drawable
return drawable1
}
}
fun setCursorTint ( editText : EditText , @ColorInt color : Int ) {
fun setCursorTint ( editText : EditText , @ColorInt color : Int ) {