Commit 1e7a6961 by likorn

AnswerCards are now checked instead of being highlighted

parent 538cc042
......@@ -3,6 +3,7 @@ package com.example.quickmax
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import androidx.core.content.ContextCompat
import com.google.android.material.card.MaterialCardView
class MyMaterialCard : MaterialCardView {
......@@ -23,13 +24,12 @@ class MyMaterialCard : MaterialCardView {
getTextView(this).setTextColor(color(context, R.color.transparent_black))
}
fun markCorrect() {
setCardBackgroundColor(color(context, R.color.colorAccent))
fun markCorrect(context: Context) {
foregroundTintList = ContextCompat.getColorStateList(context, R.color.colorAccent)
}
fun markWrong(context: Context) {
setCardBackgroundColor(color(context, R.color.colorPrimary))
getTextView(this).setTextColor(Color.WHITE)
foregroundTintList = ContextCompat.getColorStateList(context, R.color.red)
}
fun disable() {
......
......@@ -70,14 +70,14 @@ class TaskActivity : AppCompatActivity() {
btn_next.visibility = View.VISIBLE
if (answer.correct) {
answer.card.markCorrect()
answer.card.markCorrect(this@TaskActivity)
tv_response.text = resources.getString(R.string.response_correct)
btn_next.backgroundTintList = ContextCompat.getColorStateList(this, R.color.colorAccent)
btn_next.setTextColor(color(this, R.color.transparent_dark_black))
} else {
answer.card.markWrong(this@TaskActivity)
tv_response.text = resources.getString(R.string.response_wrong)
btn_next.backgroundTintList = ContextCompat.getColorStateList(this, (R.color.colorPrimary))
btn_next.backgroundTintList = ContextCompat.getColorStateList(this, R.color.colorPrimary)
btn_next.setTextColor(Color.WHITE)
}
}
......
......@@ -3,6 +3,6 @@
<gradient
android:angle="90"
android:endColor="@color/colorPrimary"
android:startColor="@color/colorAccent"
android:startColor="@color/transparentAccent"
android:type="linear" />
</shape>
\ No newline at end of file
......@@ -93,6 +93,7 @@
<com.example.quickmax.MyMaterialCard
android:id="@+id/card_left_top"
style="@style/MyCard"
app:cardBackgroundColor="#F44336"
app:cardCornerRadius="10dp"
app:layout_constraintBottom_toTopOf="@+id/card_left_bottom"
app:layout_constraintEnd_toStartOf="@+id/card_right_top"
......
......@@ -4,5 +4,7 @@
<color name="colorAccent">#4dd0e1</color>
<color name="transparent_black">#83000000</color>
<color name="transparent_dark_black">#BB000000</color>
<color name="transparent_red">#97FF0000</color>
<color name="transparent_red">#97F44336</color>
<color name="transparentAccent">#444DD0E1</color>
<color name="red">#FFF44336</color>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment