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