From 57e77dbb6e9f12504f3133285ced9c684bcbaaf0 Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Wed, 17 Dec 2025 21:16:38 +0530 Subject: [PATCH] refactor(stats): use string resources --- .../ui/statsScreen/components/visualizations.kt | 7 +++++-- .../pomodoro/ui/statsScreen/screens/LastMonthScreen.kt | 6 +++--- .../pomodoro/ui/statsScreen/screens/LastWeekScreen.kt | 4 ++-- .../pomodoro/ui/statsScreen/screens/LastYearScreen.kt | 10 +++++----- app/src/main/res/values/strings.xml | 4 ++++ 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/visualizations.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/visualizations.kt index 83daaf8..4e2a079 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/visualizations.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/visualizations.kt @@ -271,7 +271,7 @@ fun FocusBreakRatioVisualization( ) ) Text( - text = breakPercentage.roundToInt().toString() + '%', + text = "${breakPercentage.roundToInt()}%", style = typography.bodyLarge, color = colorScheme.tertiary, modifier = Modifier.padding(start = 6.dp) @@ -438,7 +438,10 @@ fun HeatmapWithWeekLabels( ) Spacer(Modifier.height(4.dp)) Text( - text = millisecondsToHoursMinutes(sum), + text = millisecondsToHoursMinutes( + sum, + stringResource(R.string.hours_and_minutes_format) + ), style = typography.bodyMedium ) Spacer(Modifier.height(8.dp)) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastMonthScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastMonthScreen.kt index 46296f4..001c96a 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastMonthScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastMonthScreen.kt @@ -269,7 +269,7 @@ fun SharedTransitionScope.LastMonthScreen( modifier = Modifier.rotate(iconRotation) ) Spacer(Modifier.width(ButtonDefaults.IconSpacing)) - Text("Show chart") + Text(stringResource(R.string.show_chart)) } FocusBreakdownChart( @@ -297,11 +297,11 @@ fun SharedTransitionScope.LastMonthScreen( item { Text( - "Focus history heatmap", + "Focus history calendar", style = typography.headlineSmall ) Text( - "Focus history of the past year. Brighter colors represent a longer focus duration.", + "Focus history of the past month", style = typography.bodySmall, color = colorScheme.onSurfaceVariant ) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastWeekScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastWeekScreen.kt index 6353655..56214a4 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastWeekScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastWeekScreen.kt @@ -270,7 +270,7 @@ fun SharedTransitionScope.LastWeekScreen( modifier = Modifier.rotate(iconRotation) ) Spacer(Modifier.width(ButtonDefaults.IconSpacing)) - Text("Show chart") + Text(stringResource(R.string.show_chart)) } FocusBreakdownChart( @@ -313,7 +313,7 @@ fun SharedTransitionScope.LastWeekScreen( Spacer(Modifier.width(18.dp)) (1..9 step 2).forEach { Text( - (it * 10).toString() + "%\n|", + "${it * 10}%\n|", style = typography.labelSmall, textAlign = TextAlign.Center, modifier = Modifier.weight(1f) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastYearScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastYearScreen.kt index b8cca1e..2d03aad 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastYearScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/screens/LastYearScreen.kt @@ -290,7 +290,7 @@ fun SharedTransitionScope.LastYearScreen( modifier = Modifier.rotate(iconRotation) ) Spacer(Modifier.width(ButtonDefaults.IconSpacing)) - Text("Show chart") + Text(stringResource(R.string.show_chart)) } FocusBreakdownChart( @@ -320,12 +320,12 @@ fun SharedTransitionScope.LastYearScreen( item { Text( - "Focus history heatmap", + stringResource(R.string.focus_history_heatmap), style = typography.headlineSmall, modifier = Modifier.padding(horizontal = 16.dp) ) Text( - "Focus history of the past year. Deeper colors represent a longer focus duration. Cells are grouped by month.", + stringResource(R.string.focus_history_heatmap_desc), style = typography.bodySmall, color = colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 16.dp) @@ -347,7 +347,7 @@ fun SharedTransitionScope.LastYearScreen( modifier = Modifier.fillMaxWidth() ) { Text( - "Less", + stringResource(R.string.less), color = colorScheme.onSurfaceVariant, style = typography.labelMedium ) @@ -374,7 +374,7 @@ fun SharedTransitionScope.LastYearScreen( } Spacer(Modifier.width(8.dp)) Text( - "More", + stringResource(R.string.more), color = colorScheme.onSurfaceVariant, style = typography.labelMedium ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4ea1d5f..2467e98 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -114,4 +114,8 @@ Average focus durations at different times of the day Focus history Focus breakdown of each day of the past week (click on each cell for more info) + Less + Show chart + Focus history heatmap + Focus history of the past year. Deeper colors represent a longer duration. Cells are grouped by month. Tap on cells for more info. \ No newline at end of file