mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Scrollable Signal Chart (#1505)
* Removed repeated calculation. * Centralized the radius used to plot points and draw lines within GraphUtil.kt. * Updated the signal metrics chart to use the scroll features. * SignalMetricsChart long method warning suppression.
This commit is contained in:
parent
d14a8de78e
commit
70a08c9d31
3 changed files with 87 additions and 98 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package com.geeksville.mesh.util
|
||||
|
||||
import android.content.res.Resources
|
||||
import androidx.compose.ui.graphics.Path
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
|
@ -25,6 +26,8 @@ import com.geeksville.mesh.TelemetryProtos.Telemetry
|
|||
|
||||
object GraphUtil {
|
||||
|
||||
val RADIUS = Resources.getSystem().displayMetrics.density * 2
|
||||
|
||||
/**
|
||||
* @param value Must be zero-scaled before passing.
|
||||
* @param divisor The range for the data set.
|
||||
|
|
@ -32,7 +35,6 @@ object GraphUtil {
|
|||
fun plotPoint(
|
||||
drawContext: DrawContext,
|
||||
color: Color,
|
||||
radius: Float,
|
||||
x: Float,
|
||||
value: Float,
|
||||
divisor: Float,
|
||||
|
|
@ -42,7 +44,7 @@ object GraphUtil {
|
|||
val y = height - (ratio * height)
|
||||
drawContext.canvas.drawCircle(
|
||||
center = Offset(x, y),
|
||||
radius = radius,
|
||||
radius = RADIUS,
|
||||
paint = androidx.compose.ui.graphics.Paint().apply { this.color = color }
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue