=== applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua ================================================================== --- applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua (revision 39884) +++ applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua (local) @@ -26,6 +26,7 @@ local Applet = require("jive.Applet") local Checkbox = require("jive.ui.Checkbox") local Window = require("jive.ui.Window") +local ContextMenuWindow = require("jive.ui.ContextMenuWindow") local Textarea = require('jive.ui.Textarea') local Framework = require('jive.ui.Framework') @@ -53,23 +54,58 @@ return indent end +-- method to give menu of hidden items that can be restored individually back to home menu +-- this feature is currently disabled in the Meta file. +function restoreHiddenItemMenu(self, menuItem) + local settings = self:getSettings() + + local window = Window('home_menu', self:string("RESTORE_HIDDEN_ITEMS")) + local menu = SimpleMenu("menu") + local menuTable = jiveMain:getMenuTable() + local atLeastOneItem = false + for id, item in pairs(menuTable) do + if settings[id] == 'hidden' then + atLeastOneItem = true + menu:addItem({ + text = item.text, + iconStyle = item.iconStyle, + callback = function() + self:getSettings()[item.id] = 'home' + jiveMain:addItemToNode(item, 'home') + self:storeSettings() + appletManager:callService("goHome") + return EVENT_CONSUME + end, + }) + end + end + + local helpText = Textarea( 'help_text', self:string('RESTORE_HIDDEN_ITEMS_HELP') ) + + if not atLeastOneItem then + window = Window('text_list', self:string("RESTORE_HIDDEN_ITEMS")) + helpText = Textarea('help_text', self:string('NO_HIDDEN_ITEMS') ) + menu:addItem({ + text = self:string('CUSTOMIZE_CANCEL'), + callback = function() + window:hide(Window.transitionPushRight) + return EVENT_CONSUME + end + }) + end + + menu:setHeaderWidget(helpText) + window:addWidget(menu) + window:show() +end + function menu(self, menuItem) log:info("menu") - self.currentSettings = self:getSettings() - -- get the menu table from jiveMain - self.menuTable = jiveMain:getMenuTable() - -- get items that have been customized - --local customTable = jiveMain:getCustomTable() - - -- get the nodes. these become the choices + hidden - self.nodeTable = jiveMain:getNodeTable() - - local homeMenuItems = {} - + local menu = SimpleMenu("menu") -- add an entry for returning everything to defaults - table.insert(homeMenuItems, + menu:addItem( { text = self:string('CUSTOMIZE_RESTORE_DEFAULTS'), weights = { 2000 }, @@ -78,105 +114,82 @@ end } ) + local window = Window("text_list", self:string("CUSTOMIZE_HOME"), 'settingstitle') + local help_text = Textarea('help_text', self:string("CUSTOMIZE_HOME_HELP")) + menu:setHeaderWidget(help_text) + window:addWidget(menu) + window:show() +end +function homeMenuItemContextMenu(self, item) - for id, item in pairs(self.menuTable) do - if id ~= 'hidden' - and id ~= 'nowhere' - -- a small hack to make sounds/effects not appear twice - and id ~= 'opmlsounds' - then - - local title, selected + local window = ContextMenuWindow(item.text) + local menu = SimpleMenu("menu") - local complexWeight = jiveMain:getComplexWeight(id, item) - local weights = {} - item.weights = string.split('%.', complexWeight, weights) - -- if this is a home item and setting = 'hidden', then unselect - if self.currentSettings[id] and self.currentSettings[id] == 'hidden' and item.node == 'home' then - selected = false - -- elseif setting = 'home' or item.node = 'home', then select - elseif (self.currentSettings[id] and self.currentSettings[id] == 'home') or item.node == 'home' then - selected = true - -- anything else is unselect + if item.noCustom then + if item.node == 'home' then + menu:addItem({ + text = "This item cannot be hidden", + style = 'item_no_action', + }) + end + else + local settings = self:getSettings() + if item.node == 'home' or settings[item.id] == 'home' then + menu:addItem({ + text = self:string('REMOVE_FROM_HOME'), + callback = function() + if item.node == 'home' then + self:getSettings()[item.id] = 'hidden' + jiveMain:setNode(item, 'hidden') + else + self:getSettings()[item.id] = nil + jiveMain:removeItemFromNode(item, 'home') + end + self:storeSettings() + window:hide() + end + }) else - selected = false + menu:addItem({ + text = self:string('ADD_TO_HOME'), + callback = function() + self:getSettings()[item.id] = 'home' + jiveMain:addItemToNode(item, 'home') + self:storeSettings() + window:hide() + end + }) end - local indentSize = 0 - for i,v in ipairs(item.weights) do - if i > 1 then - indentSize = indentSize + 2 + menu:addItem({ + text = self:string("CUSTOMIZE_CANCEL"), + sound = "WINDOWHIDE", + callback = function() + window:hide() end - end - local indent = _indent(indentSize) - - if item.node == 'home' then - title = item.text - elseif item.homeMenuToken then - title = indent .. tostring(self:string(item.homeMenuToken)) - elseif item.homeMenuText then - title = indent .. tostring(item.homeMenuText) - else - title = indent .. tostring(item.text) - end - - if not item.weights[1] then - item.weights = { 2 } - end - local menuItem - if item.noCustom then - menuItem = { - text = title, - weights = item.weights, - indent = indentSize, - style = 'item_no_arrow' - } - else - menuItem = { - text = title, - weights = item.weights, - indent = indentSize, - style = 'item_choice', - check = Checkbox( - "checkbox", - function(object, isSelected) - if isSelected then - if item.node == 'home' then - self:getSettings()[item.id] = nil - jiveMain:setNode(item, 'home') - else - self:getSettings()[item.id] = 'home' - jiveMain:addItemToNode(item, 'home') - end - else - if item.node == 'home' then - self:getSettings()[item.id] = 'hidden' - jiveMain:setNode(item, 'hidden') - else - self:getSettings()[item.id] = nil - jiveMain:removeItemFromNode(item, 'home') - end - end - self:storeSettings() - end, - selected - ), - } - end - if not item.synthetic then - table.insert(homeMenuItems, menuItem) - end - end + }) end - local menu = SimpleMenu("menu", homeMenuItems ) - menu:setComparator(menu.itemComparatorComplexWeightAlpha) + --[[ these are a tough, possibly impossible problem with complex weighting, esp. up one and down one + menu:addItem({ + text = "Move to top", + }) + menu:addItem({ + text = "Move to bottom", + }) + menu:addItem({ + text = "Move up one", + }) + menu:addItem({ + text = "Move down one", + }) + --]] - local window = Window("text_list", self:string("CUSTOMIZE_HOME"), 'settingstitle') window:addWidget(menu) - window:show() + window:show(Window.transitionFadeIn) + return end function restoreDefaultsMenu(self, id) === applets/CustomizeHomeMenu/CustomizeHomeMenuMeta.lua ================================================================== --- applets/CustomizeHomeMenu/CustomizeHomeMenuMeta.lua (revision 39884) +++ applets/CustomizeHomeMenu/CustomizeHomeMenuMeta.lua (local) @@ -20,7 +20,8 @@ end function configureApplet(self) - + self:registerService("homeMenuItemContextMenu") + end @@ -32,7 +33,7 @@ end jiveMain:addItem(self:menuItem('appletCustomizeHome', 'settings', "CUSTOMIZE_HOME", function(applet, ...) applet:menu(...) end, 55, nil, "hm_appletCustomizeHome")) + --jiveMain:addItem(self:menuItem('appletCustomizeHomeRestoreHiddenItems', 'advancedSettings', "RESTORE_HIDDEN_ITEMS", function(applet, ...) applet:restoreHiddenItemMenu(...) end, _, nil, _)) - end === applets/CustomizeHomeMenu/strings.txt ================================================================== --- applets/CustomizeHomeMenu/strings.txt (revision 39884) +++ applets/CustomizeHomeMenu/strings.txt (local) @@ -92,3 +92,39 @@ RU Нажмите кнопку "Продолжить", чтобы удалить все организационные настройки пользовательского меню. SV Välj Fortsätt om du vill ta bort alla anpassade inställningar för menyordning +RESTORE_HIDDEN_ITEMS + EN Restore Home Menu Items + +REMOVE_FROM_HOME + EN Hide from Home Menu + +ADD_TO_HOME + EN Add to Home Menu + +RESTORE_HIDDEN_ITEMS_HELP + EN Select an item to restore to the Home Menu. The following items have been hidden from view: + +CUSTOMIZE_HOME_HELP + EN By pressing the + button on a selected Settings menu item and choosing "Add to Home Menu", the item can be added to the Home Menu. Items already in the Home Menu can be hidden from view via the same method. + +CUSTOMIZE_HOME_HELP_FAB4 + EN Touch-hold on a selected Settings Menu item and choose "Add to Home Menu" to add the item to the Home Menu. Items already in the Home Menu can be hidden from view via the same method. + +NONE + CS Žádný + DA Ingen + DE Keine + EN None + ES Ninguno + FI Ei mitään + FR Aucun + IT Nessuno + NL Geen + NO Ingen + PL Brak + RU Нет + SV Ingen + +NO_HIDDEN_ITEMS + EN Currently no items are hidden from view on the Home Menu. + === jive/ui/HomeMenu.lua ================================================================== --- jive/ui/HomeMenu.lua (revision 39884) +++ jive/ui/HomeMenu.lua (local) @@ -13,10 +13,13 @@ local debug = require("jive.utils.debug") local log = require("jive.utils.log").logger("squeezeplay.ui") +local appletManager = require("jive.AppletManager") + local EVENT_WINDOW_ACTIVE = jive.ui.EVENT_WINDOW_ACTIVE local EVENT_WINDOW_INACTIVE = jive.ui.EVENT_WINDOW_INACTIVE local EVENT_UNUSED = jive.ui.EVENT_UNUSED + -- our class module(..., oo.class) @@ -344,7 +347,10 @@ function addItem(self, item) assert(item.id) assert(item.node) - + item.cmCallback = function() + appletManager:callService("homeMenuItemContextMenu", item) + return EVENT_CONSUME + end if item.iconStyle then item.icon = Icon(item.iconStyle) end