Start new installs on the Pit Log sync server so the address is already filled in.
This commit is contained in:
1 parent
3665f7941e
commit
72eb37b991
3 files changed
+6
-2
No files matched your search
@@ -2,11 +2,13 @@ package com.racingapp.pitlog.data
|
||||
|
||||
import android.content.Context
|
||||
|
||||
const val DEFAULT_SYNC_ADDRESS = "http://sync.sleepingliongames.com:27017"
|
||||
|
||||
class SyncPreferences(context: Context) {
|
||||
private val prefs = context.getSharedPreferences("pitlog-sync", Context.MODE_PRIVATE)
|
||||
|
||||
var address: String
|
||||
get() = prefs.getString(ADDRESS, "").orEmpty()
|
||||
get() = prefs.getString(ADDRESS, DEFAULT_SYNC_ADDRESS).orEmpty()
|
||||
set(value) = prefs.edit().putString(ADDRESS, value).apply()
|
||||
|
||||
var token: String
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.racingapp.pitlog.data.Car
|
||||
import com.racingapp.pitlog.data.DEFAULT_CAR
|
||||
import com.racingapp.pitlog.data.DEFAULT_CLASS
|
||||
import com.racingapp.pitlog.data.DEFAULT_DISCIPLINE
|
||||
import com.racingapp.pitlog.data.DEFAULT_SYNC_ADDRESS
|
||||
import com.racingapp.pitlog.data.Repository
|
||||
import com.racingapp.pitlog.ui.PitActionButton
|
||||
import com.racingapp.pitlog.ui.PitScroll
|
||||
@@ -304,7 +305,7 @@ fun SettingsScreen(onBack: () -> Unit) {
|
||||
label = "Server",
|
||||
value = viewModel.serverAddress,
|
||||
onValue = { viewModel.serverAddress = it.take(200).trim() },
|
||||
placeholder = "http://192.168.1.20:8787",
|
||||
placeholder = DEFAULT_SYNC_ADDRESS,
|
||||
capitalization = KeyboardCapitalization.None,
|
||||
keyboardType = KeyboardType.Uri,
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ class PreviewApp : RacingApp() {
|
||||
override fun onCreate() {
|
||||
deleteDatabase("pitlog.db")
|
||||
super.onCreate()
|
||||
repository.saveAddress("")
|
||||
runBlocking(Dispatchers.IO) {
|
||||
val nightId = repository.saveNight(
|
||||
RaceNight(
|
||||
|
||||
Reference in new issue
Block a user