Skip to content
Snippets Groups Projects
Commit 3c8adffc authored by John's avatar John
Browse files

Merge branch 'patch' into 'master'

Automatically set issue label title color based on background color

Closes #281

See merge request Commit451/LabCoat!35
parents 5dde6dd6 37bb0180
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,7 +2,9 @@ package com.commit451.gitlab.extension
 
import android.graphics.Color
import android.support.annotation.ColorInt
import com.commit451.easel.Easel
import com.commit451.gitlab.model.api.Label
import com.commit451.gitlab.util.ColorUtil
 
@ColorInt
fun Label.getColor(): Int {
Loading
Loading
@@ -11,5 +13,12 @@ fun Label.getColor(): Int {
} catch (e: Exception) {
return Color.TRANSPARENT
}
}
 
@ColorInt
fun Label.getTitleColor(): Int {
if (Easel.isColorDark(getColor())) {
return Color.WHITE
}
return Easel.darkerColor(getColor(), 0.25f)
}
\ No newline at end of file
package com.commit451.gitlab.viewHolder
 
import android.graphics.Color
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
Loading
Loading
@@ -9,6 +10,7 @@ import butterknife.BindView
import butterknife.ButterKnife
import com.commit451.gitlab.R
import com.commit451.gitlab.extension.getColor
import com.commit451.gitlab.extension.getTitleColor
import com.commit451.gitlab.model.api.Label
 
/**
Loading
Loading
@@ -33,6 +35,7 @@ class AddLabelViewHolder(view: View) : RecyclerView.ViewHolder(view) {
 
fun bind(label: Label) {
textTitle.text = label.name
textTitle.setTextColor(label.getTitleColor())
textTitle.setBackgroundColor(label.getColor())
}
}
\ No newline at end of file
Loading
Loading
@@ -9,6 +9,7 @@ import butterknife.BindView
import butterknife.ButterKnife
import com.commit451.gitlab.R
import com.commit451.gitlab.extension.getColor
import com.commit451.gitlab.extension.getTitleColor
import com.commit451.gitlab.model.api.Label
 
/**
Loading
Loading
@@ -34,6 +35,7 @@ class LabelViewHolder(view: View) : RecyclerView.ViewHolder(view) {
 
fun bind(label: Label) {
textTitle.text = label.name
textTitle.setTextColor(label.getTitleColor())
viewColor.setBackgroundColor(label.getColor())
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment