diff --git a/components/JFButton.brs b/components/JFButton.brs
new file mode 100644
index 00000000..98de4ed6
--- /dev/null
+++ b/components/JFButton.brs
@@ -0,0 +1,21 @@
+sub init()
+ m.top.observeFieldScoped("text", "onTextChanged")
+ m.top.iconUri = ""
+ m.top.focusedIconUri = ""
+ m.top.showFocusFootprint = true
+ m.top.minWidth = 0
+end sub
+
+sub onTextChanged()
+ addSpaceAfter = true
+ minChars = m.top.minChars
+ if minChars = invalid then minChars = 50
+ while m.top.text.Len() < minChars
+ if addSpaceAfter then
+ m.top.text = m.top.text + Chr(160)
+ else
+ m.top.text = Chr(160) + m.top.text
+ end if
+ addSpaceAfter = addSpaceAfter = false
+ end while
+end sub
diff --git a/components/JFButton.xml b/components/JFButton.xml
new file mode 100644
index 00000000..a4bf7db8
--- /dev/null
+++ b/components/JFButton.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/components/config/SetServerScreen.brs b/components/config/SetServerScreen.brs
index d5c78946..c65c7c15 100644
--- a/components/config/SetServerScreen.brs
+++ b/components/config/SetServerScreen.brs
@@ -4,15 +4,13 @@ sub init()
m.spinner = m.top.findNode("spinner")
m.serverPicker = m.top.findNode("serverPicker")
- m.serverUrl = m.top.findNode("serverUrl")
+ m.serverUrlTextbox = m.top.findNode("serverUrlTextbox")
m.serverUrlContainer = m.top.findNode("serverUrlContainer")
m.serverUrlOutline = m.top.findNode("serverUrlOutline")
m.submit = m.top.findNode("submit")
- m.serverUrl.focusable = true
m.serverPicker.setFocus(true)
ScanForServers()
- m.serverPicker.ObserveField("itemSelected", "onclick")
end sub
@@ -22,8 +20,11 @@ function onKeyEvent(key as string, press as boolean) as boolean
if not press then return true
handled = true
- 'if the user pressed the down key and we are already at the last child of server picker, then change focus to the url textbox
- if key = "down" and m.serverPicker.hasFocus() and m.serverPicker.itemFocused = m.serverPicker.content.getChildCount() - 1
+ if key = "OK" and m.serverPicker.hasFocus() then
+ m.top.serverUrl = m.serverPicker.content.getChild(m.serverPicker.itemFocused).baseUrl
+ m.submit.setFocus(true)
+ 'if the user pressed the down key and we are already at the last child of server picker, then change focus to the url textbox
+ else if key = "down" and m.serverPicker.hasFocus() and m.serverPicker.itemFocused = m.serverPicker.content.getChildCount() - 1
m.serverUrlContainer.setFocus(true)
else if key = "up" and m.serverUrlContainer.hasFocus()
m.serverPicker.setFocus(true)
@@ -51,15 +52,11 @@ function ScanForServers()
end function
sub ScanForServersComplete(event)
- ' m.scanOrManual.visible = false
-
- ' m.serverPicker.visible = true
- ' m.serverPicker.SetFocus(true)
servers = event.getData()
- servers = [servers[0], servers[0]]
items = CreateObject("roSGNode", "ContentNode")
for each server in servers
server.subtype = "ContentNode"
+ 'add new fields for every server property onto the ContentNode (rather than making a dedicated component just to hold data...)
items.update([server], true)
end for
m.serverPicker.content = items
@@ -70,7 +67,7 @@ function ShowKeyboard()
dialog = createObject("roSGNode", "KeyboardDialog")
dialog.title = "Enter the server name or ip address"
dialog.buttons = [tr("OK"), tr("Cancel")]
- dialog.text = m.serverUrl.text
+ dialog.text = m.serverUrlTextbox.text
m.top.getscene().dialog = dialog
m.dialog = dialog
@@ -83,7 +80,7 @@ function onDialogButton()
button_text = d.buttons[d.buttonSelected]
if button_text = tr("OK")
- m.serverUrl.text = d.text
+ m.serverUrlTextbox.text = d.text
m.dialog.close = true
return true
else if button_text = tr("Cancel")
diff --git a/components/config/SetServerScreen.xml b/components/config/SetServerScreen.xml
index 0a4f8c27..7aa3f303 100644
--- a/components/config/SetServerScreen.xml
+++ b/components/config/SetServerScreen.xml
@@ -1,9 +1,9 @@
-
-
-
+
+
+
@@ -17,23 +17,24 @@
-
+
-
-
-
+
+
-
+
-
-
-
-
+
+
+
+
+
+
diff --git a/source/Main.brs b/source/Main.brs
index 07bab61c..a609e9aa 100644
--- a/source/Main.brs
+++ b/source/Main.brs
@@ -21,7 +21,7 @@ sub Main()
m.overhang = CreateObject("roSGNode", "JFOverhang")
m.scene.insertChild(m.overhang, 0)
-
+
m.page_size = 48
app_start:
@@ -116,7 +116,7 @@ sub Main()
group = CreateItemGrid(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
- else if selectedItem.type = "Folder"
+ else if selectedItem.type = "Folder"
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
@@ -187,7 +187,7 @@ sub Main()
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
- else
+ else
dialog = createObject("roSGNode", "Dialog")
dialog.title = tr("Error loading Channel Data")
dialog.message = tr("Unable to load Channel Data from the server")
@@ -438,7 +438,7 @@ function LoginFlow(startOver = false as boolean)
end if
'Collect Jellyfin server and user information
start_login:
- if get_setting("server") = invalid or ServerInfo() = invalid or startOver = true then
+ if invalid = invalid or get_setting("server") = invalid or ServerInfo() = invalid or startOver = true then
print "Get server details"
SendPerformanceBeacon("AppDialogInitiate") ' Roku Performance monitoring - Dialog Starting
serverSelection = CreateServerGroup()
@@ -573,4 +573,4 @@ sub SendPerformanceBeacon(signalName as string)
if m.global.app_loaded = false then
m.scene.signalBeacon(signalName)
end if
-end sub
\ No newline at end of file
+end sub
diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs
index ec395330..4c85235b 100644
--- a/source/ShowScenes.brs
+++ b/source/ShowScenes.brs
@@ -10,11 +10,11 @@ function CreateServerGroup()
m.viewModel = {}
button = screen.findNode("submit")
button.observeField("buttonSelected", port)
- server_hostname = screen.serverUrl
screen.observeField("backPressed", port)
while(true)
msg = wait(0, port)
+ print type(msg), msg
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
return "false"
else if isNodeEvent(msg, "backPressed")
@@ -22,27 +22,13 @@ function CreateServerGroup()
else if type(msg) = "roSGNodeEvent"
node = msg.getNode()
if node = "submit"
- 'Append default ports
- maxSlashes = 0
- if left(server_hostname.value, 8) = "https://" or left(server_hostname.value, 7) = "http://" then maxSlashes = 2
- 'Check to make sure entry has no extra slashes before adding default ports.
- if Instr(0, server_hostname.value, "/") = maxSlashes then
- if server_hostname.value.len() > 5 and mid(server_hostname.value, server_hostname.value.len() - 4, 1) <> ":" and mid(server_hostname.value, server_hostname.value.len() - 5, 1) <> ":" then
- if left(server_hostname.value, 5) = "https" then
- server_hostname.value = server_hostname.value + ":8920"
- else
- server_hostname.value = server_hostname.value + ":8096"
- end if
- end if
- end if
- 'Append http:// to server
- if left(server_hostname.value, 4) <> "http" then server_hostname.value = "http://" + server_hostname.value
+ serverUrl = standardize_jellyfin_url(screen.serverUrl)
'If this is a different server from what we know, reset username/password setting
- if get_setting("server") <> server_hostname.value then
+ if get_setting("server") <> serverUrl then
set_setting("username", "")
set_setting("password", "")
end if
- set_setting("server", server_hostname.value)
+ set_setting("server", serverUrl)
if ServerInfo() = invalid then
' Maybe don't unset setting, but offer as a prompt
' Server not found, is it online? New values / Retry
diff --git a/source/utils/misc.brs b/source/utils/misc.brs
index c033d3b4..d3ae6f13 100644
--- a/source/utils/misc.brs
+++ b/source/utils/misc.brs
@@ -83,7 +83,7 @@ function get_dialog_result(dialog, port)
if isNodeEvent(msg, "backPressed") then
return -1
elseif isNodeEvent(msg, "itemSelected")
- return dialog.findNode("optionList").itemSelected
+ return dialog.findNode("optionList").itemSelected
end if
end while
'Dialog has closed outside of this loop, return -1 for failure
@@ -95,8 +95,8 @@ function lastFocusedChild(obj as object) as object
for i = 0 to obj.getChildCount()
if obj.focusedChild <> invalid then
child = child.focusedChild
- end if
- end for
+ end if
+ end for
return child
end function
@@ -144,3 +144,30 @@ end function
function option_dialog(options, message = "", defaultSelection = 0) as integer
return show_dialog(message, options, defaultSelection)
end function
+
+'
+' Take a jellyfin hostname and ensure it's a full url.
+' prepend http or https and append default ports, and remove excess slashes
+'
+function standardize_jellyfin_url(url as string)
+ 'Append default ports
+ maxSlashes = 0
+ if left(url, 8) = "https://" or left(url, 7) = "http://" then
+ maxSlashes = 2
+ end if
+ 'Check to make sure entry has no extra slashes before adding default ports.
+ if Instr(0, url, "/") = maxSlashes then
+ if url.len() > 5 and mid(url, url.len() - 4, 1) <> ":" and mid(url, url.len() - 5, 1) <> ":" then
+ if left(url, 5) = "https" then
+ url = url + ":8920"
+ else
+ url = url + ":8096"
+ end if
+ end if
+ end if
+ 'Append http:// to server
+ if left(url, 4) <> "http" then
+ url = "http://" + url
+ end if
+ return url
+end function