fix: leave companion URL unset by default
This commit is contained in:
@@ -137,8 +137,8 @@ class CompanionApi(private val context: Context) {
|
||||
.build()
|
||||
|
||||
var baseUrl: String
|
||||
get() = prefs.getString("baseUrl", "http://10.0.2.2:8787") ?: "http://10.0.2.2:8787"
|
||||
set(value) { prefs.edit().putString("baseUrl", value.trim().ifBlank { "http://10.0.2.2:8787" }).apply() }
|
||||
get() = prefs.getString("baseUrl", "") ?: ""
|
||||
set(value) { prefs.edit().putString("baseUrl", value.trim()).apply() }
|
||||
|
||||
var accessKey: String
|
||||
get() = prefs.getString("accessKey", "") ?: ""
|
||||
@@ -147,6 +147,7 @@ class CompanionApi(private val context: Context) {
|
||||
private fun endpoint(path: String): String = baseUrl.trimEnd('/') + path
|
||||
|
||||
private fun request(path: String, method: String = "GET", body: JSONObject? = null): JSONObject {
|
||||
if (baseUrl.isBlank()) throw IllegalStateException("Enter your companion server URL in Settings.")
|
||||
val mediaType = "application/json; charset=utf-8".toMediaType()
|
||||
val builder = Request.Builder()
|
||||
.url(endpoint(path))
|
||||
@@ -503,7 +504,7 @@ fun StatusScreen(api: CompanionApi) {
|
||||
RaisedCard(Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
FieldLabel("Companion URL")
|
||||
Text(api.baseUrl, color = Ink, fontWeight = FontWeight.Black)
|
||||
Text(api.baseUrl.ifBlank { "Not set" }, color = Ink, fontWeight = FontWeight.Black)
|
||||
FieldLabel("Hermes CLI")
|
||||
Text(health.hermesCli, color = Ink, fontWeight = FontWeight.Black)
|
||||
FieldLabel("Workspace")
|
||||
@@ -525,7 +526,7 @@ fun SettingsScreen(api: CompanionApi) {
|
||||
RaisedCard(Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
FieldLabel("Companion server URL")
|
||||
AppTextField(baseUrl, { baseUrl = it }, "http://10.0.2.2:8787", keyboardType = KeyboardType.Uri)
|
||||
AppTextField(baseUrl, { baseUrl = it }, "", keyboardType = KeyboardType.Uri)
|
||||
FieldLabel("Access key")
|
||||
AppTextField(accessKey, { accessKey = it }, "hm_…", password = true)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
|
||||
Reference in New Issue
Block a user