diff --git a/app/build.gradle b/app/build.gradle index 9e19895..5c48860 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,7 +29,7 @@ repositories { def versionMajor = 0 def versionMinor = 1 def versionPatch = 4 -def versionBuild = 3 // bump for dog food builds, public betas, etc. +def versionBuild = 4 // bump for dog food builds, public betas, etc. def ALARM_CODE() { Properties properties = new Properties() diff --git a/app/src/main/java/com/thanksmister/iot/voicepanel/network/MQTTOptions.kt b/app/src/main/java/com/thanksmister/iot/voicepanel/network/MQTTOptions.kt index 635b695..1320763 100644 --- a/app/src/main/java/com/thanksmister/iot/voicepanel/network/MQTTOptions.kt +++ b/app/src/main/java/com/thanksmister/iot/voicepanel/network/MQTTOptions.kt @@ -100,7 +100,8 @@ constructor(private val configuration: Configuration) { } fun getPort(): Int { - return configuration.mqttServerPort + val port = configuration.mqttServerPort + return port } fun getTlsConnection(): Boolean { diff --git a/app/src/main/java/com/thanksmister/iot/voicepanel/network/VoicePanelService.kt b/app/src/main/java/com/thanksmister/iot/voicepanel/network/VoicePanelService.kt index 43ffd52..da09ed9 100644 --- a/app/src/main/java/com/thanksmister/iot/voicepanel/network/VoicePanelService.kt +++ b/app/src/main/java/com/thanksmister/iot/voicepanel/network/VoicePanelService.kt @@ -175,7 +175,6 @@ class VoicePanelService : LifecycleService(), MQTTModule.MQTTListener, startForeground() initializeCommandList() configureMqtt() - configureVoice() configureTextToSpeech() configurePowerOptions() startHttp() @@ -571,12 +570,15 @@ class VoicePanelService : LifecycleService(), MQTTModule.MQTTListener, if (textToSpeechModule == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mqttOptions.isValid) { updateSyncMap(INIT_SPEECH, true) textToSpeechModule = TextToSpeechModule(this, this) - lifecycle.addObserver(textToSpeechModule!!) + if(textToSpeechModule != null) { + lifecycle.addObserver(textToSpeechModule!!) + } } } override fun onTextToSpeechInitialized() { updateSyncMap(INIT_SPEECH, false) + configureVoice() } override fun onTextToSpeechError() { diff --git a/app/src/main/java/com/thanksmister/iot/voicepanel/persistence/Configuration.kt b/app/src/main/java/com/thanksmister/iot/voicepanel/persistence/Configuration.kt index b0728ef..46879fc 100644 --- a/app/src/main/java/com/thanksmister/iot/voicepanel/persistence/Configuration.kt +++ b/app/src/main/java/com/thanksmister/iot/voicepanel/persistence/Configuration.kt @@ -260,7 +260,7 @@ constructor(private val context: Context, private val sharedPreferences: SharedP set(value) = this.setStringPref(context.getString(R.string.key_setting_mqtt_servername), value) var mqttServerPort: Int - get() = getStringPref(context.getString(R.string.key_setting_mqtt_serverport), context.getString(R.string.default_setting_mqtt_serverport)).trim().toInt() + get() = getPrefInt(context.getString(R.string.key_setting_mqtt_serverport), context.getString(R.string.default_setting_mqtt_serverport).toInt()) set(value) = this.setPrefInt(context.getString(R.string.key_setting_mqtt_serverport), value) var mqttBaseTopic: String diff --git a/app/src/main/java/com/thanksmister/iot/voicepanel/ui/fragments/MqttSettingsFragment.kt b/app/src/main/java/com/thanksmister/iot/voicepanel/ui/fragments/MqttSettingsFragment.kt index c48ecf4..b7330ae 100644 --- a/app/src/main/java/com/thanksmister/iot/voicepanel/ui/fragments/MqttSettingsFragment.kt +++ b/app/src/main/java/com/thanksmister/iot/voicepanel/ui/fragments/MqttSettingsFragment.kt @@ -142,10 +142,10 @@ class MqttSettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSha } } getString(R.string.key_setting_mqtt_serverport) -> { - value = portPreference!!.text - if (!TextUtils.isEmpty(value) && value.matches("[0-9]+".toRegex())) { - mqttOptions.setPort(Integer.valueOf(value)!!) - portPreference!!.summary = value + val port = portPreference?.text?.toIntOrNull() + if (port != null) { + mqttOptions.setPort(port) + portPreference!!.summary = port.toString() } else if (isAdded) { Toast.makeText(activity, R.string.text_error_only_numbers, Toast.LENGTH_LONG).show() portPreference!!.text = mqttOptions.getPort().toString()