From b728c4b2244944c5163eeccc9bccd3bab55d6301 Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Fri, 15 Jul 2022 22:28:59 -0400 Subject: [PATCH] Add user setting: Hide Clock #273 --- components/JFOverhang.brs | 73 +++++++++++++++++++--------- components/JFOverhang.xml | 4 +- components/JFVideo.brs | 4 ++ components/JFVideo.xml | 2 + components/movies/MovieDetails.brs | 4 +- components/tvshows/TVListDetails.brs | 4 +- locale/en_US/translations.ts | 10 ++++ settings/settings.json | 7 +++ source/utils/misc.brs | 19 ++++++++ 9 files changed, 102 insertions(+), 25 deletions(-) diff --git a/components/JFOverhang.brs b/components/JFOverhang.brs index ab779a6a..cf41f342 100644 --- a/components/JFOverhang.brs +++ b/components/JFOverhang.brs @@ -3,8 +3,10 @@ sub init() ' hide seperators till they're needed leftSeperator = m.top.findNode("overlayLeftSeperator") leftSeperator.visible = "false" - rightSeperator = m.top.findNode("overlayRightSeperator") - rightSeperator.visible = "false" + m.rightSeperator = m.top.findNode("overlayRightSeperator") + + m.hideClock = get_user_setting("ui.design.hideclock") = "true" + ' set font sizes optionText = m.top.findNode("overlayOptionsText") optionText.font.size = 20 @@ -12,20 +14,30 @@ sub init() optionStar.font.size = 58 overlayMeridian = m.top.findNode("overlayMeridian") overlayMeridian.font.size = 20 - ' get system preference clock format (12/24hr) - di = CreateObject("roDeviceInfo") - m.clockFormat = di.GetClockFormat() - ' grab current time - currentTime = CreateObject("roDateTime") - currentTime.ToLocalTime() - m.currentHours = currentTime.GetHours() - m.currentMinutes = currentTime.GetMinutes() - ' start timer - m.currentTimeTimer = m.top.findNode("currentTimeTimer") - m.currentTimeTimer.control = "start" - m.currentTimeTimer.ObserveField("fire", "updateTime") - updateTimeDisplay() + m.overlayRightGroup = m.top.findNode("overlayRightGroup") + m.overlayTimeGroup = m.top.findNode("overlayTimeGroup") + + if not m.hideClock + ' get system preference clock format (12/24hr) + di = CreateObject("roDeviceInfo") + m.clockFormat = di.GetClockFormat() + + ' grab current time + currentTime = CreateObject("roDateTime") + currentTime.ToLocalTime() + m.currentHours = currentTime.GetHours() + m.currentMinutes = currentTime.GetMinutes() + + ' start timer + m.currentTimeTimer = m.top.findNode("currentTimeTimer") + m.currentTimeTimer.control = "start" + m.currentTimeTimer.ObserveField("fire", "updateTime") + + updateTimeDisplay() + end if + + setClockVisibility() end sub sub updateTitle() @@ -37,16 +49,33 @@ sub updateTitle() end if title = m.top.findNode("overlayTitle") title.text = m.top.title - resetTime() + + if not m.hideClock + resetTime() + end if +end sub + +sub setClockVisibility() + if m.hideClock + m.overlayRightGroup.removeChild(m.overlayTimeGroup) + end if +end sub + +sub setRightSeperatorVisibility() + if m.hideClock + m.top.removeChild(m.rightSeperator) + return + end if + + if m.top.currentUser <> "" + m.rightSeperator.visible = "true" + else + m.rightSeperator.visible = "false" + end if end sub sub updateUser() - rightSeperator = m.top.findNode("overlayRightSeperator") - if m.top.currentUser <> "" - rightSeperator.visible = "true" - else - rightSeperator.visible = "false" - end if + setRightSeperatorVisibility() user = m.top.findNode("overlayCurrentUser") user.text = m.top.currentUser end sub diff --git a/components/JFOverhang.xml b/components/JFOverhang.xml index 6baf2d2a..954d4c82 100644 --- a/components/JFOverhang.xml +++ b/components/JFOverhang.xml @@ -19,7 +19,8 @@ id="overlayRightSeperator" color="#666666" width="2" - height="64"/> + height="64" + visible="false"/>