Skip to content

Commit

Permalink
Set compass source when migrating prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed May 21, 2023
1 parent a39f3f8 commit b85d15c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ class PreferenceMigrator private constructor() {
PreferenceMigration(13, 14) { context, prefs ->
val userPrefs = UserPreferences(context)
val wasLegacyCompass = prefs.getBoolean("pref_use_legacy_compass_2") ?: false
val sources = CompassProvider.getAvailableSources(context)
if (wasLegacyCompass) {
userPrefs.compass.source = CompassSource.Orientation
} else if (CompassProvider.getAvailableSources(context).contains(CompassSource.RotationVector)) {
} else if (sources.contains(CompassSource.RotationVector)) {
// The rotation vector is accurate, no need for smoothing
userPrefs.compass.compassSmoothing = 1
}
userPrefs.compass.source = sources.firstOrNull() ?: CompassSource.CustomMagnetometer
prefs.remove("pref_use_legacy_compass_2")
}
)
Expand Down

0 comments on commit b85d15c

Please sign in to comment.