Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TEHIK
hoia
dp3t-app-android
Commits
937ec183
Commit
937ec183
authored
Jun 11, 2021
by
Harri Kirik
Browse files
Merge branch 'develop' into feature/COVAPP-421-remove-2nd-day-ui
parents
312641f7
6030ac10
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/dpppt/android/app/contacts/ContactsFragment.kt
View file @
937ec183
...
...
@@ -75,7 +75,7 @@ class ContactsFragment : MvvmFragment(R.layout.fragment_contacts), ViewBindingHo
}
private
fun
showContacts
(
contacts
:
InfectedStatus
)
{
if
(
contacts
!
is
InfectedStatus
.
Ha
d
Contacts
)
{
if
(
contacts
!
is
InfectedStatus
.
Ha
s
Contacts
)
{
return
}
requireBinding
{
...
...
app/src/main/java/org/dpppt/android/app/domain/usecase/contacts/GetInfectedStatusUseCase.kt
View file @
937ec183
...
...
@@ -17,7 +17,7 @@ class GetInfectedStatusUseCase @Inject constructor() {
return
if
(
hadContacts
)
{
val
stayHomeUntilDate
=
calculateStayHomeDate
(
LocalDate
.
now
(),
status
.
daysSinceExposure
,
STAY_HOME_DAYS_AFTER_CONTACT_DAY
)
val
numContacts
=
status
.
exposureDays
.
size
InfectedStatus
.
Ha
d
Contacts
(
numContacts
,
stayHomeUntilDate
)
InfectedStatus
.
Ha
s
Contacts
(
numContacts
,
stayHomeUntilDate
)
}
else
{
InfectedStatus
.
None
}
...
...
app/src/main/java/org/dpppt/android/app/home/HomeFragment.kt
View file @
937ec183
package
org.dpppt.android.app.home
import
android.animation.LayoutTransition
import
android.content.Intent
import
android.net.Uri
import
android.os.Bundle
...
...
@@ -135,17 +136,20 @@ class HomeFragment : MvvmFragment(R.layout.fragment_home), ViewBindingHolder<Fra
}
else
{
setInfectionCardsToNotInfected
()
}
parentView
.
layoutTransition
=
LayoutTransition
().
apply
{
enableTransitionType
(
LayoutTransition
.
CHANGING
)
}
setupHeaderColor
(
infectedStatus
)
setupHeaderText
(
infectedStatus
)
setupHeaderImage
(
infectedStatus
)
infectionDetailsViews
.
isVisible
=
infectedStatus
is
InfectedStatus
.
Ha
d
Contacts
if
(
infectedStatus
is
InfectedStatus
.
Ha
d
Contacts
)
setupInfectionStateHadContactsDescription
(
infectedStatus
)
infectionDetailsViews
.
isVisible
=
infectedStatus
is
InfectedStatus
.
Ha
s
Contacts
if
(
infectedStatus
is
InfectedStatus
.
Ha
s
Contacts
)
setupInfectionStateHadContactsDescription
(
infectedStatus
)
}
private
fun
FragmentHomeBinding
.
setupHeaderText
(
infectedStatus
:
InfectedStatus
)
{
val
text
=
when
(
infectedStatus
)
{
is
InfectedStatus
.
Infected
->
getString
(
R
.
string
.
home_infection_status_infected
)
is
InfectedStatus
.
Ha
d
Contacts
->
resources
.
getQuantityString
(
is
InfectedStatus
.
Ha
s
Contacts
->
resources
.
getQuantityString
(
R
.
plurals
.
home_infection_status_had_contacts
,
infectedStatus
.
num
,
infectedStatus
.
num
...
...
@@ -156,14 +160,14 @@ class HomeFragment : MvvmFragment(R.layout.fragment_home), ViewBindingHolder<Fra
}
private
fun
FragmentHomeBinding
.
setupHeaderImage
(
infectedStatus
:
InfectedStatus
)
{
val
imageResource
=
if
(
infectedStatus
is
InfectedStatus
.
Ha
d
Contacts
)
R
.
drawable
.
ic_virus
else
R
.
drawable
.
ic_checkmark
val
imageResource
=
if
(
infectedStatus
is
InfectedStatus
.
Ha
s
Contacts
)
R
.
drawable
.
ic_virus
else
R
.
drawable
.
ic_checkmark
infectionStatusImage
.
setImageResource
(
imageResource
)
}
private
fun
FragmentHomeBinding
.
setupHeaderColor
(
infectedStatus
:
InfectedStatus
)
{
val
colorRes
=
when
(
infectedStatus
)
{
is
InfectedStatus
.
Infected
->
R
.
color
.
dark_green
is
InfectedStatus
.
Ha
d
Contacts
->
R
.
color
.
pink
is
InfectedStatus
.
Ha
s
Contacts
->
R
.
color
.
pink
is
InfectedStatus
.
None
->
R
.
color
.
primary
}.
exhaustive
val
color
=
ContextCompat
.
getColor
(
requireContext
(),
colorRes
)
...
...
@@ -172,7 +176,7 @@ class HomeFragment : MvvmFragment(R.layout.fragment_home), ViewBindingHolder<Fra
requireActivity
().
window
.
statusBarColor
=
color
}
private
fun
FragmentHomeBinding
.
setupInfectionStateHadContactsDescription
(
infectedStatus
:
InfectedStatus
.
Ha
d
Contacts
)
{
private
fun
FragmentHomeBinding
.
setupInfectionStateHadContactsDescription
(
infectedStatus
:
InfectedStatus
.
Ha
s
Contacts
)
{
val
formattedDate
=
DateUtils
.
getFormattedLocalDate
(
infectedStatus
.
stayHomeUntilDate
)
infectionStatusDescription
.
setTextWithBoldSpans
(
getString
(
...
...
@@ -192,7 +196,7 @@ class HomeFragment : MvvmFragment(R.layout.fragment_home), ViewBindingHolder<Fra
override
fun
onAnimationStart
(
animation
:
Animation
?)
=
Unit
override
fun
onAnimationEnd
(
animation
:
Animation
?)
{
if
(
infectedStatus
is
InfectedStatus
.
Ha
d
Contacts
)
{
if
(
infectedStatus
is
InfectedStatus
.
Ha
s
Contacts
)
{
infectionDetailsViews
.
isVisible
=
true
}
setupHeaderText
(
infectedStatus
)
...
...
app/src/main/java/org/dpppt/android/app/home/HomeViewModel.kt
View file @
937ec183
...
...
@@ -123,9 +123,11 @@ class HomeViewModel @Inject constructor(
_tracing
.
value
=
tracingStatus
}
val
infectionStatus
=
getInfectedStatusUseCase
.
execute
(
status
)
_infectedStatus
.
value
=
infectionStatus
if
(
infectionStatus
is
InfectedStatus
.
None
||
infectionStatus
is
InfectedStatus
.
HadContacts
)
{
_action
.
value
=
Event
(
Action
.
StartLoadingAnimation
(
infectionStatus
))
if
(
infectionStatus
!=
_infectedStatus
.
value
)
{
_infectedStatus
.
value
=
infectionStatus
if
(
infectionStatus
is
InfectedStatus
.
None
||
infectionStatus
is
InfectedStatus
.
HasContacts
)
{
_action
.
value
=
Event
(
Action
.
StartLoadingAnimation
(
infectionStatus
))
}
}
}
...
...
app/src/main/java/org/dpppt/android/app/main/model/InfectedStatus.kt
View file @
937ec183
...
...
@@ -5,5 +5,5 @@ import java.time.LocalDate
sealed
class
InfectedStatus
{
object
None
:
InfectedStatus
()
object
Infected
:
InfectedStatus
()
data class
Ha
d
Contacts
(
val
num
:
Int
,
val
stayHomeUntilDate
:
LocalDate
)
:
InfectedStatus
()
data class
Ha
s
Contacts
(
val
num
:
Int
,
val
stayHomeUntilDate
:
LocalDate
)
:
InfectedStatus
()
}
app/src/main/res/layout/fragment_home.xml
View file @
937ec183
...
...
@@ -47,7 +47,9 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
android:id=
"@+id/parentView"
android:animateLayoutChanges=
"true"
>
<include
layout=
"@layout/guidelines_all_16"
/>
...
...
@@ -55,7 +57,7 @@
android:id=
"@+id/colorView"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android
:src=
"@color/primary"
tools
:src=
"@color/primary"
app:layout_constraintBottom_toBottomOf=
"@id/headerImage"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
Write
Preview
Supports
Markdown
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