Update sorting & view UI.

This commit is contained in:
Thomas Andres Gomez 2025-12-02 18:48:08 +01:00
parent d8902dcd28
commit c694d9b4d9
11 changed files with 75 additions and 101 deletions

View file

@ -28,7 +28,7 @@ android {
minSdk = 26
targetSdk = 36
versionCode = 1
versionName = "1.0"
versionName = "1.0.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@ -38,9 +38,6 @@ android {
applicationIdSuffix = ".dev"
isDebuggable = true
isMinifyEnabled = false
defaultConfig {
versionCode = 1
}
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
@ -50,9 +47,6 @@ android {
isDebuggable = false
isMinifyEnabled = true
signingConfig = signingConfigs.getByName("pixelized")
defaultConfig {
versionCode = getGitBuildNumber()
}
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
@ -110,19 +104,6 @@ dependencies {
ksp("com.google.dagger:hilt-compiler:2.57.2")
}
@Suppress("DEPRECATION")
private fun getGitBuildNumber(
charset: Charset = Charset.defaultCharset(),
): Int {
return ByteArrayOutputStream().use { stream ->
rootProject.exec {
commandLine("git", "rev-list", "--count", "HEAD")
standardOutput = stream
}
stream.toString(charset).trim().toIntOrNull() ?: 1
}
}
fun SigningConfig.populatePixelizedSigningConfig() {
storeFile = (project.properties["PIXELIZED_RELEASE_STORE_FILE"] as? String)?.let { file(it) }
storePassword = project.properties["PIXELIZED_RELEASE_STORE_PASSWORD"] as? String

View file

@ -1,37 +0,0 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.pixelized.headache",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File",
"baselineProfiles": [
{
"minApi": 28,
"maxApi": 30,
"baselineProfiles": [
"baselineProfiles/1/app-release.dm"
]
},
{
"minApi": 31,
"maxApi": 2147483647,
"baselineProfiles": [
"baselineProfiles/0/app-release.dm"
]
}
],
"minSdkVersionForDexing": 26
}

View file

@ -62,6 +62,7 @@ class MonthSummaryFactory @Inject constructor() {
)
}
}
.sortedByDescending { it.date }
.groupByMonth()
.toSortedMap{s1, s2 ->
when{

View file

@ -21,6 +21,7 @@ import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.keepScreenOn
import androidx.compose.ui.tooling.preview.Preview
@ -90,14 +91,9 @@ private fun MonthSummaryContent(
flingBehavior = flingBehavior,
contentPadding = listPadding,
verticalArrangement = Arrangement.spacedBy(space = spacing),
reverseLayout = false,
reverseLayout = true,
) {
events.value.forEach { entry ->
item {
MonthSummaryTitle(
item = entry.key,
)
}
items(
items = entry.value,
key = { item -> item.date },
@ -107,6 +103,11 @@ private fun MonthSummaryContent(
onItem = onItem,
)
}
item {
MonthSummaryTitle(
item = entry.key,
)
}
}
}
}

View file

@ -1,18 +1,17 @@
package com.pixelized.headache.ui.page.summary.report
import android.R
import android.annotation.SuppressLint
import android.icu.text.DateFormat
import android.icu.text.SimpleDateFormat
import android.icu.util.Calendar
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
@ -153,13 +152,24 @@ private fun Month(
),
contentAlignment = Alignment.TopCenter,
) {
Text(
style = MaterialTheme.typography.labelSmall,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
color = Color.White,
text = stat.label,
)
when (index == 0 && item.stats.size >= 2) {
true -> Text(
modifier = Modifier.offset(y = (-14).dp),
style = MaterialTheme.typography.labelSmall,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
color = MaterialTheme.colorScheme.onSurface,
text = stat.label,
)
else -> Text(
style = MaterialTheme.typography.labelSmall,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
color = Color.White,
text = stat.label,
)
}
}
}
}
@ -227,8 +237,8 @@ private class ReportBoxPreviewProvider : PreviewParameterProvider<ReportBoxUio>
month(month = Calendar.JULY, headache = 7, pills = 3),
month(month = Calendar.AUGUST, headache = 8, pills = 5),
month(month = Calendar.SEPTEMBER, headache = 8, pills = 5),
month(month = Calendar.OCTOBER),
month(month = Calendar.NOVEMBER),
month(month = Calendar.OCTOBER, headache = 15, pills = 15),
month(month = Calendar.NOVEMBER, headache = 9, pills = 7),
month(month = Calendar.DECEMBER),
)
)

