Skip to content

Commit

Permalink
add goal total excess and deficit detailed statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
Razeeman committed Dec 14, 2024
1 parent 625550d commit 9323d8e
Show file tree
Hide file tree
Showing 28 changed files with 119 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum class StatisticsDetailBlock {
GoalChartGrouping,
GoalChartLength,
GoalRangeAverages,
GoalTotals,
DataDistributionHint,
DataDistributionPieChart,
DataDistributionBarChart,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class BarChartView @JvmOverloads constructor(
}

private fun drawLines(canvas: Canvas) {
val points = (0..valueUpperBound step nearestValueStep).toList()
val points = (valueDownerBound..valueUpperBound step nearestValueStep).toList()
points.forEachIndexed { index, _ ->
canvas.drawLine(
0f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,12 +730,19 @@ class StatisticsDetailViewDataMapper @Inject constructor(
availableChartLengths = availableChartLengths,
appliedChartLength = appliedChartLength,
)

items += StatisticsDetailHintViewData(
block = StatisticsDetailBlock.GoalExcessDeficitHint,
text = resourceRepo.getString(R.string.statistics_detail_goals_hint),
val goalTotals = mapGoalExcessDeficitTotals(
goalData = goalData,
useProportionalMinutes = useProportionalMinutes,
showSeconds = showSeconds,
)

if (chartData.visible) {
items += StatisticsDetailHintViewData(
block = StatisticsDetailBlock.GoalExcessDeficitHint,
text = resourceRepo.getString(R.string.statistics_detail_goals_hint),
)
}

if (chartData.visible) {
items += StatisticsDetailBarChartViewData(
block = StatisticsDetailBlock.GoalChartData,
Expand Down Expand Up @@ -770,6 +777,15 @@ class StatisticsDetailViewDataMapper @Inject constructor(
)
}

if (chartData.visible) {
items += StatisticsDetailCardViewData(
block = StatisticsDetailBlock.GoalTotals,
title = "",
marginTopDp = 0,
data = goalTotals,
)
}

return items
}

Expand Down Expand Up @@ -841,8 +857,53 @@ class StatisticsDetailViewDataMapper @Inject constructor(
).let(::listOf)
}

// TODO GOAL mark zero line on bar chart, to be more visible.
// TODO GOAL add total excess and total deficit for selected range.
private fun mapGoalExcessDeficitTotals(
goalData: List<ChartBarDataDuration>,
useProportionalMinutes: Boolean,
showSeconds: Boolean,
): List<StatisticsDetailCardInternalViewData> {
val barValues = goalData.map { bar -> bar.durations.sumOf { it.first } }
val negativeValue = barValues.filter { it < 0L }.sum()
val positiveValue = barValues.filter { it > 0L }.sum()
val total = negativeValue + positiveValue

fun formatInterval(
interval: Long,
): String {
return timeMapper.formatInterval(
interval = interval,
forceSeconds = showSeconds,
useProportionalMinutes = useProportionalMinutes,
)
}

return listOf(
StatisticsDetailCardInternalViewData(
value = formatInterval(negativeValue),
valueChange = StatisticsDetailCardInternalViewData.ValueChange.None,
secondValue = "",
description = resourceRepo.getString(R.string.statistics_detail_goals_deficit),
titleTextSizeSp = 14,
subtitleTextSizeSp = 12,
),
StatisticsDetailCardInternalViewData(
value = formatInterval(total),
valueChange = StatisticsDetailCardInternalViewData.ValueChange.None,
secondValue = "",
description = resourceRepo.getString(R.string.statistics_detail_total_duration),
titleTextSizeSp = 14,
subtitleTextSizeSp = 12,
),
StatisticsDetailCardInternalViewData(
value = formatInterval(positiveValue),
valueChange = StatisticsDetailCardInternalViewData.ValueChange.None,
secondValue = "",
description = resourceRepo.getString(R.string.statistics_detail_goals_excess),
titleTextSizeSp = 14,
subtitleTextSizeSp = 12,
),
)
}

private fun mapToChartGroupingViewData(
availableChartGroupings: List<ChartGrouping>,
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@
<string name="statistics_detail_next_activities_hint">أهم الأنشطة القادمة</string>
<string name="statistics_detail_multitasking_activities_hint">أعلى المهام المتعددة</string>
<string name="statistics_detail_goals_hint">هدف فائض أو عجز</string>
<string name="statistics_detail_goals_excess">إفراط</string>
<string name="statistics_detail_goals_deficit">العجز</string>

<plurals name="statistics_detail_times_tracked">
<item quantity="zero">تتبع</item>
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Exemple:<br/>
<string name="statistics_detail_next_activities_hint">Les properes activitats principals</string>
<string name="statistics_detail_multitasking_activities_hint">Top multitasca</string>
<string name="statistics_detail_goals_hint">Excés o dèficit d\'objectius</string>
<string name="statistics_detail_goals_excess">Excés</string>
<string name="statistics_detail_goals_deficit">Dèficit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Enregistraments</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Beispiel:<br/>
<string name="statistics_detail_next_activities_hint">Top nächste Aktivitäten</string>
<string name="statistics_detail_multitasking_activities_hint">Top Multitasking</string>
<string name="statistics_detail_goals_hint">Zielüberschreitung oder -defizit</string>
<string name="statistics_detail_goals_excess">Überschuss</string>
<string name="statistics_detail_goals_deficit">Defizit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">keine Einträge</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Ejemplo:<br/>
<string name="statistics_detail_next_activities_hint">Principales próximas actividades</string>
<string name="statistics_detail_multitasking_activities_hint">Principal multitarea</string>
<string name="statistics_detail_goals_hint">Exceso o déficit de goles</string>
<string name="statistics_detail_goals_excess">Exceso</string>
<string name="statistics_detail_goals_deficit">Déficit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Registros</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@
<string name="statistics_detail_next_activities_hint">برترین فعالیت های بعدی</string>
<string name="statistics_detail_multitasking_activities_hint">چند کاره برتر</string>
<string name="statistics_detail_goals_hint">بیش از حد یا کسری هدف</string>
<string name="statistics_detail_goals_excess">مازاد</string>
<string name="statistics_detail_goals_deficit">کسری</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">بدون تاریخچه</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Exemple:<br/>
<string name="statistics_detail_next_activities_hint">Top des prochaines activités</string>
<string name="statistics_detail_multitasking_activities_hint">Top multitâche</string>
<string name="statistics_detail_goals_hint">Excès ou déficit d\'objectif</string>
<string name="statistics_detail_goals_excess">Excès</string>
<string name="statistics_detail_goals_deficit">Déficit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Enregistrement</item> -->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ csv फ़ाइल में कॉमा से अलग किए गए य
<string name="statistics_detail_next_activities_hint">शीर्ष अगली गतिविधियाँ</string>
<string name="statistics_detail_multitasking_activities_hint">शीर्ष मल्टीटास्कड</string>
<string name="statistics_detail_goals_hint">लक्ष्य की अधिकता या कमी</string>
<string name="statistics_detail_goals_excess">अधिकता</string>
<string name="statistics_detail_goals_deficit">घाटा</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">अभिलेख</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Contoh:<br/>
<string name="statistics_detail_next_activities_hint">Aktivitas teratas selanjutnya</string>
<string name="statistics_detail_multitasking_activities_hint">Multitugas teratas</string>
<string name="statistics_detail_goals_hint">Kelebihan atau kekurangan gol</string>
<string name="statistics_detail_goals_excess">Kelebihan</string>
<string name="statistics_detail_goals_deficit">Defisit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Rekor</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Esempio:<br/>
<string name="statistics_detail_next_activities_hint">Le migliori attività successive</string>
<string name="statistics_detail_multitasking_activities_hint">Il massimo del multitasking</string>
<string name="statistics_detail_goals_hint">Eccesso o deficit di obiettivo</string>
<string name="statistics_detail_goals_excess">Eccesso</string>
<string name="statistics_detail_goals_deficit">Deficit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Registrazioni</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-iw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@
<string name="statistics_detail_next_activities_hint">פעילויות באות מובילות</string>
<string name="statistics_detail_multitasking_activities_hint">ריבוי משימות מוביל</string>
<string name="statistics_detail_goals_hint">עודף או גירעון יעד</string>
<string name="statistics_detail_goals_excess">עוֹדֶף</string>
<string name="statistics_detail_goals_deficit">גֵרָעוֹן</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">רשומות</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ CSV ファイルには、カンマで区切られた次の列が含まれてい
<string name="statistics_detail_next_activities_hint">次に注目のアクティビティ</string>
<string name="statistics_detail_multitasking_activities_hint">トップのマルチタスク</string>
<string name="statistics_detail_goals_hint">目標超過または不足</string>
<string name="statistics_detail_goals_excess">過剰</string>
<string name="statistics_detail_goals_deficit">赤字</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">記録</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ csv 파일은 다음과 같은 열(column)들을 가져야합니다:<br/>
<string name="statistics_detail_next_activities_hint">다음 주요 활동</string>
<string name="statistics_detail_multitasking_activities_hint">최고의 멀티태스킹</string>
<string name="statistics_detail_goals_hint">목표 초과 또는 적자</string>
<string name="statistics_detail_goals_excess">과잉</string>
<string name="statistics_detail_goals_deficit">부족</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">기록</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Voorbeeld:<br/>
<string name="statistics_detail_next_activities_hint">Top volgende activiteiten</string>
<string name="statistics_detail_multitasking_activities_hint">Top multitasken</string>
<string name="statistics_detail_goals_hint">Doeloverschot of -tekort</string>
<string name="statistics_detail_goals_excess">Overmaat</string>
<string name="statistics_detail_goals_deficit">Tekort</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Gegevens</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Przykład:<br/>
<string name="statistics_detail_next_activities_hint">Bezpośrednio przed</string>
<string name="statistics_detail_multitasking_activities_hint">Najczęściej razem z</string>
<string name="statistics_detail_goals_hint">Nadmiar lub niedobór celu</string>
<string name="statistics_detail_goals_excess">Nadmiar</string>
<string name="statistics_detail_goals_deficit">Deficyt</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">rekordów</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-pt-rPT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Exemplo:<br/>
<string name="statistics_detail_next_activities_hint">Principais próximas atividades</string>
<string name="statistics_detail_multitasking_activities_hint">Principais multitarefas</string>
<string name="statistics_detail_goals_hint">Excesso ou défice de meta</string>
<string name="statistics_detail_goals_excess">Excesso</string>
<string name="statistics_detail_goals_deficit">Déficit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Registos</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Exemplo:<br/>
<string name="statistics_detail_next_activities_hint">Principais próximas atividades</string>
<string name="statistics_detail_multitasking_activities_hint">Principais multitarefas</string>
<string name="statistics_detail_goals_hint">Excesso ou déficit de meta</string>
<string name="statistics_detail_goals_excess">Excesso</string>
<string name="statistics_detail_goals_deficit">Déficit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Registros</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-ro/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Examplu:<br/>
<string name="statistics_detail_next_activities_hint">Top următoare activități</string>
<string name="statistics_detail_multitasking_activities_hint">Top multitasked</string>
<string name="statistics_detail_goals_hint">Exces sau deficit de obiectiv</string>
<string name="statistics_detail_goals_excess">Exces</string>
<string name="statistics_detail_goals_deficit">Deficit</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Înregistrări</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ CSV-файл должен содержать следующие столбцы,
<string name="statistics_detail_next_activities_hint">Топ следующих активностей</string>
<string name="statistics_detail_multitasking_activities_hint">Топ многозадачности</string>
<string name="statistics_detail_goals_hint">Превышение или дефицит цели</string>
<string name="statistics_detail_goals_excess">Превышение</string>
<string name="statistics_detail_goals_deficit">Дефицит</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Записей</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Exempel:<br/>
<string name="statistics_detail_next_activities_hint">Topp nästa aktiviteter</string>
<string name="statistics_detail_multitasking_activities_hint">Top multitasked</string>
<string name="statistics_detail_goals_hint">Målöverskott eller underskott</string>
<string name="statistics_detail_goals_excess">Överskott</string>
<string name="statistics_detail_goals_deficit">Underskott</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">händelser</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ CSV dosyası virgülle ayrılmış şu sütunları içermelidir:<br/>
<string name="statistics_detail_next_activities_hint">Sonraki en iyi aktiviteler</string>
<string name="statistics_detail_multitasking_activities_hint">En iyi çoklu görev</string>
<string name="statistics_detail_goals_hint">Hedef fazlası veya açığı</string>
<string name="statistics_detail_goals_excess">Aşırı</string>
<string name="statistics_detail_goals_deficit">Açık</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Kayıt</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@
<string name="statistics_detail_next_activities_hint">Найчастіші наступні активності</string>
<string name="statistics_detail_multitasking_activities_hint">Топ багатозадачності</string>
<string name="statistics_detail_goals_hint">Перевищення або дефіцит цілі</string>
<string name="statistics_detail_goals_excess">Перевищення</string>
<string name="statistics_detail_goals_deficit">Дефіцит</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Записів</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Ví dụ:<br/>
<string name="statistics_detail_next_activities_hint">Hoạt động tiếp theo hàng đầu</string>
<string name="statistics_detail_multitasking_activities_hint">Đa nhiệm hàng đầu</string>
<string name="statistics_detail_goals_hint">Mục tiêu vượt quá hoặc thâm hụt</string>
<string name="statistics_detail_goals_excess">Thặng dư</string>
<string name="statistics_detail_goals_deficit">Thâm hụt</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Bản ghi</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ csv 文件必須包含以逗號分隔的這些列:<br/>
<string name="statistics_detail_next_activities_hint">下一個熱門活動</string>
<string name="statistics_detail_multitasking_activities_hint">頂級多工處理</string>
<string name="statistics_detail_goals_hint">目標超額或不足</string>
<string name="statistics_detail_goals_excess">過量的</string>
<string name="statistics_detail_goals_deficit">赤字</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">紀錄</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ csv 文件必须包含以逗号分隔的这些列:<br/>
<string name="statistics_detail_next_activities_hint">下一个热门活动</string>
<string name="statistics_detail_multitasking_activities_hint">顶级多任务处理</string>
<string name="statistics_detail_goals_hint">目标超出或不足</string>
<string name="statistics_detail_goals_excess">过量的</string>
<string name="statistics_detail_goals_deficit">赤字</string>

<plurals name="statistics_detail_times_tracked">
<!-- <item quantity="zero">Records</item>-->
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ Example:<br/>
<string name="statistics_detail_next_activities_hint">Top next activities</string>
<string name="statistics_detail_multitasking_activities_hint">Top multitasked</string>
<string name="statistics_detail_goals_hint">Goal excess or deficit</string>
<string name="statistics_detail_goals_excess">Excess</string>
<string name="statistics_detail_goals_deficit">Deficit</string>

<plurals name="statistics_detail_times_tracked">
<item quantity="zero">Records</item>
Expand Down

0 comments on commit 9323d8e

Please sign in to comment.