From 47a3d0fc4e7263f9bf08983de418f5022e8cd9bb Mon Sep 17 00:00:00 2001 From: Corwin-Kh Date: Thu, 26 Sep 2024 01:29:54 +0300 Subject: [PATCH 01/83] Changed test UI to test obd --- .../net/osmand/shared/obd/OBDDataComputer.kt | 8 +- .../net/osmand/shared/obd/OBDDispatcher.kt | 10 +- OsmAnd/res/layout/fragment_obd_main.xml | 432 ++++++++---------- .../fragment_vehicle_metrics_settings.xml | 61 +++ OsmAnd/res/values/strings.xml | 1 + OsmAnd/res/xml/vehicle_metrics_settings.xml | 14 + .../plus/plugins/odb/VehicleMetricsPlugin.kt | 88 +++- .../plugins/odb/dialogs/OBDMainFragment.kt | 56 +-- .../dialogs/VehicleMetricsSettingsFragment.kt | 162 +++++++ .../fragments/SettingsScreenType.java | 2 + 10 files changed, 538 insertions(+), 296 deletions(-) create mode 100644 OsmAnd/res/layout/fragment_vehicle_metrics_settings.xml create mode 100644 OsmAnd/res/xml/vehicle_metrics_settings.xml create mode 100644 OsmAnd/src/net/osmand/plus/plugins/odb/dialogs/VehicleMetricsSettingsFragment.kt diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDataComputer.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDataComputer.kt index e31b356a1b8..02e942f2a09 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDataComputer.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDataComputer.kt @@ -101,9 +101,9 @@ object OBDDataComputer { FUEL_LEFT_DISTANCE(true, listOf(OBD_FUEL_LEVEL_COMMAND), { data -> OBDValue(OBD_FUEL_LEVEL_COMMAND, data) }), - FUEL_LEFT_LITERS(false, - listOf(OBD_FUEL_LEVEL_COMMAND), - { data -> OBDValue(OBD_FUEL_LEVEL_COMMAND, data) }), +// FUEL_LEFT_LITERS(false, +// listOf(OBD_FUEL_LEVEL_COMMAND), +// { data -> OBDValue(OBD_FUEL_LEVEL_COMMAND, data) }), FUEL_LEFT_PERCENT(false, listOf(OBD_FUEL_LEVEL_COMMAND), { data -> OBDValue(OBD_FUEL_LEVEL_COMMAND, data) }), @@ -231,7 +231,7 @@ object OBDDataComputer { null } - FUEL_LEFT_LITERS, +// FUEL_LEFT_LITERS, FUEL_LEFT_PERCENT -> { if (locValues.size > 0) { locValues[locValues.size - 1].doubleValue diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDispatcher.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDispatcher.kt index 1db5df88e74..0ec4bb8d2c5 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDispatcher.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDDispatcher.kt @@ -141,11 +141,17 @@ object OBDDispatcher { readStatusListener = listener } - fun setReadWriteStreams(readStream: Source, writeStream: Sink) { + fun setReadWriteStreams(readStream: Source?, writeStream: Sink?) { scope?.cancel() inputStream = readStream outputStream = writeStream - startReadObdLooper() + if(readStream != null && writeStream != null) { + startReadObdLooper() + } + } + + fun stopReading() { + setReadWriteStreams(null, null) } private fun consumeResponse(command: OBDCommand, result: String) { diff --git a/OsmAnd/res/layout/fragment_obd_main.xml b/OsmAnd/res/layout/fragment_obd_main.xml index becb38e24b8..20e47cbfd34 100644 --- a/OsmAnd/res/layout/fragment_obd_main.xml +++ b/OsmAnd/res/layout/fragment_obd_main.xml @@ -1,286 +1,238 @@ - - - - - - - - + android:layout_height="@dimen/toolbar_height" /> - + android:layout_height="60dp" + android:orientation="horizontal"> + + - + + + + android:layout_height="60dp" + android:orientation="horizontal" + android:visibility="gone"> + -