mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Refactor map layer management and navigation infrastructure (#4921)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
b608a04ca4
commit
a005231d94
142 changed files with 5408 additions and 3090 deletions
|
|
@ -29,7 +29,9 @@ import org.koin.core.annotation.Named
|
|||
import org.koin.core.annotation.Single
|
||||
|
||||
@Single
|
||||
class BootloaderWarningDataSource(@Named("CorePreferencesDataStore") private val dataStore: DataStore<Preferences>) {
|
||||
open class BootloaderWarningDataSource(
|
||||
@Named("CorePreferencesDataStore") private val dataStore: DataStore<Preferences>,
|
||||
) {
|
||||
|
||||
private object PreferencesKeys {
|
||||
val DISMISSED_BOOTLOADER_ADDRESSES = stringPreferencesKey("dismissed-bootloader-addresses")
|
||||
|
|
@ -51,10 +53,10 @@ class BootloaderWarningDataSource(@Named("CorePreferencesDataStore") private val
|
|||
}
|
||||
|
||||
/** Returns true if the bootloader warning has been dismissed for the given [address]. */
|
||||
suspend fun isDismissed(address: String): Boolean = dismissedAddressesFlow.first().contains(address)
|
||||
open suspend fun isDismissed(address: String): Boolean = dismissedAddressesFlow.first().contains(address)
|
||||
|
||||
/** Marks the bootloader warning as dismissed for the given [address]. */
|
||||
suspend fun dismiss(address: String) {
|
||||
open suspend fun dismiss(address: String) {
|
||||
val current = dismissedAddressesFlow.first()
|
||||
if (current.contains(address)) return
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,21 @@ import org.koin.core.annotation.Named
|
|||
import org.koin.core.annotation.Single
|
||||
import org.meshtastic.proto.LocalStats
|
||||
|
||||
/** Class that handles saving and retrieving [LocalStats] data. */
|
||||
/** Interface that handles saving and retrieving [LocalStats] data. */
|
||||
interface LocalStatsDataSource {
|
||||
val localStatsFlow: Flow<LocalStats>
|
||||
|
||||
suspend fun setLocalStats(stats: LocalStats)
|
||||
|
||||
suspend fun clearLocalStats()
|
||||
}
|
||||
|
||||
/** Implementation of [LocalStatsDataSource] using DataStore. */
|
||||
@Single
|
||||
open class LocalStatsDataSource(@Named("CoreLocalStatsDataStore") private val localStatsStore: DataStore<LocalStats>) {
|
||||
val localStatsFlow: Flow<LocalStats> =
|
||||
open class LocalStatsDataSourceImpl(
|
||||
@Named("CoreLocalStatsDataStore") private val localStatsStore: DataStore<LocalStats>,
|
||||
) : LocalStatsDataSource {
|
||||
override val localStatsFlow: Flow<LocalStats> =
|
||||
localStatsStore.data.catch { exception ->
|
||||
if (exception is IOException) {
|
||||
Logger.e { "Error reading LocalStats: ${exception.message}" }
|
||||
|
|
@ -38,11 +49,11 @@ open class LocalStatsDataSource(@Named("CoreLocalStatsDataStore") private val lo
|
|||
}
|
||||
}
|
||||
|
||||
open suspend fun setLocalStats(stats: LocalStats) {
|
||||
override suspend fun setLocalStats(stats: LocalStats) {
|
||||
localStatsStore.updateData { stats }
|
||||
}
|
||||
|
||||
open suspend fun clearLocalStats() {
|
||||
override suspend fun clearLocalStats() {
|
||||
localStatsStore.updateData { LocalStats() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue