Skip to content

Commit

Permalink
refactor:AA Rename "Dynamic" to "Performance" Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Dec 27, 2024
1 parent 3711768 commit 4791611
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 58 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ android {
dimension "version"
resValue "string", "DEFAULT_PROFILE", "profile_8"
applicationId "org.obd.graphs.my.giulia.aa"
versionCode 153
versionCode 157
}

giuliaPerformanceMonitor {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@
<string name="pref.aa.general_views_category">General views settings </string>


<string name="pref.aa.dynamic.category">Dynamic Screen</string>
<string name="pref.aa.dynamic.enabled">Enable dynamic screen</string>
<string name="pref.aa.dynamic.enabled_summary">It enables dynamic screen with predefined set of metrics. Screen is dedicated to 2.0 GME engines</string>
<string name="pref.aa.performance.category">Performance Screen</string>
<string name="pref.aa.performance.enabled">Enable performance screen</string>
<string name="pref.aa.performance.enabled_summary">It enables Performance screen with predefined set of metrics. Screen is dedicated to 2.0 GME engines</string>


<string name="pref.aa.trip_info.category">Trip Info Screen</string>
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1482,13 +1482,13 @@
</PreferenceCategory>

<PreferenceCategory
android:title="@string/pref.aa.dynamic.category"
android:title="@string/pref.aa.performance.category"
app:singleLineTitle="false">

<org.obd.graphs.preferences.aa.AASeekBar
android:defaultValue="30"
android:dialogTitle="@string/pref.aa.virtual_screens.font_size.category"
android:key="pref.aa.dynamic.font_size"
android:key="pref.aa.performance.font_size"
android:max="72"
android:title="@string/pref.aa.virtual_screens.font_size.category"
app:min="22"
Expand All @@ -1498,9 +1498,9 @@

<org.obd.graphs.preferences.aa.AACheckBoxPreference
android:defaultValue="true"
android:key="pref.aa.dynamic.enabled"
android:title="@string/pref.aa.dynamic.enabled"
android:summary="@string/pref.aa.dynamic.enabled_summary"
android:key="pref.aa.performance.enabled"
android:title="@string/pref.aa.performance.enabled"
android:summary="@string/pref.aa.performance.enabled_summary"
app:singleLineTitle="false" />
</PreferenceCategory>

Expand Down
4 changes: 2 additions & 2 deletions automotive/src/main/java/org/obd/graphs/aa/CarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class CarSettings(private val carContext: CarContext) : ScreenSettings {
}

override fun getDynamicScreenSettings(): DynamicScreenSettings = dynamicScreenSettings.apply {
fontSize = Prefs.getS("pref.aa.dynamic.font_size", "24").toInt()
viewEnabled = Prefs.getBoolean("pref.aa.dynamic.enabled", true)
fontSize = Prefs.getS("pref.aa.performance.font_size", "24").toInt()
viewEnabled = Prefs.getBoolean("pref.aa.performance.enabled", true)
}

override fun getColorTheme(): ColorTheme = colorTheme.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ internal class SurfaceRendererScreen(
surfaceRendererController.allocateSurfaceRenderer(surfaceRendererType = SurfaceRendererType.TRIP_INFO)
}

SurfaceRendererType.DYNAMIC -> {
SurfaceRendererType.PERFORMANCE -> {

dataLogger.updateQuery(query = query.apply {
setStrategy(QueryStrategyType.DYNAMIC)
setStrategy(QueryStrategyType.PERFORMANCE)
})
surfaceRendererController.allocateSurfaceRenderer(surfaceRendererType = SurfaceRendererType.DYNAMIC)
surfaceRendererController.allocateSurfaceRenderer(surfaceRendererType = SurfaceRendererType.PERFORMANCE)
}
}

Expand Down Expand Up @@ -197,11 +197,10 @@ internal class SurfaceRendererScreen(
setStrategy(QueryStrategyType.TRIP_INFO_QUERY)
})

SurfaceRendererType.DYNAMIC ->
SurfaceRendererType.PERFORMANCE ->
dataLogger.start(query.apply{
setStrategy(QueryStrategyType.DYNAMIC)
setStrategy(QueryStrategyType.PERFORMANCE)
})

}
}

