From c32806ab90a66fa8fb28b1edbe546d5bb1b03212 Mon Sep 17 00:00:00 2001 From: Kyle Corry Date: Fri, 22 Dec 2023 13:37:53 -0500 Subject: [PATCH] Reorganize existing guides --- .../tools/guide/infrastructure/Guides.kt | 61 +++++++++---------- ...apps.md => guide_tool_recommended_apps.md} | 2 + 2 files changed, 30 insertions(+), 33 deletions(-) rename app/src/main/res/raw/{recommended_apps.md => guide_tool_recommended_apps.md} (83%) diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/guide/infrastructure/Guides.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/guide/infrastructure/Guides.kt index 66c908084..a3a03c8e9 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/guide/infrastructure/Guides.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/guide/infrastructure/Guides.kt @@ -1,15 +1,11 @@ package com.kylecorry.trail_sense.tools.guide.infrastructure import android.content.Context -import android.hardware.Sensor import com.kylecorry.andromeda.sense.Sensors import com.kylecorry.trail_sense.R -import com.kylecorry.trail_sense.shared.UserPreferences -import com.kylecorry.trail_sense.shared.sensors.SensorService import com.kylecorry.trail_sense.tools.guide.domain.UserGuide import com.kylecorry.trail_sense.tools.guide.domain.UserGuideCategory import com.kylecorry.trail_sense.tools.ui.Tools -import com.kylecorry.trail_sense.tools.ui.sort.AlphabeticalToolSort import com.kylecorry.trail_sense.tools.ui.sort.CategoricalToolSort object Guides { @@ -18,26 +14,7 @@ object Guides { val tools = Tools.getTools(context) val sortedTools = CategoricalToolSort(context).sort(tools) - val otherGuides = UserGuideCategory( - "TO BE UPDATED", - listOfNotNull( - if (Sensors.hasBarometer(context)) UserGuide( - context.getString(R.string.guide_barometer_calibration_title), - null, - R.raw.calibrating_barometer - ) else null, - UserGuide( - context.getString(R.string.guide_thermometer_calibration_title), - null, - R.raw.calibrating_thermometer - ), - UserGuide( - context.getString(R.string.guide_recommended_apps), - context.getString(R.string.guide_recommended_apps_description), - R.raw.recommended_apps - ) - ) - ) + val otherCategoryName = context.getString(R.string.other) val toolGuides = sortedTools.mapNotNull { category -> val guides = category.tools.mapNotNull { tool -> @@ -45,20 +22,23 @@ object Guides { return@mapNotNull null } - // TODO: Remove this once the guides are updated - // If the guide hasn't been updated, don't show it - if (otherGuides.guides.any { it.contents == tool.guideId }) { - return@mapNotNull null - } - UserGuide( tool.name, tool.description, tool.guideId ) - } + } + listOfNotNull( + // Add recommended apps guide to the bottom of the other category + if (category.categoryName == otherCategoryName) { + UserGuide( + context.getString(R.string.guide_recommended_apps), + context.getString(R.string.guide_recommended_apps_description), + R.raw.guide_tool_recommended_apps + ) + } else null + ) - if (guides.isEmpty()){ + if (guides.isEmpty()) { return@mapNotNull null } @@ -68,7 +48,22 @@ object Guides { ) } + val sensors = UserGuideCategory( + context.getString(R.string.sensors), + listOfNotNull( + if (Sensors.hasBarometer(context)) UserGuide( + context.getString(R.string.guide_barometer_calibration_title), + null, + R.raw.calibrating_barometer + ) else null, + UserGuide( + context.getString(R.string.guide_thermometer_calibration_title), + null, + R.raw.calibrating_thermometer + ), + ) + ) - return toolGuides + otherGuides + return toolGuides + sensors } } \ No newline at end of file diff --git a/app/src/main/res/raw/recommended_apps.md b/app/src/main/res/raw/guide_tool_recommended_apps.md similarity index 83% rename from app/src/main/res/raw/recommended_apps.md rename to app/src/main/res/raw/guide_tool_recommended_apps.md index ef723a4d8..b4e4a5686 100644 --- a/app/src/main/res/raw/recommended_apps.md +++ b/app/src/main/res/raw/guide_tool_recommended_apps.md @@ -1,3 +1,5 @@ +The following apps have been recommended by users of Trail Sense as useful tools to have on your phone. These apps are not affiliated with Trail Sense. + ## Offline Survival Manual A survival guide application. This app will teach you how to use resources around you to survive in almost every environment.