Bookmarks (#153)
* Empty bookmarks screen * Bookmarks object * Long press support * Lint fix * Context menu v1 * A working context menu * Basic bookmarks in context menu * Use a root content node for bookmarks * context menu animation * small tweak * move logger around, adjust animation * Lint fix * Restore logger fix * Cache channel info * Bookmarks v1 * Added comment * Adjust "popular" feed error handling * Progress with bookmarks * Add todo * add todo * handle roDateTime logging * logger adjustment * Use yaml for api and layout * rename requestData to feedSource * Restructure things * Lint fix * remove comment * introduce feedSource id * small cleanup * playlist context menu * Context menu for the channel view * changelog --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
620a8a6e2b
commit
c740d5e0a0
63 files changed
+1889
-510
No files matched your search
@@ -0,0 +1,171 @@
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' TODO:P0 Web app support
|
||||
' TODO:P0 Web apis and open api spec updates
|
||||
'
|
||||
' From the main screen:
|
||||
' When a video is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Open Channel" - DONE
|
||||
' - "Add to "Videos" bookmark" - DONE
|
||||
' - If video is already in a bookmark, "Remove from Bookmarks" - DONE
|
||||
'
|
||||
' When a channel is selected:
|
||||
' - "Open" - DONE
|
||||
' - "Add to "Channels" bookmark" - DONE
|
||||
' - "Add to <ChannelName> bookmark" - DONE
|
||||
' - If channel is already in a bookmark, "Remove from Bookmarks" - DONE
|
||||
' - PlaylistId starting with "IV" cannot be added to a bookmark - DONE
|
||||
'
|
||||
' When a playlist is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Open" - DONE
|
||||
' - "Add to "Playlists" bookmark" - DONE
|
||||
' - "Add to <PlaylistName> bookmark" - DONE
|
||||
' - If playlist is already in a bookmark, "Remove from Bookmarks" - DONE
|
||||
' When any:
|
||||
' - "Reload feed" - DONE
|
||||
'
|
||||
' From Playlist view:
|
||||
' When a video is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Play video" - DONE
|
||||
' - "Queue video" - DONE
|
||||
' - "Open Channel" - DONE
|
||||
' - "Add to "Playlists" bookmark" - DONE
|
||||
' - "Add to <PlaylistName> bookmark" - DONE
|
||||
' - "Add to "Videos" bookmark" - DONE
|
||||
'
|
||||
' From Channel view:
|
||||
' When a video is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Add to "Channels" bookmark" - DONE
|
||||
' - "Add to <ChannelName> - <feed> bookmark" feed being latest videos, live, shorts, etc - DONE
|
||||
' - "Add to "Videos" bookmark" - DONE
|
||||
'
|
||||
' When a playlist is selected:
|
||||
' - "Play" - DONE
|
||||
' - "Queue" - DONE
|
||||
' - "Open" - DONE
|
||||
' - "Add to "Channels" bookmark" - DONE
|
||||
' - "Add to <ChannelName> - <feed> bookmark" feed being latest videos, live, shorts, etc - DONE
|
||||
' - "Add to "Playlists" bookmark" - DONE
|
||||
' - "Add to <PlaylistName> bookmark" - DONE
|
||||
'
|
||||
' From search view:
|
||||
' When a video/channel/playlist is selected:
|
||||
' - Inherit options - DONE
|
||||
' - "Add to "Search - ${q}" bookmark" - this includes the search filters used - DONE
|
||||
'
|
||||
' From bookmarks view:
|
||||
' When a video/channel/playlist is selected:
|
||||
' - Inherit options
|
||||
' - "Remove item from Bookmarks"
|
||||
' - "Remove group from Bookmarks"
|
||||
' - "Reload bookmarks" - DONE
|
||||
'
|
||||
' TODO:P1 Playlist item seletected from the bookmarks need to play as a playlist, not as a single video
|
||||
' TODO:P1 Context menu might need to be scrollable (both horizontally and vertically)
|
||||
' TODO:P1 Context menu might need sections. Example:
|
||||
' In a Channel view, while selecting a playlist:
|
||||
' - Channel
|
||||
' - Add to "Channels" bookmark
|
||||
' - Other "Channels" related context menu items
|
||||
' - Playlist
|
||||
' - Add to "Playlists" bookmark
|
||||
' - "Play/Queue"
|
||||
' - Other "Playlists" related context menu items
|
||||
|
||||
function Init()
|
||||
m.optionsList = m.top.findNode("optionsList")
|
||||
m.showAnimation = m.top.findNode("showAnimation")
|
||||
end function
|
||||
|
||||
function Show(unsued as dynamic)
|
||||
m.optionsList.ObserveField("itemSelected", FuncName(OnItemSelected))
|
||||
m.showAnimation.control = "start"
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
NodeSetFocus(m.optionsList, true)
|
||||
end function
|
||||
|
||||
function OnOptionsSet() as void
|
||||
options = m.top.options
|
||||
if options = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
for each option in options
|
||||
optionNode = CreateObject("roSGNode", "ContentNode")
|
||||
optionNode.title = option.title
|
||||
content.appendChild(optionNode)
|
||||
end for
|
||||
|
||||
m.optionsList.content = content
|
||||
end function
|
||||
|
||||
function OnItemSelected(event as object) as void
|
||||
index = event.getData()
|
||||
button = m.optionsList.content.getChild(index)
|
||||
Close()
|
||||
LogInfo("Menu button selected:", button.title)
|
||||
|
||||
options = m.top.options
|
||||
if index >= options.count()
|
||||
LogError("Menu button index out of range:", index)
|
||||
return
|
||||
end if
|
||||
|
||||
option = options[index]
|
||||
|
||||
node = option.node
|
||||
func = option.func
|
||||
args = option.args
|
||||
|
||||
if node = invalid or StringUtils.IsNullOrEmpty(func) or args = invalid
|
||||
LogError("Menu button action is invalid")
|
||||
return
|
||||
end if
|
||||
|
||||
if args.count() = 1
|
||||
node.callFunc(func, args[0])
|
||||
else if args.count() = 2
|
||||
node.callFunc(func, args[0], args[1])
|
||||
else if args.count() = 3
|
||||
node.callFunc(func, args[0], args[1], args[2])
|
||||
else if args.count() = 4
|
||||
node.callFunc(func, args[0], args[1], args[2], args[3])
|
||||
else if args.count() = 5
|
||||
node.callFunc(func, args[0], args[1], args[2], args[3], args[4])
|
||||
else
|
||||
LogError("Menu button action has too many arguments")
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if press = false
|
||||
return false
|
||||
end if
|
||||
|
||||
if key = "back"
|
||||
Close()
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function Close()
|
||||
m.top.appController@.PopScreen(invalid)
|
||||
end function
|
||||
@@ -0,0 +1,70 @@
|
||||
<component name="ContextMenu" extends="Group" includes="Focus">
|
||||
<interface>
|
||||
<field id="thumbnail" type="uri" alias="thumbnail.uri" />
|
||||
<field id="title" type="string" alias="titleLabel.text" />
|
||||
<field id="subtitle" type="string" alias="subtitleLabel.text" />
|
||||
<field id="options" type="nodearray" onChange="OnOptionsSet" />
|
||||
<field id="appController" type="node" />
|
||||
<function name="Show" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
id="background"
|
||||
width="1280"
|
||||
height="720"
|
||||
color="#000000"
|
||||
opacity="0" />
|
||||
<Rectangle
|
||||
id="container"
|
||||
width="470"
|
||||
height="720"
|
||||
translation="[-470,0]"
|
||||
color="0x242424">
|
||||
<Poster
|
||||
id="thumbnail"
|
||||
width="190"
|
||||
height="110"
|
||||
loadDisplayMode="scaleToFit"
|
||||
translation="[40,50]" />
|
||||
|
||||
<LayoutGroup
|
||||
translation="[40,180]"
|
||||
itemSpacings="[10]">
|
||||
<Label
|
||||
id="titleLabel"
|
||||
width="390"
|
||||
maxLines="2"
|
||||
font="font:MediumBoldSystemFont"
|
||||
wrap="true" />
|
||||
<Label
|
||||
id="subtitleLabel"
|
||||
width="390"
|
||||
font="font:SmallestBoldSystemFont"
|
||||
wrap="true" />
|
||||
</LayoutGroup>
|
||||
|
||||
<MarkupList
|
||||
id="optionsList"
|
||||
itemSize="[420,50]"
|
||||
translation="[25,310]"
|
||||
itemComponentName="ContextMenuRow"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
numRows="8" />
|
||||
</Rectangle>
|
||||
|
||||
<Animation id="showAnimation"
|
||||
duration="0.3"
|
||||
optional="true">
|
||||
<FloatFieldInterpolator
|
||||
id="fadeInterpolator"
|
||||
key="[0.0, 0.5, 1.0]"
|
||||
keyValue="[0.0, 0.4, 0.8]"
|
||||
fieldToInterp="background.opacity" />
|
||||
<Vector2DFieldInterpolator
|
||||
id="translationInterpolator"
|
||||
key="[0.0, 0.5, 1.0]"
|
||||
keyValue="[[-470,0], [-235,0], [0,0]]"
|
||||
fieldToInterp="container.translation" />
|
||||
</Animation>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,29 @@
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.text = content.title
|
||||
end function
|
||||
|
||||
function OnItemHasFocus()
|
||||
hasFocus = m.top.itemHasFocus
|
||||
if hasFocus
|
||||
m.top.font = "font:SmallestBoldSystemFont"
|
||||
m.top.color = "0x262626ff"
|
||||
else
|
||||
m.top.font = "font:SmallestSystemFont"
|
||||
m.top.color = "0xddddddff"
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnFocusPercent()
|
||||
if m.top.focusPercent > 0.5
|
||||
m.top.font = "font:SmallestBoldSystemFont"
|
||||
m.top.color = "0x262626ff"
|
||||
else
|
||||
m.top.font = "font:SmallestSystemFont"
|
||||
m.top.color = "0xddddddff"
|
||||
end if
|
||||
end function
|
||||
@@ -0,0 +1,19 @@
|
||||
<component name="ContextMenuRow" extends="Group">
|
||||
<interface>
|
||||
<field id="text" type="string" alias="label.text" />
|
||||
<field id="font" type="node" alias="label.font" />
|
||||
<field id="color" type="color" alias="label.color" />
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
|
||||
<field id="listHasFocus" type="boolean" />
|
||||
<field id="focusPercent" type="float" onChange="OnFocusPercent" />
|
||||
</interface>
|
||||
<children>
|
||||
<ScrollingLabel
|
||||
id="label"
|
||||
maxWidth="420"
|
||||
height="50"
|
||||
vertAlign="center"
|
||||
font="font:SmallestSystemFont" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,76 @@
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
namespace ContextMenuUtils
|
||||
function Open(providers as object, appController as object, item as object) as object
|
||||
if item = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
options = GetOptions(item, providers)
|
||||
if options.Count() = 0
|
||||
LogWarn("No context menu options available for item")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
contextMenu = CreateObject("roSGNode", "ContextMenu")
|
||||
contextMenu.appController = appController
|
||||
appController@.PushScreen(contextMenu)
|
||||
|
||||
ContextMenuUtils.SetItem(contextMenu, item)
|
||||
contextMenu.options = options
|
||||
|
||||
contextMenu@.Show(invalid)
|
||||
return contextMenu
|
||||
end function
|
||||
|
||||
function SetItem(contextMenu as object, item as object)
|
||||
title = ""
|
||||
subtitle = ""
|
||||
thumbnail = ""
|
||||
|
||||
if item.type = "video"
|
||||
LogInfo("Opening context menu for video:", item.videoId)
|
||||
title = item.title
|
||||
subtitle = item.author
|
||||
thumbnail = item.thumbnail
|
||||
else if item.type = "playlist"
|
||||
LogInfo("Opening context menu for playlist:", item.playlistId)
|
||||
title = item.title
|
||||
subtitle = item._author
|
||||
thumbnail = item.thumbnail
|
||||
else if item.type = "channel"
|
||||
LogInfo("Opening context menu for channel:", item.authorId)
|
||||
title = item._author
|
||||
thumbnail = item.thumbnail
|
||||
end if
|
||||
|
||||
contextMenu.title = title
|
||||
contextMenu.subtitle = subtitle
|
||||
contextMenu.thumbnail = thumbnail
|
||||
end function
|
||||
|
||||
function GetOptions(item as object, providers as object) as object
|
||||
allOptions = []
|
||||
|
||||
for each provider in providers
|
||||
if provider <> invalid and provider.hasField("supportsContextMenu") and provider.supportsContextMenu = true
|
||||
options = provider@.GetContextMenuOptionsForItem(item)
|
||||
if options <> invalid
|
||||
allOptions.append(options)
|
||||
end if
|
||||
end if
|
||||
|
||||
end for
|
||||
|
||||
return allOptions
|
||||
end function
|
||||
|
||||
function CreateOption(title as string, node as object, func as string, args as object) as object
|
||||
option = CreateObject("roSGNode", "ContextMenuItemContentNode")
|
||||
option.title = title
|
||||
option.node = node
|
||||
option.func = func
|
||||
option.args = args
|
||||
return option
|
||||
end function
|
||||
end namespace
|
||||
Reference in new issue
Block a user