Added default color drawable

This commit is contained in:
h4h13 2020-02-25 18:45:23 +05:30
parent 5bce11177f
commit d65314f4b8
47 changed files with 306 additions and 125 deletions

View file

@ -26,24 +26,19 @@ import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil
class ColorIconsImageView : AppCompatImageView {
class ColorIconsImageView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = -1
) : AppCompatImageView(context, attrs, defStyleAttr) {
constructor(context: Context) : super(context) {
init(context, null)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs)
}
private fun init(context: Context, attrs: AttributeSet?) {
init {
// Load the styled attributes and set their properties
val attributes = context.obtainStyledAttributes(attrs, R.styleable.ColorIconsImageView, 0, 0)
val color = attributes.getColor(R.styleable.ColorIconsImageView_iconBackgroundColor, Color.RED);
val attributes =
context.obtainStyledAttributes(attrs, R.styleable.ColorIconsImageView, 0, 0)
val color =
attributes.getColor(R.styleable.ColorIconsImageView_iconBackgroundColor, Color.RED);
setIconBackgroundColor(color)
attributes.recycle()
}
@ -53,7 +48,8 @@ class ColorIconsImageView : AppCompatImageView {
if (ATHUtil.isWindowBackgroundDark(context) && PreferenceUtil.getInstance(context).desaturatedColor()) {
val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f)
backgroundTintList = ColorStateList.valueOf(desaturatedColor)
imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorSurface))
imageTintList =
ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorSurface))
} else {
backgroundTintList = ColorStateList.valueOf(ColorUtil.adjustAlpha(color, 0.22f))
imageTintList = ColorStateList.valueOf(ColorUtil.withAlpha(color, 0.75f))

View file

@ -27,14 +27,24 @@ class RetroShapeableImageView @JvmOverloads constructor(
defStyle: Int = -1
) : ShapeableImageView(context, attrs, defStyle) {
init {
val typedArray =
context.obtainStyledAttributes(attrs, R.styleable.RetroShapeableImageView, defStyle, -1)
val cornerSize =
typedArray.getDimension(R.styleable.RetroShapeableImageView_retroCornerSize, 0f);
updateCornerSize(cornerSize)
typedArray.recycle()
}
fun updateCornerSize(cornerSize: Float) {
shapeAppearanceModel = ShapeAppearanceModel.Builder()
.setAllCorners(CornerFamily.ROUNDED, cornerSize)
.build()
typedArray.recycle()
}
//For square
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec)
}
}

View file

@ -24,31 +24,26 @@ import kotlinx.android.synthetic.main.list_setting_item_view.view.*
/**
* Created by hemanths on 2019-12-10.
*/
class SettingListItemView : FrameLayout {
constructor(context: Context) : super(context) {
init(context, null)
}
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
init(context, attrs)
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs)
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
init(context, attrs)
}
private fun init(context: Context, attributeSet: AttributeSet?) {
class SettingListItemView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = -1,
defStyleRes: Int = -1
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
init {
View.inflate(context, R.layout.list_setting_item_view, this)
val typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.SettingListItemView)
val typedArray =
context.obtainStyledAttributes(attrs, R.styleable.SettingListItemView)
icon as ColorIconsImageView
if (typedArray.hasValue(R.styleable.SettingListItemView_settingListItemIcon)) {
icon.setImageDrawable(typedArray.getDrawable(R.styleable.SettingListItemView_settingListItemIcon))
}
icon.setIconBackgroundColor(typedArray.getColor(R.styleable.SettingListItemView_settingListItemIconColor, Color.WHITE))
icon.setIconBackgroundColor(
typedArray.getColor(
R.styleable.SettingListItemView_settingListItemIconColor,
Color.WHITE
)
)
title.text = typedArray.getText(R.styleable.SettingListItemView_settingListItemTitle)
text.text = typedArray.getText(R.styleable.SettingListItemView_settingListItemText)
typedArray.recycle()