diff --git a/components/data/SceneManager.brs b/components/data/SceneManager.brs index e876957f5..e294ba390 100755 --- a/components/data/SceneManager.brs +++ b/components/data/SceneManager.brs @@ -98,14 +98,6 @@ sub popScene() if group <> invalid registerOverhangData(group) - if group.subtype() = "Home" - currentTime = CreateObject("roDateTime").AsSeconds() - if group.timeLastRefresh = invalid or (currentTime - group.timeLastRefresh) > 20 - group.timeLastRefresh = currentTime - group.callFunc("refresh") - end if - end if - group.visible = true m.content.replaceChild(group, 0) @@ -143,6 +135,11 @@ end function ' Clear all content from group stack sub clearScenes() if m.content <> invalid then m.content.removeChildrenIndex(m.content.getChildCount(), 0) + for each group in m.groups + if LCase(group.subtype()) = "jfscreen" + group.callFunc("OnScreenHidden") + end if + end for m.groups = [] end sub diff --git a/components/home/Home.brs b/components/home/Home.brs index 00e056f66..67dcdeb88 100644 --- a/components/home/Home.brs +++ b/components/home/Home.brs @@ -1,10 +1,14 @@ import "pkg:/source/api/baserequest.brs" import "pkg:/source/utils/config.brs" import "pkg:/source/utils/misc.brs" +import "pkg:/source/utils/deviceCapabilities.brs" sub init() + m.isFirstRun = true m.top.overhangTitle = "Home" m.top.optionsAvailable = true + m.postTask = createObject("roSGNode", "PostTask") + if m.global.session.user.settings["ui.home.splashBackground"] = true m.backdrop = m.top.findNode("backdrop") m.backdrop.uri = buildURL("/Branding/Splashscreen?format=jpg&foregroundLayer=0.15&fillWidth=1280&width=1280&fillHeight=720&height=720&tag=splash") @@ -18,3 +22,31 @@ end sub sub loadLibraries() m.top.findNode("homeRows").callFunc("loadLibraries") end sub + +' JFScreen hook that gets ran as needed. +' Used to update the focus, the state of the data, and tells the server about the device profile +sub OnScreenShown() + if isValid(m.top.lastFocus) + m.top.lastFocus.setFocus(true) + else + m.top.setFocus(true) + end if + + refresh() + + ' post the device profile the first time this screen is loaded + if m.isFirstRun + m.isFirstRun = false + m.postTask.arrayData = getDeviceCapabilities() + m.postTask.apiUrl = "/Sessions/Capabilities/Full" + m.postTask.control = "RUN" + m.postTask.observeField("responseCode", "postFinished") + end if +end sub + +' Triggered by m.postTask after completing a post. +' Empty the task data when finished. +sub postFinished() + m.postTask.unobserveField("responseCode") + m.postTask.callFunc("empty") +end sub diff --git a/components/home/Home.xml b/components/home/Home.xml index 802e0b94a..9ce89fcf5 100644 --- a/components/home/Home.xml +++ b/components/home/Home.xml @@ -1,5 +1,5 @@ - + @@ -8,7 +8,6 @@ - diff --git a/components/settings/settings.brs b/components/settings/settings.brs index 3d63dde93..c46d30c25 100644 --- a/components/settings/settings.brs +++ b/components/settings/settings.brs @@ -1,6 +1,8 @@ import "pkg:/source/utils/config.brs" import "pkg:/source/utils/misc.brs" import "pkg:/source/roku_modules/log/LogMixin.brs" +' post device profile +import "pkg:/source/utils/deviceCapabilities.brs" sub init() m.log = log.Logger("Settings") @@ -27,6 +29,8 @@ sub init() m.boolSetting.observeField("checkedItem", "boolSettingChanged") m.radioSetting.observeField("checkedItem", "radioSettingChanged") + m.postTask = createObject("roSGNode", "PostTask") + ' Load Configuration Tree m.configTree = GetConfigTree() LoadMenu({ children: m.configTree }) @@ -201,6 +205,23 @@ sub radioSettingChanged() set_user_setting(selectedSetting.settingName, m.radioSetting.content.getChild(m.radioSetting.checkedItem).id) end sub +' JFScreen hook that gets ran as needed. +' Assumes settings were changed and they affect the device profile. +' Posts a new device profile to the server using the task thread +sub OnScreenHidden() + m.postTask.arrayData = getDeviceCapabilities() + m.postTask.apiUrl = "/Sessions/Capabilities/Full" + m.postTask.control = "RUN" + m.postTask.observeField("responseCode", "postFinished") +end sub + +' Triggered by m.postTask after completing a post. +' Empty the task data when finished. +sub postFinished() + m.postTask.unobserveField("responseCode") + m.postTask.callFunc("empty") +end sub + ' Returns true if any of the data entry forms are in focus function isFormInFocus() as boolean if isValid(m.settingDetail.focusedChild) or m.radioSetting.hasFocus() or m.boolSetting.hasFocus() or m.integerSetting.hasFocus() diff --git a/components/settings/settings.xml b/components/settings/settings.xml index b34a4139c..10f3a24da 100644 --- a/components/settings/settings.xml +++ b/components/settings/settings.xml @@ -1,5 +1,5 @@ - +