Revert "Update Home Screen to Respect User Preferences (#553)"

This reverts commit 26d9360fd3.
This commit is contained in:
Charles Ewert 2022-07-12 19:15:59 -04:00
parent 3a27212c46
commit 13b660c7c2
14 changed files with 297 additions and 954 deletions

View File

@ -3,13 +3,13 @@
<children>
<poster id="backdrop"
loadDisplayMode="scaleToFit"
loadDisplayMode="scaleToFill"
width="1920"
height="1080"
opacity="0.25"
/>
<poster id="backdropTransition"
loadDisplayMode="scaleToFit"
loadDisplayMode="scaleToFill"
width="1920"
height="1080"
opacity="0.25"

View File

@ -37,7 +37,7 @@ sub setData()
imgParams.Append({ "maxHeight": 261 })
imgParams.Append({ "maxWidth": 464 })
m.top.thumbnailURL = ImageURL(datum.Id, "Primary", imgParams)
m.top.thumbnailURL = ImageURL(datum.id, "Primary", imgParams)
' Add Wide Poster (Series Backdrop)
if datum.ParentThumbImageTag <> invalid
@ -45,7 +45,7 @@ sub setData()
else if datum.ParentBackdropImageTags <> invalid
m.top.widePosterUrl = ImageURL(datum.ParentBackdropItemId, "Backdrop", imgParams)
else if datum.ImageTags.Primary <> invalid
m.top.posterUrl = ImageURL(datum.SeriesId, "Primary", imgParams)
m.top.widePosterUrl = ImageURL(datum.id, "Primary", imgParams)
end if
else if datum.type = "Series"
@ -82,7 +82,7 @@ sub setData()
if datum.ImageTags <> invalid and datum.imageTags.Thumb <> invalid
m.top.thumbnailUrl = ImageURL(datum.Id, "Thumb", imgParams)
else if datum.BackdropImageTags <> invalid and datum.BackdropImageTags[0] <> invalid
else if datum.BackdropImageTags[0] <> invalid
m.top.thumbnailUrl = ImageURL(datum.id, "Backdrop", imgParams)
end if
@ -106,7 +106,7 @@ sub setData()
else if datum.BackdropImageTags[0] <> invalid
m.top.thumbnailUrl = ImageURL(datum.id, "Backdrop", imgParams)
end if
else if datum.type = "MusicAlbum" or datum.type = "Audio" or datum.type = "Book"
else if datum.type = "MusicAlbum"
params = { "maxHeight": 261, "maxWidth": 261 }
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL

View File

@ -12,8 +12,6 @@
<field id="collectionType" type="string" />
<field id="imageWidth" type="integer" value="464" />
<field id="usePoster" type="bool" value="false" />
<field id="stretch" type="bool" value="false" />
<field id="isSmall" type="bool" value="false" />
</interface>
<script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />

View File

@ -9,7 +9,7 @@ sub init()
end sub
sub refresh()
m.top.findNode("homeRows").callFunc("loadLibraries")
m.top.findNode("homeRows").callFunc("updateHomeRows")
end sub
sub loadLibraries()

View File

@ -18,6 +18,8 @@ sub itemContentChanged()
itemData = m.top.itemContent
if itemData = invalid then return
itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem"
m.itemPoster.width = itemData.imageWidth
m.itemText.maxWidth = itemData.imageWidth
m.itemTextExtra.width = itemData.imageWidth
@ -30,32 +32,18 @@ sub itemContentChanged()
m.itemIcon.uri = itemData.iconUrl
end if
if itemData.stretch = true
m.itemPoster.loadDisplayMode = "scaleToZoom"
end if
' Format the Data based on the type of Home Data
if itemData.type = "CollectionFolder" or itemData.type = "UserView" or itemData.type = "Channel"
m.itemText.text = itemData.name
if itemData.isSmall = true
m.backdrop.height = "100"
m.itemText.translation = [0, 20]
itemData.usePoster = false
end if
if itemData.usePoster = true
m.itemPoster.uri = itemData.widePosterURL
end if
m.itemPoster.uri = itemData.widePosterURL
return
end if
if itemData.type = "UserView" and itemData.usePoster = true
if itemData.type = "UserView"
m.itemPoster.width = "96"
m.itemPoster.height = "96"
m.itemPoster.translation = "[192, 88]"
m.itemText.text = itemData.name
if itemData.isSmall = true
m.itemText.translation = [8, 10]
end if
m.itemPoster.uri = itemData.widePosterURL
return
end if
@ -64,7 +52,8 @@ sub itemContentChanged()
m.itemText.height = 34
m.itemText.font.size = 25
m.itemText.horizAlign = "left"
' m.itemText.vertAlign = "bottom"
m.itemText.vertAlign = "bottom"
m.itemTextExtra.visible = true
m.itemTextExtra.font.size = 22
' "Program" is from clicking on an "On Now" item on the Home Screen
@ -86,12 +75,9 @@ sub itemContentChanged()
m.itemText.text = itemData.json.SeriesName
if itemData.usePoster = true
m.itemPoster.uri = itemData.posterURL
else
m.itemPoster.uri = itemData.widePosterURL
end if
if itemData.json.ImageURL <> invalid
m.itemPoster.uri = itemData.json.ImageURL
else
m.itemPoster.uri = itemData.thumbnailURL
end if
' Set Series and Episode Number for Extra Text
@ -119,9 +105,6 @@ sub itemContentChanged()
else
m.itemPoster.uri = itemData.thumbnailURL
end if
if itemData.json.ImageURL <> invalid
m.itemPoster.uri = itemData.json.ImageURL
end if
' Set Release Year and Age Rating for Extra Text
textExtra = ""
@ -148,17 +131,22 @@ sub itemContentChanged()
else
m.itemPoster.uri = itemData.thumbnailURL
end if
if itemData.json.ImageURL <> invalid
m.itemPoster.uri = itemData.json.ImageURL
end if
return
end if
if itemData.type = "Series"
m.itemText.text = itemData.name
m.itemPoster.uri = itemData.posterURL
if itemData.json.ImageURL <> invalid
m.itemPoster.uri = itemData.json.ImageURL
if itemData.usePoster = true
if itemData.imageWidth = 180
m.itemPoster.uri = itemData.posterURL
else
m.itemPoster.uri = itemData.widePosterURL
end if
else
m.itemPoster.uri = itemData.thumbnailURL
end if
textExtra = ""
if itemData.json.ProductionYear <> invalid
textExtra = StrI(itemData.json.ProductionYear).trim()
@ -175,25 +163,10 @@ sub itemContentChanged()
return
end if
if itemData.type = "MusicAlbum" or itemData.type = "Audio" or itemData.type = "Book" or itemData.type = "AudioBook"
if itemData.type = "MusicAlbum"
m.itemText.text = itemData.name
m.itemTextExtra.text = itemData.json.AlbumArtist
if itemData.usePoster = true
if itemData.posterURL <> ""
m.itemPoster.uri = itemData.posterURL
else
m.itemPoster.uri = itemData.json.ImageURL
end if
end if
return
end if
if itemData.type = "Photo" or itemData.type = "PhotoAlbum"
if itemData.usePoster = true
if itemData.json.ImageURL <> invalid
m.itemPoster.uri = itemData.json.ImageURL
end if
end if
m.itemPoster.uri = itemData.posterURL
return
end if
@ -215,13 +188,11 @@ end sub
'Hide backdrop and icon when poster loaded
sub onPosterLoadStatusChanged()
if m.itemPoster <> invalid
if m.itemPoster.loadStatus = "ready" and m.itemPoster.uri <> ""
m.backdrop.visible = false
m.itemIcon.visible = false
else
m.backdrop.visible = true
m.itemIcon.visible = true
end if
if m.itemPoster.loadStatus = "ready" and m.itemPoster.uri <> ""
m.backdrop.visible = false
m.itemIcon.visible = false
else
m.backdrop.visible = true
m.itemIcon.visible = true
end if
end sub

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="HomeItem" extends="Group">
<children>
<Rectangle id="backdrop" width="464" height="270" translation="[8,0]" />
<Rectangle id="backdrop" width="464" height="261" translation="[8,5]" />
<Poster id="itemIcon" width="100" height="100" translation="[190,85]" loadDisplayMode="scaleToFit" />
<Poster id="itemPoster" width="464" height="270" translation="[0,0]" loadDisplayMode="scaleToZoom" />
<ScrollingLabel id="itemText" horizAlign="center" vertAlign="center" font="font:SmallBoldSystemFont" height="64" maxWidth="456" translation="[8,280]" repeatCount="0" />
<Label id="itemTextExtra" horizAlign="left" vertAlign="center" font="font:SmallBoldSystemFont" height="32" width="456" translation="[8,319]" visible="true" color="#777777FF" />
<Poster id="itemPoster" width="464" height="261" translation="[8,5]" loadDisplayMode="scaleToZoom" />
<ScrollingLabel id="itemText" horizAlign="center" vertAlign="center" font="font:SmallBoldSystemFont" height="64" maxWidth="456" translation="[8,267]" repeatCount="0" />
<Label id="itemTextExtra" horizAlign="left" vertAlign="center" font="font:SmallBoldSystemFont" height="32" width="456" translation="[8,300]" visible="false" color="#777777FF" />
</children>
<interface>
<field id="itemContent" type="node" onChange="itemContentChanged" />

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="HomeRow" extends="ContentNode">
<interface>
<field id="imageWidth" type="integer" value="200" />
<field id="stretch" type="bool" value="false" />
<field id="imageWidth" type="integer" value="464" />
<field id="usePoster" type="bool" value="false" />
</interface>
</component>

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,5 @@
<function name="updateHomeRows" />
<function name="loadLibraries" />
</interface>
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
<script type="text/brightscript" uri="HomeRows.brs"/>
</component>

View File

@ -13,9 +13,12 @@ sub loadItems()
resp = APIRequest(url)
data = getJson(resp)
for each item in data.Items
tmp = CreateObject("roSGNode", "HomeData")
tmp.json = item
results.push(tmp)
' Skip Books for now as we don't support it (issue #525)
if item.CollectionType <> "books"
tmp = CreateObject("roSGNode", "HomeData")
tmp.json = item
results.push(tmp)
end if
end for
' Load Latest Additions to Libraries
@ -27,20 +30,17 @@ sub loadItems()
params["ParentId"] = m.top.itemId
params["EnableImageTypes"] = "Primary,Backdrop,Thumb"
params["ImageTypeLimit"] = 1
params["fields"] = "PrimaryImageAspectRatio,BasicSyncInfo,Path"
params["MaxWidth"] = 416
params["MaxHeight"] = 416
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data
tmp = CreateObject("roSGNode", "HomeData")
item.ImageURL = ImageURL(item.Id, "Primary", params)
if item.type = "Episode"
item.ImageURL = ImageURL(item.Id)
' Skip Books for now as we don't support it (issue #525)
if item.Type <> "Book"
tmp = CreateObject("roSGNode", "HomeData")
tmp.json = item
results.push(tmp)
end if
tmp.json = item
results.push(tmp)
end for
' Load Next Up
@ -48,7 +48,6 @@ sub loadItems()
url = "Shows/NextUp"
params = {}
params["Limit"] = 30
params["recursive"] = true
params["SortBy"] = "DatePlayed"
params["SortOrder"] = "Descending"
@ -59,96 +58,38 @@ sub loadItems()
data = getJson(resp)
for each item in data.Items
tmp = CreateObject("roSGNode", "HomeData")
if item.type = "Episode"
item.ImageURL = ImageURL(item.SeriesId, "Backdrop")
else
item.ImageURL = ImageURL(item.Id, "Backdrop")
end if
item.stretch = true
tmp.json = item
results.push(tmp)
end for
' Load Continue Watching
else if m.top.itemsToLoad = "continueVideo"
else if m.top.itemsToLoad = "continue"
url = Substitute("Users/{0}/Items/Resume", get_setting("active_user"))
params = {}
params["Limit"] = 30
params["recursive"] = true
params["SortBy"] = "DatePlayed"
params["SortOrder"] = "Descending"
params["Filters"] = "IsResumable"
params["MediaTypes"] = "Video"
params["EnableImageTypes"] = "Primary,Backdrop,Thumb"
params["ImageTypeLimit"] = 1
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
tmp = CreateObject("roSGNode", "HomeData")
if item.type = "Episode"
item.ImageURL = ImageURL(item.SeriesId, "Backdrop")
else
item.ImageURL = ImageURL(item.Id, "Backdrop")
' Skip Books for now as we don't support it (issue #558)
if item.Type <> "Book"
tmp = CreateObject("roSGNode", "HomeData")
tmp.json = item
results.push(tmp)
end if
item.stretch = true
tmp.json = item
results.push(tmp)
end for
else if m.top.itemsToLoad = "continueAudio"
url = Substitute("Users/{0}/Items/Resume", get_setting("active_user"))
params = {}
params["Limit"] = 30
params["recursive"] = true
params["SortBy"] = "DatePlayed"
params["SortOrder"] = "Descending"
params["Filters"] = "IsResumable"
params["MediaTypes"] = "Audio"
params["EnableImageTypes"] = "Primary,Backdrop,Thumb"
params["ImageTypeLimit"] = 1
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
tmp = CreateObject("roSGNode", "HomeData")
item.ImageURL = ImageURL(item.Id, "Backdrop")
tmp.json = item
results.push(tmp)
end for
else if m.top.itemsToLoad = "continueBook"
url = Substitute("Users/{0}/Items/Resume", get_setting("active_user"))
params = {}
params["Limit"] = 30
params["recursive"] = true
params["SortBy"] = "DatePlayed"
params["SortOrder"] = "Descending"
params["Filters"] = "IsResumable"
params["MediaTypes"] = "Book"
params["EnableImageTypes"] = "Primary,Backdrop,Thumb"
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
tmp = CreateObject("roSGNode", "HomeData")
item.ImageURL = ImageURL(item.Id, "Backdrop")
tmp.json = item
results.push(tmp)
end for
else if m.top.itemsToLoad = "onNow"
url = "LiveTv/Programs/Recommended"
params = {}
params["Limit"] = 30
params["userId"] = get_setting("active_user")
params["isAiring"] = true
params["limit"] = 16 ' 16 to be consistent with "Latest In"
params["imageTypeLimit"] = 1
params["enableImageTypes"] = "Primary,Thumb,Backdrop"
params["enableTotalRecordCount"] = false

View File

@ -4,7 +4,6 @@
<interface>
<field id="itemsToLoad" type="string" value="libraries" />
<field id="itemId" type="string" />
<field id="nodeNumber" type="integer" />
<field id="metadata" type="assocarray" />
<field id="peopleList" type="array" />
<field id="content" type="array" />

View File

@ -166,7 +166,7 @@ sub Main (args as dynamic) as void
group = CreateAudioPlayerGroup([selectedItem.json])
else
' TODO - switch on more node types
message_dialog(Substitute(tr("{0} support is coming soon!"), selectedItem.type))
message_dialog("This type is not yet supported: " + selectedItem.type + ".")
end if
else if isNodeEvent(msg, "movieSelected")
' If you select a movie from ANYWHERE, follow this flow

View File

@ -38,15 +38,15 @@ end function
function ImageURL(id, version = "Primary", params = {})
' set defaults
if params.maxHeight = invalid
param = { "fillHeight": "331" }
param = { "maxHeight": "384" }
params.append(param)
end if
if params.maxWidth = invalid
param = { "fillWidth": "464" }
param = { "maxWidth": "196" }
params.append(param)
end if
if params.quality = invalid
param = { "quality": "96" }
param = { "quality": "90" }
params.append(param)
end if
url = Substitute("Items/{0}/Images/{1}", id, version)
@ -63,7 +63,7 @@ function UserImageURL(id, params = {})
params.append({ "maxWidth": "300" })
end if
if params.quality = invalid
params.append({ "quality": "96" })
params.append({ "quality": "90" })
end if
url = Substitute("Users/{0}/Images/Primary", id)

View File

@ -141,52 +141,11 @@ sub LoadUserPreferences()
resp = APIRequest(url)
jsonResponse = getJson(resp)
if jsonResponse <> invalid and jsonResponse.CustomPrefs <> invalid
if jsonResponse.CustomPrefs["landing-livetv"] <> invalid
set_user_setting("display.livetv.landing", jsonResponse.CustomPrefs["landing-livetv"])
end if
' Take into account nones, if nones are in the middle then resort them to the end to be removed later in HomeRows
nones = 0
for i = 0 to 6
if jsonResponse.CustomPrefs["homesection" + i.ToStr()] <> invalid
if jsonResponse.CustomPrefs["homesection" + i.ToStr()] = "none"
nones += 1
else
if nones > 0
j = i - nones
set_user_setting("display.homesection" + i.ToStr(), "none")
set_user_setting("display.homesection" + j.ToStr(), jsonResponse.CustomPrefs["homesection" + i.ToStr()])
else
set_user_setting("display.homesection" + i.ToStr(), jsonResponse.CustomPrefs["homesection" + i.ToStr()])
end if
end if
end if
end for
if jsonResponse.CustomPrefs["homesection0"] = invalid
setHomeScreenDefaults()
end if
if jsonResponse <> invalid and jsonResponse.CustomPrefs <> invalid and jsonResponse.CustomPrefs["landing-livetv"] <> invalid
set_user_setting("display.livetv.landing", jsonResponse.CustomPrefs["landing-livetv"])
else
setHomeScreenDefaults()
unset_user_setting("display.livetv.landing")
end if
' Actual user settings for getting ordered views
url = Substitute("Users/{0}", id)
resp = APIRequest(url)
jsonResponse = getJson(resp)
if jsonResponse <> invalid
set_user_setting("display.userConfig", FormatJson(jsonResponse))
end if
end sub
sub setHomeScreenDefaults()
set_user_setting("display.homesection0", "smalllibrarytiles")
set_user_setting("display.homesection1", "resume")
set_user_setting("display.homesection2", "resumeaudio")
set_user_setting("display.homesection3", "resumebook")
set_user_setting("display.homesection4", "livetv")
set_user_setting("display.homesection5", "nextup")
set_user_setting("display.homesection6", "latestmedia")
end sub
sub LoadUserAbilities(user)