* Dial+Lounge API PoC * format * Fix for chrome * comments * Rate limit and logger stuff * rename route * remove invalid routes * remove device image * Simplify device description * command test * Lint fix * register pairing code * tv code UI * Lint fix * Avoid creating lots of objects * dpad command * small refactor * tweak * validation * timer * fix * Revert "timer" This reverts commit e349565910882408898c9bddda55dadaa9d743de. * Commands * setVolume command * lounge service timer * Some state messages * Lint fix * player state sync * voice handler * Adjustments, and add a TODO list * Lint fix * comment * play at timestamp * Remote screen UI * UI adjustment * Small refactor * Refactor long polling * Add TODO * Manage logging a bit better to avoid spam in DIAL server * cache dial file * logging * comment * Join lounge lazily * long poller tweak * ui tweak * set shouldQuit field * remote connect notification * Lint fix * Randomize device id, new device on start * Lint fix * Lounge disconnect on start * Speed up lounge by not blocking on sent messages * add version to lounge data saved * dial server fix rendezvous * todo * no message * Display network name * playlist changes * Lint fix * tweak params * tweak * player state * comments * Refactor Video Queue (#295) * Refactor Video Queue * Video queue and playlists * Web app casting * queue playlist notification * VideoQueueView work * restore properties * changes * queue notification and previous/next state * Lint fix * very basic error handling * Update changelog and privacy policy --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
162 lines
4.5 KiB
Plaintext
162 lines
4.5 KiB
Plaintext
import "pkg:/components/Navigation/Navigation.bs"
|
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
|
import "pkg:/source/utils/Logging.bs"
|
|
import "pkg:/source/utils/MathUtils.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
function Init()
|
|
m.homeLayout = {}
|
|
homeLayout = ParseJson(ReadAsciiFile("libpkg:/config/default_home_layout.yaml"))
|
|
for each item in homeLayout
|
|
m.homeLayout[item.id] = item
|
|
end for
|
|
|
|
m.checkList = m.top.findNode("checkList")
|
|
m.moveUpButton = m.top.findNode("moveUpButton")
|
|
m.moveDownButton = m.top.findNode("moveDownButton")
|
|
m.closeButton = m.top.findNode("closeButton")
|
|
m.saveButton = m.top.findNode("saveButton")
|
|
|
|
SetNavigation(m.checkList, "down", m.saveButton)
|
|
SetNavigation(m.saveButton, "up", m.checkList)
|
|
SetNavigation(m.closeButton, "up", m.checkList)
|
|
SetNavigation(m.saveButton, "right", m.closeButton)
|
|
SetNavigation(m.closeButton, "left", m.saveButton)
|
|
SetNavigation(m.moveUpButton, "left", m.checkList)
|
|
SetNavigation(m.moveDownButton, "left", m.checkList)
|
|
SetNavigation(m.checkList, "right", m.moveUpButton)
|
|
SetNavigation(m.moveUpButton, "down", m.moveDownButton)
|
|
SetNavigation(m.moveDownButton, "up", m.moveUpButton)
|
|
SetNavigation(m.moveDownButton, "down", m.closeButton)
|
|
|
|
m.moveUpButton.observeField("buttonSelected", FuncName(OnMoveUpButtonSelected))
|
|
m.moveDownButton.observeField("buttonSelected", FuncName(OnMoveDownButtonSelected))
|
|
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
|
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
|
|
|
m.checkList.observeField("checkedState", FuncName(OnCheckedStateChange))
|
|
end function
|
|
|
|
function OnFocusChange() as void
|
|
if not m.top.focus
|
|
return
|
|
end if
|
|
|
|
NodeSetFocus(m.checkList, true)
|
|
end function
|
|
|
|
function OnkeyEvent(key as string, press as boolean) as boolean
|
|
if NavigationKeyHandler(key, press).handled
|
|
return true
|
|
end if
|
|
|
|
if key = "options"
|
|
' A pass-through to the app controller, so it can toggle picture-in-picture
|
|
return false
|
|
end if
|
|
|
|
if key = "back" and press
|
|
Close()
|
|
return true
|
|
end if
|
|
|
|
return true
|
|
end function
|
|
|
|
function OnValueChange()
|
|
content = m.checkList.content
|
|
value = m.top.value
|
|
|
|
nodes = []
|
|
checkedState = []
|
|
for each item in value
|
|
feed = m.homeLayout[item.id]
|
|
if feed = invalid
|
|
LogWarn("unknown feed id:", item.id)
|
|
continue for
|
|
end if
|
|
node = CreateObject("roSGNode", "ContentNode")
|
|
node.id = feed.id
|
|
node.title = feed.title
|
|
nodes.push(node)
|
|
checkedState.push(item.enabled)
|
|
end for
|
|
|
|
labelCount = content.getChildCount()
|
|
if labelCount > 0
|
|
content.removeChildrenIndex(labelCount, 0)
|
|
end if
|
|
|
|
content.appendChildren(nodes)
|
|
m.checkList.checkedState = checkedState
|
|
end function
|
|
|
|
function OnCheckedStateChange() as void
|
|
content = m.checkList.content
|
|
if content = invalid or content.getChildCount() = 0
|
|
return
|
|
end if
|
|
checkedState = m.checkList.checkedState
|
|
if checkedState = invalid or checkedState.Count() = 0
|
|
return
|
|
end if
|
|
|
|
value = []
|
|
checkboxes = content.getChildren(-1, 0)
|
|
|
|
for i = 0 to checkboxes.Count() - 1
|
|
checkbox = checkboxes[i]
|
|
value.push({
|
|
id: checkbox.id
|
|
enabled: checkedState[i]
|
|
})
|
|
end for
|
|
|
|
m.top.value = value
|
|
end function
|
|
|
|
function OnMoveUpButtonSelected() as void
|
|
MoveItem(-1)
|
|
end function
|
|
|
|
function OnMoveDownButtonSelected() as void
|
|
MoveItem(1)
|
|
end function
|
|
|
|
function MoveItem(offset as integer) as void
|
|
content = m.checkList.content
|
|
if content = invalid or content.getChildCount() = 0
|
|
return
|
|
end if
|
|
|
|
itemCount = content.getChildCount()
|
|
index = m.checkList.itemFocused
|
|
newIndex = MathUtils.Clamp(index + offset, 0, itemCount - 1)
|
|
if index = newIndex
|
|
return
|
|
end if
|
|
|
|
checkedState = m.checkList.checkedState
|
|
node = content.getChild(index)
|
|
content.insertChild(node, newIndex)
|
|
|
|
tmp = checkedState[index]
|
|
checkedState[index] = checkedState[newIndex]
|
|
checkedState[newIndex] = tmp
|
|
|
|
m.checkList.itemFocused = newIndex
|
|
m.checkList.jumpToItem = newIndex
|
|
m.checkList.checkedState = checkedState
|
|
end function
|
|
|
|
function OnSaveButtonSelected()
|
|
' Save the new layout to m.top.value
|
|
OnCheckedStateChange()
|
|
m.top.save = true
|
|
Close()
|
|
end function
|
|
|
|
function Close()
|
|
m.appController@.PopScreen()
|
|
end function
|