Merge pull request #1140 from cewert/expand-global-var

This commit is contained in:
Charles Ewert 2023-05-02 14:39:17 -04:00 committed by GitHub
commit 92e1535f88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 105 additions and 106 deletions

View File

@ -67,13 +67,10 @@ sub init()
'Get reset folder setting
m.resetGrid = get_user_setting("itemgrid.reset") = "true"
'Check if device has voice remote
devinfo = CreateObject("roDeviceInfo")
m.deviFeature = devinfo.HasFeature("voice_remote")
m.micButton = m.top.findNode("micButton")
m.micButtonText = m.top.findNode("micButtonText")
'Hide voice search if device does not have voice remote
if m.deviFeature = false
if m.global.device.hasVoiceRemote = false
m.micButton.visible = false
m.micButtonText.visible = false
end if
@ -104,7 +101,7 @@ sub loadInitialItems()
' Translate between app and server nomenclature
viewSetting = get_user_setting("display.livetv.landing")
'Move mic to be visiable on TV Guide screen
if m.deviFeature = true
if m.global.device.hasVoiceRemote = true
m.micButton.translation = "[1540, 92]"
m.micButtonText.visible = true
m.micButtonText.translation = "[1600,130]"

View File

@ -82,11 +82,8 @@ sub init()
'Get reset folder setting
m.resetGrid = get_user_setting("itemgrid.reset") = "true"
'Check if device has voice remote
devinfo = CreateObject("roDeviceInfo")
'Hide voice search if device does not have voice remote
if devinfo.HasFeature("voice_remote") = false
if m.global.device.hasVoiceRemote = false
m.micButton.visible = false
m.micButtonText.visible = false
end if

View File

@ -76,11 +76,8 @@ sub init()
'Get reset folder setting
m.resetGrid = get_user_setting("itemgrid.reset") = "true"
'Check if device has voice remote
devinfo = CreateObject("roDeviceInfo")
'Hide voice search if device does not have voice remote
if devinfo.HasFeature("voice_remote") = false
if m.global.device.hasVoiceRemote = false
m.micButton.visible = false
m.micButtonText.visible = false
end if

View File

@ -18,9 +18,6 @@ sub init()
' show clock based on user setting
m.hideClock = get_user_setting("ui.design.hideclock") = "true"
if not m.hideClock
' get system preference clock format (12/24hr)
di = CreateObject("roDeviceInfo")
m.clockFormat = di.GetClockFormat()
' save node references
m.overlayHours = m.top.findNode("overlayHours")
m.overlayMinutes = m.top.findNode("overlayMinutes")
@ -105,7 +102,7 @@ sub resetTime()
end sub
sub updateTimeDisplay()
if m.clockFormat = "24h"
if m.global.device.clockFormat = "24h"
m.overlayMeridian.text = ""
if m.currentHours < 10
m.overlayHours.text = "0" + StrI(m.currentHours).trim()

View File

@ -8,8 +8,6 @@ sub init()
m.backdrop = m.top.findNode("backdrop")
m.deviceInfo = CreateObject("roDeviceInfo")
' Randmomise the background colors
posterBackgrounds = m.global.constants.poster_bg_pallet
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
@ -101,7 +99,7 @@ sub focusChanged()
m.staticTitle.visible = false
m.title.visible = true
' text to speech for accessibility
if m.deviceInfo.IsAudioGuideEnabled() = true
if m.global.device.isAudioGuideEnabled = true
txt2Speech = CreateObject("roTextToSpeech")
txt2Speech.Flush()
txt2Speech.Say(m.title.text)

View File

@ -17,12 +17,12 @@ sub init()
m.textColorDict = { "Default": &HFFFFFFFF, "White": &HFFFFFFFF, "Black": &H000000FF, "Red": &HFF0000FF, "Green": &H008000FF, "Blue": &H0000FFFF, "Yellow": &HFFFF00FF, "Magenta": &HFF00FFFF, "Cyan": &H00FFFFFF }
m.bgColorDict = { "Default": &H000000FF, "White": &HFFFFFFFF, "Black": &H000000FF, "Red": &HFF0000FF, "Green": &H008000FF, "Blue": &H0000FFFF, "Yellow": &HFFFF00FF, "Magenta": &HFF00FFFF, "Cyan": &H00FFFFFF }
m.settings = CreateObject("roDeviceInfo")
m.fontSize = m.fontSizeDict[m.settings.GetCaptionsOption("Text/Size")]
m.textColor = m.textColorDict[m.settings.GetCaptionsOption("Text/Color")]
m.textOpac = m.percentageDict[m.settings.GetCaptionsOption("Text/Opacity")]
m.bgColor = m.bgColorDict[m.settings.GetCaptionsOption("Background/Color")]
m.bgOpac = m.percentageDict[m.settings.GetCaptionsOption("Background/Opacity")]
deviceInfo = CreateObject("roDeviceInfo")
m.fontSize = m.fontSizeDict[deviceInfo.GetCaptionsOption("Text/Size")]
m.textColor = m.textColorDict[deviceInfo.GetCaptionsOption("Text/Color")]
m.textOpac = m.percentageDict[deviceInfo.GetCaptionsOption("Text/Opacity")]
m.bgColor = m.bgColorDict[deviceInfo.GetCaptionsOption("Background/Color")]
m.bgOpac = m.percentageDict[deviceInfo.GetCaptionsOption("Background/Opacity")]
setFont()
end sub

