Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ android {
resValue "string", "DEFAULT_PROFILE", "profile_8"
resValue "string", "applicationId", "org.obd.graphs.my.giulia.performance_monitor"
applicationId "org.obd.graphs.my.giulia.performance_monitor"
versionCode 90
versionCode 92
}

giulia {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ import org.obd.graphs.bl.datalogger.DataLoggerRepository
import org.obd.graphs.bl.query.Query
import org.obd.graphs.getPowerPreferences
import org.obd.graphs.registerReceiver
import org.obd.graphs.renderer.Fps
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.SurfaceRenderer
import org.obd.graphs.renderer.SurfaceRendererType
import org.obd.graphs.renderer.api.Fps
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.SurfaceRenderer
import org.obd.graphs.renderer.api.SurfaceRendererType
import org.obd.graphs.sendBroadcastEvent
import org.obd.graphs.ui.common.SurfaceController

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import android.util.Log
import android.view.Surface
import android.view.SurfaceHolder
import androidx.annotation.MainThread
import org.obd.graphs.renderer.SurfaceRenderer
import org.obd.graphs.renderer.api.SurfaceRenderer

private const val LOG_KEY = "SurfaceController"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.obd.graphs.ui.drag_racing
import org.obd.graphs.R
import org.obd.graphs.bl.query.Query
import org.obd.graphs.bl.query.QueryStrategyType
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.SurfaceRendererType
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.SurfaceRendererType
import org.obd.graphs.ui.SurfaceRendererFragment

internal class DragRacingRendererFragment : SurfaceRendererFragment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package org.obd.graphs.ui.drag_racing

import org.obd.graphs.preferences.Prefs
import org.obd.graphs.preferences.getS
import org.obd.graphs.renderer.DragRacingScreenSettings
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.api.DragRacingScreenSettings
import org.obd.graphs.renderer.api.ScreenSettings

class DragRacingSettings: ScreenSettings {

private val dragRacingScreenSettings = DragRacingScreenSettings()

override fun getDragRacingScreenSettings(): DragRacingScreenSettings = dragRacingScreenSettings.apply {
override fun getDragRacingScreenSettings(): DragRacingScreenSettings = dragRacingScreenSettings.apply {
metricsFrequencyReadEnabled = Prefs.getBoolean("pref.drag_racing.metrics_reading.display_frequency.enabled", true)
vehicleSpeedDisplayDebugEnabled = Prefs.getBoolean("pref.drag_racing.debug.vehicle_speed_measurement", false)
displayMetricsExtendedEnabled= Prefs.getBoolean("pref.profile.2_0_GME_extension.enabled", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import android.widget.Button
import org.obd.graphs.R
import org.obd.graphs.bl.datalogger.DataLoggerRepository
import org.obd.graphs.bl.query.Query
import org.obd.graphs.renderer.SurfaceRendererType
import org.obd.graphs.renderer.api.SurfaceRendererType
import org.obd.graphs.ui.SurfaceRendererFragment
import org.obd.graphs.ui.common.COLOR_PHILIPPINE_GREEN
import org.obd.graphs.ui.common.COLOR_TRANSPARENT
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/obd/graphs/ui/gauge/GaugeSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import org.obd.graphs.bl.query.Query
import org.obd.graphs.preferences.Prefs
import org.obd.graphs.preferences.getS
import org.obd.graphs.preferences.isEnabled
import org.obd.graphs.renderer.GaugeRendererSettings
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.api.GaugeRendererSettings
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.ui.common.COLOR_RAINBOW_INDIGO

class GaugeSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import android.view.ViewGroup
import android.widget.Button
import org.obd.graphs.R
import org.obd.graphs.bl.query.Query
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.SurfaceRendererType
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.SurfaceRendererType
import org.obd.graphs.ui.SurfaceRendererFragment
import org.obd.graphs.ui.common.COLOR_PHILIPPINE_GREEN
import org.obd.graphs.ui.common.COLOR_TRANSPARENT
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/obd/graphs/ui/giulia/GiuliaSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.obd.graphs.ui.giulia
import org.obd.graphs.bl.query.Query
import org.obd.graphs.preferences.Prefs
import org.obd.graphs.preferences.getS
import org.obd.graphs.renderer.GiuliaRendererSettings
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.api.GiuliaRendererSettings
import org.obd.graphs.renderer.api.ScreenSettings

class GiuliaSettings(
private val query: Query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.obd.graphs.ui.performance
import org.obd.graphs.R
import org.obd.graphs.bl.query.Query
import org.obd.graphs.bl.query.QueryStrategyType
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.SurfaceRendererType
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.SurfaceRendererType
import org.obd.graphs.ui.SurfaceRendererFragment

internal class PerformanceRendererFragment : SurfaceRendererFragment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package org.obd.graphs.ui.performance

import org.obd.graphs.preferences.Prefs
import org.obd.graphs.preferences.getS
import org.obd.graphs.renderer.PerformanceScreenSettings
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.api.PerformanceScreenSettings
import org.obd.graphs.renderer.api.ScreenSettings

class PerformanceSettings : ScreenSettings {
private val settings = PerformanceScreenSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.obd.graphs.ui.trip_info
import org.obd.graphs.R
import org.obd.graphs.bl.query.Query
import org.obd.graphs.bl.query.QueryStrategyType
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.SurfaceRendererType
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.SurfaceRendererType
import org.obd.graphs.ui.SurfaceRendererFragment

internal class TripInfoRendererFragment : SurfaceRendererFragment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package org.obd.graphs.ui.trip_info

import org.obd.graphs.preferences.Prefs
import org.obd.graphs.preferences.getS
import org.obd.graphs.renderer.ScreenSettings
import org.obd.graphs.renderer.TripInfoScreenSettings
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.TripInfoScreenSettings

class TripInfoSettings: ScreenSettings {

Expand Down
25 changes: 22 additions & 3 deletions automotive/src/main/java/org/obd/graphs/aa/CarSession.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ import android.content.Intent
import android.content.res.Configuration
import androidx.car.app.Screen
import androidx.car.app.Session
import androidx.car.app.connection.CarConnection
import org.obd.graphs.aa.screen.CarScreen
import org.obd.graphs.aa.screen.CarScreenFactory
import org.obd.graphs.aa.screen.nav.GOTO_LAST_VSITED_SCREEN_EVENT
import org.obd.graphs.aa.screen.nav.START_DATA_LOGGING_EVENT
import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.bl.datalogger.DataLoggerRepository
import org.obd.graphs.preferences.initPrefs
import org.obd.graphs.renderer.Fps
import org.obd.graphs.renderer.api.Fps
import org.obd.graphs.sendBroadcastEvent
import org.obd.graphs.setCarContext

internal class CarSession : Session() {

private val settings by lazy { CarSettings(carContext) }
private val settings by lazy { CarSettings(carContext) }
private val metricsCollector = MetricsCollector.instance()
private val fps: Fps = Fps()
private lateinit var screen: CarScreen
Expand All @@ -38,11 +42,26 @@ internal class CarSession : Session() {
setCarContext(carContext)
initPrefs(carContext)
screen = CarScreenFactory.instance(carContext, settings, metricsCollector, fps)
CarConnection(carContext).type.observe(this, ::onConnectionStateUpdated)
return screen
}

override fun onCarConfigurationChanged(newConfiguration: Configuration) {
super.onCarConfigurationChanged(newConfiguration)
screen.onCarConfigurationChanged()
}

private fun onConnectionStateUpdated(connectionState: Int) {
when (connectionState) {
CarConnection.CONNECTION_TYPE_PROJECTION -> {
if (settings.isLoadLastVisitedScreenEnabled()) {
sendBroadcastEvent(GOTO_LAST_VSITED_SCREEN_EVENT)
}

if (settings.isAutomaticConnectEnabled() && !DataLoggerRepository.isRunning()) {
sendBroadcastEvent(START_DATA_LOGGING_EVENT)
}
}
}
}
}
18 changes: 13 additions & 5 deletions automotive/src/main/java/org/obd/graphs/aa/CarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ import org.obd.graphs.PREF_DYNAMIC_SELECTOR_ENABLED
import org.obd.graphs.ViewPreferencesSerializer
import org.obd.graphs.bl.datalogger.dataLoggerSettings
import org.obd.graphs.preferences.*
import org.obd.graphs.renderer.*
import org.obd.graphs.renderer.api.ColorTheme
import org.obd.graphs.renderer.api.DragRacingScreenSettings
import org.obd.graphs.renderer.api.DynamicSelectorMode
import org.obd.graphs.renderer.api.GaugeProgressBarType
import org.obd.graphs.renderer.api.GaugeRendererSettings
import org.obd.graphs.renderer.api.GiuliaRendererSettings
import org.obd.graphs.renderer.api.Identity
import org.obd.graphs.renderer.api.PerformanceScreenSettings
import org.obd.graphs.renderer.api.RoutinesScreenSettings
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.SurfaceRendererType
import org.obd.graphs.renderer.api.TripInfoScreenSettings
import org.obd.graphs.runAsync
import org.obd.graphs.ui.common.COLOR_DYNAMIC_SELECTOR_ECO
import org.obd.graphs.ui.common.COLOR_DYNAMIC_SELECTOR_NORMAL
Expand Down Expand Up @@ -124,7 +135,7 @@ class CarSettings(private val carContext: CarContext) : ScreenSettings {
}


override fun getRoutinesScreenSettings(): RoutinesScreenSettings = routinesScreenSettings.apply {
override fun getRoutinesScreenSettings(): RoutinesScreenSettings = routinesScreenSettings.apply {
viewEnabled = Prefs.getBoolean("pref.aa.routines.enabled", true)
}

Expand Down Expand Up @@ -190,9 +201,6 @@ class CarSettings(private val carContext: CarContext) : ScreenSettings {

override fun isScaleEnabled(): Boolean = Prefs.getBoolean("pref.aa.virtual_screens.scale.enabled", true)

override fun getHeightPixels(): Int = carContext.resources.displayMetrics.heightPixels
override fun getWidthPixels(): Int = carContext.resources.displayMetrics.widthPixels

override fun getMaxColumns(): Int =
Prefs.getS("pref.aa.max_pids_in_column.${getCurrentVirtualScreenId(giuliaRendererSettings.dataPrefs)}", DEFAULT_ITEMS_IN_COLUMN).toInt()

Expand Down
31 changes: 4 additions & 27 deletions automotive/src/main/java/org/obd/graphs/aa/screen/CarScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package org.obd.graphs.aa.screen
import android.util.Log
import androidx.car.app.CarContext
import androidx.car.app.Screen
import androidx.car.app.connection.CarConnection
import androidx.car.app.model.ActionStrip
import androidx.car.app.model.CarColor
import androidx.lifecycle.DefaultLifecycleObserver
Expand All @@ -34,8 +33,8 @@ import org.obd.graphs.aa.toast
import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.bl.datalogger.DataLoggerRepository
import org.obd.graphs.bl.datalogger.WorkflowStatus
import org.obd.graphs.renderer.Fps
import org.obd.graphs.renderer.Identity
import org.obd.graphs.renderer.api.Fps
import org.obd.graphs.renderer.api.Identity
import org.obd.graphs.sendBroadcastEvent

const val GIULIA_VIRTUAL_SCREEN_1_SETTINGS_CHANGED = "pref.aa.pids.profile_1.event.changed"
Expand All @@ -54,9 +53,7 @@ internal abstract class CarScreen(
DefaultLifecycleObserver {
open fun getFeatureDescription(): List<FeatureDescription> = emptyList()

abstract fun actionStartDataLogging()

protected open fun gotoScreen(identity: Identity) {}
abstract fun startDataLogging()

protected open fun updateLastVisitedScreen(identity: Identity) {
settings.setLastVisitedScreen(identity)
Expand All @@ -77,10 +74,6 @@ internal abstract class CarScreen(
},
)

protected fun registerConnectionStateReceiver() {
CarConnection(carContext).type.observe(this, ::onConnectionStateUpdated)
}

protected fun actionStopDataLogging() {
Log.i(LOG_TAG, "Stopping data logging process")
withDataLogger {
Expand Down Expand Up @@ -115,7 +108,7 @@ internal abstract class CarScreen(
R.drawable.actions_connect,
mapColor(settings.getColorTheme().actionsBtnConnectColor),
) {
actionStartDataLogging()
startDataLogging()
},
)
}
Expand Down Expand Up @@ -167,20 +160,4 @@ internal abstract class CarScreen(
fps.start()
}
}

private fun onConnectionStateUpdated(connectionState: Int) {
when (connectionState) {
CarConnection.CONNECTION_TYPE_PROJECTION -> {
if (settings.isLoadLastVisitedScreenEnabled()) {
Log.i(LOG_TAG, "Load last visited screen flag is enabled. Loading last visited screen....")
gotoScreen(settings.getLastVisitedScreen())
}

if (settings.isAutomaticConnectEnabled() && !DataLoggerRepository.isRunning()) {
Log.i(LOG_TAG, "Auto connection enabled. Auto start data logging.....")
actionStartDataLogging()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.obd.graphs.aa.ScreenTemplateType
import org.obd.graphs.aa.screen.iot.IotTemplateCarScreen
import org.obd.graphs.aa.screen.nav.NavTemplateCarScreen
import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.renderer.Fps
import org.obd.graphs.renderer.api.Fps

internal interface CarScreenFactory {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2019-2026, Tomasz Żebrowski
*
* <p>Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* <p>http://www.apache.org/licenses/LICENSE-2.0
*
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.obd.graphs.aa.screen.behaviour

import android.content.Context
import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.bl.query.QueryStrategyType
import org.obd.graphs.renderer.api.Fps
import org.obd.graphs.renderer.api.ScreenSettings
import org.obd.graphs.renderer.api.SurfaceRendererType

internal class DragRacingScreenBehavior(
context: Context,
metricsCollector: MetricsCollector,
settings: Map<SurfaceRendererType, ScreenSettings>,
fps: Fps,
) : ScreenBehavior(context, metricsCollector, settings[SurfaceRendererType.DRAG_RACING]!!, fps, SurfaceRendererType.DRAG_RACING) {
override fun queryStrategyType() = QueryStrategyType.DRAG_RACING_QUERY

override fun applyFilters(metricsCollector: MetricsCollector) {
query.setStrategy(queryStrategyType())
metricsCollector.applyFilter(enabled = query.getIDs())
query.update(metricsCollector.getMetrics().map { p -> p.source.command.pid.id }.toSet())
}
}
Loading
Loading