Skip to content

Commit

Permalink
feat: AA: Conditionally draw background
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Sep 6, 2023
1 parent 7dd7b83 commit b651a52
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
<string name="pref.aa.alerting.legend.enabled">Enable Alerting Legend</string>
<string name="pref.aa.alerting.legend.enabled_summary">When enabled, rules for alerting are displayed on the screen if available for given PID: ENGINE_TEMP > 110</string>

<string name="pref.aa.theme.background.enabled">Background enabled</string>

<string name="pref.aa.theme.dynamic_selector.enabled">Dynamic selector enabled</string>
<string name="pref.aa.theme.dynamic_selector.enabled_summary">When enabled, colors are applied based on selected dynamic mode: SPORT,NORMAL,ECO</string>

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,12 @@
</PreferenceCategory>

<PreferenceCategory android:title="@string/pref.theme">
<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="true"
android:key="pref.aa.theme.background.enabled"
android:title="@string/pref.aa.theme.background.enabled" />

<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="false"
Expand Down
4 changes: 4 additions & 0 deletions automotive/src/main/java/org/obd/graphs/aa/CarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ private const val PREF_PIDS_HISTORY_ENABLED= "pref.aa.pids.history.enabled"
private const val PREF_THEME_IN_ALLERT_VALUE_COLOR= "pref.aa.theme.inAlertValueColor"
private const val PREF_DYNAMIC_SELECTOR_ENABLED= "pref.aa.theme.dynamic-selector.enabled"

private const val BACKGROUND_ENABLED= "pref.aa.theme.background.enabled"

private const val PREF_ALERT_LEGEND_ENABLED= "pref.aa.alerting.legend.enabled"
private const val PREF_ALERTING_ENABLED= "pref.aa.alerting.enabled"
private const val PREF_THEME_PROGRESS_BAR_COLOR= "pref.aa.theme.progressColor"
Expand Down Expand Up @@ -77,6 +79,8 @@ internal class CarSettings : ScreenSettings {
}
}

override fun isBackgroundDrawingEnabled(): Boolean = Prefs.getBoolean(BACKGROUND_ENABLED, true)

override fun isDynamicSelectorThemeEnabled(): Boolean = Prefs.getBoolean(PREF_DYNAMIC_SELECTOR_ENABLED, false)

override fun isAlertingEnabled(): Boolean = Prefs.getBoolean(PREF_ALERTING_ENABLED, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ internal class DrawingManager(context: Context, private val settings: ScreenSet
canvas?.let {
it.drawRect(area, paint)
it.drawColor(Color.BLACK)
it.drawBitmap(background, area.left.toFloat(), area.top.toFloat(), backgroundPaint)
if (settings.isBackgroundDrawingEnabled()) {
it.drawBitmap(background, area.left.toFloat(), area.top.toFloat(), backgroundPaint)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ interface ScreenSettings {

fun dynamicSelectorChangedEvent(mode: DynamicSelectorMode){}


fun isBackgroundDrawingEnabled (): Boolean = true

fun isDynamicSelectorThemeEnabled (): Boolean = false

fun isAlertLegendEnabled (): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ internal class SimpleScreenRenderer(
) : ScreenRenderer {

private val drawingManager = DrawingManager(context, settings)

override fun onDraw(canvas: Canvas, visibleArea: Rect?) {

visibleArea?.let { area ->
Expand All @@ -37,6 +36,7 @@ internal class SimpleScreenRenderer(
val textSize = textHeight - ROW_SPACING

drawingManager.drawBackground(area)

var verticalPos = area.top + textHeight.toFloat() / 2

if (settings.isStatusPanelEnabled()) {
Expand Down

0 comments on commit b651a52

Please sign in to comment.