From 6d5bdbe4a48370529f0ea742d24864c756a1aaed Mon Sep 17 00:00:00 2001
From: 1hitsong <3330318+1hitsong@users.noreply.github.com>
Date: Fri, 29 Nov 2024 10:02:10 -0500
Subject: [PATCH] Fix loss of focus bug when closing options popup on Live TV
show details
---
components/ItemGrid/ItemGridOptions.bs | 3 -
components/liveTv/LiveTVLibraryView.bs | 18 ++--
components/liveTv/ProgramDetails.bs | 10 +--
components/liveTv/ProgramDetails.xml | 2 +-
components/liveTv/schedule.bs | 31 +++++--
source/Main.bs | 117 +++++++++++++------------
source/static/whatsNew/1.1.2.json | 4 +
7 files changed, 102 insertions(+), 83 deletions(-)
diff --git a/components/ItemGrid/ItemGridOptions.bs b/components/ItemGrid/ItemGridOptions.bs
index 3f19576d4..2a2f73d80 100644
--- a/components/ItemGrid/ItemGridOptions.bs
+++ b/components/ItemGrid/ItemGridOptions.bs
@@ -16,9 +16,6 @@ sub init()
m.buttons = m.top.findNode("buttons")
m.buttons.buttons = [tr("View"), tr("Sort"), tr("Filter")]
m.buttons.selectedIndex = MenuType.SORT
- m.buttons.setFocus(true)
- group = m.global.sceneManager.callFunc("getActiveScene")
- group.lastFocus = m.buttons
m.favoriteMenu = m.top.findNode("favoriteMenu")
m.selectedFavoriteItem = m.top.findNode("selectedFavoriteItem")
diff --git a/components/liveTv/LiveTVLibraryView.bs b/components/liveTv/LiveTVLibraryView.bs
index 54d96a5fb..6cfeeddd4 100644
--- a/components/liveTv/LiveTVLibraryView.bs
+++ b/components/liveTv/LiveTVLibraryView.bs
@@ -278,10 +278,11 @@ sub ItemDataLoaded(msg)
group = m.global.sceneManager.callFunc("getActiveScene")
group.lastFocus = m.alphaMenu
else
- m.alphaMenu.setFocus(false)
- m.itemGrid.setFocus(true)
- group = m.global.sceneManager.callFunc("getActiveScene")
- group.lastFocus = m.itemGrid
+ if not isStringEqual(m.global.session.user.settings["display.livetv.landing"], "guide") or isStringEqual(m.options.view, "livetv")
+ m.itemGrid.setFocus(true)
+ group = m.global.sceneManager.callFunc("getActiveScene")
+ group.lastFocus = m.itemGrid
+ end if
end if
'Update the stored counts
@@ -442,11 +443,14 @@ sub optionsClosed()
group = m.global.sceneManager.callFunc("getActiveScene")
group.lastFocus = m.itemGrid.opacity = 1 ? m.itemGrid : m.tvGuide
- if m.tvGuide <> invalid
+ if isValid(m.tvGuide)
m.tvGuide.lastFocus.setFocus(true)
- group.lastFocus = m.tvGuide
- end if
+ group.lastFocus = m.tvGuide.lastFocus
+ if isChainValid(m.tvGuide, "lastFocus.hasFocus")
+ m.tvGuide.lastFocus.hasFocus = m.tvGuide.lastFocus.hasFocus
+ end if
+ end if
end sub
sub showTVGuide()
diff --git a/components/liveTv/ProgramDetails.bs b/components/liveTv/ProgramDetails.bs
index 1d76ac4ce..3d006544f 100644
--- a/components/liveTv/ProgramDetails.bs
+++ b/components/liveTv/ProgramDetails.bs
@@ -299,7 +299,7 @@ sub focusChanged()
m.viewChannelOutline.visible = true
m.recordOutline.visible = false
m.recordSeriesOutline.visible = false
- m.viewChannelButtonBackground.blendColor = "#006fab"
+ m.viewChannelButtonBackground.blendColor = ColorPalette.HIGHLIGHT
m.recordButtonBackground.blendColor = "#000000"
m.recordSeriesButtonBackground.blendColor = "#000000"
else
@@ -343,7 +343,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.viewChannelOutline.visible = false
m.recordOutline.visible = true
m.viewChannelButtonBackground.blendColor = "#000000"
- m.recordButtonBackground.blendColor = "#006fab"
+ m.recordButtonBackground.blendColor = ColorPalette.HIGHLIGHT
m.recordSeriesButtonBackground.blendColor = "#000000"
return true
else if key = "right" and m.recordButton.hasFocus()
@@ -354,7 +354,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.recordSeriesOutline.visible = true
m.viewChannelButtonBackground.blendColor = "#000000"
m.recordButtonBackground.blendColor = "#000000"
- m.recordSeriesButtonBackground.blendColor = "#006fab"
+ m.recordSeriesButtonBackground.blendColor = ColorPalette.HIGHLIGHT
return true
else if key = "left" and m.recordSeriesButton.hasFocus()
m.recordButton.setFocus(true)
@@ -363,7 +363,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.recordOutline.visible = true
m.recordSeriesOutline.visible = false
m.viewChannelButtonBackground.blendColor = "#000000"
- m.recordButtonBackground.blendColor = "#006fab"
+ m.recordButtonBackground.blendColor = ColorPalette.HIGHLIGHT
m.recordSeriesButtonBackground.blendColor = "#000000"
return true
else if key = "left" and m.recordButton.hasFocus()
@@ -372,7 +372,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
group.lastFocus = m.viewChannelButton
m.viewChannelOutline.visible = true
m.recordOutline.visible = false
- m.viewChannelButtonBackground.blendColor = "#006fab"
+ m.viewChannelButtonBackground.blendColor = ColorPalette.HIGHLIGHT
m.recordButtonBackground.blendColor = "#000000"
m.recordSeriesButtonBackground.blendColor = "#000000"
return true
diff --git a/components/liveTv/ProgramDetails.xml b/components/liveTv/ProgramDetails.xml
index b02ca5c65..530e9593b 100644
--- a/components/liveTv/ProgramDetails.xml
+++ b/components/liveTv/ProgramDetails.xml
@@ -83,6 +83,6 @@
-
+
\ No newline at end of file
diff --git a/components/liveTv/schedule.bs b/components/liveTv/schedule.bs
index 710f26ac2..225249663 100644
--- a/components/liveTv/schedule.bs
+++ b/components/liveTv/schedule.bs
@@ -1,7 +1,9 @@
import "pkg:/source/enums/ColorPalette.bs"
+import "pkg:/source/enums/TaskControl.bs"
import "pkg:/source/utils/misc.bs"
sub init()
+ m.state = TaskControl.RUN
m.loadedChannelCount = 0
m.channelFirstLoadLimit = 20
m.channelLaterLoadLimit = 100
@@ -35,6 +37,15 @@ sub init()
m.LoadChannelsTask = createObject("roSGNode", "LoadChannelsTask")
m.LoadChannelsTask.observeField("channels", "onChannelsLoaded")
+
+ m.LoadScheduleTask = createObject("roSGNode", "LoadScheduleTask")
+ m.LoadScheduleTask.observeField("schedule", "onScheduleLoaded")
+ m.LoadScheduleTask.startTime = m.gridStartDate.ToISOString()
+ m.LoadScheduleTask.endTime = m.gridEndDate.ToISOString()
+
+ m.LoadProgramDetailsTask = createObject("roSGNode", "LoadProgramDetailsTask")
+ m.LoadProgramDetailsTask.observeField("programDetails", "onProgramDetailsLoaded")
+
loadChannels(m.channelFirstLoadLimit)
m.top.lastFocus = m.scheduleGrid
@@ -43,6 +54,8 @@ sub init()
end sub
sub loadChannels(limit as integer)
+ if not isStringEqual(m.state, TaskControl.RUN) then return
+
m.LoadChannelsTask.limit = limit
m.LoadChannelsTask.startIndex = m.loadedChannelCount
m.LoadChannelsTask.control = "RUN"
@@ -96,17 +109,9 @@ sub onChannelsLoaded()
channelIdList = channelIdList + item.Id + ","
end for
- m.LoadScheduleTask = createObject("roSGNode", "LoadScheduleTask")
- m.LoadScheduleTask.observeField("schedule", "onScheduleLoaded")
-
- m.LoadScheduleTask.startTime = m.gridStartDate.ToISOString()
- m.LoadScheduleTask.endTime = m.gridEndDate.ToISOString()
m.LoadScheduleTask.channelIds = channelIdList
m.LoadScheduleTask.control = "RUN"
- m.LoadProgramDetailsTask = createObject("roSGNode", "LoadProgramDetailsTask")
- m.LoadProgramDetailsTask.observeField("programDetails", "onProgramDetailsLoaded")
-
if m.EPGLaunchCompleteSignaled = false
m.top.signalBeacon("EPGLaunchComplete") ' Required Roku Performance monitoring
m.EPGLaunchCompleteSignaled = true
@@ -331,7 +336,15 @@ function onKeyEvent(key as string, press as boolean) as boolean
group.lastFocus = gridGrp
return true
else if key = "back"
- m.LoadChannelsTask.control = "stop"
+ m.state = TaskControl.STOP
+
+ m.LoadChannelsTask.control = TaskControl.STOP
+ m.LoadScheduleTask.control = TaskControl.STOP
+
+ m.LoadChannelsTask.channels = []
+ m.LoadScheduleTask.schedule = []
+ m.channelIndex = {}
+
m.global.sceneManager.callFunc("popScene")
return true
end if
diff --git a/source/Main.bs b/source/Main.bs
index 15d63bfee..aae7f08af 100644
--- a/source/Main.bs
+++ b/source/Main.bs
@@ -5,17 +5,12 @@ import "pkg:/source/enums/String.bs"
sub Main (args as dynamic) as void
' The main function that runs when the application is launched.
m.screen = CreateObject("roSGScreen")
+ m.port = CreateObject("roMessagePort")
+ m.screen.setMessagePort(m.port)
' Set global constants
setConstants()
- ' Write screen tracker for screensaver
- WriteAsciiFile("tmp:/scene.temp", "")
- MoveFile("tmp:/scene.temp", "tmp:/scene")
-
- m.port = CreateObject("roMessagePort")
- m.screen.setMessagePort(m.port)
-
' Set any initial Global Variables
m.global = m.screen.getGlobalNode()
SaveAppToGlobal()
@@ -23,11 +18,6 @@ sub Main (args as dynamic) as void
session.Init()
- ' update global LastRunVersion now that migrations are finished
- if m.global.app.version <> m.global.app.lastRunVersion
- set_setting("LastRunVersion", m.global.app.version)
- end if
-
m.scene = m.screen.CreateScene("BaseScene")
m.screen.show() ' vscode_rale_tracker_entry
'vscode_rdb_on_device_component_entry
@@ -70,52 +60,14 @@ sub Main (args as dynamic) as void
m.scene.observeField("exit", m.port)
- ' Downloads and stores a fallback font to tmp:/
- configEncoding = api.system.GetConfigurationByName("encoding")
-
- if isChainValid(configEncoding, "EnableFallbackFont")
- if configEncoding.EnableFallbackFont
- re = CreateObject("roRegex", "Name.:.(.*?).,.Size", "s")
- filename = APIRequest("FallbackFont/Fonts").GetToString()
- if isValid(filename)
- filename = re.match(filename)
- if isValidAndNotEmpty(filename)
- filename = filename[1]
- APIRequest("FallbackFont/Fonts/" + filename).gettofile("tmp:/font")
- end if
- end if
- end if
- end if
+ ' Download and store the fallback font to tmp:/
+ ' This font may be used for CJK subtitles
+ downloadFallbackFont()
' Delete any old library filters
- for each settingKeys in m.global.session.user.settings.keys()
- if isStringEqual(left(settingKeys, 8), "display.")
- if isStringEqual(right(settingKeys, 7), ".filter") or isStringEqual(right(settingKeys, 14), ".filterOptions")
- m.global.session.user.settings.delete(settingKeys)
- unset_user_setting(settingKeys)
- end if
- end if
- end for
+ clearOldLibraryFilters()
- ' Bypass What's New popup if server is Jellyfin demo
- if isStringEqual(m.global.session.server.url, "https://demo.jellyfin.org/stable")
- set_user_setting("LastRunVersion", m.global.app.version)
- end if
-
- ' Bypass What's New popup if deep linking arguments were passed
- if isValidAndNotEmpty(args.mediaType) and isValidAndNotEmpty(args.contentId)
- set_user_setting("LastRunVersion", m.global.app.version)
- end if
-
- ' Has the current user run this version before?
- usersLastRunVersion = m.global.session.user.settings.lastRunVersion
- if ChannelVersionUpdated(usersLastRunVersion)
- set_user_setting("LastRunVersion", m.global.app.version)
- ' show what's new popup
- if m.global.session.user.settings["load.allowwhatsnew"]
- m.global.sceneManager.callFunc("whatsNewDialog")
- end if
- end if
+ displayWhatsNewPopup(args)
' Handle input messages
input = CreateObject("roInput")
@@ -124,11 +76,9 @@ sub Main (args as dynamic) as void
device = CreateObject("roDeviceInfo")
device.setMessagePort(m.port)
device.EnableScreensaverExitedEvent(true)
- device.EnableAppFocusEvent(true)
+ device.EnableAudioGuideChangedEvent(true)
device.EnableLowGeneralMemoryEvent(true)
- device.EnableLinkStatusEvent(true)
device.EnableCodecCapChangedEvent(true)
- device.EnableAudioGuideChangedEvent(true)
' Check if we were sent content to play with the startup command (Deep Link)
onDeepLinkingEvent(args)
@@ -255,3 +205,54 @@ sub Main (args as dynamic) as void
end if
end while
end sub
+
+sub downloadFallbackFont()
+ configEncoding = api.system.GetConfigurationByName("encoding")
+
+ if isChainValid(configEncoding, "EnableFallbackFont")
+ if configEncoding.EnableFallbackFont
+ re = CreateObject("roRegex", "Name.:.(.*?).,.Size", "s")
+ filename = APIRequest("FallbackFont/Fonts").GetToString()
+ if isValid(filename)
+ filename = re.match(filename)
+ if isValidAndNotEmpty(filename)
+ filename = filename[1]
+ APIRequest("FallbackFont/Fonts/" + filename).gettofile("tmp:/font")
+ end if
+ end if
+ end if
+ end if
+end sub
+
+sub clearOldLibraryFilters()
+ for each settingKeys in m.global.session.user.settings.keys()
+ if isStringEqual(left(settingKeys, 8), "display.")
+ if isStringEqual(right(settingKeys, 7), ".filter") or isStringEqual(right(settingKeys, 14), ".filterOptions")
+ m.global.session.user.settings.delete(settingKeys)
+ unset_user_setting(settingKeys)
+ end if
+ end if
+ end for
+end sub
+
+sub displayWhatsNewPopup(args)
+ ' Bypass What's New popup if server is Jellyfin demo
+ if isStringEqual(m.global.session.server.url, "https://demo.jellyfin.org/stable")
+ set_user_setting("LastRunVersion", m.global.app.version)
+ end if
+
+ ' Bypass What's New popup if deep linking arguments were passed
+ if isValidAndNotEmpty(args.mediaType) and isValidAndNotEmpty(args.contentId)
+ set_user_setting("LastRunVersion", m.global.app.version)
+ end if
+
+ ' Has the current user run this version before?
+ usersLastRunVersion = m.global.session.user.settings.lastRunVersion
+ if ChannelVersionUpdated(usersLastRunVersion)
+ set_user_setting("LastRunVersion", m.global.app.version)
+ ' show what's new popup
+ if m.global.session.user.settings["load.allowwhatsnew"]
+ m.global.sceneManager.callFunc("whatsNewDialog")
+ end if
+ end if
+end sub
diff --git a/source/static/whatsNew/1.1.2.json b/source/static/whatsNew/1.1.2.json
index 7b0e23ef2..fee452ae6 100644
--- a/source/static/whatsNew/1.1.2.json
+++ b/source/static/whatsNew/1.1.2.json
@@ -11,6 +11,10 @@
"description": "Fix TV episode watched button text not changing when clicked",
"author": "1hitsong"
},
+ {
+ "description": "Fix loss of focus bug when closing options popup from Live TV show details",
+ "author": "1hitsong"
+ },
{
"description": "Update item API calls",
"author": "jimdogx"