Skip to content

Commit

Permalink
fix small issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph5610 committed Apr 3, 2023
1 parent 9bb348b commit 1c07080
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ class HumbleAudioComponent {

var rawAudio: ByteBuffer? = null

//Log audio format
logger.debug { audioFrame?.format }

setVolume(lastTriedVolumeChange)

val packet = MediaPacket.make()
Expand All @@ -86,7 +83,7 @@ class HumbleAudioComponent {
rawAudio = converter.toJavaAudio(rawAudio, samples)
audioFrame?.play(rawAudio)
}
} while (samples.isComplete)
} while (samples.isComplete && isActive)
}
} catch (e: Exception) {
deMuxer.correctlyClose()
Expand All @@ -100,8 +97,8 @@ class HumbleAudioComponent {
fun setVolume(newVolume: Double) {
lastTriedVolumeChange = newVolume

//Dirty hack, since the api does not provide direct access to field,
//we use reflection to get access to line field to change volume
// Dirty hack, since the api does not provide direct access to field,
// we use reflection to get access to line field to change volume
AudioFrame::class.memberProperties
.filter { it.name == "mLine" }[0].apply {
isAccessible = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import tornadofx.hbox
import tornadofx.listProperty
import tornadofx.observableListOf
import tornadofx.validator
import java.util.Locale

class AddStationFragment : BaseFragment() {

Expand All @@ -58,6 +59,13 @@ class AddStationFragment : BaseFragment() {
bind(libraryViewModel.countriesProperty) { c -> c.name }
}

// List of Languages for autocomplete
private val languagesProperty = listProperty<String>(observableListOf()).apply {
bind(libraryViewModel.countriesProperty) {
c -> Locale.of(c.iso3166).displayLanguage
}
}

override fun onDock() {
// Recheck ViewModel validity when reopening fragment
viewModel.validate(focusFirstError = false)
Expand Down Expand Up @@ -123,7 +131,7 @@ class AddStationFragment : BaseFragment() {

field(
messages["add.language"], messages["add.language.prompt"],
viewModel.languageProperty, isRequired = true, countriesListProperty
viewModel.languageProperty, isRequired = true, languagesProperty
) { field ->
field.validator {
if (!validate(it, 150)) error(messages["field.invalid.length"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package online.hudacek.fxradio.ui.fragment

import javafx.geometry.Pos
import online.hudacek.fxradio.FxRadio
import online.hudacek.fxradio.apiclient.ApiUtils
import online.hudacek.fxradio.apiclient.radiobrowser.model.Station
import online.hudacek.fxradio.ui.BaseFragment
import online.hudacek.fxradio.ui.style.Styles
Expand Down Expand Up @@ -75,7 +76,7 @@ class OpenStreamFragment : BaseFragment(FxRadio.appName) {
}

val validator = context.addValidator(textField, textField.textProperty()) {
if (it == null || it.trim().length < 5) error(messages["field.min.length"]) else null
if (it == null || !ApiUtils.isValidUrl(it)) error(messages["field.invalid.url"]) else null
}

vbox(alignment = Pos.CENTER_RIGHT) {
Expand Down
16 changes: 12 additions & 4 deletions src/main/kotlin/online/hudacek/fxradio/ui/style/Styles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ import javafx.geometry.Pos
import javafx.scene.paint.Color
import javafx.scene.text.FontSmoothingType
import javafx.scene.text.FontWeight
import tornadofx.*
import tornadofx.FXVisibility
import tornadofx.InternalWindow
import tornadofx.Stylesheet
import tornadofx.box
import tornadofx.c
import tornadofx.cssclass
import tornadofx.em
import tornadofx.px

/**
* Type-safe CSS classes used around the app
Expand Down Expand Up @@ -103,9 +110,8 @@ class Styles : Stylesheet() {
borderRadius += box(4.px)
backgroundColor += c(colors.background)
borderColor += box(c(colors.backgroundBorder))
maxWidth = 300.px
minWidth = 300.px
prefWidth = 300.px
maxWidth = 290.px
prefWidth = 290.px
alignment = Pos.CENTER
prefHeight = 40.px
minHeight = 40.px
Expand Down Expand Up @@ -504,6 +510,8 @@ class Styles : Stylesheet() {
borderColor += box(c(colors.backgroundBorder))
padding = box(0.px)
backgroundInsets += box(0.px)
backgroundRadius += box(4.px)
borderRadius += box(4.px)
unsafe("-fx-control-inner-background", raw(colors.background))
unsafe("-fx-accent", raw(colors.primary))
unsafe("-fx-selection-bar-non-focused", raw(colors.backgroundSelected))
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/online/hudacek/fxradio/ui/style/StylesDark.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class StylesDark : Stylesheet() {
val colorRadioButton by cssclass()

val autoCompletePopup by cssclass()

}

init {
Expand All @@ -108,9 +107,8 @@ class StylesDark : Stylesheet() {
borderRadius += box(4.px)
backgroundColor += c(colors.playerBox)
borderColor += box(c(colors.backgroundBorder))
maxWidth = 300.px
minWidth = 300.px
prefWidth = 300.px
maxWidth = 290.px
prefWidth = 290.px
alignment = Pos.CENTER
prefHeight = 40.px
minHeight = 40.px
Expand Down Expand Up @@ -587,6 +585,8 @@ class StylesDark : Stylesheet() {
borderColor += box(c(colors.backgroundBorder))
padding = box(0.px)
backgroundInsets += box(0.px)
backgroundRadius += box(4.px)
borderRadius += box(4.px)
unsafe("-fx-control-inner-background", raw(colors.background))
unsafe("-fx-accent", raw(colors.primary))
unsafe("-fx-selection-bar-non-focused", raw(colors.backgroundSelected))
Expand Down

0 comments on commit 1c07080

Please sign in to comment.