Skip to content

Commit

Permalink
* fix for setting port as string instead of number
Browse files Browse the repository at this point in the history
* ensuring text to speech is initialized before trying the Snips client
  • Loading branch information
thanksmister committed Jun 21, 2019
1 parent e9f6451 commit 87736d3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ constructor(private val configuration: Configuration) {
}

fun getPort(): Int {
return configuration.mqttServerPort
val port = configuration.mqttServerPort
return port
}

fun getTlsConnection(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ class VoicePanelService : LifecycleService(), MQTTModule.MQTTListener,
startForeground()
initializeCommandList()
configureMqtt()
configureVoice()
configureTextToSpeech()
configurePowerOptions()
startHttp()
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 87736d3

Please sign in to comment.