View file

@ -38,17 +38,25 @@ class ReportFactory @Inject constructor() {
year = yearEntry.key
)
}.time,
stats = listOf(
ReportBoxUio.Bar(
color = HeadacheColorPalette.Calendar.Headache,
label = "$headache",
ratio = headache.toFloat() / dayInMonth.toFloat(),
),
ReportBoxUio.Bar(
color = HeadacheColorPalette.Calendar.Pill,
label = "$pills",
ratio = pills.toFloat() / maxPillAmountPerMonth.toFloat(),
),
stats = listOfNotNull(
if (headache > 0) {
ReportBoxUio.Bar(
color = HeadacheColorPalette.Calendar.Headache,
label = "$headache",
ratio = headache.toFloat() / dayInMonth.toFloat(),
)
} else {
null
},
if (pills > 0) {
ReportBoxUio.Bar(
color = HeadacheColorPalette.Calendar.Pill,
label = "$pills",
ratio = pills.toFloat() / maxPillAmountPerMonth.toFloat(),
)
} else {
null
},
).sortedByDescending { it.ratio },
)
}

View file

@ -91,6 +91,7 @@ private fun ReportContent(
state = state,
flingBehavior = flingBehavior,
contentPadding = paddingValues,
reverseLayout = true,
verticalArrangement = Arrangement.spacedBy(space = contentSpace),
) {
items(
@ -158,9 +159,9 @@ private class ReportPreviewProvider : PreviewParameterProvider<List<ReportBoxUio
month(month = Calendar.JUNE, headache = 12, pills = 13),
month(month = Calendar.JULY, headache = 7, pills = 3),
month(month = Calendar.AUGUST, headache = 8, pills = 5),
month(month = Calendar.SEPTEMBER, headache = 8, pills = 5),
month(month = Calendar.OCTOBER, headache = 0, pills = 0),
month(month = Calendar.NOVEMBER, headache = 0, pills = 0),
month(month = Calendar.SEPTEMBER, headache = 10, pills = 5),
month(month = Calendar.OCTOBER, headache = 15, pills = 15),
month(month = Calendar.NOVEMBER, headache = 9, pills = 7),
month(month = Calendar.DECEMBER, headache = 0, pills = 0),
),
),

View file

@ -12,15 +12,15 @@ class YearSummaryFactory @Inject constructor() {
): List<YearUio> {
val monthFirstDayCalendar = Calendar.getInstance().apply {
firstDayOfWeek = Calendar.MONDAY
setMinimalDaysInFirstWeek(1)
minimalDaysInFirstWeek = 1
}
val monthLastDayCalendar = Calendar.getInstance().apply {
firstDayOfWeek = Calendar.MONDAY
setMinimalDaysInFirstWeek(1)
minimalDaysInFirstWeek = 1
}
val currentDayCalendar = Calendar.getInstance().apply {
firstDayOfWeek = Calendar.MONDAY
setMinimalDaysInFirstWeek(1)
minimalDaysInFirstWeek = 1
}
return events
@ -73,6 +73,14 @@ class YearSummaryFactory @Inject constructor() {
date = monthFirstDayCalendar.time,
weeks = weeks,
)
}.sortedWith { s1, s2 ->
when {
s1.date.month / 3 < s2.date.month / 3 -> 1
s1.date.month / 3 > s2.date.month / 3 -> -1
s1.date.month < s2.date.month -> -1
s1.date.month > s2.date.month -> 1
else -> 0
}
},
)
}

View file

@ -111,19 +111,10 @@ fun YearSummaryContent(
columns = GridCells.Adaptive(minSize = daySize * 7),
horizontalArrangement = Arrangement.spacedBy(space = space),
verticalArrangement = Arrangement.spacedBy(space = space),
reverseLayout = true,
contentPadding = paddingValues,
) {
uio.value.forEachIndexed { index, (year, months) ->
item(
span = { GridItemSpan(maxLineSpan) },
contentType = { "Title" },
) {
Text(
modifier = Modifier.padding(top = 16.dp),
style = MaterialTheme.typography.displaySmall,
text = "$year",
)
}
items(
items = months,
key = { it.date.time },
@ -137,6 +128,16 @@ fun YearSummaryContent(
onMonth = onMonth,
)
}
item(
span = { GridItemSpan(maxLineSpan) },
contentType = { "Title" },
) {
Text(
modifier = Modifier.padding(top = 16.dp),
style = MaterialTheme.typography.displaySmall,
text = "$year",
)
}
}
}
}