From 33fe6bbf79720398834037770dd7726010d6c8b4 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Mon, 27 Nov 2023 10:31:26 -0500 Subject: [PATCH 1/7] update alpha - refactor, bugfix, and QOL updates --- components/ItemGrid/Alpha.bs | 41 +++++++------- components/ItemGrid/Alpha.xml | 14 ++--- components/ItemGrid/ItemGrid.bs | 70 +++++++++++++----------- components/ItemGrid/ItemGrid.xml | 8 +-- components/ItemGrid/MovieLibraryView.bs | 43 +++++++-------- components/ItemGrid/MovieLibraryView.xml | 6 +- components/ItemGrid/MusicLibraryView.bs | 44 +++++++-------- components/ItemGrid/MusicLibraryView.xml | 6 +- 8 files changed, 114 insertions(+), 118 deletions(-) diff --git a/components/ItemGrid/Alpha.bs b/components/ItemGrid/Alpha.bs index 26b68680..d64753e6 100644 --- a/components/ItemGrid/Alpha.bs +++ b/components/ItemGrid/Alpha.bs @@ -1,40 +1,39 @@ sub init() - m.top.visible = true - m.Alphamenu = m.top.findNode("Alphamenu") - m.Alphamenu.focusable = true - m.Alphatext = m.top.findNode("alphatext") - m.focusedChild = m.top.findNode("focusedChild") - m.Alphamenu.focusedFont.size = 25 - m.Alphamenu.font.size = 25 + m.top.setFocus(false) + + m.alphaText = m.top.findNode("alphaText") + m.alphaMenu = m.top.findNode("alphaMenu") + m.alphaMenu.setFocus(false) + m.alphaMenu.focusedFont.size = 25 + m.alphaMenu.font.size = 25 + + ' show mic icon above alpha menu if remote supports voice commands + if m.global.device.hasVoiceRemote + alphaMic = m.top.findNode("alphaMic") + alphaMic.visible = true + end if end sub function onKeyEvent(key as string, press as boolean) as boolean - if not press then return false + if not m.alphaMenu.isInFocusChain() then return false if key = "OK" - child = m.Alphatext.getChild(m.Alphamenu.itemFocused) - - if child.title = m.top.itemAlphaSelected - m.top.itemAlphaSelected = "" - m.Alphamenu.focusFootprintBitmapUri = "" - else - m.Alphamenu.focusFootprintBitmapUri = "pkg:/images/white.png" - m.top.itemAlphaSelected = child.title - end if + child = m.alphaText.getChild(m.alphaMenu.itemFocused) + m.top.letterSelected = child.title return true end if if key = "up" - if m.Alphamenu.itemFocused = 0 - m.Alphamenu.jumpToItem = m.Alphamenu.numRows - 1 + if m.alphaMenu.itemFocused = 0 + m.alphaMenu.jumpToItem = m.alphaMenu.numRows - 1 return true end if end if if key = "down" - if m.Alphamenu.itemFocused = m.Alphamenu.numRows - 1 - m.Alphamenu.jumpToItem = 0 + if m.alphaMenu.itemFocused = m.alphaMenu.numRows - 1 + m.alphaMenu.jumpToItem = 0 return true end if end if diff --git a/components/ItemGrid/Alpha.xml b/components/ItemGrid/Alpha.xml index 8525180d..89e7294e 100644 --- a/components/ItemGrid/Alpha.xml +++ b/components/ItemGrid/Alpha.xml @@ -1,21 +1,23 @@ + - + @@ -47,8 +49,6 @@ - - - + \ No newline at end of file diff --git a/components/ItemGrid/ItemGrid.bs b/components/ItemGrid/ItemGrid.bs index c23bc962..ba9c6fcd 100644 --- a/components/ItemGrid/ItemGrid.bs +++ b/components/ItemGrid/ItemGrid.bs @@ -36,7 +36,6 @@ sub init() m.itemGrid.observeField("itemFocused", "onItemFocused") m.itemGrid.observeField("itemSelected", "onItemSelected") - m.itemGrid.observeField("alphaSelected", "onItemalphaSelected") 'Voice filter setup m.voiceBox = m.top.findNode("voiceBox") @@ -67,19 +66,11 @@ sub init() m.spinner = m.top.findNode("spinner") m.spinner.visible = true - m.Alpha = m.top.findNode("AlphaMenu") - m.AlphaSelected = m.top.findNode("AlphaSelected") + m.alpha = m.top.findNode("alpha") + m.alphaSelected = m.top.findNode("alphaSelected") 'Get reset folder setting m.resetGrid = m.global.session.user.settings["itemgrid.reset"] - - m.micButton = m.top.findNode("micButton") - m.micButtonText = m.top.findNode("micButtonText") - 'Hide voice search if device does not have voice remote - if m.global.device.hasVoiceRemote = false - m.micButton.visible = false - m.micButtonText.visible = false - end if end sub ' @@ -106,13 +97,22 @@ sub loadInitialItems() if m.top.parentItem.collectionType = "livetv" ' Translate between app and server nomenclature viewSetting = m.global.session.user.settings["display.livetv.landing"] - 'Move mic to be visiable on TV Guide screen - if m.global.device.hasVoiceRemote = true - m.micButton.translation = "[1540, 92]" - m.micButtonText.visible = true - m.micButtonText.translation = "[1600,130]" - m.micButtonText.font.size = 22 - m.micButtonText.text = tr("Search") + ' Show mic icon and text on TV Guide screen + if m.global.device.hasVoiceRemote + micIcon = CreateObject("roSGNode", "Poster") + micIcon.id = "micIcon" + micIcon.uri = "pkg:/images/icons/mic_icon.png" + micIcon.translation = "[1578, 130]" + + micIconText = CreateObject("roSGNode", "Label") + micIconText.id = "micIconText" + micIconText.font = "font:SmallSystemFont" + micIconText.translation = "[1600,130]" + micIconText.font.size = 22 + micIconText.text = tr("Search") + + m.top.appendChild(micIcon) + m.top.appendChild(micIconText) end if if viewSetting = "guide" m.view = "tvGuide" @@ -166,9 +166,15 @@ sub loadInitialItems() else m.loadItemsTask.itemId = m.top.parentItem.Id end if + + ' if we already searched for this alpha text than reset filter + if m.loadItemsTask.nameStartsWith = m.top.alphaSelected + m.loadItemsTask.nameStartsWith = "" + else + m.loadItemsTask.nameStartsWith = m.alpha.letterSelected + end if updateTitle() - m.loadItemsTask.nameStartsWith = m.top.alphaSelected m.loadItemsTask.searchTerm = m.voiceBox.text m.emptyText.visible = false m.loadItemsTask.sortField = m.sortField @@ -446,7 +452,6 @@ sub SetUpOptions() m.options.options = options end sub - ' 'Handle loaded data, and add to Grid sub ItemDataLoaded(msg) @@ -483,8 +488,14 @@ sub ItemDataLoaded(msg) m.data.appendChild(item) end for - m.itemGrid.opacity = "1" - m.genreList.opacity = "0" + ' keep focus on alpha menu when loading new data + if not m.alpha.isinFocusChain() + m.itemGrid.opacity = "1" + m.genreList.opacity = "0" + + m.itemGrid.setFocus(true) + m.genreList.setFocus(false) + end if 'Update the stored counts m.loadedItems = m.itemGrid.content.getChildCount() @@ -496,8 +507,6 @@ sub ItemDataLoaded(msg) m.emptyText.visible = true end if - m.itemGrid.setFocus(true) - m.genreList.setFocus(false) m.spinner.visible = false end sub @@ -585,7 +594,7 @@ sub onItemSelected() m.top.selectedItem = m.itemGrid.content.getChild(m.itemGrid.itemSelected) end sub -sub onItemalphaSelected() +sub alphaSelectedChanged() if m.top.alphaSelected <> "" m.loadedRows = 0 m.loadedItems = 0 @@ -593,8 +602,8 @@ sub onItemalphaSelected() m.itemGrid.content = m.data m.loadItemsTask.searchTerm = "" m.VoiceBox.text = "" - m.loadItemsTask.nameStartsWith = m.alpha.itemAlphaSelected m.spinner.visible = true + loadInitialItems() end if end sub @@ -826,14 +835,13 @@ function onKeyEvent(key as string, press as boolean) as boolean else if key = "left" and topGrp.isinFocusChain() m.top.alphaActive = true topGrp.setFocus(false) - alpha = m.alpha.getChild(0).findNode("Alphamenu") + alpha = m.alpha.getChild(0).findNode("alphaMenu") alpha.setFocus(true) return true - else if key = "right" and m.Alpha.isinFocusChain() + else if key = "right" and m.alpha.isinFocusChain() m.top.alphaActive = false - m.Alpha.setFocus(false) - m.Alpha.visible = true + m.alpha.setFocus(false) topGrp.setFocus(true) return true else if key = "replay" and topGrp.isinFocusChain() @@ -872,7 +880,7 @@ sub updateTitle() m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.searchTerm + ")" end if - if m.top.alphaSelected <> "" + if m.loadItemsTask.nameStartsWith <> "" m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.nameStartsWith + ")" end if diff --git a/components/ItemGrid/ItemGrid.xml b/components/ItemGrid/ItemGrid.xml index 3c5d2c79..dc39a50a 100644 --- a/components/ItemGrid/ItemGrid.xml +++ b/components/ItemGrid/ItemGrid.xml @@ -17,9 +17,7 @@ drawFocusFeedback="false" /> - -