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