mirror of
https://github.com/jellyfin/jellyfin-roku.git
synced 2024-11-23 14:19:40 +00:00
Working v1 (no username or pass)
This commit is contained in:
parent
a591d4dd6c
commit
c3cb43ad4d
@ -11,7 +11,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||
return true
|
||||
else if key = "options"
|
||||
group = m.global.sceneManager.callFunc("getActiveScene")
|
||||
if group.optionsAvailable
|
||||
if group <> invalid and group.optionsAvailable
|
||||
group.lastFocus = group.focusedChild
|
||||
panel = group.findNode("options")
|
||||
panel.visible = true
|
||||
|
@ -1,6 +1,5 @@
|
||||
sub init()
|
||||
m.top.setFocus(true)
|
||||
m.top.optionsAvailable = false
|
||||
|
||||
m.spinner = m.top.findNode("spinner")
|
||||
m.serverPicker = m.top.findNode("serverPicker")
|
||||
@ -15,7 +14,7 @@ sub init()
|
||||
end sub
|
||||
|
||||
function onKeyEvent(key as string, press as boolean) as boolean
|
||||
print "onKeyEvent", key, press
|
||||
print "SetServerScren onKeyEvent", key, press
|
||||
|
||||
if not press then return true
|
||||
handled = true
|
||||
@ -38,6 +37,12 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||
'focus the submit button from serverUrl
|
||||
else if key = "down" and m.serverUrlContainer.hasFocus()
|
||||
m.submit.setFocus(true)
|
||||
else if key = "options"
|
||||
if m.serverPicker.content.getChild(m.serverPicker.itemFocused).name = "Saved"
|
||||
'Can only delete previously saved servers, not locally discovered ones
|
||||
'So if we are on a "Saved" item, let the options dialog be shown (handled elsewhere)
|
||||
handled = false
|
||||
end if
|
||||
else
|
||||
handled = false
|
||||
end if
|
||||
@ -63,6 +68,25 @@ sub ScanForServersComplete(event)
|
||||
'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
|
||||
|
||||
'load any previously logged in to servers as well (if they aren't already discovered on the local network)
|
||||
saved = get_setting("saved_servers")
|
||||
if saved <> invalid
|
||||
savedServers = ParseJson(saved)
|
||||
for each server in savedServers.serverList
|
||||
alreadyListed = false
|
||||
for each listed in m.servers
|
||||
if listed.baseUrl = server.baseUrl
|
||||
alreadyListed = true
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
if alreadyListed = false
|
||||
items.update([server], true)
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
|
||||
m.serverPicker.content = items
|
||||
m.spinner.visible = false
|
||||
|
||||
|
@ -33,8 +33,10 @@
|
||||
</LayoutGroup>
|
||||
</LayoutGroup>
|
||||
|
||||
<OptionsSlider id="options" />
|
||||
</children>
|
||||
|
||||
<script type="text/brightscript" uri="SetServerScreen.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
|
||||
|
||||
</component>
|
||||
|
@ -92,6 +92,10 @@
|
||||
<source>Profile</source>
|
||||
<translation>Profile</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Delete Saved</source>
|
||||
<translation>Delete Saved</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>My Media</source>
|
||||
<translation>My Media</translation>
|
||||
|
@ -373,6 +373,7 @@ function LoginFlow(startOver = false as boolean)
|
||||
get_token(userSelected, "")
|
||||
if get_setting("active_user") <> invalid
|
||||
m.user = AboutMe()
|
||||
SaveServerList()
|
||||
LoadUserPreferences()
|
||||
SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed
|
||||
return true
|
||||
@ -395,6 +396,7 @@ function LoginFlow(startOver = false as boolean)
|
||||
goto start_login
|
||||
end if
|
||||
|
||||
SaveServerList()
|
||||
LoadUserPreferences()
|
||||
m.global.sceneManager.callFunc("clearScenes")
|
||||
|
||||
@ -406,6 +408,42 @@ function LoginFlow(startOver = false as boolean)
|
||||
return true
|
||||
end function
|
||||
|
||||
sub SaveServerList()
|
||||
'Save off this server to our list of saved servers for easier navigation between servers
|
||||
server = get_setting("server")
|
||||
alreadySaved = false
|
||||
saved = get_setting("saved_servers")
|
||||
if saved <> invalid
|
||||
savedServers = ParseJson(saved)
|
||||
for each item in savedServers.serverList
|
||||
if item.baseUrl = server
|
||||
alreadySaved = true
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
if alreadySaved = false
|
||||
savedServers.serverList.Push({ name: "Saved", baseUrl: server, username: m.user})
|
||||
set_setting("saved_servers", FormatJson(savedServers))
|
||||
end if
|
||||
else
|
||||
set_setting("saved_servers", FormatJson({ serverList: [{name: "Saved", baseUrl: server, username: m.user}]}))
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub DeleteFromServerList(urlToDelete)
|
||||
saved = get_setting("saved_servers")
|
||||
if saved <> invalid
|
||||
savedServers = ParseJson(saved)
|
||||
newServers = {serverList: []}
|
||||
for each item in savedServers.serverList
|
||||
if item.baseUrl <> urlToDelete
|
||||
newServers.serverList.Push(item)
|
||||
end if
|
||||
end for
|
||||
set_setting("saved_servers", FormatJson(newServers))
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub RunScreenSaver()
|
||||
print "Starting screensaver..."
|
||||
screen = createObject("roSGScreen")
|
||||
|
@ -1,5 +1,6 @@
|
||||
function CreateServerGroup()
|
||||
screen = CreateObject("roSGNode", "SetServerScreen")
|
||||
screen.optionsAvailable = true
|
||||
m.global.sceneManager.callFunc("pushScene", screen)
|
||||
port = CreateObject("roMessagePort")
|
||||
m.colors = {}
|
||||
@ -10,6 +11,17 @@ function CreateServerGroup()
|
||||
m.viewModel = {}
|
||||
button = screen.findNode("submit")
|
||||
button.observeField("buttonSelected", port)
|
||||
'create delete saved server option
|
||||
new_options = []
|
||||
sidepanel = screen.findNode("options")
|
||||
opt = CreateObject("roSGNode", "OptionsButton")
|
||||
opt.title = tr("Delete Saved")
|
||||
opt.id = "delete_saved"
|
||||
opt.observeField("optionSelected", port)
|
||||
new_options.push(opt)
|
||||
sidepanel.options = new_options
|
||||
sidepanel.observeField("closeSidePanel", port)
|
||||
|
||||
screen.observeField("backPressed", port)
|
||||
|
||||
while true
|
||||
@ -19,6 +31,10 @@ function CreateServerGroup()
|
||||
return "false"
|
||||
else if isNodeEvent(msg, "backPressed")
|
||||
return "backPressed"
|
||||
else if isNodeEvent(msg, "closeSidePanel")
|
||||
screen.setFocus(true)
|
||||
serverPicker = screen.findNode("serverPicker")
|
||||
serverPicker.setFocus(true)
|
||||
else if type(msg) = "roSGNodeEvent"
|
||||
node = msg.getNode()
|
||||
if node = "submit"
|
||||
@ -61,6 +77,16 @@ function CreateServerGroup()
|
||||
screen.visible = false
|
||||
return "true"
|
||||
end if
|
||||
else if node = "delete_saved"
|
||||
serverPicker = screen.findNode("serverPicker")
|
||||
itemToDelete = serverPicker.content.getChild(serverPicker.itemFocused)
|
||||
urlToDelete = itemToDelete.baseUrl
|
||||
if urlToDelete <> invalid
|
||||
DeleteFromServerList(urlToDelete)
|
||||
serverPicker.content.removeChild(itemToDelete)
|
||||
sidepanel.visible = false
|
||||
serverPicker.setFocus(true)
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
|
Loading…
Reference in New Issue
Block a user