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
261ad107
authored
Sep 29, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
package refactoring
parent
6df10aa4
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
62 additions
and
47 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/paktalin/quickmax/MainActivity.kt
app/src/main/java/com/paktalin/quickmax/ViewUtils.kt
app/src/main/java/com/paktalin/quickmax/answers/Answer.kt → app/src/main/java/com/paktalin/quickmax/task/model/Answer.kt
app/src/main/java/com/paktalin/quickmax/answers/AnswerSet.kt → app/src/main/java/com/paktalin/quickmax/task/model/AnswerSet.kt
app/src/main/java/com/paktalin/quickmax/answers/Calculator.kt → app/src/main/java/com/paktalin/quickmax/task/model/Calculator.kt
app/src/main/java/com/paktalin/quickmax/AnswerCardView.kt → app/src/main/java/com/paktalin/quickmax/task/ui/AnswerCardView.kt
app/src/main/java/com/paktalin/quickmax/ButtonNextFragment.kt → app/src/main/java/com/paktalin/quickmax/task/ui/ButtonNextFragment.kt
app/src/main/java/com/paktalin/quickmax/TaskActivity.kt → app/src/main/java/com/paktalin/quickmax/task/ui/TaskActivity.kt
app/src/main/java/com/paktalin/quickmax/TimerFragment.kt → app/src/main/java/com/paktalin/quickmax/task/ui/TimerFragment.kt
app/src/main/res/layout-land/activity_task.xml
app/src/main/res/layout/activity_task.xml
app/src/test/java/com/paktalin/quickmax/AnswerSetTest.kt
app/src/test/java/com/paktalin/quickmax/CalculatorTest.kt
app/src/main/AndroidManifest.xml
View file @
261ad107
...
...
@@ -9,7 +9,7 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.MaterialComponents.Light.NoActionBar"
>
<activity
android:name=
"com.paktalin.quickmax.TaskActivity"
>
<activity
android:name=
"com.paktalin.quickmax.
task.ui.
TaskActivity"
>
</activity>
<activity
android:name=
"com.paktalin.quickmax.MainActivity"
>
<intent-filter>
...
...
app/src/main/java/com/paktalin/quickmax/MainActivity.kt
View file @
261ad107
...
...
@@ -3,9 +3,9 @@ package com.paktalin.quickmax
import
android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.view.View
import
androidx.appcompat.app.AppCompatActivity
import
com.google.android.material.card.MaterialCardView
import
com.paktalin.quickmax.task.ui.TaskActivity
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
...
...
app/src/main/java/com/paktalin/quickmax/ViewUtils.kt
View file @
261ad107
...
...
@@ -10,6 +10,7 @@ import androidx.core.content.ContextCompat
import
androidx.fragment.app.FragmentManager
import
androidx.fragment.app.commit
import
com.google.android.material.card.MaterialCardView
import
com.paktalin.quickmax.task.ui.ButtonNextFragment
fun
getTextView
(
card
:
View
):
TextView
{
return
((
card
as
MaterialCardView
).
getChildAt
(
0
)
as
FrameLayout
).
getChildAt
(
0
)
as
TextView
...
...
app/src/main/java/com/paktalin/quickmax/
answers
/Answer.kt
→
app/src/main/java/com/paktalin/quickmax/
task/model
/Answer.kt
View file @
261ad107
package
com.paktalin.quickmax.
answers
package
com.paktalin.quickmax.
task.model
import
com.paktalin.quickmax.AnswerCardView
import
com.paktalin.quickmax.
task.ui.
AnswerCardView
class
Answer
(
val
card
:
AnswerCardView
,
val
value
:
Int
)
{
var
correct
:
Boolean
=
false
...
...
app/src/main/java/com/paktalin/quickmax/
answers
/AnswerSet.kt
→
app/src/main/java/com/paktalin/quickmax/
task/model
/AnswerSet.kt
View file @
261ad107
package
com.paktalin.quickmax.
answers
package
com.paktalin.quickmax.
task.model
import
com.paktalin.quickmax.AnswerCardView
import
com.paktalin.quickmax.
task.ui.
AnswerCardView
class
AnswerSet
(
numDigits
:
Int
,
cards
:
List
<
AnswerCardView
>):
Iterable
<
Answer
>
{
private
val
numAnswers
=
4
...
...
app/src/main/java/com/paktalin/quickmax/
answers
/Calculator.kt
→
app/src/main/java/com/paktalin/quickmax/
task/model
/Calculator.kt
View file @
261ad107
package
com.paktalin.quickmax.
answers
package
com.paktalin.quickmax.
task.model
import
kotlin.math.pow
...
...
app/src/main/java/com/paktalin/quickmax/AnswerCardView.kt
→
app/src/main/java/com/paktalin/quickmax/
task/ui/
AnswerCardView.kt
View file @
261ad107
package
com.paktalin.quickmax
package
com.paktalin.quickmax
.task.ui
import
android.content.Context
import
android.graphics.Color
import
android.util.AttributeSet
import
androidx.core.content.ContextCompat
import
com.google.android.material.card.MaterialCardView
import
com.paktalin.quickmax.R
import
com.paktalin.quickmax.color
import
com.paktalin.quickmax.getTextView
class
AnswerCardView
:
MaterialCardView
{
...
...
app/src/main/java/com/paktalin/quickmax/ButtonNextFragment.kt
→
app/src/main/java/com/paktalin/quickmax/
task/ui/
ButtonNextFragment.kt
View file @
261ad107
package
com.paktalin.quickmax
package
com.paktalin.quickmax
.task.ui
import
android.os.Bundle
import
android.view.LayoutInflater
...
...
@@ -6,6 +6,7 @@ import android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
com.paktalin.quickmax.R
import
kotlinx.android.synthetic.main.btn_next.view.*
class
ButtonNextFragment
:
Fragment
()
{
...
...
@@ -15,7 +16,9 @@ class ButtonNextFragment : Fragment() {
val
correct
=
arguments
!!
.
getBoolean
(
"correct"
)
val
view
=
inflater
.
inflate
(
R
.
layout
.
btn_next
,
container
,
false
)
if
(
correct
)
view
.
btn_next
.
backgroundTintList
=
ContextCompat
.
getColorStateList
(
context
!!
,
R
.
color
.
colorAccent
)
view
.
btn_next
.
backgroundTintList
=
ContextCompat
.
getColorStateList
(
context
!!
,
R
.
color
.
colorAccent
)
view
.
btn_next
.
setOnClickListener
{
(
activity
as
TaskActivity
).
startNewRound
()
}
return
view
...
...
app/src/main/java/com/paktalin/quickmax/TaskActivity.kt
→
app/src/main/java/com/paktalin/quickmax/
task/ui/
TaskActivity.kt
View file @
261ad107
package
com.paktalin.quickmax
package
com.paktalin.quickmax
.task.ui
import
android.content.Intent
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.commit
import
com.paktalin.quickmax.answers.Answer
import
com.paktalin.quickmax.answers.AnswerSet
import
com.paktalin.quickmax.MainActivity
import
com.paktalin.quickmax.R
import
com.paktalin.quickmax.addButtonNextFragment
import
com.paktalin.quickmax.removeButtonNextFragment
import
com.paktalin.quickmax.task.model.Answer
import
com.paktalin.quickmax.task.model.AnswerSet
import
kotlinx.android.synthetic.main.activity_task.*
// TODO save state
...
...
app/src/main/java/com/paktalin/quickmax/TimerFragment.kt
→
app/src/main/java/com/paktalin/quickmax/
task/ui/
TimerFragment.kt
View file @
261ad107
package
com.paktalin.quickmax
package
com.paktalin.quickmax
.task.ui
import
android.animation.ArgbEvaluator
import
android.animation.ValueAnimator
...
...
@@ -12,6 +12,9 @@ import android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
androidx.fragment.app.Fragment
import
com.paktalin.quickmax.R
import
com.paktalin.quickmax.color
import
com.paktalin.quickmax.textSize
private
const
val
interval
:
Long
=
1000
...
...
@@ -60,6 +63,9 @@ class TimerFragment : Fragment() {
if
(
state
==
State
.
IN_PROGRESS
)
{
initTimer
()
initColorAnimation
()
}
else
{
setResult
()
setBackgroundFilter
(
colorFrom
)
}
return
view
}
...
...
@@ -73,9 +79,8 @@ class TimerFragment : Fragment() {
override
fun
onSaveInstanceState
(
outState
:
Bundle
)
{
super
.
onSaveInstanceState
(
outState
)
outState
.
putString
(
KEY_STATE
,
state
.
name
)
if
(
state
==
State
.
IN_PROGRESS
)
outState
.
putLong
(
KEY_MILLIS_TO_SOLVE
,
millisToSolve
)
// try to update colorFrom from animation
colorAnimation
?.
let
{
animator
->
animator
.
animatedValue
?.
let
{
value
->
colorFrom
=
value
as
Int
...
...
@@ -92,7 +97,9 @@ class TimerFragment : Fragment() {
private
fun
setResult
()
{
if
(
isAdded
)
{
tvResponse
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
textSize
(
resources
))
tvResponse
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
textSize
(
resources
)
)
tvResponse
.
text
=
state
.
response
}
}
...
...
@@ -103,12 +110,7 @@ class TimerFragment : Fragment() {
private
fun
restoreState
(
savedInstanceState
:
Bundle
)
{
state
=
State
.
valueOf
(
savedInstanceState
.
getString
(
KEY_STATE
)
!!
)
colorFrom
=
savedInstanceState
.
getInt
(
KEY_COLOR_FROM
)
if
(
state
==
State
.
IN_PROGRESS
)
{
millisToSolve
=
savedInstanceState
.
getLong
(
KEY_MILLIS_TO_SOLVE
)
}
else
{
setResult
()
setBackgroundFilter
(
colorFrom
)
}
millisToSolve
=
savedInstanceState
.
getLong
(
KEY_MILLIS_TO_SOLVE
,
0
)
}
private
fun
initTimer
()
{
...
...
@@ -127,7 +129,8 @@ class TimerFragment : Fragment() {
}
private
fun
initColorAnimation
()
{
val
colorTo
=
color
(
context
!!
,
R
.
color
.
transparent_red
)
val
colorTo
=
color
(
context
!!
,
R
.
color
.
transparent_red
)
colorAnimation
=
ValueAnimator
.
ofObject
(
ArgbEvaluator
(),
colorFrom
,
colorTo
)
.
apply
{
duration
=
millisToSolve
}
colorAnimation
?.
addUpdateListener
{
animator
->
...
...
app/src/main/res/layout-land/activity_task.xml
View file @
261ad107
...
...
@@ -6,7 +6,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#DADADA"
tools:context=
"com.paktalin.quickmax.TaskActivity"
>
tools:context=
"com.paktalin.quickmax.
task.ui.
TaskActivity"
>
<FrameLayout
android:id=
"@+id/fragment_timer"
...
...
@@ -77,7 +77,7 @@
app:layout_constraintStart_toStartOf=
"@+id/guideline"
app:layout_constraintTop_toTopOf=
"parent"
>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_left_top"
style=
"@style/MyCard"
app:cardCornerRadius=
"10dp"
...
...
@@ -88,9 +88,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_right_top"
style=
"@style/MyCard"
app:layout_constraintBottom_toTopOf=
"@id/card_right_bottom"
...
...
@@ -100,9 +100,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_left_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -112,9 +112,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_right_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -124,7 +124,7 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_task.xml
View file @
261ad107
...
...
@@ -6,7 +6,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#DADADA"
tools:context=
"com.paktalin.quickmax.TaskActivity"
>
tools:context=
"com.paktalin.quickmax.
task.ui.
TaskActivity"
>
<FrameLayout
android:id=
"@+id/fragment_timer"
...
...
@@ -82,7 +82,7 @@
app:layout_constraintVertical_bias=
"0.5"
app:layout_constraintVertical_chainStyle=
"packed"
>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_left_top"
style=
"@style/MyCard"
app:cardCornerRadius=
"10dp"
...
...
@@ -94,9 +94,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_right_top"
style=
"@style/MyCard"
app:layout_constraintBottom_toTopOf=
"@id/card_right_bottom"
...
...
@@ -107,9 +107,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_left_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -120,9 +120,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
<com.paktalin.quickmax.AnswerCardView
<com.paktalin.quickmax.
task.ui.
AnswerCardView
android:id=
"@+id/card_right_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -133,7 +133,7 @@
<TextView
style=
"@style/AnswerCardText"
/>
</com.paktalin.quickmax.AnswerCardView>
</com.paktalin.quickmax.
task.ui.
AnswerCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/test/java/com/paktalin/quickmax/AnswerSetTest.kt
View file @
261ad107
package
com.paktalin.quickmax
import
com.paktalin.quickmax.
answers
.AnswerSet
import
com.paktalin.quickmax.
answers
.findSecondMax
import
com.paktalin.quickmax.
task.model
.AnswerSet
import
com.paktalin.quickmax.
task.model
.findSecondMax
import
org.junit.Test
import
org.junit.Assert.*
...
...
app/src/test/java/com/paktalin/quickmax/CalculatorTest.kt
View file @
261ad107
package
com.paktalin.quickmax
import
com.paktalin.quickmax.
answers
.findSecondMax
import
com.paktalin.quickmax.
answers
.generateRandom
import
com.paktalin.quickmax.
task.model
.findSecondMax
import
com.paktalin.quickmax.
task.model
.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