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
cef6183d
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Design refactoring; removed CheckableCardView
parent
4ff3f1db
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
48 additions
and
168 deletions
app/src/main/java/com/example/quickmax/CheckableCardView.java
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/res/color/selector_card_view_colors.xml
app/src/main/res/drawable/gradient.xml
app/src/main/res/layout/activity_main.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/main/java/com/example/quickmax/CheckableCardView.java
deleted
100644 → 0
View file @
4ff3f1db
package
com
.
example
.
quickmax
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Checkable
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.cardview.widget.CardView
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
androidx.core.content.ContextCompat
;
public
class
CheckableCardView
extends
CardView
implements
Checkable
{
private
boolean
isChecked
=
false
;
private
static
final
int
[]
CHECKED_STATE_SET
=
{
android
.
R
.
attr
.
state_checked
};
public
CheckableCardView
(
@NonNull
Context
context
)
{
super
(
context
);
setCardBackgroundColor
(
ContextCompat
.
getColorStateList
(
getContext
(),
R
.
color
.
selector_card_view_colors
)
);
}
public
CheckableCardView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
setCardBackgroundColor
(
ContextCompat
.
getColorStateList
(
getContext
(),
R
.
color
.
selector_card_view_colors
)
);
}
public
CheckableCardView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
setCardBackgroundColor
(
ContextCompat
.
getColorStateList
(
getContext
(),
R
.
color
.
selector_card_view_colors
)
);
}
@Override
public
boolean
performClick
()
{
toggle
();
return
super
.
performClick
();
}
@Override
public
void
setChecked
(
boolean
checked
)
{
this
.
isChecked
=
checked
;
ConstraintLayout
parent
=
(
ConstraintLayout
)
this
.
getParent
();
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
CheckableCardView
child
=
(
CheckableCardView
)
parent
.
getChildAt
(
i
);
if
(
child
.
getId
()
!=
this
.
getId
())
{
child
.
isChecked
=
false
;
child
.
onCreateDrawableState
(
0
);
// ((TextView) child.getChildAt(0)).setTextColor(-1979711488);
}
}
}
@Override
public
boolean
isChecked
()
{
return
isChecked
;
}
@Override
public
void
toggle
()
{
setChecked
(
true
);
}
@Override
protected
int
[]
onCreateDrawableState
(
int
extraSpace
)
{
final
int
[]
drawableState
=
super
.
onCreateDrawableState
(
extraSpace
+
1
);
TextView
tv
=
(
TextView
)
getChildAt
(
0
);
if
(
isChecked
())
{
mergeDrawableStates
(
drawableState
,
CHECKED_STATE_SET
);
tv
.
setTextColor
(
ContextCompat
.
getColor
(
getContext
(),
R
.
color
.
white
));
}
else
{
if
(
tv
!=
null
)
tv
.
setTextColor
(-
1979711488
);
}
return
drawableState
;
}
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/MainActivity.kt
View file @
cef6183d
package
com.example.quickmax
import
android.content.Intent
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
...
...
@@ -14,8 +14,10 @@ class MainActivity: AppCompatActivity() {
seek_bar
.
setOnSeekbarChangeListener
{
n
->
seek_bar_value
.
text
=
resources
.
getString
(
R
.
string
.
time_to_solve
,
n
.
toString
())
}
seek_bar
.
setMinStartValue
(
4f
).
apply
()
card_3_digits
.
setOnClickListener
{
startActivity
(
Intent
(
this
,
TaskActivity
::
class
.
java
))
}
}
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/ResponseFragment.kt
View file @
cef6183d
...
...
@@ -24,9 +24,9 @@ class ResponseFragment: Fragment() {
val
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_response
,
container
,
false
)
val
correct
=
arguments
!!
.
getBoolean
(
"correct"
)
return
if
(
correct
)
view
(
view
,
ContextCompat
.
getColor
(
activity
!!
,
R
.
color
.
gradient_ligh
t
),
R
.
string
.
response_correct
)
view
(
view
,
ContextCompat
.
getColor
(
activity
!!
,
R
.
color
.
colorAccen
t
),
R
.
string
.
response_correct
)
else
view
(
view
,
ContextCompat
.
getColor
(
activity
!!
,
R
.
color
.
gradient_dark
),
R
.
string
.
response_wrong
)
view
(
view
,
ContextCompat
.
getColor
(
activity
!!
,
R
.
color
.
colorPrimary
),
R
.
string
.
response_wrong
)
}
private
fun
view
(
view
:
View
,
color
:
Int
,
responseId
:
Int
):
View
{
...
...
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
cef6183d
...
...
@@ -2,6 +2,7 @@ package com.example.quickmax
import
android.animation.ArgbEvaluator
import
android.animation.ValueAnimator
import
android.graphics.Color
import
android.os.Build
import
android.os.Bundle
import
android.os.CountDownTimer
...
...
@@ -54,8 +55,8 @@ class TaskActivity : AppCompatActivity() {
}
private
fun
startProgressBarAnimation
()
{
val
colorFrom
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
gradient_dark
)
val
colorTo
=
Co
ntextCompat
.
getColor
(
this
,
R
.
color
.
red
)
val
colorFrom
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
colorPrimary
)
val
colorTo
=
Co
lor
.
RED
val
colorAnimation
=
ValueAnimator
.
ofObject
(
ArgbEvaluator
(),
colorFrom
,
colorTo
)
colorAnimation
.
duration
=
timeToSolve
colorAnimation
.
addUpdateListener
{
animator
->
...
...
app/src/main/java/com/example/quickmax/TimeIsOverFragment.kt
View file @
cef6183d
...
...
@@ -4,7 +4,6 @@ import android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageButton
import
androidx.fragment.app.Fragment
class
TimeIsOverFragment
:
Fragment
()
{
...
...
@@ -18,7 +17,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
TaskActivity
).
reload
()
}
view
.
setOnClickListener
{
(
activity
as
TaskActivity
).
reload
()
}
return
view
}
}
\ No newline at end of file
app/src/main/res/color/selector_card_view_colors.xml
deleted
100644 → 0
View file @
4ff3f1db
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:color=
"@color/gradient_dark"
android:state_checked=
"true"
/>
<item
android:color=
"@color/white"
/>
</selector>
\ No newline at end of file
app/src/main/res/drawable/gradient.xml
View file @
cef6183d
...
...
@@ -2,7 +2,7 @@
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<gradient
android:angle=
"90"
android:endColor=
"@color/
gradient_dark
"
android:startColor=
"@color/
gradient_ligh
t"
android:endColor=
"@color/
colorPrimary
"
android:startColor=
"@color/
colorAccen
t"
android:type=
"linear"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
cef6183d
...
...
@@ -16,7 +16,7 @@
android:gravity=
"center"
android:text=
"@string/how_many_digits"
android:textAppearance=
"@style/TextAppearance.MaterialComponents.Headline4"
android:textColor=
"@color/white"
android:textColor=
"@
android:
color/white"
app:layout_constraintBottom_toTopOf=
"@+id/layout_num_digits"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -33,7 +33,7 @@
app:layout_constraintStart_toStartOf=
"@+id/textView4"
app:layout_constraintTop_toBottomOf=
"@+id/textView4"
>
<
com.example.quickmax.Checkable
CardView
<
androidx.cardview.widget.
CardView
android:id=
"@+id/card_2_digits"
style=
"@style/MyCard"
android:foreground=
"?android:attr/selectableItemBackground"
...
...
@@ -45,9 +45,9 @@
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_2"
/>
</
com.example.quickmax.Checkable
CardView>
</
androidx.cardview.widget.
CardView>
<
com.example.quickmax.Checkable
CardView
<
androidx.cardview.widget.
CardView
android:id=
"@+id/card_3_digits"
style=
"@style/MyCard"
android:foreground=
"?android:attr/selectableItemBackground"
...
...
@@ -59,9 +59,9 @@
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_3"
/>
</
com.example.quickmax.Checkable
CardView>
</
androidx.cardview.widget.
CardView>
<
com.example.quickmax.Checkable
CardView
<
androidx.cardview.widget.
CardView
android:id=
"@+id/card_4_digits"
style=
"@style/MyCard"
android:foreground=
"?android:attr/selectableItemBackground"
...
...
@@ -73,7 +73,7 @@
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_4"
/>
</
com.example.quickmax.Checkable
CardView>
</
androidx.cardview.widget.
CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.crystal.crystalrangeseekbar.widgets.CrystalSeekbar
...
...
@@ -81,15 +81,15 @@
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
app:bar_color=
"@color/white"
app:bar_highlight_color=
"@color/
gradient_dark
"
app:bar_color=
"@
android:
color/white"
app:bar_highlight_color=
"@color/
colorPrimary
"
app:corner_radius=
"10"
app:data_type=
"_integer"
app:layout_constraintEnd_toEndOf=
"@+id/layout_num_digits"
app:layout_constraintStart_toStartOf=
"@+id/layout_num_digits"
app:layout_constraintTop_toBottomOf=
"@+id/layout_num_digits"
app:left_thumb_color=
"@color/white"
app:left_thumb_color_pressed=
"@color/
gradient_dark
"
app:left_thumb_color=
"@
android:
color/white"
app:left_thumb_color_pressed=
"@color/
colorPrimary
"
app:max_value=
"10"
app:min_value=
"2"
/>
...
...
@@ -101,17 +101,8 @@
android:layout_marginTop=
"8dp"
android:text=
"@string/time_to_solve"
android:textAppearance=
"@style/TextAppearance.MaterialComponents.Caption"
android:textColor=
"@color/white"
android:textColor=
"@
android:
color/white"
app:layout_constraintStart_toStartOf=
"@+id/layout_num_digits"
app:layout_constraintTop_toBottomOf=
"@+id/seek_bar"
/>
<RadioButton
android:id=
"@+id/radioButton"
style=
"@style/CardView.Light"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:button=
"@android:color/transparent"
android:text=
"@string/number_digits_2"
android:background=
"@color/cardview_light_background"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_time_is_over.xml
View file @
cef6183d
...
...
@@ -9,8 +9,7 @@
android:id=
"@+id/img_view_timer"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:tint=
"@color/white"
android:tint=
"@android:color/white"
app:layout_constraintBottom_toTopOf=
"@id/textView"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -22,33 +21,25 @@
android:id=
"@+id/textView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:text=
"@string/time_is_over"
android:textAppearance=
"@style/TextAppearance.AppCompat.Large"
android:textColor=
"@color/white"
app:layout_constraintBottom_toTopOf=
"@+id/
response_layout
"
android:textColor=
"@
android:
color/white"
app:layout_constraintBottom_toTopOf=
"@+id/
textView2
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/img_view_timer"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/response_layout"
android:layout_width=
"match_parent"
android:layout_height=
"54dp"
android:background=
"@color/white"
<TextView
android:id=
"@+id/textView2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"32dp"
android:text=
"Tap to continue"
android:textAppearance=
"@style/TextAppearance.MaterialComponents.Subtitle1"
android:textColor=
"#97000000"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
<ImageButton
android:id=
"@+id/btn_next"
style=
"@style/ButtonNext"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_double_arrow_small"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintStart_toStartOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/colors.xml
View file @
cef6183d
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"colorPrimary"
>
#008577
</color>
<color
name=
"colorPrimaryDark"
>
#00574B
</color>
<color
name=
"colorAccent"
>
#FF4A148C
</color>
<color
name=
"colorBackground"
>
#C4BFCC
</color>
<color
name=
"colorCorrect"
>
#81C784
</color>
<color
name=
"gradient_dark"
>
#FF4A148C
</color>
<color
name=
"gradient_light"
>
#FF00BCD4
</color>
<color
name=
"white"
>
#FFF
</color>
<color
name=
"red"
>
#F00
</color>
<color
name=
"colorPrimary"
>
#4a148c
</color>
<color
name=
"colorPrimaryDark"
>
#12005e
</color>
<color
name=
"colorAccent"
>
#4dd0e1
</color>
<color
name=
"transparent_black"
>
#97000000
</color>
</resources>
app/src/main/res/values/strings.xml
View file @
cef6183d
...
...
@@ -9,4 +9,5 @@
<string
name=
"number_digits_4"
>
4
</string>
<string
name=
"how_many_digits"
>
HOW MANY DIGITS?
</string>
<string
name=
"time_to_solve"
>
Time to solve: %1$s seconds
</string>
<string
name=
"btn_next"
>
Next
</string>
</resources>
app/src/main/res/values/styles.xml
View file @
cef6183d
...
...
@@ -32,7 +32,7 @@
<item
name=
"android:layout_marginTop"
>
8dp
</item>
<item
name=
"android:layout_marginEnd"
>
24dp
</item>
<item
name=
"android:layout_marginBottom"
>
8dp
</item>
<item
name=
"background"
>
@android:color/transparent
</item>
<item
name=
"tint"
>
@color/white
</item>
<item
name=
"
android:
background"
>
@android:color/transparent
</item>
<item
name=
"tint"
>
@
android:
color/white
</item>
</style>
</resources>
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