diff --git a/app/src/main/java/org/obd/graphs/activity/Navigation.kt b/app/src/main/java/org/obd/graphs/activity/Navigation.kt index 119d7a34..ba2e5d1f 100644 --- a/app/src/main/java/org/obd/graphs/activity/Navigation.kt +++ b/app/src/main/java/org/obd/graphs/activity/Navigation.kt @@ -20,6 +20,7 @@ package org.obd.graphs.activity import android.text.SpannableString import android.text.style.ForegroundColorSpan +import android.util.Log import android.view.MenuItem import androidx.core.os.bundleOf import androidx.core.view.GravityCompat @@ -146,7 +147,9 @@ internal fun MainActivity.setupNavigationBar() { it.menu.findItem(R.id.ctx_menu_view_custom_action_1).isVisible = true it.menu.findItem(R.id.ctx_menu_view_custom_action_1).title = resources.getString(R.string.pref_graph_trips_selected) - } + + it.menu.findItem(R.id.ctx_menu_submenu_filters).isVisible = true + } resources.getString(R.string.navigation_title_giulia) -> { it.menu.findItem(R.id.ctx_menu_view_custom_action_1).isVisible = true @@ -156,6 +159,8 @@ internal fun MainActivity.setupNavigationBar() { else -> { it.menu.findItem(R.id.ctx_menu_view_custom_action_1).isVisible = false + it.menu.findItem(R.id.ctx_menu_submenu_filters).isVisible = false + } } } @@ -184,6 +189,14 @@ internal fun MainActivity.setupNavigationBarButtons() { } } + R.id.ctx_menu_submenu_filters_filter_1 -> applyGraphViewFilter(1) + R.id.ctx_menu_submenu_filters_filter_2 -> applyGraphViewFilter(2) + R.id.ctx_menu_submenu_filters_filter_3 -> applyGraphViewFilter(3) + R.id.ctx_menu_submenu_filters_filter_4 -> applyGraphViewFilter(4) + R.id.ctx_menu_submenu_filters_filter_5 -> applyGraphViewFilter(5) + R.id.ctx_menu_submenu_filters_filter_6 -> applyGraphViewFilter(6) + R.id.ctx_menu_submenu_filters_filter_7 -> applyGraphViewFilter(7) + R.id.ctx_menu_pids_to_display -> { val screenId = when (getCurrentScreenId()) { R.id.navigation_gauge -> PREF_GAUGE_DISPLAYED_PARAMETERS_IDS @@ -238,6 +251,15 @@ internal fun MainActivity.setupNavigationBarButtons() { } } +private fun applyGraphViewFilter(screenId: Int) { + Log.e("EEEEEEEEEEE", "EEEEEEEEEEEEEEEEEE $screenId") + + tripVirtualScreenManager.updateReservedVirtualScreen(Prefs.getStringSet(giuliaVirtualScreen.getVirtualScreenPrefKey("$screenId")).toList()) + tripVirtualScreenManager.updateScreenId() + + navigateToScreen(R.id.navigation_graph) +} + private fun MainActivity.getCurrentScreenId(): Int { val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottom_nav_view) val selectedItemId: Int = bottomNavigationView.selectedItemId diff --git a/app/src/main/java/org/obd/graphs/ui/giulia/GiuliaVirtualScreenPreferences.kt b/app/src/main/java/org/obd/graphs/ui/giulia/GiuliaVirtualScreenPreferences.kt index 76567f97..cac96149 100644 --- a/app/src/main/java/org/obd/graphs/ui/giulia/GiuliaVirtualScreenPreferences.kt +++ b/app/src/main/java/org/obd/graphs/ui/giulia/GiuliaVirtualScreenPreferences.kt @@ -28,7 +28,8 @@ const val PREF_GAUGE_DIALOG = "pref.giulia.pids.selected" class GiuliaVirtualScreenPreferences { fun getCurrentVirtualScreen() = Prefs.getString(VIRTUAL_SCREEN_SELECTION, "1")!! - fun getVirtualScreenPrefKey(): String = "$PREF_GAUGE_DIALOG.${getCurrentVirtualScreen()}" + fun getVirtualScreenPrefKey(default: String = getCurrentVirtualScreen()): String = "$PREF_GAUGE_DIALOG.${default}" + fun updateVirtualScreen(screenId: String) { Prefs.updateString(VIRTUAL_SCREEN_SELECTION, screenId) diff --git a/app/src/main/res/menu/context_menu.xml b/app/src/main/res/menu/context_menu.xml index 84ae9beb..041cdbd6 100644 --- a/app/src/main/res/menu/context_menu.xml +++ b/app/src/main/res/menu/context_menu.xml @@ -33,6 +33,43 @@ android:id="@+id/ctx_menu_view_custom_action_1" android:title="@string/context_menu.custom_action_1" /> + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b46a276..5a439aa7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -411,6 +411,15 @@ 4 5 Reserved + Filters (from Giulia screen) + Filter 1 + Filter 2 + Filter 3 + Filter 4 + Filter 5 + Filter 6 + Filter 7 + 0 diff --git a/datalogger/src/main/java/org/obd/graphs/bl/trip/TripVirtualScreenManager.kt b/datalogger/src/main/java/org/obd/graphs/bl/trip/TripVirtualScreenManager.kt index 1de1df29..6a0604d4 100644 --- a/datalogger/src/main/java/org/obd/graphs/bl/trip/TripVirtualScreenManager.kt +++ b/datalogger/src/main/java/org/obd/graphs/bl/trip/TripVirtualScreenManager.kt @@ -27,16 +27,13 @@ const val RESERVED_SCREEN_ID = "6" class TripVirtualScreenManager { fun getCurrentScreenId() = Prefs.getString(VIRTUAL_SCREEN_SELECTION, "1")!! - fun updateScreenId(screenId: String) { - Prefs.updateString(VIRTUAL_SCREEN_SELECTION, screenId) - } + fun updateScreenId(screenId: String = getCurrentScreenId()) = Prefs.updateString(VIRTUAL_SCREEN_SELECTION, screenId) fun getCurrentMetrics(): Set = Prefs.getStringSet(getVirtualScreenPrefKey(), mutableSetOf())!! fun updateReservedVirtualScreen(metrics: List) { Prefs.updateStringSet("$PREF_GRAPH_DIALOG.$RESERVED_SCREEN_ID",metrics) - } fun getVirtualScreenPrefKey(): String = "$PREF_GRAPH_DIALOG.${getCurrentScreenId()}" }