Expand All @@ -222,8 +221,8 @@ internal class SurfaceRendererScreen(
}
if (settings.getDynamicScreenSettings().viewEnabled) {
add(
FeatureDescription(SurfaceRendererType.DYNAMIC, R.drawable.action_drag_race,
carContext.getString(R.string.available_features_dynamic_screen_title)),
FeatureDescription(SurfaceRendererType.PERFORMANCE, R.drawable.action_drag_race,
carContext.getString(R.string.available_features_performance_screen_title)),
)
}
}
Expand Down Expand Up @@ -302,10 +301,10 @@ internal class SurfaceRendererScreen(
Log.i(LOG_TAG, "User selection PIDs=${query.getIDs()}")
dataLogger.updateQuery(query)

} else if (screenId == SurfaceRendererType.DYNAMIC) {
} else if (screenId == SurfaceRendererType.PERFORMANCE) {
Log.i(LOG_TAG, "Updating query for DYNAMIC_SCREEN_ID screen")

query.setStrategy(QueryStrategyType.DYNAMIC)
query.setStrategy(QueryStrategyType.PERFORMANCE)
metricsCollector.applyFilter(enabled = query.getIDs())
Log.i(LOG_TAG, "User selection PIDs=${query.getIDs()}")
dataLogger.updateQuery(query)
Expand Down
2 changes: 1 addition & 1 deletion automotive/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<string name="available_features.page_title">Available screens</string>
<string name="available_features.routine_screen.title">Routines</string>
<string name="available_features.drag_race_screen.title">Drag Racing</string>
<string name="available_features.dynamic_screen.title">Dynamic</string>
<string name="available_features.performance_screen.title">Performance</string>
<string name="available_features.giulia_screen.title">Giulia</string>
<string name="available_features.gauge_screen.title">Gauge</string>
<string name="available_features.trip_info_screen.title">Trip Info</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.obd.graphs.bl.query

import org.obd.graphs.preferences.Prefs
import org.obd.graphs.preferences.getLongSet

private const val DYNAMIC_QUERY_PREF_KEY = "pref.aa.dynamic.pids.selected"

internal class DynamicQueryStrategy : QueryStrategy() {
internal class PerformanceQueryStrategy : QueryStrategy() {

private val defaults = mutableSetOf(
namesRegistry.getAtmPressurePID(),
Expand All @@ -22,5 +18,5 @@ internal class DynamicQueryStrategy : QueryStrategy() {
)
override fun getDefaults() = defaults

override fun getPIDs() = Prefs.getLongSet(DYNAMIC_QUERY_PREF_KEY).toMutableSet()
override fun getPIDs() = getDefaults()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class QueryStrategyOrchestrator : java.io.Serializable, Query {
this[QueryStrategyType.INDIVIDUAL_QUERY_FOR_EACH_VIEW] = IndividualQueryStrategy()
this[QueryStrategyType.ROUTINES_QUERY] = RoutinesQueryStrategy()
this[QueryStrategyType.TRIP_INFO_QUERY] = TripInfoQueryStrategy()
this[QueryStrategyType.DYNAMIC] = DynamicQueryStrategy()
this[QueryStrategyType.PERFORMANCE] = PerformanceQueryStrategy()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ enum class QueryStrategyType {
TRIP_INFO_QUERY,
SHARED_QUERY,
INDIVIDUAL_QUERY_FOR_EACH_VIEW,
DYNAMIC
PERFORMANCE
}
4 changes: 3 additions & 1 deletion ext/src/main/assets/giulia_2_2_multijet.properties
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,6 @@ profile_15.pref.aa.trip_info.pids.selected=[7021, 7076, 7046, 7035, 7002, 7037,

profile_15.pref.adapter.query.individual.enabled=true
profile_15.pref.aa.drag_race.debug.vehicle_speed_measurement=false
profile_15.pref.aa.dynamic.enabled=false

#performance
profile_15.pref.aa.performance.enabled=false
3 changes: 2 additions & 1 deletion ext/src/main/assets/qiulia_qv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,5 @@ profile_14.pref.aa.trip_info.enabled=false
profile_14.pref.aa.trip_info.pids.selected=[7021, 7076, 7046, 7035, 7002, 7037, 7014, 7047, 7025, 7003, 7036, 7028, 7016, 17078, 7005, 7020, 7019, 7018, 7009]
profile_14.pref.aa.drag_race.debug.vehicle_speed_measurement=false

profile_14.pref.aa.dynamic.enabled=false
#performance
profile_14.pref.aa.performance.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import android.graphics.Rect
import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.bl.query.Query
import org.obd.graphs.renderer.drag.DragRacingSurfaceRenderer
import org.obd.graphs.renderer.dynamic.DynamicSurfaceRenderer
import org.obd.graphs.renderer.dynamic.PerformanceSurfaceRenderer
import org.obd.graphs.renderer.gauge.GaugeSurfaceRenderer
import org.obd.graphs.renderer.giulia.GiuliaSurfaceRenderer
import org.obd.graphs.renderer.trip.TripInfoSurfaceRenderer
Expand All @@ -39,7 +39,7 @@ enum class SurfaceRendererType(private val code: Int) : Identity {
GAUGE(4),
DRAG_RACING(1),
TRIP_INFO(3),
DYNAMIC(5);
PERFORMANCE(5);

override fun id(): Int = this.code

Expand Down Expand Up @@ -69,7 +69,7 @@ interface SurfaceRenderer {
SurfaceRendererType.GIULIA -> GiuliaSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
SurfaceRendererType.DRAG_RACING -> DragRacingSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
SurfaceRendererType.TRIP_INFO -> TripInfoSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
SurfaceRendererType.DYNAMIC -> DynamicSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
SurfaceRendererType.PERFORMANCE -> PerformanceSurfaceRenderer(context, settings, metricsCollector, fps, viewSettings)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private const val NEW_MAX = 1.6f
private const val NEW_MIN = 0.6f

@Suppress("NOTHING_TO_INLINE")
internal class DynamicDrawer(context: Context, settings: ScreenSettings) : AbstractDrawer(context, settings) {
internal class PerformanceDrawer(context: Context, settings: ScreenSettings) : AbstractDrawer(context, settings) {

private val gaugeDrawer = GaugeDrawer(
settings = settings, context = context,
Expand All @@ -60,26 +60,26 @@ internal class DynamicDrawer(context: Context, settings: ScreenSettings) : Abstr
area: Rect,
left: Float,
top: Float,
dynamicInfoDetails: DynamicInfoDetails
performanceInfoDetails: PerformanceInfoDetails
) {

val (textSizeBase) = calculateFontSize(area)
val x = maxItemWidth(area) + 4

var rowTop = top + 12f
var leftAlignment = 0
dynamicInfoDetails.airTemp?.let { tripInfoDrawer.drawMetric(it, top = rowTop, left = left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true, area=area) }
dynamicInfoDetails.coolantTemp?.let { tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true,area=area) }
dynamicInfoDetails.oilTemp?.let{ tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true,area=area) }
dynamicInfoDetails.exhaustTemp?.let { tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true, area=area) }
dynamicInfoDetails.gearboxOilTemp?.let { tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true, area=area) }
dynamicInfoDetails.oilPressure?.let{ tripInfoDrawer.drawMetric(metricBuilder.buildDiff(it), rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, area=area) }
performanceInfoDetails.airTemp?.let { tripInfoDrawer.drawMetric(it, top = rowTop, left = left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true, area=area) }
performanceInfoDetails.coolantTemp?.let { tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true,area=area) }
performanceInfoDetails.oilTemp?.let{ tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true,area=area) }
performanceInfoDetails.exhaustTemp?.let { tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true, area=area) }
performanceInfoDetails.gearboxOilTemp?.let { tripInfoDrawer.drawMetric(it, rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, statsEnabled = true, area=area) }
performanceInfoDetails.oilPressure?.let{ tripInfoDrawer.drawMetric(metricBuilder.buildDiff(it), rowTop, left + (leftAlignment++) * x, canvas, textSizeBase, area=area) }

drawDivider(canvas, left, area.width().toFloat(), rowTop + textSizeBase + 4, Color.DKGRAY)

rowTop += textSizeBase + 16

dynamicInfoDetails.torque?.let {
performanceInfoDetails.torque?.let {
gaugeDrawer.drawGauge(
canvas = canvas,
left = area.left.toFloat(),
Expand All @@ -90,7 +90,7 @@ internal class DynamicDrawer(context: Context, settings: ScreenSettings) : Abstr
fontSize = settings.getDynamicScreenSettings().fontSize
)
}
dynamicInfoDetails.intakePressure?.let {
performanceInfoDetails.intakePressure?.let {
gaugeDrawer.drawGauge(
canvas = canvas,
left = (area.left + area.width() / 2f) - 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.obd.graphs.renderer.dynamic

import org.obd.graphs.bl.collector.Metric

data class DynamicInfoDetails(
data class PerformanceInfoDetails(
var ambientTemp: Metric? = null,
var atmPressure: Metric? = null,
var oilTemp: Metric? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.bl.query.*
import org.obd.graphs.renderer.*

private const val LOG_TAG = "DynamicSurfaceRenderer"
private const val LOG_TAG = "PerformanceSurfaceRenderer"

internal class DynamicSurfaceRenderer(
internal class PerformanceSurfaceRenderer(
context: Context,
private val settings: ScreenSettings,
private val metricsCollector: MetricsCollector,
private val fps: Fps,
viewSettings: ViewSettings
) : CoreSurfaceRenderer(viewSettings) {
private val dynamicInfoDetails = DynamicInfoDetails()
private val dynamicDrawer = DynamicDrawer(context, settings)
private val performanceInfoDetails = PerformanceInfoDetails()
private val performanceDrawer = PerformanceDrawer(context, settings)

override fun applyMetricsFilter(query: Query) {
Log.d(LOG_TAG,"Query strategy ${query.getStrategy()}, selected ids: ${query.getIDs()}")
Expand All @@ -51,28 +51,28 @@ internal class DynamicSurfaceRenderer(

drawArea?.let { it ->

dynamicDrawer.drawBackground(canvas, it)
performanceDrawer.drawBackground(canvas, it)

val margin = 0
val area = getArea(it, canvas, margin)
var top = getTop(area)
val left = dynamicDrawer.getMarginLeft(area.left.toFloat())
val left = performanceDrawer.getMarginLeft(area.left.toFloat())

if (settings.isStatusPanelEnabled()) {
dynamicDrawer.drawStatusPanel(canvas, top, left, fps, metricsCollector, drawContextInfo = true)
performanceDrawer.drawStatusPanel(canvas, top, left, fps, metricsCollector, drawContextInfo = true)
top += MARGIN_TOP
dynamicDrawer.drawDivider(canvas, left, area.width().toFloat(), top, Color.DKGRAY)
performanceDrawer.drawDivider(canvas, left, area.width().toFloat(), top, Color.DKGRAY)
top += 40
} else {
top += MARGIN_TOP
}

dynamicDrawer.drawScreen(
performanceDrawer.drawScreen(
canvas = canvas,
area = area,
left = left,
top = top,
dynamicInfoDetails = dynamicInfoDetails.apply {
performanceInfoDetails = performanceInfoDetails.apply {
airTemp = metricsCollector.getMetric(namesRegistry.getAirTempPID())
ambientTemp = metricsCollector.getMetric(namesRegistry.getAmbientTempPID())
atmPressure = metricsCollector.getMetric(namesRegistry.getAtmPressurePID())
Expand All @@ -89,11 +89,11 @@ internal class DynamicSurfaceRenderer(
}

override fun recycle() {
dynamicDrawer.recycle()
performanceDrawer.recycle()
}

init {
Log.i(LOG_TAG,"Init Trip Info Surface renderer")
applyMetricsFilter(Query.instance(QueryStrategyType.DYNAMIC))
applyMetricsFilter(Query.instance(QueryStrategyType.PERFORMANCE))
}
}

0 comments on commit 4791611

Please sign in to comment.