View File

@ -2,8 +2,6 @@ sub init()
m.posterImg = m.top.findNode("posterImg")
m.name = m.top.findNode("pLabel")
m.role = m.top.findNode("subTitle")
m.deviceInfo = CreateObject("roDeviceInfo")
end sub
sub showContent()
@ -30,7 +28,7 @@ sub focusChanged()
m.role.repeatCount = 0
end if
if m.deviceInfo.IsAudioGuideEnabled() = true
if m.global.device.isAudioGuideEnabled = true
txt2Speech = CreateObject("roTextToSpeech")
txt2Speech.Flush()
txt2Speech.Say(m.name.text)

View File

@ -4,7 +4,6 @@ sub init()
m.options = m.top.findNode("tvListOptions")
m.overview = m.top.findNode("overview")
m.poster = m.top.findNode("poster")
m.deviceInfo = CreateObject("roDeviceInfo")
m.rating = m.top.findnode("rating")
m.infoBar = m.top.findnode("infoBar")
@ -146,7 +145,7 @@ end function
sub focusChanged()
if m.top.itemHasFocus = true
' text to speech for accessibility
if m.deviceInfo.IsAudioGuideEnabled() = true
if m.global.device.isAudioGuideEnabled = true
txt2Speech = CreateObject("roTextToSpeech")
txt2Speech.Flush()
txt2Speech.Say(m.title.text)

View File

@ -9,11 +9,13 @@ sub Main (args as dynamic) as void
m.port = CreateObject("roMessagePort")
m.screen.setMessagePort(m.port)
m.scene = m.screen.CreateScene("JFScene")
m.screen.show() ' vscode_rale_tracker_entry
' Set any initial Global Variables
m.global = m.screen.getGlobalNode()
SaveAppToGlobal()
SaveDeviceToGlobal()
m.scene = m.screen.CreateScene("JFScene")
m.screen.show() ' vscode_rale_tracker_entry
playstateTask = CreateObject("roSGNode", "PlaystateTask")
playstateTask.id = "playstateTask"
@ -57,11 +59,10 @@ sub Main (args as dynamic) as void
end if
' Only show the Whats New popup the first time a user runs a new client version.
appInfo = CreateObject("roAppInfo")
if appInfo.GetVersion() <> get_setting("LastRunVersion")
if m.global.app.version <> get_setting("LastRunVersion")
' Ensure the user hasn't disabled Whats New popups
if get_user_setting("load.allowwhatsnew") = "true"
set_setting("LastRunVersion", appInfo.GetVersion())
set_setting("LastRunVersion", m.global.app.version)
dialog = createObject("roSGNode", "WhatsNewDialog")
m.scene.dialog = dialog
m.scene.dialog.observeField("buttonSelected", m.port)
@ -72,10 +73,11 @@ sub Main (args as dynamic) as void
input = CreateObject("roInput")
input.SetMessagePort(m.port)
m.device = CreateObject("roDeviceInfo")
m.device.setMessagePort(m.port)
m.device.EnableScreensaverExitedEvent(true)
m.device.EnableAppFocusEvent(false)
device = CreateObject("roDeviceInfo")
device.setMessagePort(m.port)
device.EnableScreensaverExitedEvent(true)
device.EnableAppFocusEvent(false)
device.EnableAudioGuideChangedEvent(true)
' Check if we were sent content to play with the startup command (Deep Link)
if isValidAndNotEmpty(args.mediaType) and isValidAndNotEmpty(args.contentId)
@ -573,6 +575,12 @@ sub Main (args as dynamic) as void
end if
' todo: add other screens to be refreshed - movie detail, tv series, episode list etc.
end if
else if event.audioGuideEnabled <> invalid
tmpGlobalDevice = m.global.device
tmpGlobalDevice.AddReplace("isaudioguideenabled", event.audioGuideEnabled)
' update global device array
m.global.setFields({ device: tmpGlobalDevice })
else
print "Unhandled roDeviceInfoEvent:"
print msg.GetInfo()

View File

