2020-07-17 16:35:39 +02:00
|
|
|
package sushi.hardcore.droidfs.widgets
|
|
|
|
|
|
|
|
import android.content.Context
|
2020-08-05 14:06:54 +02:00
|
|
|
import android.content.res.ColorStateList
|
2020-07-17 16:35:39 +02:00
|
|
|
import android.util.AttributeSet
|
2020-08-05 14:06:54 +02:00
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
2020-07-17 16:35:39 +02:00
|
|
|
|
|
|
|
class ColoredFAB: FloatingActionButton {
|
2020-08-05 14:06:54 +02:00
|
|
|
constructor(context: Context) : super(context) { applyColor() }
|
|
|
|
constructor(context: Context, attrs: AttributeSet): super(context, attrs) { applyColor() }
|
|
|
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int): super(context, attrs, defStyleAttr) { applyColor() }
|
2020-07-17 16:35:39 +02:00
|
|
|
private fun applyColor(){
|
|
|
|
val themeColor = ThemeColor.getThemeColor(context)
|
2020-08-05 14:06:54 +02:00
|
|
|
backgroundTintList = ColorStateList.valueOf(themeColor)
|
|
|
|
setColorFilter(ContextCompat.getColor(context, android.R.color.white))
|
2020-07-17 16:35:39 +02:00
|
|
|
}
|
|
|
|
}
|