Skip to content

Commit

Permalink
Add north reference description
Browse files Browse the repository at this point in the history
Closes #1347
  • Loading branch information
kylecorry31 committed Nov 18, 2023
1 parent 9d26118 commit 1932a82
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ class NavigatorFragment : BoundFragment<ActivityNavigatorBinding>() {
// Update the UI
updateNavigator()

binding.northReferenceIndicator.showDetailsOnClick = true
binding.northReferenceIndicator.useTrueNorth = useTrueNorth
binding.northReferenceIndicator.showLabel = true
northReferenceHideTimer.once(Duration.ofSeconds(5))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.widget.FrameLayout
import androidx.navigation.findNavController
import com.kylecorry.andromeda.alerts.Alerts
import com.kylecorry.andromeda.core.system.Resources
import com.kylecorry.ceres.badge.CeresBadge
import com.kylecorry.trail_sense.R
Expand All @@ -29,6 +31,18 @@ class NorthReferenceBadge(
updateBadge()
}

var showDetailsOnClick: Boolean = false
set(value) {
field = value
if (value){
badge.setOnClickListener {
showDescription()
}
} else {
badge.setOnClickListener(null)
}
}

init {
badge.layoutParams = LayoutParams(
LayoutParams.WRAP_CONTENT,
Expand All @@ -50,4 +64,24 @@ class NorthReferenceBadge(
badge.setStatusText(text)
}

private fun showDescription(){
val title = if (useTrueNorth){
context.getString(R.string.true_north)
} else {
context.getString(R.string.magnetic_north)
}

val message = if (useTrueNorth){
context.getString(R.string.true_north_description)
} else {
context.getString(R.string.magnetic_north_description)
}

Alerts.dialog(context, title, message, okText = context.getString(R.string.settings)){ cancelled ->
if (!cancelled){
findNavController().navigate(R.id.calibrateCompassFragment)
}
}
}

}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,8 @@
<string name="no_sensor_unable_to_fix">No, unfortunately this is a hardware feature, so there is nothing that can be done to add it.</string>
<string name="why_missing_sensor">My device is new/expensive, why is it missing this sensor?</string>
<string name="missing_sensor_explanation">Some phone manufacturers choose not to add this sensor, even on new or expensive devices. You can get more information by visiting your device manufacturer\’s website or getting in touch with them.</string>
<string name="true_north_description">Points to the geographic North Pole using the declination for your location. This will align with most maps.</string>
<string name="magnetic_north_description">Points to the magnetic North Pole. This will align with most compasses.</string>
<plurals name="map_group_summary">
<item quantity="one">%d map</item>
<item quantity="other">%d maps</item>
Expand Down

0 comments on commit 1932a82

Please sign in to comment.