Skip to content

Commit

Permalink
Add AR message when no gyro
Browse files Browse the repository at this point in the history
Closes #2035
  • Loading branch information
kylecorry31 committed Jan 30, 2024
1 parent 520d162 commit 6c83e86
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.kylecorry.trail_sense.tools.augmented_reality

import android.content.Context
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.shared.CustomUiUtils
import com.kylecorry.trail_sense.shared.alerts.IAlerter
import com.kylecorry.trail_sense.shared.alerts.MissingSensorAlert

class ARNoGyroAlert(private val context: Context) : IAlerter {
override fun alert() {
CustomUiUtils.disclaimer(
context,
MissingSensorAlert.getMissingSensorTitle(
context,
context.getString(R.string.sensor_gyroscope)
),
context.getString(R.string.augmented_reality_no_gyro_message),
"pref_ar_no_gyro_disclaimer",
cancelText = null
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.kylecorry.andromeda.core.system.Resources
import com.kylecorry.andromeda.core.ui.Colors.withAlpha
import com.kylecorry.andromeda.fragments.BoundFragment
import com.kylecorry.andromeda.fragments.observeFlow
import com.kylecorry.andromeda.sense.Sensors
import com.kylecorry.sol.science.astronomy.moon.MoonPhase
import com.kylecorry.sol.units.Distance
import com.kylecorry.trail_sense.R
Expand Down Expand Up @@ -120,6 +121,10 @@ class AugmentedRealityFragment : BoundFragment<FragmentAugmentedRealityBinding>(
binding.arView.setOnFocusLostListener {
binding.focusActionButton.isVisible = false
}

if (!Sensors.hasGyroscope(requireContext())) {
ARNoGyroAlert(requireContext()).alert()
}
}

override fun onResume() {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@
<string name="show_dial_ticks_on_nearby_radar">Show dial ticks on nearby radar</string>
<string name="show_dial_ticks_on_nearby_radar_summary">Your device does not have a compass, but you can still see what direction beacons are.</string>
<string name="pref_tool_category_holder_key" translatable="false">pref_tool_category_holder_key</string>
<string name="augmented_reality_no_gyro_message">You can still use the Augmented Reality tool, but it will not be as accurate.</string>
<plurals name="map_group_summary">
<item quantity="one">%d map</item>
<item quantity="other">%d maps</item>
Expand Down

0 comments on commit 6c83e86

Please sign in to comment.