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
70ac0fd1
authored
Sep 24, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP MainActivity
parent
e9056a6a
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
366 additions
and
234 deletions
app/src/androidTest/java/com/example/quickmax/MainActivityTest.kt → app/src/androidTest/java/com/example/quickmax/TaskActivityTest.kt
app/src/main/AndroidManifest.xml
app/src/main/java/com/example/quickmax/MainActivity.kt
app/src/main/java/com/example/quickmax/ResponseFragment.kt
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/java/com/example/quickmax/TimeIsOverFragment.kt
app/src/main/java/com/example/quickmax/Answer.kt → app/src/main/java/com/example/quickmax/answers/Answer.kt
app/src/main/java/com/example/quickmax/AnswerSet.kt → app/src/main/java/com/example/quickmax/answers/AnswerSet.kt
app/src/main/java/com/example/quickmax/Calculator.kt → app/src/main/java/com/example/quickmax/answers/Calculator.kt
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_task.xml
app/src/main/res/layout/fragment_time_is_over.xml
app/src/main/res/values/colors.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml
app/src/test/java/com/example/quickmax/AnswerSetTest.kt
app/src/test/java/com/example/quickmax/CalculatorTest.kt
app/src/androidTest/java/com/example/quickmax/
Main
ActivityTest.kt
→
app/src/androidTest/java/com/example/quickmax/
Task
ActivityTest.kt
View file @
70ac0fd1
...
...
@@ -11,14 +11,15 @@ import androidx.test.espresso.UiController
import
androidx.test.espresso.action.ViewActions.click
import
androidx.test.espresso.assertion.ViewAssertions.matches
import
androidx.test.espresso.matcher.ViewMatchers.*
import
com.example.quickmax.answers.findSecondMax
import
junit.framework.Assert.assertNotNull
import
junit.framework.Assert.assertTrue
import
org.hamcrest.Matcher
import
org.junit.Before
class
Main
ActivityTest
{
class
Task
ActivityTest
{
@get
:
Rule
val
testRule
=
ActivityTestRule
<
MainActivity
>(
Main
Activity
::
class
.
java
,
true
,
true
)
val
testRule
=
ActivityTestRule
<
TaskActivity
>(
Task
Activity
::
class
.
java
,
true
,
true
)
private
lateinit
var
answers
:
Map
<
Int
,
Int
>
...
...
app/src/main/AndroidManifest.xml
View file @
70ac0fd1
...
...
@@ -9,8 +9,10 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".
Main
Activity"
<activity
android:name=
".
Task
Activity"
android:theme=
"@style/Theme.MaterialComponents.Light.NoActionBar"
>
</activity>
<activity
android:name=
".MainActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
app/src/main/java/com/example/quickmax/MainActivity.kt
View file @
70ac0fd1
package
com.example.quickmax
import
android.animation.ArgbEvaluator
import
android.animation.ValueAnimator
import
android.os.Build
import
android.os.Bundle
import
android.os.CountDownTimer
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.cardview.widget.CardView
import
androidx.core.content.ContextCompat
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
private
lateinit
var
answerSet
:
AnswerSet
private
val
timeToSolve
:
Long
=
4000
class
MainActivity
:
AppCompatActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_main
)
answerSet
=
AnswerSet
(
3
)
setUpAnswerButtons
()
timer
.
start
()
startProgressBarAnimation
()
}
private
fun
setUpAnswerButtons
()
{
for
(
answer
in
answerSet
)
{
(
findViewById
<
CardView
>(
answer
.
buttonId
).
getChildAt
(
0
)
as
TextView
).
text
=
answer
.
value
.
toString
()
findViewById
<
CardView
>(
answer
.
buttonId
).
setOnClickListener
{
processAnswer
(
answer
.
correct
)
}
}
}
private
fun
processAnswer
(
correct
:
Boolean
)
{
timer
.
cancel
()
makeButtonsUncheckable
()
val
responseFragment
=
ResponseFragment
.
newInstance
().
also
{
f
->
f
.
arguments
=
Bundle
().
also
{
b
->
b
.
putBoolean
(
"correct"
,
correct
)
}
}
supportFragmentManager
.
beginTransaction
()
.
add
(
R
.
id
.
main_layout
,
responseFragment
,
"response"
)
.
commitAllowingStateLoss
()
}
private
fun
makeButtonsUncheckable
()
{
for
(
answer
in
answerSet
)
{
findViewById
<
CardView
>(
answer
.
buttonId
).
isClickable
=
false
}
}
private
fun
startProgressBarAnimation
()
{
val
colorFrom
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
gradient_dark
)
val
colorTo
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
red
)
val
colorAnimation
=
ValueAnimator
.
ofObject
(
ArgbEvaluator
(),
colorFrom
,
colorTo
)
colorAnimation
.
duration
=
timeToSolve
colorAnimation
.
addUpdateListener
{
animator
->
progress_bar
.
progressDrawable
.
setColorFilter
(
animator
.
animatedValue
as
Int
,
android
.
graphics
.
PorterDuff
.
Mode
.
SRC_ATOP
)
}
colorAnimation
.
start
()
}
fun
reload
()
{
val
intent
=
intent
finish
()
startActivity
(
intent
)
}
private
val
timer
=
object
:
CountDownTimer
(
timeToSolve
,
100
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
val
progress
=
((
timeToSolve
-
millisUntilFinished
).
toFloat
()
/
timeToSolve
)
*
100
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
progress_bar
.
setProgress
(
progress
.
toInt
(),
true
)
else
progress_bar
.
progress
=
progress
.
toInt
()
}
override
fun
onFinish
()
{
cv_task
.
elevation
=
0f
makeButtonsUncheckable
()
supportFragmentManager
.
beginTransaction
()
.
replace
(
R
.
id
.
main_layout
,
TimeIsOverFragment
.
newInstance
(),
"time_is_over"
)
.
commitAllowingStateLoss
()
}
}
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/ResponseFragment.kt
View file @
70ac0fd1
...
...
@@ -32,7 +32,7 @@ class ResponseFragment: Fragment() {
private
fun
view
(
view
:
View
,
color
:
Int
,
responseId
:
Int
):
View
{
view
.
findViewById
<
TextView
>(
R
.
id
.
tv_response
).
text
=
resources
.
getString
(
responseId
)
view
.
findViewById
<
ConstraintLayout
>(
R
.
id
.
response_layout
).
setBackgroundColor
(
color
)
view
.
findViewById
<
ImageButton
>(
R
.
id
.
btn_next
).
setOnClickListener
{
(
activity
as
Main
Activity
).
reload
()
}
view
.
findViewById
<
ImageButton
>(
R
.
id
.
btn_next
).
setOnClickListener
{
(
activity
as
Task
Activity
).
reload
()
}
return
view
}
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/TaskActivity.kt
0 → 100644
View file @
70ac0fd1
package
com.example.quickmax
import
android.animation.ArgbEvaluator
import
android.animation.ValueAnimator
import
android.os.Build
import
android.os.Bundle
import
android.os.CountDownTimer
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.cardview.widget.CardView
import
androidx.core.content.ContextCompat
import
com.example.quickmax.answers.AnswerSet
import
kotlinx.android.synthetic.main.activity_task.*
class
TaskActivity
:
AppCompatActivity
()
{
private
lateinit
var
answerSet
:
AnswerSet
private
val
timeToSolve
:
Long
=
4000
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_task
)
answerSet
=
AnswerSet
(
3
)
setUpAnswerButtons
()
timer
.
start
()
startProgressBarAnimation
()
}
private
fun
setUpAnswerButtons
()
{
for
(
answer
in
answerSet
)
{
(
findViewById
<
CardView
>(
answer
.
buttonId
).
getChildAt
(
0
)
as
TextView
).
text
=
answer
.
value
.
toString
()
findViewById
<
CardView
>(
answer
.
buttonId
).
setOnClickListener
{
processAnswer
(
answer
.
correct
)
}
}
}
private
fun
processAnswer
(
correct
:
Boolean
)
{
timer
.
cancel
()
makeButtonsUncheckable
()
val
responseFragment
=
ResponseFragment
.
newInstance
().
also
{
f
->
f
.
arguments
=
Bundle
().
also
{
b
->
b
.
putBoolean
(
"correct"
,
correct
)
}
}
supportFragmentManager
.
beginTransaction
()
.
add
(
R
.
id
.
main_layout
,
responseFragment
,
"response"
)
.
commitAllowingStateLoss
()
}
private
fun
makeButtonsUncheckable
()
{
for
(
answer
in
answerSet
)
{
findViewById
<
CardView
>(
answer
.
buttonId
).
isClickable
=
false
}
}
private
fun
startProgressBarAnimation
()
{
val
colorFrom
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
gradient_dark
)
val
colorTo
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
red
)
val
colorAnimation
=
ValueAnimator
.
ofObject
(
ArgbEvaluator
(),
colorFrom
,
colorTo
)
colorAnimation
.
duration
=
timeToSolve
colorAnimation
.
addUpdateListener
{
animator
->
progress_bar
.
progressDrawable
.
setColorFilter
(
animator
.
animatedValue
as
Int
,
android
.
graphics
.
PorterDuff
.
Mode
.
SRC_ATOP
)
}
colorAnimation
.
start
()
}
fun
reload
()
{
val
intent
=
intent
finish
()
startActivity
(
intent
)
}
private
val
timer
=
object
:
CountDownTimer
(
timeToSolve
,
100
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
val
progress
=
((
timeToSolve
-
millisUntilFinished
).
toFloat
()
/
timeToSolve
)
*
100
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
progress_bar
.
setProgress
(
progress
.
toInt
(),
true
)
else
progress_bar
.
progress
=
progress
.
toInt
()
}
override
fun
onFinish
()
{
cv_task
.
elevation
=
0f
makeButtonsUncheckable
()
supportFragmentManager
.
beginTransaction
()
.
replace
(
R
.
id
.
main_layout
,
TimeIsOverFragment
.
newInstance
(),
"time_is_over"
)
.
commitAllowingStateLoss
()
}
}
}
app/src/main/java/com/example/quickmax/TimeIsOverFragment.kt
View file @
70ac0fd1
...
...
@@ -18,7 +18,7 @@ class TimeIsOverFragment: Fragment() {
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
val
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_time_is_over
,
container
,
false
)
view
.
findViewById
<
ImageButton
>(
R
.
id
.
btn_next
).
setOnClickListener
{
(
activity
as
Main
Activity
).
reload
()
}
view
.
findViewById
<
ImageButton
>(
R
.
id
.
btn_next
).
setOnClickListener
{
(
activity
as
Task
Activity
).
reload
()
}
return
view
}
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/Answer.kt
→
app/src/main/java/com/example/quickmax/
answers/
Answer.kt
View file @
70ac0fd1
package
com.example.quickmax
package
com.example.quickmax
.answers
class
Answer
(
val
buttonId
:
Int
,
val
value
:
Int
)
{
var
correct
:
Boolean
=
false
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/AnswerSet.kt
→
app/src/main/java/com/example/quickmax/
answers/
AnswerSet.kt
View file @
70ac0fd1
package
com.example.quickmax
package
com.example.quickmax.answers
import
com.example.quickmax.R
class
AnswerSet
(
numDigits
:
Int
):
Iterable
<
Answer
>
{
private
val
buttonIds
=
listOf
(
R
.
id
.
card_left_top
,
R
.
id
.
card_right_top
,
R
.
id
.
card_left_bottom
,
R
.
id
.
card_right_bottom
)
private
val
buttonIds
=
listOf
(
R
.
id
.
card_left_top
,
R
.
id
.
card_right_top
,
R
.
id
.
card_left_bottom
,
R
.
id
.
card_right_bottom
)
private
val
numAnswers
=
4
private
lateinit
var
correctAnswer
:
Answer
val
answers
:
MutableList
<
Answer
>
=
mutableListOf
()
init
{
val
randomNumbers
=
generateNRandomNumbers
(
numDigits
,
numAnswers
)
val
randomNumbers
=
generateNRandomNumbers
(
numDigits
,
numAnswers
)
for
(
i
in
0
until
numAnswers
)
answers
.
add
(
Answer
(
buttonIds
[
i
],
randomNumbers
.
elementAt
(
i
)))
answers
.
add
(
Answer
(
buttonIds
[
i
],
randomNumbers
.
elementAt
(
i
)
)
)
val
correctAnswerNum
=
findSecondMax
(
answers
.
map
{
answer
->
answer
.
value
})
val
correctAnswerNum
=
findSecondMax
(
answers
.
map
{
answer
->
answer
.
value
})
answers
.
forEach
{
n
->
n
.
correct
=
n
.
value
==
correctAnswerNum
if
(
n
.
correct
)
...
...
app/src/main/java/com/example/quickmax/Calculator.kt
→
app/src/main/java/com/example/quickmax/
answers/
Calculator.kt
View file @
70ac0fd1
package
com.example.quickmax
package
com.example.quickmax
.answers
import
kotlin.math.pow
...
...
app/src/main/res/layout/activity_main.xml
View file @
70ac0fd1
...
...
@@ -2,169 +2,93 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/main_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#DADADA"
tools:context=
".MainActivity"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"0dp"
android:layout_height=
"200dp"
android:background=
"@drawable/gradient"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/layout_progress_bar"
android:layout_width=
"match_parent"
android:layout_height=
"4dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ProgressBar
android:id=
"@+id/progress_bar"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"match_parent"
android:layout_height=
"32dp"
android:layout_gravity=
"center"
android:foregroundTint=
"#320A64"
android:indeterminate=
"false"
android:max=
"100"
/>
</FrameLayout>
<ImageButton
android:id=
"@+id/imageButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@android:color/transparent"
android:tint=
"@android:color/white"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/layout_progress_bar"
app:srcCompat=
"@drawable/ic_back"
/>
android:background=
"@drawable/gradient"
>
<TextView
android:id=
"@+id/tv_score
"
android:layout_width=
"0dp
"
android:id=
"@+id/textView4
"
android:layout_width=
"wrap_content
"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"16dp"
android:gravity=
"center"
android:text=
"Score: 5"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
android:textColor=
"@android:color/white"
app:layout_constraintBottom_toBottomOf=
"@+id/imageButton"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/layout_progress_bar"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:id=
"@+id/cv_task"
style=
"@style/CardView.Light"
android:layout_width=
"0dp"
android:layout_height=
"150dp"
android:layout_margin=
"16dp"
app:cardBackgroundColor=
"@android:color/white"
app:cardCornerRadius=
"4dp"
app:cardElevation=
"2dp"
app:layout_constraintBottom_toTopOf=
"@+id/layout_answers"
android:text=
"@string/how_many_digits"
android:textAppearance=
"@style/TextAppearance.MaterialComponents.Headline4"
android:textColor=
"@color/white"
app:layout_constraintBottom_toTopOf=
"@+id/layout_num_digits"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.5"
app:layout_constraintVertical_chainStyle=
"packed"
>
<TextView
android:id=
"@+id/tv_task"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginStart=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginBottom=
"8dp"
android:gravity=
"center"
android:includeFontPadding=
"true"
android:text=
"@string/second_max"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textColor=
"#323753"
/>
</androidx.cardview.widget.CardView>
app:layout_constraintVertical_chainStyle=
"packed"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/layout_
answer
s"
android:id=
"@+id/layout_
num_digit
s"
android:layout_width=
"0dp"
android:layout_height=
"200dp"
android:layout_marginStart=
"8dp"
android:layout_height=
"100dp"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"8dp"
android:layout_marginBottom=
"8dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/cv_task"
app:layout_constraintVertical_bias=
"0.5"
app:layout_constraintVertical_chainStyle=
"packed"
>
app:layout_constraintEnd_toEndOf=
"@+id/textView4"
app:layout_constraintStart_toStartOf=
"@+id/textView4"
app:layout_constraintTop_toBottomOf=
"@+id/textView4"
>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_left_top"
style=
"@style/AnswerCard"
app:layout_constraintBottom_toTopOf=
"@+id/card_left_bottom"
app:layout_constraintEnd_toStartOf=
"@+id/card_right_top"
app:layout_constraintHorizontal_bias=
"0.5"
android:id=
"@+id/card_2_digits"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/card_3_digits"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
style=
"@style/AnswerCardText"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_right_top"
style=
"@style/AnswerCard"
app:layout_constraintBottom_toTopOf=
"@id/card_right_bottom"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toEndOf=
"@+id/card_left_top"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
style=
"@style/AnswerCardText"
/>
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_2"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_
left_bottom
"
style=
"@style/
Answer
Card"
android:id=
"@+id/card_
3_digits
"
style=
"@style/
My
Card"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/card_right_bottom"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/card_left_top"
>
<TextView
style=
"@style/AnswerCardText"
/>
app:layout_constraintEnd_toStartOf=
"@+id/card_4_digits"
app:layout_constraintStart_toEndOf=
"@+id/card_2_digits"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_3"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_
right_bottom
"
style=
"@style/
Answer
Card"
android:id=
"@+id/card_
4_digits
"
style=
"@style/
My
Card"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toEndOf=
"@+id/card_left_bottom"
app:layout_constraintTop_toBottomOf=
"@+id/card_right_top"
>
<TextView
style=
"@style/AnswerCardText"
/>
app:layout_constraintStart_toEndOf=
"@id/card_3_digits"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_4"
/>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<SeekBar
android:id=
"@+id/seekBar"
android:layout_height=
"wrap_content"
android:layout_width=
"0dp"
android:layout_marginTop=
"32dp"
app:layout_constraintEnd_toEndOf=
"@+id/textView4"
app:layout_constraintStart_toStartOf=
"@+id/textView4"
app:layout_constraintTop_toBottomOf=
"@+id/layout_num_digits"
>
</SeekBar>
<TextView
android:id=
"@+id/textView8"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"TIme to solve"
app:layout_constraintStart_toStartOf=
"@+id/seekBar"
app:layout_constraintTop_toBottomOf=
"@+id/seekBar"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_task.xml
0 → 100644
View file @
70ac0fd1
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/main_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#DADADA"
tools:context=
".TaskActivity"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"0dp"
android:layout_height=
"200dp"
android:background=
"@drawable/gradient"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/layout_progress_bar"
android:layout_width=
"match_parent"
android:layout_height=
"4dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ProgressBar
android:id=
"@+id/progress_bar"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"match_parent"
android:layout_height=
"32dp"
android:layout_gravity=
"center"
android:foregroundTint=
"#320A64"
android:indeterminate=
"false"
android:max=
"100"
/>
</FrameLayout>
<ImageButton
android:id=
"@+id/imageButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@android:color/transparent"
android:tint=
"@android:color/white"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/layout_progress_bar"
app:srcCompat=
"@drawable/ic_back"
/>
<TextView
android:id=
"@+id/tv_score"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:gravity=
"center"
android:text=
"Score: 5"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
android:textColor=
"@android:color/white"
app:layout_constraintBottom_toBottomOf=
"@+id/imageButton"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/layout_progress_bar"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:id=
"@+id/cv_task"
style=
"@style/CardView.Light"
android:layout_width=
"0dp"
android:layout_height=
"150dp"
android:layout_margin=
"16dp"
app:cardBackgroundColor=
"@android:color/white"
app:cardCornerRadius=
"4dp"
app:cardElevation=
"2dp"
app:layout_constraintBottom_toTopOf=
"@+id/layout_answers"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.5"
app:layout_constraintVertical_chainStyle=
"packed"
>
<TextView
android:id=
"@+id/tv_task"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginStart=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginBottom=
"8dp"
android:gravity=
"center"
android:includeFontPadding=
"true"
android:text=
"@string/second_max"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textColor=
"#323753"
/>
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/layout_answers"
android:layout_width=
"0dp"
android:layout_height=
"200dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"8dp"
android:layout_marginBottom=
"8dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/cv_task"
app:layout_constraintVertical_bias=
"0.5"
app:layout_constraintVertical_chainStyle=
"packed"
>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_left_top"
style=
"@style/MyCard"
app:layout_constraintBottom_toTopOf=
"@+id/card_left_bottom"
app:layout_constraintEnd_toStartOf=
"@+id/card_right_top"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
style=
"@style/AnswerCardText"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_right_top"
style=
"@style/MyCard"
app:layout_constraintBottom_toTopOf=
"@id/card_right_bottom"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toEndOf=
"@+id/card_left_top"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
style=
"@style/AnswerCardText"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_left_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/card_right_bottom"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/card_left_top"
>
<TextView
style=
"@style/AnswerCardText"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_right_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toEndOf=
"@+id/card_left_bottom"
app:layout_constraintTop_toBottomOf=
"@+id/card_right_top"
>
<TextView
style=
"@style/AnswerCardText"
/>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_time_is_over.xml
View file @
70ac0fd1
...
...
@@ -24,7 +24,7 @@
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:text=
"@string/time_is_over"
android:textAppearance=
"@
android:style/TextAppearance.Material
.Large"
android:textAppearance=
"@
style/TextAppearance.AppCompat
.Large"
android:textColor=
"@color/white"
app:layout_constraintBottom_toTopOf=
"@+id/response_layout"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
app/src/main/res/values/colors.xml
View file @
70ac0fd1
...
...
@@ -2,7 +2,7 @@
<resources>
<color
name=
"colorPrimary"
>
#008577
</color>
<color
name=
"colorPrimaryDark"
>
#00574B
</color>
<color
name=
"colorAccent"
>
#
D81B60
</color>
<color
name=
"colorAccent"
>
#
FF4A148C
</color>
<color
name=
"colorBackground"
>
#C4BFCC
</color>
<color
name=
"colorCorrect"
>
#81C784
</color>
...
...
app/src/main/res/values/strings.xml
View file @
70ac0fd1
...
...
@@ -4,4 +4,8 @@
<string
name=
"response_correct"
>
CORRECT
</string>
<string
name=
"response_wrong"
>
WRONG
</string>
<string
name=
"time_is_over"
>
TIME IS OVER
</string>
<string
name=
"number_digits_2"
>
2
</string>
<string
name=
"number_digits_3"
>
3
</string>
<string
name=
"number_digits_4"
>
4
</string>
<string
name=
"how_many_digits"
>
HOW MANY DIGITS?
</string>
</resources>
app/src/main/res/values/styles.xml
View file @
70ac0fd1
...
...
@@ -8,13 +8,13 @@
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
</style>
<style
name=
"
Answer
Card"
parent=
"CardView"
>
<style
name=
"
My
Card"
parent=
"CardView"
>
<item
name=
"android:layout_width"
>
0dp
</item>
<item
name=
"android:layout_height"
>
0dp
</item>
<item
name=
"android:layout_margin"
>
8dp
</item>
<item
name=
"android:clickable"
>
true
</item>
<item
name=
"android:focusable"
>
true
</item>
<item
name=
"android:foreground"
>
?a
ndroid:a
ttr/selectableItemBackground
</item>
<item
name=
"android:foreground"
>
?attr/selectableItemBackground
</item>
<item
name=
"cardCornerRadius"
>
4dp
</item>
<item
name=
"cardBackgroundColor"
>
@android:color/white
</item>
</style>
...
...
@@ -32,8 +32,8 @@
<item
name=
"android:layout_marginTop"
>
8dp
</item>
<item
name=
"android:layout_marginEnd"
>
24dp
</item>
<item
name=
"android:layout_marginBottom"
>
8dp
</item>
<item
name=
"
android:
background"
>
@android:color/transparent
</item>
<item
name=
"
android:
tint"
>
@color/white
</item>
<item
name=
"background"
>
@android:color/transparent
</item>
<item
name=
"tint"
>
@color/white
</item>
</style>
</resources>
app/src/test/java/com/example/quickmax/AnswerSetTest.kt
View file @
70ac0fd1
package
com.example.quickmax
import
com.example.quickmax.answers.AnswerSet
import
com.example.quickmax.answers.findSecondMax
import
org.junit.Test
import
org.junit.Assert.*
...
...
app/src/test/java/com/example/quickmax/CalculatorTest.kt
View file @
70ac0fd1
package
com.example.quickmax
import
com.example.quickmax.answers.findSecondMax
import
com.example.quickmax.answers.generateRandom
import
org.junit.Test
import
org.junit.Assert.*
...
...
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