Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
quick_max
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b6d125e
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Response is displayed at timer's place
parent
4079ae8a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
29 deletions
app/src/main/java/com/example/quickmax/ResponseFragment.kt
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/res/layout/activity_task.xml
app/src/main/res/layout/fragment_response.xml
app/src/main/res/values/dimens.xml
app/src/main/java/com/example/quickmax/ResponseFragment.kt
View file @
4b6d125e
...
...
@@ -6,7 +6,6 @@ import android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
com.google.android.material.button.MaterialButton
...
...
@@ -25,17 +24,12 @@ class ResponseFragment: Fragment() {
val
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_response
,
container
,
false
)
val
correct
=
arguments
!!
.
getBoolean
(
"correct"
)
return
if
(
correct
)
view
(
view
,
color
(
R
.
color
.
colorAccent
),
R
.
string
.
response_correct
,
color
(
R
.
color
.
transparent_dark_black
))
view
(
view
,
color
(
R
.
color
.
colorAccent
),
color
(
R
.
color
.
transparent_dark_black
))
else
view
(
view
,
color
(
R
.
color
.
colorPrimary
),
R
.
string
.
response_wrong
,
Color
.
WHITE
)
}
private
fun
view
(
view
:
View
,
color
:
Int
,
responseId
:
Int
,
textColor
:
Int
):
View
{
view
.
findViewById
<
TextView
>(
R
.
id
.
tv_response
).
apply
{
text
=
resources
.
getString
(
responseId
)
setTextColor
(
color
)
view
(
view
,
color
(
R
.
color
.
colorPrimary
),
Color
.
WHITE
)
}
private
fun
view
(
view
:
View
,
color
:
Int
,
textColor
:
Int
):
View
{
view
.
findViewById
<
MaterialButton
>(
R
.
id
.
btn_next
).
apply
{
background
.
setColorFilter
(
color
,
PorterDuff
.
Mode
.
MULTIPLY
)
setTextColor
(
textColor
)
...
...
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
4b6d125e
...
...
@@ -6,6 +6,7 @@ import android.content.Intent
import
android.graphics.Color
import
android.os.Bundle
import
android.os.CountDownTimer
import
android.util.TypedValue
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
...
...
@@ -50,15 +51,24 @@ class TaskActivity : AppCompatActivity() {
private
fun
processAnswer
(
answer
:
Answer
)
{
timer
.
cancel
()
colorAnimation
.
cancel
()
if
(
answer
.
correct
)
setResponseText
(
answer
)
makeButtonsUncheckable
()
startResponseFragment
(
answer
)
}
private
fun
setResponseText
(
answer
:
Answer
)
{
tv_timer
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
if
(
answer
.
correct
)
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
answer
.
card
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorAccent
))
else
{
}
else
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
answer
.
card
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorPrimary
))
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
Color
.
WHITE
)
}
}
makeButtonsUncheckable
()
private
fun
startResponseFragment
(
answer
:
Answer
)
{
val
responseFragment
=
ResponseFragment
.
newInstance
().
also
{
f
->
f
.
arguments
=
Bundle
().
also
{
b
->
b
.
putBoolean
(
"correct"
,
answer
.
correct
)
}
}
...
...
app/src/main/res/layout/activity_task.xml
View file @
4b6d125e
...
...
@@ -38,7 +38,7 @@
android:gravity=
"center"
android:text=
"@string/number_digits_3"
android:textColor=
"@android:color/white"
a
pp:autoSizeTextType=
"uniform
"
a
ndroid:textSize=
"60sp
"
app:layout_constraintBottom_toTopOf=
"@+id/cv_task"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
app/src/main/res/layout/fragment_response.xml
View file @
4b6d125e
...
...
@@ -3,7 +3,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/response_layout"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_cont
ent"
android:layout_height=
"
match_par
ent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
...
...
@@ -12,22 +12,10 @@
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginBottom=
"8dp"
android:text=
"@string/btn_next"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintEnd_toEndOf=
"parent"
/>
<TextView
android:id=
"@+id/tv_response"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"24dp"
android:textAppearance=
"@style/TextAppearance.MaterialComponents.Headline5"
android:textColor=
"@android:color/white"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/dimens.xml
0 → 100644
View file @
4b6d125e
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen
name=
"response_text_size"
>
20sp
</dimen>
</resources>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment