Skip to content

Commit

Permalink
refactor:Enable by default Dynamic Mode Selector themes
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Aug 17, 2023
1 parent d948b82 commit 1ed42ca
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions automotive/src/main/assets/alfa_2_0_gme_aa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ profile_8.pref.giulia.max_pids_in_column.2="1"
#batch
profile_8.pref.adapter.batch.enabled=true
profile_8.pref.adapter.batch.size="3"

profile_8.pref.aa.theme.dynamic-selector.enabled=true
4 changes: 3 additions & 1 deletion automotive/src/main/assets/alfa_2_0_gme_aa_stn.properties
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@ profile_9.pref.adapter.batch.enabled=true
profile_9.pref.adapter.batch.size="10"

#stn setting
profile_9.pref.adapter.stn.enabled=true
profile_9.pref.adapter.stn.enabled=true

profile_9.pref.aa.theme.dynamic-selector.enabled=true
16 changes: 9 additions & 7 deletions automotive/src/main/java/org/obd/graphs/aa/CarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ internal class CarSettings : ScreenSettings {
)
}

override fun dynamicSelectorChangedEvent(dynamicMode: DynamicSelectorMode) {
when (dynamicMode) {
DynamicSelectorMode.NORMAL -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_NORMAL)
DynamicSelectorMode.SPORT -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_SPORT)
DynamicSelectorMode.ECO -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_ECO)
DynamicSelectorMode.RACE -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_RACE)
}
override fun dynamicSelectorChangedEvent(dynamicSelectorMode: DynamicSelectorMode) {
if (isDynamicSelectorThemeEnabled()) {
when (dynamicSelectorMode) {
DynamicSelectorMode.NORMAL -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_NORMAL)
DynamicSelectorMode.SPORT -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_SPORT)
DynamicSelectorMode.ECO -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_ECO)
DynamicSelectorMode.RACE -> Prefs.updateInt(PREF_THEME_PROGRESS_BAR_COLOR, COLOR_DYNAMIC_SELECTOR_RACE)
}
}
}

override fun applyVirtualScreen1() = applyVirtualScreen(VIRTUAL_SCREEN_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import org.obd.metrics.api.model.ObdMetric

private const val DYNAMIC_SELECTOR_PID_ID = 7036L

internal class DynamicSelectorModeEvenEmitter() {
internal class DynamicSelectorModeEventEmitter {
private var currentMode = -1

fun postValue(obdMetric: ObdMetric) {
if (isDynamicSelectorPID(obdMetric)) {

if (currentMode != obdMetric.value) {
currentMode = obdMetric.value.toInt()
when (obdMetric.value.toInt()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.obd.metrics.api.model.ReplyObserver

internal class MetricsObserver : ReplyObserver<Reply<*>>() {
internal val metrics: MutableLiveData<ObdMetric> = MutableLiveData<ObdMetric>()
private val dynamicSelectorModeEvenEmitter = DynamicSelectorModeEvenEmitter()
private val dynamicSelectorModeEvenEmitter = DynamicSelectorModeEventEmitter()
fun reset() {
metrics.postValue(null)
}
Expand Down

0 comments on commit 1ed42ca

Please sign in to comment.