PlayerAndroid/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt

37 lines
1.3 KiB
Kotlin
Raw Normal View History

/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.extensions
2019-12-01 15:27:01 +00:00
import android.content.Context
2019-12-16 05:06:08 +00:00
import android.content.res.ColorStateList
2019-12-01 15:27:01 +00:00
import android.graphics.Color
2019-12-16 05:06:08 +00:00
import androidx.appcompat.widget.Toolbar
2019-12-01 15:27:01 +00:00
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
2019-12-01 15:27:01 +00:00
import code.name.monkey.retromusic.R
fun Int.ripAlpha(): Int {
return ColorUtil.stripAlpha(this)
2019-12-01 15:27:01 +00:00
}
fun Any.surfaceColor(context: Context): Int {
return ATHUtil.resolveColor(context, R.attr.colorSurface, Color.WHITE)
2019-12-16 05:06:08 +00:00
}
fun Toolbar.backgroundTintList() {
val surfaceColor = ATHUtil.resolveColor(context, R.attr.colorSurface, Color.BLACK)
val colorStateList = ColorStateList.valueOf(surfaceColor)
backgroundTintList = colorStateList
}