Increase font size in line graph forecast datafields (#142)
This commit is contained in:
parent
d1b6f2c525
commit
410441c3a6
@ -82,7 +82,7 @@ abstract class LineGraphForecastDataType(private val karooSystem: KarooSystemSer
|
|||||||
val settingsAndProfile = settingsAndProfileStream.firstOrNull()
|
val settingsAndProfile = settingsAndProfileStream.firstOrNull()
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
val data = (0..<10).map { index ->
|
val data = (0..<12).map { index ->
|
||||||
val timeAtFullHour = Instant.now().truncatedTo(ChronoUnit.HOURS).epochSecond
|
val timeAtFullHour = Instant.now().truncatedTo(ChronoUnit.HOURS).epochSecond
|
||||||
|
|
||||||
val weatherData = (0..<12).map {
|
val weatherData = (0..<12).map {
|
||||||
@ -228,7 +228,13 @@ abstract class LineGraphForecastDataType(private val karooSystem: KarooSystemSer
|
|||||||
val result = glance.compose(context, DpSize.Unspecified) {
|
val result = glance.compose(context, DpSize.Unspecified) {
|
||||||
val data = buildList {
|
val data = buildList {
|
||||||
for(i in 0..<12){
|
for(i in 0..<12){
|
||||||
val locationData = if (upcomingRoute != null){
|
val isRouteLoaded = if (config.preview){
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
upcomingRoute != null
|
||||||
|
}
|
||||||
|
|
||||||
|
val locationData = if (isRouteLoaded){
|
||||||
allData?.data?.getOrNull(i)
|
allData?.data?.getOrNull(i)
|
||||||
} else {
|
} else {
|
||||||
allData?.data?.firstOrNull()
|
allData?.data?.firstOrNull()
|
||||||
@ -267,9 +273,9 @@ abstract class LineGraphForecastDataType(private val karooSystem: KarooSystemSer
|
|||||||
val end = (afterData?.distance ?: upcomingRoute?.routeLength?.toFloat()) ?: 0.0f
|
val end = (afterData?.distance ?: upcomingRoute?.routeLength?.toFloat()) ?: 0.0f
|
||||||
val distance = start + (end - start) * (x - floor(x))
|
val distance = start + (end - start) * (x - floor(x))
|
||||||
val distanceLabel = if (settingsAndProfile.isImperial) {
|
val distanceLabel = if (settingsAndProfile.isImperial) {
|
||||||
"${(distance * 0.000621371).toInt()}mi"
|
"${(distance * 0.000621371).toInt()}"
|
||||||
} else {
|
} else {
|
||||||
"${(distance / 1000).toInt()}km"
|
"${(distance / 1000).toInt()}"
|
||||||
}
|
}
|
||||||
return@drawLineGraph distanceLabel
|
return@drawLineGraph distanceLabel
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class PrecipitationForecastDataType(karooSystem: KarooSystemService) : LineGraph
|
|||||||
}
|
}
|
||||||
|
|
||||||
val precipitationPropagation = lineData.map { data ->
|
val precipitationPropagation = lineData.map { data ->
|
||||||
data.weatherData.precipitationProbability ?: 0.0
|
(data.weatherData.precipitationProbability?.coerceAtMost(99.0)) ?: 0.0 // Max 99 % so that the label doesn't take up too much space
|
||||||
}
|
}
|
||||||
|
|
||||||
return setOf(
|
return setOf(
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
if (lines.isEmpty() || lines.all { it.dataPoints.isEmpty() }) {
|
if (lines.isEmpty() || lines.all { it.dataPoints.isEmpty() }) {
|
||||||
val emptyPaint = Paint().apply {
|
val emptyPaint = Paint().apply {
|
||||||
color = primaryTextColor
|
color = primaryTextColor
|
||||||
textSize = 24f // Increased from 20f
|
textSize = 30f // Increased from 24f
|
||||||
textAlign = Align.CENTER
|
textAlign = Align.CENTER
|
||||||
isAntiAlias = true
|
isAntiAlias = true
|
||||||
}
|
}
|
||||||
@ -63,8 +63,8 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val marginTop = 10f
|
val marginTop = 10f
|
||||||
val marginBottom = 40f // Increased from 30f
|
val marginBottom = 55f // Increased from 40f
|
||||||
var marginRight = 20f // Increased from 5f // Made var
|
var marginRight = 25f // Increased from 20f // Made var, default updated
|
||||||
|
|
||||||
var dataMinX = Float.MAX_VALUE
|
var dataMinX = Float.MAX_VALUE
|
||||||
var dataMaxX = Float.MIN_VALUE
|
var dataMaxX = Float.MIN_VALUE
|
||||||
@ -101,7 +101,7 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
if (!hasData) {
|
if (!hasData) {
|
||||||
val emptyPaint = Paint().apply {
|
val emptyPaint = Paint().apply {
|
||||||
color = primaryTextColor
|
color = primaryTextColor
|
||||||
textSize = 48f // Increased from 40f
|
textSize = 60f // Increased from 48f
|
||||||
textAlign = Align.CENTER
|
textAlign = Align.CENTER
|
||||||
isAntiAlias = true
|
isAntiAlias = true
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
|
|
||||||
// Dynamically calculate marginLeft based on Y-axis label widths
|
// Dynamically calculate marginLeft based on Y-axis label widths
|
||||||
val yAxisLabelPaint = Paint().apply {
|
val yAxisLabelPaint = Paint().apply {
|
||||||
textSize = 32f
|
textSize = 40f // Increased from 32f
|
||||||
isAntiAlias = true
|
isAntiAlias = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +149,8 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val yAxisTextRightToAxisGap = 15f // Current gap used: graphLeft - 15f
|
val yAxisTextRightToAxisGap = 18f // Increased from 15f
|
||||||
val canvasEdgePadding = 5f // Desired padding from the canvas edge
|
val canvasEdgePadding = 3f // Increased from 5f
|
||||||
|
|
||||||
val dynamicMarginLeft =
|
val dynamicMarginLeft =
|
||||||
if (hasLeftYAxisData) maxLabelWidthLeft + yAxisTextRightToAxisGap + canvasEdgePadding else canvasEdgePadding
|
if (hasLeftYAxisData) maxLabelWidthLeft + yAxisTextRightToAxisGap + canvasEdgePadding else canvasEdgePadding
|
||||||
@ -199,12 +199,13 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
val graphBottom = height - marginBottom
|
val graphBottom = height - marginBottom
|
||||||
val graphRight = width - marginRight // Define graphRight for clarity
|
val graphRight = width - marginRight // Define graphRight for clarity
|
||||||
|
|
||||||
|
|
||||||
// Legend properties
|
// Legend properties
|
||||||
val legendTextSize = 26f // Increased from 22f
|
val legendTextSize = 25f
|
||||||
val legendTextColor = primaryTextColor
|
val legendTextColor = primaryTextColor
|
||||||
val legendPadding = 5f
|
val legendPadding = 5f
|
||||||
val legendEntryHeight = 30f // Increased from 25f
|
val legendEntryHeight = 30f
|
||||||
val legendColorBoxSize = 24f // Increased from 20f
|
val legendColorBoxSize = 24f
|
||||||
val legendTextMargin = 5f
|
val legendTextMargin = 5f
|
||||||
|
|
||||||
var effectiveMinX = dataMinX
|
var effectiveMinX = dataMinX
|
||||||
@ -353,7 +354,7 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
|
|
||||||
val textPaint = Paint().apply {
|
val textPaint = Paint().apply {
|
||||||
color = primaryTextColor
|
color = primaryTextColor
|
||||||
textSize = 32f // Increased from 28f
|
textSize = 40f // Increased from 32f
|
||||||
isAntiAlias = true
|
isAntiAlias = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,13 +507,13 @@ class LineGraphBuilder(val context: Context) {
|
|||||||
val xPos = mapX(value)
|
val xPos = mapX(value)
|
||||||
if (xPos >= graphLeft - 5f && xPos <= graphLeft + graphWidth + 5f) {
|
if (xPos >= graphLeft - 5f && xPos <= graphLeft + graphWidth + 5f) {
|
||||||
canvas.drawLine(xPos, graphBottom - 5f, xPos, graphBottom + 5f, axisPaint)
|
canvas.drawLine(xPos, graphBottom - 5f, xPos, graphBottom + 5f, axisPaint)
|
||||||
canvas.drawText(labelProvider(value), xPos, graphBottom + 30f, textPaint)
|
canvas.drawText(labelProvider(value), xPos, graphBottom + 40f, textPaint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val xPos = mapX(dataMinX)
|
val xPos = mapX(dataMinX)
|
||||||
canvas.drawLine(xPos, graphBottom - 5f, xPos, graphBottom + 5f, axisPaint)
|
canvas.drawLine(xPos, graphBottom - 5f, xPos, graphBottom + 5f, axisPaint)
|
||||||
canvas.drawText(labelProvider(dataMinX), xPos, graphBottom + 30f, textPaint)
|
canvas.drawText(labelProvider(dataMinX), xPos, graphBottom + 40f, textPaint)
|
||||||
}
|
}
|
||||||
|
|
||||||
textPaint.textAlign = Align.CENTER
|
textPaint.textAlign = Align.CENTER
|
||||||
|
|||||||
BIN
preview0.png
BIN
preview0.png
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 37 KiB |
Loading…
x
Reference in New Issue
Block a user