Skip to content

Commit

Permalink
feat: Add individual label top offset settings for each virtual screen
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Nov 7, 2024
1 parent dfe63f4 commit a2a4001
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
<string name="pref.aa.renderer_type">Screen type</string>
<string name="pref.aa.renderer.gauge.progress_type"><b><i>Gauge</i></b> screen progress bar type</string>
<string name="pref.aa.renderer.gauge.top_offset"><b><i>Gauge</i></b> screen label top offset</string>
<string name="pref.aa.renderer.gauge.top_offset.1"><b><i>Gauge</i></b> screen label top offset for screen 1</string>
<string name="pref.aa.renderer.gauge.top_offset.2"><b><i>Gauge</i></b> screen label top offset for screen 2</string>
<string name="pref.aa.renderer.gauge.top_offset.3"><b><i>Gauge</i></b> screen label top offset for screen 3</string>
<string name="pref.aa.renderer.gauge.top_offset.4"><b><i>Gauge</i></b> screen label top offset for screen 4</string>

<string name="pref.aa.renderer.gauge.top_offset_summary">Choose label top offset each individual virtual screen</string>

<string name="pref.aa.virtual_screens.number_of_items_in_column.category">Number of columns</string>
<string name="pref.aa.virtual_screens.number_of_items_in_column.category.summary">Choose number of columns for each individual virtual screen</string>
Expand Down
66 changes: 57 additions & 9 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1017,16 +1017,63 @@
app:singleLineTitle="false"
app:useSimpleSummaryProvider="true" />

<org.obd.graphs.preferences.aa.AASeekBar
android:defaultValue="0"
android:dialogTitle="@string/pref.aa.renderer.gauge.top_offset"
android:key="pref.aa.virtual_screens.gauge.top_offset"
android:max="80"

<PreferenceScreen
android:key="pref.aa.screen.gauge.top_offset.category"
android:summary="@string/pref.aa.renderer.gauge.top_offset_summary"
android:title="@string/pref.aa.renderer.gauge.top_offset"
app:min="-30"
app:showSeekBarValue="true"
app:singleLineTitle="false"
app:useSimpleSummaryProvider="true" />
app:singleLineTitle="false">
<PreferenceCategory
android:title="@string/pref.aa.renderer.gauge.top_offset"

app:singleLineTitle="false">
<org.obd.graphs.preferences.aa.AASeekBar
android:defaultValue="0"
android:dialogTitle="@string/pref.aa.renderer.gauge.top_offset"
android:key="pref.aa.virtual_screens.gauge.top_offset.1"
android:max="80"
android:title="@string/pref.aa.renderer.gauge.top_offset.1"
app:min="-30"
app:showSeekBarValue="true"
app:singleLineTitle="false"
app:useSimpleSummaryProvider="true" />

<org.obd.graphs.preferences.aa.AASeekBar
android:defaultValue="0"
android:dialogTitle="@string/pref.aa.renderer.gauge.top_offset"
android:key="pref.aa.virtual_screens.gauge.top_offset.2"
android:max="80"
android:title="@string/pref.aa.renderer.gauge.top_offset.2"
app:min="-30"
app:showSeekBarValue="true"
app:singleLineTitle="false"
app:useSimpleSummaryProvider="true" />

<org.obd.graphs.preferences.aa.AASeekBar
android:defaultValue="0"
android:dialogTitle="@string/pref.aa.renderer.gauge.top_offset"
android:key="pref.aa.virtual_screens.gauge.top_offset.3"
android:max="80"
android:title="@string/pref.aa.renderer.gauge.top_offset.3"
app:min="-30"
app:showSeekBarValue="true"
app:singleLineTitle="false"
app:useSimpleSummaryProvider="true" />


<org.obd.graphs.preferences.aa.AASeekBar
android:defaultValue="0"
android:dialogTitle="@string/pref.aa.renderer.gauge.top_offset"
android:key="pref.aa.virtual_screens.gauge.top_offset.4"
android:max="80"
android:title="@string/pref.aa.renderer.gauge.top_offset.4"
app:min="-30"
app:showSeekBarValue="true"
app:singleLineTitle="false"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
</PreferenceScreen>


<PreferenceScreen
android:key="pref.aa.displayed.pids"
Expand Down Expand Up @@ -1076,6 +1123,7 @@
</PreferenceCategory>
</PreferenceScreen>


<PreferenceScreen
android:key="pref.aa.screen.columns.category"
android:summary="@string/pref.aa.virtual_screens.number_of_items_in_column.category.summary"
Expand Down
2 changes: 1 addition & 1 deletion automotive/src/main/java/org/obd/graphs/aa/CarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class CarSettings(private val carContext: CarContext) : ScreenSettings {

override fun getGaugeRendererSetting(): GaugeRendererSettings = gaugeRendererSettings.apply {
gaugeProgressBarType = GaugeProgressBarType.valueOf(Prefs.getS("pref.aa.virtual_screens.screen.gauge.progress_type", GaugeProgressBarType.LONG.name))
topOffset = Prefs.getS("pref.aa.virtual_screens.gauge.top_offset","0").toInt()
topOffset = Prefs.getS("pref.aa.virtual_screens.gauge.top_offset.${getCurrentVirtualScreenId()}","0").toInt()
}

override fun getMaxItems(): Int = Prefs.getS("pref.aa.virtual_screens.screen.max_items","6").toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ internal class GaugeDrawer(
valuePaint.getTextBounds(value, 0, value.length, textRect)

var centerY = (area.centerY() + labelCenterYPadding - (if (settings.isStatisticsEnabled()) 8 else 1) * scaleRationBasedOnScreenSize(area))
val topOffset = settings.getGaugeRendererSetting().topOffset
val valueHeight = max(textRect.height(), MIN_TEXT_VALUE_HEIGHT) + topOffset
val valueHeight = max(textRect.height(), MIN_TEXT_VALUE_HEIGHT) + settings.getGaugeRendererSetting().topOffset
val valueY = centerY - valueHeight
canvas.drawText(value, area.centerX() - (textRect.width() / 2), valueY, valuePaint)

Expand Down

0 comments on commit a2a4001

Please sign in to comment.