Commit 937ec183 authored by Harri Kirik's avatar Harri Kirik
Browse files

Merge branch 'develop' into feature/COVAPP-421-remove-2nd-day-ui

parents 312641f7 6030ac10
......@@ -75,7 +75,7 @@ class ContactsFragment : MvvmFragment(R.layout.fragment_contacts), ViewBindingHo
}
private fun showContacts(contacts: InfectedStatus) {
if (contacts !is InfectedStatus.HadContacts) {
if (contacts !is InfectedStatus.HasContacts) {
return
}
requireBinding {
......
......@@ -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.HadContacts(numContacts, stayHomeUntilDate)
InfectedStatus.HasContacts(numContacts, stayHomeUntilDate)
} else {
InfectedStatus.None
}
......
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.HadContacts
if (infectedStatus is InfectedStatus.HadContacts) setupInfectionStateHadContactsDescription(infectedStatus)
infectionDetailsViews.isVisible = infectedStatus is InfectedStatus.HasContacts
if (infectedStatus is InfectedStatus.HasContacts) setupInfectionStateHadContactsDescription(infectedStatus)
}
private fun FragmentHomeBinding.setupHeaderText(infectedStatus: InfectedStatus) {
val text = when (infectedStatus) {
is InfectedStatus.Infected -> getString(R.string.home_infection_status_infected)
is InfectedStatus.HadContacts -> resources.getQuantityString(
is InfectedStatus.HasContacts -> 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.HadContacts) R.drawable.ic_virus else R.drawable.ic_checkmark
val imageResource = if (infectedStatus is InfectedStatus.HasContacts) 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.HadContacts -> R.color.pink
is InfectedStatus.HasContacts -> 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.HadContacts) {
private fun FragmentHomeBinding.setupInfectionStateHadContactsDescription(infectedStatus: InfectedStatus.HasContacts) {
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.HadContacts) {
if (infectedStatus is InfectedStatus.HasContacts) {
infectionDetailsViews.isVisible = true
}
setupHeaderText(infectedStatus)
......
......@@ -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))
}
}
}
......
......@@ -5,5 +5,5 @@ import java.time.LocalDate
sealed class InfectedStatus {
object None : InfectedStatus()
object Infected : InfectedStatus()
data class HadContacts(val num: Int, val stayHomeUntilDate: LocalDate) : InfectedStatus()
data class HasContacts(val num: Int, val stayHomeUntilDate: LocalDate) : InfectedStatus()
}
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment