mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Pref fixes (#3175)
This commit is contained in:
parent
c5c433c165
commit
a1d9f926cb
7 changed files with 99 additions and 29 deletions
|
|
@ -39,6 +39,7 @@ import androidx.compose.ui.platform.LocalView
|
|||
import androidx.core.net.toUri
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.geeksville.mesh.android.GeeksvilleApplication
|
||||
import com.geeksville.mesh.android.Logging
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
|
|
@ -48,8 +49,9 @@ import com.geeksville.mesh.ui.common.theme.MODE_DYNAMIC
|
|||
import com.geeksville.mesh.ui.intro.AppIntroductionScreen
|
||||
import com.geeksville.mesh.ui.sharing.toSharedContact
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import org.meshtastic.core.datastore.UiPreferencesDataSource
|
||||
import org.meshtastic.core.navigation.DEEP_LINK_BASE_URI
|
||||
import org.meshtastic.core.prefs.ui.UiPrefs
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
|
|
@ -61,7 +63,7 @@ class MainActivity :
|
|||
// This is aware of the Activity lifecycle and handles binding to the mesh service.
|
||||
@Inject internal lateinit var meshServiceClient: MeshServiceClient
|
||||
|
||||
@Inject internal lateinit var uiPrefs: UiPrefs
|
||||
@Inject internal lateinit var uiPreferencesDataSource: UiPreferencesDataSource
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
installSplashScreen()
|
||||
|
|
@ -77,8 +79,11 @@ class MainActivity :
|
|||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
if (uiPrefs.appIntroCompleted) {
|
||||
(application as GeeksvilleApplication).askToRate(this)
|
||||
lifecycleScope.launch {
|
||||
val appIntroCompleted = uiPreferencesDataSource.appIntroCompleted.value
|
||||
if (appIntroCompleted) {
|
||||
(application as GeeksvilleApplication).askToRate(this@MainActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ import kotlinx.coroutines.flow.shareIn
|
|||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import org.meshtastic.core.datastore.UiPreferencesDataSource
|
||||
import org.meshtastic.core.model.DeviceHardware
|
||||
import org.meshtastic.core.prefs.ui.UiPrefs
|
||||
import org.meshtastic.core.strings.R
|
||||
|
|
@ -188,11 +189,12 @@ constructor(
|
|||
private val quickChatActionRepository: QuickChatActionRepository,
|
||||
firmwareReleaseRepository: FirmwareReleaseRepository,
|
||||
private val uiPrefs: UiPrefs,
|
||||
private val uiPreferencesDataSource: UiPreferencesDataSource,
|
||||
private val meshServiceNotifications: MeshServiceNotifications,
|
||||
) : ViewModel(),
|
||||
Logging {
|
||||
|
||||
val theme: StateFlow<Int> = uiPrefs.themeFlow
|
||||
val theme: StateFlow<Int> = uiPreferencesDataSource.theme
|
||||
|
||||
private val _lastTraceRouteTime = MutableStateFlow<Long?>(null)
|
||||
val lastTraceRouteTime: StateFlow<Long?> = _lastTraceRouteTime.asStateFlow()
|
||||
|
|
@ -822,9 +824,9 @@ constructor(
|
|||
nodeFilterText.value = text
|
||||
}
|
||||
|
||||
val appIntroCompleted: StateFlow<Boolean> = uiPrefs.appIntroCompletedFlow
|
||||
val appIntroCompleted: StateFlow<Boolean> = uiPreferencesDataSource.appIntroCompleted
|
||||
|
||||
fun onAppIntroCompleted() {
|
||||
uiPrefs.appIntroCompleted = true
|
||||
uiPreferencesDataSource.setAppIntroCompleted(true)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import kotlinx.coroutines.flow.stateIn
|
|||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.meshtastic.core.datastore.UiPreferencesDataSource
|
||||
import org.meshtastic.core.prefs.ui.UiPrefs
|
||||
import java.io.BufferedWriter
|
||||
import java.io.FileNotFoundException
|
||||
|
|
@ -65,6 +66,7 @@ constructor(
|
|||
private val nodeRepository: NodeRepository,
|
||||
private val meshLogRepository: MeshLogRepository,
|
||||
private val uiPrefs: UiPrefs,
|
||||
private val uiPreferencesDataSource: UiPreferencesDataSource,
|
||||
) : ViewModel(),
|
||||
Logging {
|
||||
val myNodeInfo: StateFlow<MyNodeEntity?> = nodeRepository.myNodeInfo
|
||||
|
|
@ -109,11 +111,11 @@ constructor(
|
|||
}
|
||||
|
||||
fun setTheme(theme: Int) {
|
||||
uiPrefs.theme = theme
|
||||
uiPreferencesDataSource.setTheme(theme)
|
||||
}
|
||||
|
||||
fun showAppIntro() {
|
||||
uiPrefs.appIntroCompleted = false
|
||||
uiPreferencesDataSource.setAppIntroCompleted(false)
|
||||
}
|
||||
|
||||
fun unlockExcludedModules() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue