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,101 @@
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.noBookmarks = m.top.findNode("noBookmarks")
|
||||
m.yesBookmarks = m.top.findNode("yesBookmarks")
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
m.rowList.screen = m.top
|
||||
m.isDirty = true
|
||||
|
||||
m.top.ObserveField("visible", FuncName(OnVisibleChange))
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
SetNavigation(invalid, "back", m.navBar)
|
||||
SetNavigation(invalid, "left", m.navBar)
|
||||
|
||||
m.rowList@.BindNode(invalid)
|
||||
|
||||
OnBookmarksChange()
|
||||
m.bookmarks.ObserveField("contentChange", FuncName(OnBookmarksChange))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
|
||||
if m.yesBookmarks.visible
|
||||
NodeSetFocus(m.rowList, true)
|
||||
else
|
||||
NodeSetFocus(m.navBar, true)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnVisibleChange()
|
||||
if m.top.visible and m.isDirty
|
||||
OnBookmarksChange()
|
||||
end if
|
||||
end function
|
||||
|
||||
function Refresh(unused as dynamic)
|
||||
m.isDirty = true
|
||||
OnBookmarksChange()
|
||||
end function
|
||||
|
||||
function OnBookmarksChange() as void
|
||||
if not m.top.visible
|
||||
m.isDirty = true
|
||||
return
|
||||
end if
|
||||
m.isDirty = false
|
||||
|
||||
hasBookmarks = m.bookmarks.content.getChildCount() > 0
|
||||
m.noBookmarks.visible = not hasBookmarks
|
||||
m.yesBookmarks.visible = hasBookmarks
|
||||
m.top.focusable = hasBookmarks
|
||||
|
||||
if hasBookmarks
|
||||
SetRowListContent(m.bookmarks.content)
|
||||
else
|
||||
if m.rowList.hasFocus()
|
||||
NodeSetFocus(m.navBar, true)
|
||||
end if
|
||||
end if
|
||||
end function
|
||||
|
||||
function SetRowListContent(bookmarksContent as object)
|
||||
bookmarkGroupNodes = bookmarksContent.getChildren(-1, 0)
|
||||
|
||||
feeds = []
|
||||
for each bookmarkGroupNode in bookmarkGroupNodes
|
||||
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
|
||||
feed = {
|
||||
title: bookmarkGroupNode.title,
|
||||
feedSources: []
|
||||
}
|
||||
|
||||
for each bookmarkNode in bookmarkNodes
|
||||
feed.feedSources.push(bookmarkNode.feedSource)
|
||||
end for
|
||||
|
||||
feeds.push(feed)
|
||||
end for
|
||||
|
||||
m.rowList.feeds = feeds
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
if NavigationKeyHandler(key, press).handled
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(rowItem as object) as object
|
||||
refreshItem = ContextMenuUtils.CreateOption("Refresh Bookmarks", m.top, "Refresh", [invalid])
|
||||
return [refreshItem]
|
||||
end function
|
||||
@@ -0,0 +1,38 @@
|
||||
<component name="BookmarksScreen" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="navBar" type="node" bind="/NavBar" />
|
||||
<field id="applicationInfo" type="node" bind="/ApplicationInfo" />
|
||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||
<function name="Refresh" />
|
||||
</interface>
|
||||
<children>
|
||||
<Group id="noBookmarks" visible="false">
|
||||
<Label
|
||||
height="720"
|
||||
width="1280"
|
||||
font="font:MediumBoldSystemFont"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
text="You currently have no bookmarks.

To add bookmarks, long-press 'OK' on a video, playlist or channel.

