diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/triangulate/ui/FragmentToolTriangulate.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/triangulate/ui/FragmentToolTriangulate.kt index 87a365c1b..ae11ae3f1 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/triangulate/ui/FragmentToolTriangulate.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/triangulate/ui/FragmentToolTriangulate.kt @@ -5,6 +5,8 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.text.buildSpannedString +import androidx.core.text.scale import androidx.core.view.isInvisible import androidx.core.view.isVisible import com.kylecorry.andromeda.alerts.Alerts @@ -174,18 +176,34 @@ class FragmentToolTriangulate : BoundFragment() return } - binding.triangulateTitle.subtitle.text = if (shouldCalculateMyLocation) { - null - } else { - // TODO: Display this on each location instead - getDistanceToDestination(2)?.let { - formatService.formatDistance(it, Units.getDecimalPlaces(it.units)) - } - } + binding.location1Title.text = getLocationTitle(1) + binding.location2Title.text = getLocationTitle(2) // TODO: Display distance between locations } + private fun getLocationTitle(locationIdx: Int): CharSequence { + val distance = getDistanceToDestination(locationIdx) + val formattedDistance = distance?.let { + formatService.formatDistance(it, Units.getDecimalPlaces(it.units)) + } + return buildSpannedString { + append(getString(if (locationIdx == 1) R.string.beacon_1 else R.string.beacon_2)) + if (distance != null) { + appendLine() + scale(0.75f) { + append( + if (shouldCalculateMyLocation) { + getString(R.string.distance_away_from_self, formattedDistance) + } else { + getString(R.string.distance_away_from_destination, formattedDistance) + } + ) + } + } + } + } + private fun updateInstructions() { if (!isBound) { return diff --git a/app/src/main/res/layout/fragment_tool_triangulate.xml b/app/src/main/res/layout/fragment_tool_triangulate.xml index 0b23fd06c..9b95841a9 100644 --- a/app/src/main/res/layout/fragment_tool_triangulate.xml +++ b/app/src/main/res/layout/fragment_tool_triangulate.xml @@ -16,6 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" app:rightButtonIcon="@drawable/ic_copy" + app:showSubtitle="false" tools:title="10.0000, 40.0000" /> Choose a known location that you can see and record the direction from where you are to that location. Choose another known location that you can see and record the direction from where you are to that location. Location to triangulate + + %s away + + %s from destination %d map %d maps