@ -135,35 +135,20 @@ function get_url()
end function
function authorize_request(request)
devinfo = CreateObject("roDeviceInfo")
appinfo = CreateObject("roAppInfo")
auth = "MediaBrowser"
client = "Jellyfin Roku"
auth = auth + " Client=" + Chr(34) + client + Chr(34)
device = devinfo.getModelDisplayName()
friendly = devinfo.getFriendlyName()
' remove special characters
regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "")
friendly = regex.ReplaceAll(friendly, "")
auth = auth + ", Device=" + Chr(34) + device + " (" + friendly + ")" + Chr(34)
device_id = devinfo.getChannelClientID()
if get_setting("active_user") = invalid or get_setting("active_user") = ""
device_id = devinfo.GetRandomUUID()
end if
auth = auth + ", DeviceId=" + Chr(34) + device_id + Chr(34)
version = appinfo.GetVersion()
auth = auth + ", Version=" + Chr(34) + version + Chr(34)
user = get_setting("active_user")
auth = "MediaBrowser" + " Client=" + Chr(34) + "Jellyfin Roku" + Chr(34)
auth = auth + ", Device=" + Chr(34) + m.global.device.name + " (" + m.global.device.friendlyName + ")" + Chr(34)
if user <> invalid and user <> ""
auth = auth + ", DeviceId=" + Chr(34) + m.global.device.id + Chr(34)
auth = auth + ", UserId=" + Chr(34) + user + Chr(34)
else
auth = auth + ", DeviceId=" + Chr(34) + m.global.device.uuid + Chr(34)
end if
auth = auth + ", Version=" + Chr(34) + m.global.app.version + Chr(34)
token = get_user_setting("token")
if token <> invalid and token <> ""
auth = auth + ", Token=" + Chr(34) + token + Chr(34)

View File

@ -1,26 +0,0 @@
' Set global constants
sub setConstants()
globals = m.screen.getGlobalNode()
' Set Global Constants
globals.addFields({
constants: {
poster_bg_pallet: ["#00455c", "#44bae1", "#00a4db", "#1c4c5c", "#007ea8"],
colors: {
button: "#006fab",
blue: "#00a4dcFF"
},
icons: {
ascending_black: "pkg:/images/icons/up_black.png",
ascending_white: "pkg:/images/icons/up_white.png",
descending_black: "pkg:/images/icons/down_black.png",
descending_white: "pkg:/images/icons/down_white.png",
check_black: "pkg:/images/icons/check_black.png",
check_white: "pkg:/images/icons/check_white.png"
}
}
})
end sub

View File

@ -177,7 +177,8 @@ sub turnoffSubtitles()
current = video.SelectedSubtitle
video.SelectedSubtitle = -1
video.globalCaptionMode = "Off"
m.device.EnableAppFocusEvent(false)
device = CreateObject("roDeviceInfo")
device.EnableAppFocusEvent(false)
' Check if Enoded subtitles are being displayed, and turn off
if current > -1 and video.Subtitles[current].IsEncoded
video.control = "stop"

View File

@ -1,15 +1,64 @@
sub initGlobal()
if m.globals = invalid
m.globals = CreateObject("roAssociativeArray")
end if
' Set global constants
sub setConstants()
globals = m.screen.getGlobalNode()
' Set Global Constants
globals.addFields({
constants: {
poster_bg_pallet: ["#00455c", "#44bae1", "#00a4db", "#1c4c5c", "#007ea8"],
colors: {
button: "#006fab",
blue: "#00a4dcFF"
},
icons: {
ascending_black: "pkg:/images/icons/up_black.png",
ascending_white: "pkg:/images/icons/up_white.png",
descending_black: "pkg:/images/icons/down_black.png",
descending_white: "pkg:/images/icons/down_white.png",
check_black: "pkg:/images/icons/check_black.png",
check_white: "pkg:/images/icons/check_white.png"
}
}
})
end sub
function getGlobal(key = "" as string) as dynamic
initGlobal()
return m.globals[key]
end function
sub setGlobal(key = "" as string, value = invalid as dynamic)
initGlobal()
m.globals[key] = value
' Save information from roAppInfo to m.global.app
sub SaveAppToGlobal()
appInfo = CreateObject("roAppInfo")
m.global.addFields({
app: {
id: appInfo.GetID(),
isDev: appInfo.IsDev(),
version: appInfo.GetVersion()
}
})
end sub
' Save information from roDeviceInfo to m.global.device
sub SaveDeviceToGlobal()
deviceInfo = CreateObject("roDeviceInfo")
' remove special characters
regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "")
filteredFriendly = regex.ReplaceAll(deviceInfo.getFriendlyName(), "")
m.global.addFields({
device: {
id: deviceInfo.getChannelClientID(),
uuid: deviceInfo.GetRandomUUID(),
name: deviceInfo.getModelDisplayName(),
friendlyName: filteredFriendly,
model: deviceInfo.GetModel(),
modelType: deviceInfo.GetModelType(),
osVersion: deviceInfo.GetOSVersion(),
locale: deviceInfo.GetCurrentLocale(),
clockFormat: deviceInfo.GetClockFormat(),
isAudioGuideEnabled: deviceInfo.IsAudioGuideEnabled(),
hasVoiceRemote: deviceInfo.HasFeature("voice_remote"),
displayType: deviceInfo.GetDisplayType(),
displayMode: deviceInfo.GetDisplayMode()
}
})
end sub

View File

@ -57,8 +57,7 @@ end function
function formatTime(time) as string
hours = time.getHours()
minHourDigits = 1
di = CreateObject("roDeviceInfo")
if di.GetClockFormat() = "12h"
if m.global.device.clockFormat = "12h"
meridian = "AM"
if hours = 0
hours = 12