Please note that Bookmarks is an experimental feature."
|
||||
wrap="true" />
|
||||
</Group>
|
||||
<Group id="yesBookmarks" visible="false">
|
||||
<VideoRowList
|
||||
itemComponentName="RowCell"
|
||||
id="rowList"
|
||||
translation="[0,50]"
|
||||
numRows="2"
|
||||
rowitemSize="[[350,196]]"
|
||||
rowItemSpacing="[[25,0]]"
|
||||
itemSize="[1280,326]"
|
||||
itemSpacing="[0,65]"
|
||||
rowLabelOffset="[[125,20]]"
|
||||
focusXOffset="[125]"
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
focusBitmapUri="pkg:/images/focus_grid.9.png"
|
||||
/>
|
||||
</Group>
|
||||
</children>
|
||||
</component>
|
||||
@@ -1,8 +1,11 @@
|
||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
m.rowList.screen = m.top
|
||||
m.pendingLoadTasks = {}
|
||||
end function
|
||||
|
||||
@@ -11,7 +14,7 @@ function OnNodeReady()
|
||||
SetNavigation(invalid, "left", m.navBar)
|
||||
|
||||
m.rowList@.BindNode(invalid)
|
||||
m.rowList.contentData = ParseJson(ReadAsciiFile(m.top.feedFile))
|
||||
m.rowList.feeds = ParseJson(ReadAsciiFile(m.top.feedFile))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
@@ -27,3 +30,8 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
function GetContextMenuOptionsForItem(rowItem as object) as object
|
||||
refresh = ContextMenuUtils.CreateOption("Refresh Home", m.rowList, "Refresh", [invalid])
|
||||
return [refresh]
|
||||
end function
|
||||
@@ -1,8 +1,8 @@
|
||||
<component name="HomeScreen" extends="Group" includes="AutoBind,Focus">
|
||||
<component name="HomeScreen" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
|
||||
<interface>
|
||||
<field id="navBar" type="node" bind="/NavBar" />
|
||||
<field id="invidious" type="node" bind="/Invidious" />
|
||||
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.json5" />
|
||||
<field id="feedFile" type="string" value="libpkg:/config/default_home_layout.yaml" />
|
||||
</interface>
|
||||
<children>
|
||||
<VideoRowList
|
||||
@@ -14,8 +14,8 @@
|
||||
rowItemSpacing="[[25,0]]"
|
||||
itemSize="[1280,326]"
|
||||
itemSpacing="[0,65]"
|
||||
rowLabelOffset="[[115,20]]"
|
||||
focusXOffset="[115]"
|
||||
rowLabelOffset="[[125,20]]"
|
||||
focusXOffset="[125]"
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
|
||||
@@ -8,6 +8,7 @@ import "pkg:/source/utils/LoadingScreen.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.container = m.top.FindNode("container")
|
||||
m.keyboard = m.top.FindNode("keyboard")
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
@@ -16,6 +17,8 @@ function Init()
|
||||
m.suggestions = m.top.FindNode("suggestions")
|
||||
m.filtersButton = m.top.FindNode("filtersButton")
|
||||
|
||||
m.rowList.screen = m.top
|
||||
|
||||
textEditBox = m.keyboard.textEditBox
|
||||
textEditBox.voiceEntryType = "generic"
|
||||
textEditBox.voiceEnabled = true
|
||||
@@ -200,7 +203,8 @@ function Search(text as string)
|
||||
m.rowlist.ObserveFieldScoped("someContentReady", FuncName(OnSearchContentReady))
|
||||
ShowLoadingScreen()
|
||||
|
||||
requestData = {
|
||||
feedSource = {
|
||||
id: `inv_search_${CryptoUtils.GetMd5(text)}`,
|
||||
title: `Search - ${text}`,
|
||||
apiType: "Invidious",
|
||||
endpoint: "search",
|
||||
@@ -213,18 +217,21 @@ function Search(text as string)
|
||||
for each filter in filters
|
||||
value = filters[filter]
|
||||
if IsString(value) and value.len() > 0
|
||||
requestData.queryParams[filter] = value
|
||||
feedSource.queryParams[filter] = value
|
||||
else if IsArray(value) and value.Count() > 0
|
||||
' TODO:P1 this is http client implementation details leaking
|
||||
' We need a declarative way to set array types
|
||||
requestData.queryParams[filter] = {
|
||||
feedSource.queryParams[filter] = {
|
||||
value: value,
|
||||
__arrayType: HttpClient.QueryParamArrayType.CommaSeparated
|
||||
}
|
||||
end if
|
||||
end for
|
||||
|
||||
m.rowList.contentData = [requestData]
|
||||
m.rowList.feeds = [{
|
||||
title: `Search - ${text}`,
|
||||
feedSources: [feedSource]
|
||||
}]
|
||||
end function
|
||||
|
||||
function OnSearchContentReady() as void
|
||||
@@ -243,7 +250,7 @@ function OnSearchContentReady() as void
|
||||
end function
|
||||
|
||||
function OnSearchError()
|
||||
m.rowlist.contentData = invalid
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
HideLoadingScreen()
|
||||
end function
|
||||
@@ -258,7 +265,7 @@ end function
|
||||
|
||||
function ClearSearch()
|
||||
m.keyboard.text = ""
|
||||
m.rowlist.contentData = invalid
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
ScrollUp()
|
||||
end function
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
rowItemSpacing="[[25,0]]"
|
||||
itemSize="[1280,326]"
|
||||
itemSpacing="[0,65]"
|
||||
rowLabelOffset="[[115,20]]"
|
||||
focusXOffset="[115]"
|
||||
rowLabelOffset="[[125,20]]"
|
||||
focusXOffset="[125]"
|
||||
showRowLabel="[true]"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
variableWidthItems="true"
|
||||
|
||||
@@ -3,6 +3,7 @@ import "pkg:/components/Navigation/ScrollTo.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.container = m.top.findNode("Container")
|
||||
m.scrollAnimation = m.top.findNode("scrollAnimation")
|
||||
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
|
||||
|
||||
Reference in new issue
Block a user