Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

ExposureHistory - high risk by multiple low risk (EXPOSUREAPP-3515) #2397

Merged
merged 18 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ object DiaryData {
)

val HIGH_RISK = ListItem.Risk(
R.string.contact_diary_risk_body,
R.string.contact_diary_high_risk_title,
R.drawable.ic_high_risk_alert
title = R.string.contact_diary_high_risk_title,
body = R.string.contact_diary_risk_body,
bodyExtended = R.string.contact_diary_risk_body_extended,
drawableId = R.drawable.ic_high_risk_alert
)

val HIGH_RISK_DUE_LOW_RISK_ENCOUNTERS = HIGH_RISK.copy(body = R.string.contact_diary_risk_body_high_risk_due_to_low_risk_encounters)

val LOW_RISK = ListItem.Risk(
R.string.contact_diary_risk_body,
R.string.contact_diary_low_risk_title,
R.drawable.ic_low_risk_alert
title = R.string.contact_diary_low_risk_title,
body = R.string.contact_diary_risk_body,
bodyExtended = R.string.contact_diary_risk_body_extended,
drawableId = R.drawable.ic_low_risk_alert
)

val LOCATIONS: List<DiaryLocationListItem> = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,14 @@ class MainActivityTest : BaseUITest() {
MutableLiveData(
(0 until ContactDiaryOverviewViewModel.DAY_COUNT)
.map { LocalDate.now().minusDays(it) }
.map {
ListItem(it).apply {
.mapIndexed { index, localDate ->
ListItem(localDate).apply {
data.addAll(DiaryData.DATA_ITEMS)
risk = if (it.dayOfYear % 2 == 0) DiaryData.HIGH_RISK else DiaryData.LOW_RISK
risk = when (index % 3) {
0 -> DiaryData.HIGH_RISK
1 -> DiaryData.HIGH_RISK_DUE_LOW_RISK_ENCOUNTERS
else -> DiaryData.LOW_RISK
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[
{
"ageInDays": 1,
"reportType": 3,
"infectiousness": 1,
"calibrationConfidence": 0,
"scanInstances": [
{
"minAttenuation": 30,
"typicalAttenuation": 25,
"secondsSinceLastScan": 300
},
{
"minAttenuation": 30,
"typicalAttenuation": 25,
"secondsSinceLastScan": 300
}
]
},
{
"ageInDays": 1,
"reportType": 3,
"infectiousness": 1,
"calibrationConfidence": 0,
"scanInstances": [
{
"minAttenuation": 30,
"typicalAttenuation": 26,
"secondsSinceLastScan": 300
},
{
"minAttenuation": 30,
"typicalAttenuation": 26,
"secondsSinceLastScan": 300
}
]
},
{
"ageInDays": 1,
"reportType": 3,
"infectiousness": 1,
"calibrationConfidence": 0,
"scanInstances": [
{
"minAttenuation": 30,
"typicalAttenuation": 27,
"secondsSinceLastScan": 300
},
{
"minAttenuation": 30,
"typicalAttenuation": 27,
"secondsSinceLastScan": 300
}
]
},
{
"ageInDays": 2,
"reportType": 3,
"infectiousness": 1,
"calibrationConfidence": 0,
"scanInstances": [
{
"minAttenuation": 30,
"typicalAttenuation": 25,
"secondsSinceLastScan": 300
},
{
"minAttenuation": 30,
"typicalAttenuation": 25,
"secondsSinceLastScan": 300
}
]
},
{
"ageInDays": 2,
"reportType": 3,
"infectiousness": 1,
"calibrationConfidence": 0,
"scanInstances": [
{
"minAttenuation": 30,
"typicalAttenuation": 26,
"secondsSinceLastScan": 300
},
{
"minAttenuation": 30,
"typicalAttenuation": 26,
"secondsSinceLastScan": 300
}
]
},
{
"ageInDays": 2,
"reportType": 3,
"infectiousness": 1,
"calibrationConfidence": 0,
"scanInstances": [
{
"minAttenuation": 30,
"typicalAttenuation": 27,
"secondsSinceLastScan": 300
},
{
"minAttenuation": 30,
"typicalAttenuation": 27,
"secondsSinceLastScan": 300
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class FakeExposureWindowProvider @Inject constructor(
fun getExposureWindows(testSettings: FakeExposureWindowTypes): List<ExposureWindow> {
val jsonInput = when (testSettings) {
FakeExposureWindowTypes.INCREASED_RISK_DEFAULT -> "exposure-windows-increased-risk-random.json"
FakeExposureWindowTypes.INCREASED_RISK_DUE_LOW_RISK_ENCOUNTER_DEFAULT -> "exposure-windows-increased-risk-due-to-low-risk-encounter-random.json"
FakeExposureWindowTypes.LOW_RISK_DEFAULT -> "exposure-windows-lowrisk-random.json"
else -> throw NotImplementedError()
}.let { context.assets.open(it) }.readBytes().toString(Charsets.UTF_8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,33 @@ class ContactDiaryOverviewViewModel @AssistedInject constructor(
data.addLocationVisitsForDate(locationVisitList, date)
risk = riskLevelPerDateList
.firstOrNull { riskLevelPerDate -> riskLevelPerDate.day == it }
?.toRisk(data.isEmpty())
?.toRisk(data.isNotEmpty())
}
}
}

private fun AggregatedRiskPerDateResult.toRisk(noLocationOrPerson: Boolean): ListItem.Risk {
private fun AggregatedRiskPerDateResult.toRisk(locationOrPerson: Boolean): ListItem.Risk {
@StringRes val title: Int
@StringRes var body: Int = R.string.contact_diary_risk_body
@DrawableRes val drawableId: Int

@StringRes val body: Int = when (noLocationOrPerson) {
true -> R.string.contact_diary_risk_body
false -> R.string.contact_diary_risk_body_extended
@StringRes val bodyExtend: Int? = when (locationOrPerson) {
true -> R.string.contact_diary_risk_body_extended
false -> null
}

if (this.riskLevel == RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.HIGH) {
title = R.string.contact_diary_high_risk_title
drawableId = R.drawable.ic_high_risk_alert
if (minimumDistinctEncountersWithHighRisk == 0) {
body = R.string.contact_diary_risk_body_high_risk_due_to_low_risk_encounters
}
} else {
title = R.string.contact_diary_low_risk_title
drawableId = R.drawable.ic_low_risk_alert
}

return ListItem.Risk(title, body, drawableId)
return ListItem.Risk(title, body, bodyExtend, drawableId)
}

private fun MutableList<ListItem.Data>.addPersonEncountersForDate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ class ContactDiaryOverviewAdapter(
item.risk?.let {
this.contactDiaryOverviewRiskItem.isGone = false
this.contactDiaryOverviewItemRiskTitle.text = context.getString(it.title)
this.contactDiaryOverviewItemRiskBody.text = context.getString(it.body)
this.contactDiaryOverviewRiskItemImage.setImageResource(it.drawableId)

val sb = StringBuilder().append(context.getString(it.body))

it.bodyExtended?.let { extend ->
sb.appendLine().append(context.getString(extend))
}

this.contactDiaryOverviewItemRiskBody.text = sb
} ?: run { this.contactDiaryOverviewRiskItem.isGone = true }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data class ListItem(
data class Risk(
@StringRes val title: Int,
@StringRes val body: Int,
@StringRes val bodyExtended: Int? = null,
@DrawableRes val drawableId: Int
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class TestSettings @Inject constructor(
@SerializedName("INCREASED_RISK_DEFAULT")
INCREASED_RISK_DEFAULT,

@SerializedName("INCREASED_RISK_DUE_LOW_RISK_ENCOUNTER_DEFAULT")
INCREASED_RISK_DUE_LOW_RISK_ENCOUNTER_DEFAULT,

@SerializedName("LOW_RISK_DEFAULT")
LOW_RISK_DEFAULT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@
<string name="contact_diary_low_risk_title">"Niedriges Risiko"</string>
<!-- XTXT: Body for contact diary overview screen risk information -->
<string name="contact_diary_risk_body">"aufgrund der von der App ausgewerteten Begegnungen."</string>
<!-- XTXT: Body for contact diary overview screen risk information when high risk due to low risk encounters-->
<string name="contact_diary_risk_body_high_risk_due_to_low_risk_encounters">"aufgrund von mehreren Begegnungen mit niedrigem Risiko."</string>
<!-- XTXT: Extended Body for contact diary overview screen risk information -->
<string name="contact_diary_risk_body_extended">"aufgrund der von der App ausgewerteten Begegnungen. Diese müssen nicht in Zusammenhang mit den von Ihnen erfassten Personen und Orten stehen."</string>
<string name="contact_diary_risk_body_extended">"Diese müssen nicht in Zusammenhang mit den von Ihnen erfassten Personen und Orten stehen."</string>


<!-- XTXT: content description of contact journal image on home screen -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@
<string name="contact_diary_low_risk_title">"Low Risk"</string>
<!-- XTXT: Body for contact diary overview screen risk information -->
<string name="contact_diary_risk_body">"based on the encounters evaluated by the app."</string>
<!-- XTXT: Body for contact diary overview screen risk information when high risk due to low risk encounters-->
<string name="contact_diary_risk_body_high_risk_due_to_low_risk_encounters">"based on several encounters with low risk."</string>
<!-- XTXT: Extended Body for contact diary overview screen risk information -->
<string name="contact_diary_risk_body_extended">"based on the encounters evaluated by the app. They are not necessarily related to the people and places you have recorded."</string>
<string name="contact_diary_risk_body_extended">"They are not necessarily related to the people and places you have recorded."</string>


<!-- XTXT: content description of contact journal image on home screen -->
Expand Down
Loading