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
2c5fa167
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Material library version
parent
5d376899
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
27 deletions
app/build.gradle
app/src/main/java/com/example/quickmax/MainActivity.kt
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/java/com/example/quickmax/ViewUtils.kt
app/src/main/res/layout/activity_task.xml
app/src/main/res/values/styles.xml
app/build.gradle
View file @
2c5fa167
...
...
@@ -30,11 +30,10 @@ dependencies {
implementation
'androidx.appcompat:appcompat:1.1.0'
implementation
'androidx.core:core-ktx:1.1.0'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'com.google.android.material:material:1.
0.
0'
implementation
'com.google.android.material:material:1.
1.0-alpha1
0'
implementation
'androidx.cardview:cardview:1.0.0'
implementation
'com.crystal:crystalrangeseekbar:1.1.3'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
...
...
app/src/main/java/com/example/quickmax/MainActivity.kt
View file @
2c5fa167
...
...
@@ -4,9 +4,7 @@ import android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.view.View
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
com.google.android.material.card.MaterialCardView
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
...
...
@@ -30,7 +28,7 @@ class MainActivity: AppCompatActivity() {
}
private
val
cardOnClickListener
=
View
.
OnClickListener
{
card
->
val
numDigits
=
((
card
as
MaterialCardView
).
getChildAt
(
0
)
as
TextView
).
text
.
toString
().
toInt
()
val
numDigits
=
getTextView
(
card
).
text
.
toString
().
toInt
()
saveSelectedValues
()
...
...
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
2c5fa167
...
...
@@ -9,7 +9,6 @@ import android.os.Bundle
import
android.os.CountDownTimer
import
android.util.TypedValue
import
android.view.View
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
com.example.quickmax.answers.Answer
...
...
@@ -47,8 +46,8 @@ class TaskActivity : AppCompatActivity() {
private
fun
setUpButtons
()
{
for
(
answer
in
answerSet
)
{
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
text
=
answer
.
value
.
toString
()
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
color
(
R
.
color
.
transparent_black
))
getTextView
(
answer
.
card
).
text
=
answer
.
value
.
toString
()
getTextView
(
answer
.
card
).
setTextColor
(
color
(
this
,
R
.
color
.
transparent_black
))
answer
.
card
.
setOnClickListener
{
processAnswer
(
answer
)
}
answer
.
card
.
setCardBackgroundColor
(
Color
.
WHITE
)
}
...
...
@@ -67,20 +66,20 @@ class TaskActivity : AppCompatActivity() {
}
private
fun
setResponseText
(
answer
:
Answer
)
{
tv_
timer
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
tv_
response
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
btn_next
.
visibility
=
View
.
VISIBLE
if
(
answer
.
correct
)
{
tv_
timer
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
answer
.
card
.
setCardBackgroundColor
(
color
(
R
.
color
.
colorAccent
))
tv_
response
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
answer
.
card
.
setCardBackgroundColor
(
color
(
this
,
R
.
color
.
colorAccent
))
btn_next
.
backgroundTintList
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
colorAccent
)
btn_next
.
setTextColor
(
color
(
R
.
color
.
transparent_dark_black
))
btn_next
.
setTextColor
(
color
(
this
,
R
.
color
.
transparent_dark_black
))
}
else
{
tv_
timer
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
answer
.
card
.
setCardBackgroundColor
(
color
(
R
.
color
.
colorPrimary
))
tv_
response
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
answer
.
card
.
setCardBackgroundColor
(
color
(
this
,
R
.
color
.
colorPrimary
))
btn_next
.
backgroundTintList
=
ContextCompat
.
getColorStateList
(
this
,
(
R
.
color
.
colorPrimary
))
btn_next
.
setTextColor
(
Color
.
WHITE
)
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
Color
.
WHITE
)
getTextView
(
answer
.
card
).
setTextColor
(
Color
.
WHITE
)
}
}
...
...
@@ -92,7 +91,7 @@ class TaskActivity : AppCompatActivity() {
private
fun
startProgressBarAnimation
()
{
val
colorFrom
=
Color
.
TRANSPARENT
val
colorTo
=
color
(
R
.
color
.
transparent_red
)
val
colorTo
=
color
(
this
,
R
.
color
.
transparent_red
)
colorAnimation
=
ValueAnimator
.
ofObject
(
ArgbEvaluator
(),
colorFrom
,
colorTo
)
colorAnimation
.
duration
=
millisToSolve
colorAnimation
.
addUpdateListener
{
animator
->
...
...
@@ -105,20 +104,16 @@ class TaskActivity : AppCompatActivity() {
private
fun
initTimer
()
{
timer
=
object
:
CountDownTimer
(
millisToSolve
,
1000
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
tv_
timer
.
text
=
(
millisUntilFinished
/
1000
).
toString
()
tv_
response
.
text
=
(
millisUntilFinished
/
1000
).
toString
()
}
override
fun
onFinish
()
{
tv_
timer
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
tv_
timer
.
text
=
resources
.
getString
(
R
.
string
.
time_is_over
)
btn_next
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorPrimary
),
PorterDuff
.
Mode
.
MULTIPLY
)
tv_
response
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
tv_
response
.
text
=
resources
.
getString
(
R
.
string
.
time_is_over
)
btn_next
.
background
.
setColorFilter
(
color
(
this
@TaskActivity
,
R
.
color
.
colorPrimary
),
PorterDuff
.
Mode
.
MULTIPLY
)
btn_next
.
setTextColor
(
Color
.
WHITE
)
btn_next
.
visibility
=
View
.
VISIBLE
}
}
}
private
fun
color
(
id
:
Int
):
Int
{
return
ContextCompat
.
getColor
(
this
,
id
)
}
}
app/src/main/java/com/example/quickmax/ViewUtils.kt
0 → 100644
View file @
2c5fa167
package
com.example.quickmax
import
android.content.Context
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.TextView
import
androidx.core.content.ContextCompat
import
com.google.android.material.card.MaterialCardView
fun
getTextView
(
card
:
View
):
TextView
{
return
((
card
as
MaterialCardView
).
getChildAt
(
0
)
as
FrameLayout
).
getChildAt
(
0
)
as
TextView
}
fun
color
(
context
:
Context
,
id
:
Int
):
Int
{
return
ContextCompat
.
getColor
(
context
,
id
)
}
\ No newline at end of file
app/src/main/res/layout/activity_task.xml
View file @
2c5fa167
...
...
@@ -32,7 +32,7 @@
</LinearLayout>
<TextView
android:id=
"@+id/tv_
timer
"
android:id=
"@+id/tv_
response
"
style=
"@style/TextAppearance.MaterialComponents.Headline4"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
...
...
app/src/main/res/values/styles.xml
View file @
2c5fa167
...
...
@@ -14,9 +14,9 @@
<item
name=
"android:layout_margin"
>
8dp
</item>
<item
name=
"android:clickable"
>
true
</item>
<item
name=
"android:focusable"
>
true
</item>
<item
name=
"android:foreground"
>
?attr/selectableItemBackground
</item>
<item
name=
"android:checkable"
>
true
</item>
<item
name=
"android:selectable"
>
true
</item>
<item
name=
"cardCornerRadius"
>
6dp
</item>
<item
name=
"cardBackgroundColor"
>
@android:color/white
</item>
</style>
<style
name=
"AnswerCardText"
>
...
...
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