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
4079ae8a
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced ImageButton with MaterialButton next
parent
bd22e856
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
13 deletions
app/src/main/java/com/example/quickmax/ResponseFragment.kt
app/src/main/res/layout/fragment_response.xml
app/src/main/res/values/colors.xml
app/src/main/java/com/example/quickmax/ResponseFragment.kt
View file @
4079ae8a
package
com.example.quickmax
import
android.graphics.Color
import
android.graphics.PorterDuff
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageButton
import
android.widget.TextView
import
androidx.constraintlayout.widget.ConstraintLayout
import
androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
com.google.android.material.button.MaterialButton
class
ResponseFragment
:
Fragment
()
{
...
...
@@ -24,15 +25,25 @@ 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
.
colorAccent
),
R
.
string
.
response_correct
)
view
(
view
,
color
(
R
.
color
.
colorAccent
),
R
.
string
.
response_correct
,
color
(
R
.
color
.
transparent_dark_black
)
)
else
view
(
view
,
ContextCompat
.
getColor
(
activity
!!
,
R
.
color
.
colorPrimary
),
R
.
string
.
response_wrong
)
view
(
view
,
color
(
R
.
color
.
colorPrimary
),
R
.
string
.
response_wrong
,
Color
.
WHITE
)
}
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
TaskActivity
).
reload
()
}
private
fun
view
(
view
:
View
,
color
:
Int
,
responseId
:
Int
,
textColor
:
Int
):
View
{
view
.
findViewById
<
TextView
>(
R
.
id
.
tv_response
).
apply
{
text
=
resources
.
getString
(
responseId
)
setTextColor
(
color
)
}
view
.
findViewById
<
MaterialButton
>(
R
.
id
.
btn_next
).
apply
{
background
.
setColorFilter
(
color
,
PorterDuff
.
Mode
.
MULTIPLY
)
setTextColor
(
textColor
)
setOnClickListener
{
(
activity
as
TaskActivity
).
reload
()
}
}
return
view
}
private
fun
color
(
colorId
:
Int
):
Int
{
return
ContextCompat
.
getColor
(
activity
!!
,
colorId
)
}
}
\ No newline at end of file
app/src/main/res/layout/fragment_response.xml
View file @
4079ae8a
...
...
@@ -3,18 +3,22 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/response_layout"
android:layout_width=
"match_parent"
android:layout_height=
"
54dp
"
android:layout_height=
"
wrap_content
"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
<
Image
Button
<
com.google.android.material.button.Material
Button
android:id=
"@+id/btn_next"
style=
"@style/ButtonNext"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginBottom=
"8dp"
android:text=
"@string/btn_next"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_double_arrow_small"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/tv_response"
...
...
app/src/main/res/values/colors.xml
View file @
4079ae8a
...
...
@@ -4,5 +4,6 @@
<color
name=
"colorPrimaryDark"
>
#12005e
</color>
<color
name=
"colorAccent"
>
#4dd0e1
</color>
<color
name=
"transparent_black"
>
#97000000
</color>
<color
name=
"transparent_dark_black"
>
#BB000000
</color>
<color
name=
"transparent_red"
>
#97FF0000
</color>
</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