From 514d1e11aa30b11806f3d38206c418036751fc92 Mon Sep 17 00:00:00 2001 From: Dominik Korsa Date: Sat, 2 Mar 2019 19:41:38 +0100 Subject: [PATCH] Update grade colors (#231) --- .../modules/grade/details/GradeDetailsDialog.kt | 5 +++-- .../ui/modules/grade/details/GradeDetailsItem.kt | 9 +++++---- .../grade/details/GradeDetailsPresenter.kt | 4 ++-- .../io/github/wulkanowy/utils/GradeExtension.kt | 2 +- app/src/main/res/values/colors.xml | 15 ++++++++------- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt index 19b462b1b..491caa069 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt @@ -5,12 +5,13 @@ import android.view.LayoutInflater import android.view.View import android.view.View.GONE import android.view.ViewGroup +import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Grade import io.github.wulkanowy.utils.colorStringId import io.github.wulkanowy.utils.toFormattedString -import io.github.wulkanowy.utils.valueColor +import io.github.wulkanowy.utils.valueBgColor import kotlinx.android.synthetic.main.dialog_grade.* @@ -57,7 +58,7 @@ class GradeDetailsDialog : DialogFragment() { gradeDialogValue.run { text = grade.entry - setBackgroundResource(grade.valueColor) + setBackgroundResource(grade.valueBgColor) } gradeDialogTeacherValue.text = if (grade.teacher.isBlank()) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt index e522a7805..ab958bc26 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.view.View import android.view.View.GONE import android.view.View.VISIBLE +import androidx.core.content.ContextCompat import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.AbstractFlexibleItem import eu.davidea.flexibleadapter.items.IFlexible @@ -14,7 +15,7 @@ import io.github.wulkanowy.utils.toFormattedString import kotlinx.android.extensions.LayoutContainer import kotlinx.android.synthetic.main.item_grade_details.* -class GradeDetailsItem(val grade: Grade, private val weightString: String, private val valueColor: Int) : +class GradeDetailsItem(val grade: Grade, private val weightString: String, private val valueBgColor: Int) : AbstractFlexibleItem() { override fun getLayoutRes() = R.layout.item_grade_details @@ -31,7 +32,7 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva holder.run { gradeItemValue.run { text = grade.entry - setBackgroundResource(valueColor) + setBackgroundResource(valueBgColor) } gradeItemDescription.text = if (grade.description.isNotBlank()) grade.description else grade.gradeSymbol gradeItemDate.text = grade.date.toFormattedString() @@ -49,7 +50,7 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva if (grade != other.grade) return false if (grade.id != other.grade.id) return false if (weightString != other.weightString) return false - if (valueColor != other.valueColor) return false + if (valueBgColor != other.valueBgColor) return false return true } @@ -58,7 +59,7 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva var result = grade.hashCode() result = 31 * result + grade.id.toInt() result = 31 * result + weightString.hashCode() - result = 31 * result + valueColor + result = 31 * result + valueBgColor return result } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt index 2d5b64b48..a0d9d2086 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt @@ -12,7 +12,7 @@ import io.github.wulkanowy.utils.FirebaseAnalyticsHelper import io.github.wulkanowy.utils.SchedulersProvider import io.github.wulkanowy.utils.calcAverage import io.github.wulkanowy.utils.changeModifier -import io.github.wulkanowy.utils.valueColor +import io.github.wulkanowy.utils.valueBgColor import timber.log.Timber import javax.inject.Inject @@ -151,7 +151,7 @@ class GradeDetailsPresenter @Inject constructor( GradeDetailsItem( grade = item, weightString = view?.weightString.orEmpty(), - valueColor = item.valueColor + valueBgColor = item.valueBgColor ) } } diff --git a/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt b/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt index cbf464cc3..cb1967ad2 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt @@ -22,7 +22,7 @@ fun List.calcAverage(): Double { }.average().let { if (it.isNaN()) 0.0 else it } } -inline val Grade.valueColor: Int +inline val Grade.valueBgColor: Int get() { return when (value) { 6 -> R.color.grade_six diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 5b1dba26a..deff45fbd 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,14 +5,15 @@ #ff6659 #f0f0f0 + #03a9f4 + #4caf50 + #92c400 + #ffa000 + #ff5722 + #d32f2f + #607d8b + #ffffff - #91b43c - #2cbd92 - #50b6d6 - #d2ab24 - #9071b3 - #d65757 - #3d5f9c #303030 #ffffff