Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Common/src/main/java/tk/glucodata/OutboundApiSettings.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tk.glucodata

import android.content.Context
import android.net.Uri
import androidx.annotation.Keep
import org.json.JSONArray
import org.json.JSONObject
Expand Down Expand Up @@ -124,7 +125,7 @@ object OutboundApiSettings {
if (normalizedPreset() == PRESET_GLUCODROID_CLOUD) {
val subdomain = url.trim()
if (subdomain.isBlank()) return ""
return "https://$subdomain.glucodroid.cloud/api/v1/ingest?token=${token.trim()}"
return "https://$subdomain.glucodroid.cloud/api/v1/ingest?token=${Uri.encode(token.trim())}"
}
val trimmed = url.trim()
val replacementToken = if (normalizedPreset() == PRESET_TELEGRAM_BOT) {
Expand Down
29 changes: 15 additions & 14 deletions Common/src/mobile/java/tk/glucodata/ui/OutboundApiSettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,20 @@ private fun DestinationEditor(
onChangePreset = { showPresetSheet = true }
)

if (isGlucodroid) {
OutlinedTextField(
value = destination.url,
onValueChange = { onChange(destination.copy(url = it.trim())) },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
label = { Text(stringResource(R.string.outbound_api_glucodroid_subdomain)) },
suffix = { Text(".glucodroid.cloud", color = MaterialTheme.colorScheme.onSurfaceVariant) },
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Next
)
)
}
if (isTelegram || isVk || isGlucodroid) {
OutlinedTextField(
value = destination.token,
Expand Down Expand Up @@ -504,20 +518,7 @@ private fun DestinationEditor(
)
}

if (isGlucodroid) {
OutlinedTextField(
value = destination.url,
onValueChange = { onChange(destination.copy(url = it.trim())) },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
label = { Text(stringResource(R.string.outbound_api_glucodroid_subdomain)) },
suffix = { Text(".glucodroid.cloud", color = MaterialTheme.colorScheme.onSurfaceVariant) },
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Next
)
)
} else {
if (!isGlucodroid) {
OutlinedTextField(
value = destination.url.ifBlank { OutboundApiSettings.defaultUrl(preset) },
onValueChange = { onChange(destination.copy(url = it)) },
Expand Down
Loading