Skip to content

Commit

Permalink
Reorganize existing guides
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Dec 22, 2023
1 parent 3f9c0ed commit c32806a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -18,47 +14,31 @@ 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 ->
if (tool.guideId == null) {
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
}

Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit c32806a

Please sign in to comment.