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
18d8b0b0
authored
Sep 28, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ButtonNext is moved to fragment
parent
2a6b1943
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
74 deletions
app/build.gradle
app/src/main/java/com/paktalin/quickmax/ButtonNext.kt
app/src/main/java/com/paktalin/quickmax/ButtonNextFragment.kt
app/src/main/java/com/paktalin/quickmax/MyColorAnimation.kt
app/src/main/java/com/paktalin/quickmax/TaskActivity.kt
app/src/main/res/layout-land/activity_task.xml
app/src/main/res/layout/activity_task.xml
app/src/main/res/layout/btn_next.xml
app/src/main/res/values/colors.xml
app/build.gradle
View file @
18d8b0b0
...
...
@@ -28,11 +28,13 @@ dependencies {
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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.1.0-alpha10'
implementation
'androidx.cardview:cardview:1.0.0'
implementation
'com.crystal:crystalrangeseekbar:1.1.3'
// kotlin
implementation
'androidx.core:core-ktx:1.2.0-alpha04'
implementation
'androidx.fragment:fragment-ktx:1.1.0'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
...
...
app/src/main/java/com/paktalin/quickmax/ButtonNext.kt
deleted
100644 → 0
View file @
2a6b1943
package
com.paktalin.quickmax
import
android.content.Context
import
android.graphics.Color
import
android.util.AttributeSet
import
android.view.View
import
androidx.core.content.ContextCompat
import
com.google.android.material.button.MaterialButton
class
ButtonNext
:
MaterialButton
{
constructor
(
context
:
Context
)
:
super
(
context
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?)
:
super
(
context
,
attrs
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?,
defStyleAttr
:
Int
)
:
super
(
context
,
attrs
,
defStyleAttr
)
fun
initial
()
{
visibility
=
View
.
INVISIBLE
}
fun
correct
(
context
:
Context
)
{
visibility
=
View
.
VISIBLE
backgroundTintList
=
ContextCompat
.
getColorStateList
(
context
,
R
.
color
.
colorAccent
)
setTextColor
(
color
(
context
,
R
.
color
.
transparent_dark_black
))
}
fun
incorrect
(
context
:
Context
)
{
visibility
=
View
.
VISIBLE
backgroundTintList
=
ContextCompat
.
getColorStateList
(
context
,
R
.
color
.
colorPrimary
)
setTextColor
(
Color
.
WHITE
)
}
}
app/src/main/java/com/paktalin/quickmax/ButtonNextFragment.kt
0 → 100644
View file @
18d8b0b0
package
com.paktalin.quickmax
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
kotlinx.android.synthetic.main.btn_next.view.*
class
ButtonNextFragment
:
Fragment
()
{
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
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
.
setOnClickListener
{
(
activity
as
TaskActivity
).
startNewRound
()
}
return
view
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/quickmax/MyColorAnimation.kt
deleted
100644 → 0
View file @
2a6b1943
package
com.paktalin.quickmax
app/src/main/java/com/paktalin/quickmax/TaskActivity.kt
View file @
18d8b0b0
...
...
@@ -9,7 +9,7 @@ import android.os.Bundle
import
android.os.CountDownTimer
import
android.util.TypedValue
import
androidx.appcompat.app.AppCompatActivity
import
androidx.
core.content.ContextCompa
t
import
androidx.
fragment.app.commi
t
import
com.paktalin.quickmax.answers.Answer
import
com.paktalin.quickmax.answers.AnswerSet
import
kotlinx.android.synthetic.main.activity_task.*
...
...
@@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.activity_task.*
// TODO save state
class
TaskActivity
:
AppCompatActivity
()
{
private
lateinit
var
answerSet
:
AnswerSet
internal
lateinit
var
answerSet
:
AnswerSet
private
var
millisToSolve
:
Long
=
4000
private
var
numDigits
:
Int
=
3
private
lateinit
var
timer
:
CountDownTimer
...
...
@@ -27,12 +27,22 @@ class TaskActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_task
)
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
retrieveExtras
()
initTimer
()
startNewRound
()
}
private
fun
startNewRound
()
{
override
fun
onSaveInstanceState
(
outState
:
Bundle
)
{
super
.
onSaveInstanceState
(
outState
)
// TODO save selection
// TODO save animation state
// TODO save timer
// TODO save button next state
// TODO save
}
internal
fun
startNewRound
()
{
answerSet
=
AnswerSet
(
numDigits
,
listOf
(
card_left_top
,
card_right_top
,
card_left_bottom
,
card_right_bottom
)
...
...
@@ -52,11 +62,6 @@ class TaskActivity : AppCompatActivity() {
answer
.
card
.
setOnCheckedChangeListener
{
_
,
isChecked
->
if
(
isChecked
)
processAnswer
(
answer
)
}
answer
.
card
.
initial
(
this
@TaskActivity
,
answer
.
value
)
}
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
btn_next
.
apply
{
setOnClickListener
{
startNewRound
()
}
initial
()
}
}
private
fun
processAnswer
(
answer
:
Answer
)
{
...
...
@@ -72,11 +77,15 @@ class TaskActivity : AppCompatActivity() {
if
(
answer
.
correct
)
{
answer
.
card
.
markCorrect
(
this
@TaskActivity
)
tv_response
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
btn_next
.
correct
(
this
@TaskActivity
)
supportFragmentManager
.
commit
(
true
)
{
add
(
R
.
id
.
main_layout
,
ButtonNextFragment
().
apply
{
arguments
=
Bundle
().
apply
{
putBoolean
(
"correct"
,
true
)
}
})
}
}
else
{
answer
.
card
.
markWrong
(
this
@TaskActivity
)
tv_response
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
btn_next
.
incorrect
(
this
@TaskActivity
)
supportFragmentManager
.
commit
(
true
)
{
add
(
R
.
id
.
main_layout
,
ButtonNextFragment
().
apply
{
arguments
=
Bundle
().
apply
{
putBoolean
(
"correct"
,
false
)
}
})
}
}
}
...
...
@@ -101,7 +110,10 @@ class TaskActivity : AppCompatActivity() {
override
fun
onFinish
()
{
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
.
incorrect
(
this
@TaskActivity
)
supportFragmentManager
.
commit
(
true
)
{
add
(
R
.
id
.
main_layout
,
ButtonNextFragment
().
apply
{
arguments
=
Bundle
().
apply
{
putBoolean
(
"correct"
,
false
)
}
})
}
answerSet
.
forEach
{
answer
->
answer
.
card
.
disable
()}
}
}
...
...
app/src/main/res/layout-land/activity_task.xml
View file @
18d8b0b0
...
...
@@ -142,15 +142,4 @@
</com.paktalin.quickmax.AnswerCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.paktalin.quickmax.ButtonNext
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginBottom=
"8dp"
android:text=
"@string/btn_next"
android:visibility=
"invisible"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_task.xml
View file @
18d8b0b0
...
...
@@ -151,15 +151,4 @@
</com.paktalin.quickmax.AnswerCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.paktalin.quickmax.ButtonNext
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginBottom=
"16dp"
android:text=
"@string/btn_next"
android:visibility=
"invisible"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/btn_next.xml
0 → 100644
View file @
18d8b0b0
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.button.MaterialButton
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginBottom=
"16dp"
android:text=
"@string/btn_next"
app:backgroundTint=
"@color/colorPrimary"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
\ No newline at end of file
app/src/main/res/values/colors.xml
View file @
18d8b0b0
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"colorPrimary"
>
#4
a148c
</color>
<color
name=
"colorPrimary"
>
#4
A148C
</color>
<color
name=
"colorAccent"
>
#4dd0e1
</color>
<color
name=
"transparent_black"
>
#83000000
</color>
<color
name=
"transparent_dark_black"
>
#BB000000
</color>
...
...
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