Skip to content

Commit

Permalink
Add notice of settings move
Browse files Browse the repository at this point in the history
Closes #1935
  • Loading branch information
kylecorry31 committed Nov 13, 2023
1 parent ff51d0e commit e475298
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/kylecorry/trail_sense/main/AppState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.kylecorry.trail_sense.main

object AppState {
var isReturningUser: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.kylecorry.trail_sense.astronomy.domain.AstronomyService
import com.kylecorry.trail_sense.backup.BackupService
import com.kylecorry.trail_sense.onboarding.OnboardingActivity
import com.kylecorry.trail_sense.receivers.RestartServicesCommand
import com.kylecorry.trail_sense.settings.ui.SettingsMoveNotice
import com.kylecorry.trail_sense.shared.NavigationUtils.setupWithNavController
import com.kylecorry.trail_sense.shared.UserPreferences
import com.kylecorry.trail_sense.shared.commands.ComposedCommand
Expand Down Expand Up @@ -142,6 +143,7 @@ class MainActivity : AndromedaActivity() {
ShowDisclaimerCommand(this),
PowerSavingModeAlertCommand(this),
RestartServicesCommand(this),
SettingsMoveNotice(this)
).execute()

if (!Sensors.hasBarometer(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import com.kylecorry.andromeda.core.system.Screen
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.astronomy.infrastructure.AstronomyDailyWorker
import com.kylecorry.trail_sense.main.AppState
import com.kylecorry.trail_sense.shared.UserPreferences
import com.kylecorry.trail_sense.shared.preferences.PreferencesSubsystem
import com.kylecorry.trail_sense.shared.sensors.CustomGPS
Expand All @@ -22,6 +23,8 @@ class PreferenceMigrator private constructor() {
val prefs = PreferencesSubsystem.getInstance(context).preferences
var currentVersion = prefs.getInt("pref_version") ?: 0

AppState.isReturningUser = currentVersion > 0

while (currentVersion < version) {
val current = currentVersion
val next = currentVersion + 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.kylecorry.trail_sense.settings.ui

import android.content.Context
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.main.AppState
import com.kylecorry.trail_sense.shared.CustomUiUtils
import com.kylecorry.trail_sense.shared.commands.Command
import com.kylecorry.trail_sense.shared.preferences.PreferencesSubsystem

class SettingsMoveNotice(private val context: Context) : Command {

private val key = "settings_move_notice_shown"
private val prefs = PreferencesSubsystem.getInstance(context).preferences

override fun execute() {
if (!AppState.isReturningUser) {
prefs.putBoolean(key, true)
return
}

CustomUiUtils.disclaimer(
context,
context.getString(R.string.settings_have_moved),
context.getString(R.string.settings_have_moved_message),
key,
cancelText = null
)
}
}
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 @@ -1365,6 +1365,8 @@
<string name="pref_tool_quick_action_header_key" translatable="false">pref_tool_quick_action_header_key</string>
<string name="pref_tool_quick_actions" translatable="false">pref_tool_quick_actions</string>
<string name="pref_pinned_tools" translatable="false">pref_pinned_tools</string>
<string name="settings_have_moved">Settings have moved</string>
<string name="settings_have_moved_message">App settings have been moved to the Tools tab</string>
<plurals name="map_group_summary">
<item quantity="one">%d map</item>
<item quantity="other">%d maps</item>
Expand Down

0 comments on commit e475298

Please sign in to comment.