Commit 1e7a6961 by likorn

AnswerCards are now checked instead of being highlighted

parent 538cc042
...@@ -3,6 +3,7 @@ package com.example.quickmax ...@@ -3,6 +3,7 @@ package com.example.quickmax
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import androidx.core.content.ContextCompat
import com.google.android.material.card.MaterialCardView import com.google.android.material.card.MaterialCardView
class MyMaterialCard : MaterialCardView { class MyMaterialCard : MaterialCardView {
...@@ -16,24 +17,23 @@ class MyMaterialCard : MaterialCardView { ...@@ -16,24 +17,23 @@ class MyMaterialCard : MaterialCardView {
) )
fun clean(context: Context) { fun clean(context: Context) {
isCheckable = true isCheckable = true
isEnabled = true isEnabled = true
isChecked = false isChecked = false
setCardBackgroundColor(Color.WHITE) setCardBackgroundColor(Color.WHITE)
getTextView(this).setTextColor(color(context, R.color.transparent_black)) getTextView(this).setTextColor(color(context, R.color.transparent_black))
} }
fun markCorrect() { fun markCorrect(context: Context) {
setCardBackgroundColor(color(context, R.color.colorAccent)) foregroundTintList = ContextCompat.getColorStateList(context, R.color.colorAccent)
} }
fun markWrong(context: Context) { fun markWrong(context: Context) {
setCardBackgroundColor(color(context, R.color.colorPrimary)) foregroundTintList = ContextCompat.getColorStateList(context, R.color.red)
getTextView(this).setTextColor(Color.WHITE)
} }
fun disable() { fun disable() {
isCheckable = false isCheckable = false
isEnabled = false isEnabled = false
} }
} }
\ No newline at end of file
...@@ -70,14 +70,14 @@ class TaskActivity : AppCompatActivity() { ...@@ -70,14 +70,14 @@ class TaskActivity : AppCompatActivity() {
btn_next.visibility = View.VISIBLE btn_next.visibility = View.VISIBLE
if (answer.correct) { if (answer.correct) {
answer.card.markCorrect() answer.card.markCorrect(this@TaskActivity)
tv_response.text = resources.getString(R.string.response_correct) tv_response.text = resources.getString(R.string.response_correct)
btn_next.backgroundTintList = ContextCompat.getColorStateList(this, R.color.colorAccent) btn_next.backgroundTintList = ContextCompat.getColorStateList(this, R.color.colorAccent)
btn_next.setTextColor(color(this, R.color.transparent_dark_black)) btn_next.setTextColor(color(this, R.color.transparent_dark_black))
} else { } else {
answer.card.markWrong(this@TaskActivity) answer.card.markWrong(this@TaskActivity)
tv_response.text = resources.getString(R.string.response_wrong) 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) btn_next.setTextColor(Color.WHITE)
} }
} }
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
<gradient <gradient
android:angle="90" android:angle="90"
android:endColor="@color/colorPrimary" android:endColor="@color/colorPrimary"
android:startColor="@color/colorAccent" android:startColor="@color/transparentAccent"
android:type="linear" /> android:type="linear" />
</shape> </shape>
\ No newline at end of file
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
<com.example.quickmax.MyMaterialCard <com.example.quickmax.MyMaterialCard
android:id="@+id/card_left_top" android:id="@+id/card_left_top"
style="@style/MyCard" style="@style/MyCard"
app:cardBackgroundColor="#F44336"
app:cardCornerRadius="10dp" app:cardCornerRadius="10dp"
app:layout_constraintBottom_toTopOf="@+id/card_left_bottom" app:layout_constraintBottom_toTopOf="@+id/card_left_bottom"
app:layout_constraintEnd_toStartOf="@+id/card_right_top" app:layout_constraintEnd_toStartOf="@+id/card_right_top"
......
...@@ -4,5 +4,7 @@ ...@@ -4,5 +4,7 @@
<color name="colorAccent">#4dd0e1</color> <color name="colorAccent">#4dd0e1</color>
<color name="transparent_black">#83000000</color> <color name="transparent_black">#83000000</color>
<color name="transparent_dark_black">#BB000000</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> </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