start cleaning up models

This commit is contained in:
geeksville 2020-02-17 13:34:52 -08:00
parent 52deba7d4b
commit f18ac28dc0
9 changed files with 307 additions and 268 deletions

View file

@ -0,0 +1,32 @@
package com.geeksville.mesh.model
import android.util.Base64
import androidx.compose.mutableStateOf
import com.geeksville.mesh.MeshProtos
/// FIXME - figure out how to merge this staate with the AppStatus Model
object UIState {
/// Kinda ugly - created in the activity but used from Compose - figure out if there is a cleaner way GIXME
// lateinit var googleSignInClient: GoogleSignInClient
/// Are we connected to our radio device
val isConnected = mutableStateOf(false)
/// various radio settings (including the channel)
val radioConfig = mutableStateOf(MeshProtos.RadioConfig.getDefaultInstance())
/// our name in hte radio
/// Note, we generate owner initials automatically for now
val ownerName = mutableStateOf("fixme readfromprefs")
/// Return an URL that represents the current channel values
val channelUrl
get(): String {
val channelBytes = radioConfig.value.channelSettings.toByteArray()
val enc = Base64.encodeToString(channelBytes, Base64.URL_SAFE + Base64.NO_WRAP)
return "https://www.meshtastic.org/c/$enc"
}
}