Fix invalid port indicator
This commit is contained in:
@@ -4,13 +4,14 @@ import android.content.Context
|
||||
import android.content.Context.WIFI_SERVICE
|
||||
import android.content.SharedPreferences
|
||||
import android.net.wifi.WifiManager
|
||||
import com.bartlomiejpluta.ttsserver.core.web.server.WebServer
|
||||
import com.bartlomiejpluta.ttsserver.ui.preference.key.PreferenceKey
|
||||
import java.net.InetAddress
|
||||
|
||||
|
||||
class NetworkUtil(private val context: Context, private val preferences: SharedPreferences) {
|
||||
val port: Int
|
||||
get() = preferences.getInt(PreferenceKey.PORT, 8000)
|
||||
get() = preferences.getInt(PreferenceKey.PORT, WebServer.DEFAULT_PORT)
|
||||
|
||||
val url: String
|
||||
get() = "http://$address:$port"
|
||||
|
||||
@@ -97,5 +97,6 @@ class WebServer(
|
||||
|
||||
companion object {
|
||||
private const val MIME_JSON = "application/json"
|
||||
const val DEFAULT_PORT = 8080
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class WebServerFactory(
|
||||
private val endpointLoader: EndpointLoader
|
||||
) {
|
||||
fun createWebServer() = WebServer(
|
||||
preferences.getInt(PreferenceKey.PORT, 8080),
|
||||
preferences.getInt(PreferenceKey.PORT, WebServer.DEFAULT_PORT),
|
||||
context,
|
||||
preferences,
|
||||
tts,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
local announcementUrl = "http://" .. server.address .. ":8080/cache"
|
||||
local snapshot = nil
|
||||
local snapshot
|
||||
|
||||
function prepareTTSFile(phrase, language)
|
||||
local file = tts.sayToFile(phrase, language, AudioFormat.MP3)
|
||||
return announcementUrl .. "/" .. file:getName()
|
||||
return string.format("%s/cache/%s", server.url, file:getName())
|
||||
end
|
||||
|
||||
function updateSnapshotIfFirst(device)
|
||||
|
||||
Reference in New Issue
Block a user