mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +00:00
Allow for disabling flashing of menu, icons and buttons (#3339)
This commit is contained in:
parent
430b61ba76
commit
f90973f73a
@ -111,6 +111,7 @@ common_settings.screen = {
|
|||||||
require("ui/elements/screen_eink_opt_menu_table"),
|
require("ui/elements/screen_eink_opt_menu_table"),
|
||||||
require("ui/elements/menu_activate"),
|
require("ui/elements/menu_activate"),
|
||||||
require("ui/elements/screen_disable_double_tap_table"),
|
require("ui/elements/screen_disable_double_tap_table"),
|
||||||
|
require("ui/elements/flash_ui"),
|
||||||
require("ui/elements/flash_keyboard"),
|
require("ui/elements/flash_keyboard"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
11
frontend/ui/elements/flash_ui.lua
Normal file
11
frontend/ui/elements/flash_ui.lua
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
local _ = require("gettext")
|
||||||
|
|
||||||
|
return {
|
||||||
|
text = _("Flash buttons and menu items"),
|
||||||
|
checked_func = function()
|
||||||
|
return G_reader_settings:nilOrTrue("flash_ui")
|
||||||
|
end,
|
||||||
|
callback = function()
|
||||||
|
G_reader_settings:flipNilOrTrue("flash_ui")
|
||||||
|
end,
|
||||||
|
}
|
@ -188,19 +188,23 @@ end
|
|||||||
|
|
||||||
function Button:onTapSelectButton()
|
function Button:onTapSelectButton()
|
||||||
if self.enabled and self.callback then
|
if self.enabled and self.callback then
|
||||||
UIManager:scheduleIn(0.0, function()
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
self[1].invert = true
|
|
||||||
UIManager:setDirty(self.show_parent, function()
|
|
||||||
return "ui", self[1].dimen
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self.callback()
|
self.callback()
|
||||||
self[1].invert = false
|
else
|
||||||
UIManager:setDirty(self.show_parent, function()
|
UIManager:scheduleIn(0.0, function()
|
||||||
return "ui", self[1].dimen
|
self[1].invert = true
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self[1].dimen
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self.callback()
|
||||||
|
self[1].invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self[1].dimen
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
elseif self.tap_input then
|
elseif self.tap_input then
|
||||||
self:onInput(self.tap_input)
|
self:onInput(self.tap_input)
|
||||||
elseif type(self.tap_input_func) == "function" then
|
elseif type(self.tap_input_func) == "function" then
|
||||||
|
@ -88,19 +88,23 @@ end
|
|||||||
|
|
||||||
function CheckButton:onTapCheckButton()
|
function CheckButton:onTapCheckButton()
|
||||||
if self.enabled and self.callback then
|
if self.enabled and self.callback then
|
||||||
UIManager:scheduleIn(0.0, function()
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
self.invert = true
|
|
||||||
UIManager:setDirty(self.show_parent, function()
|
|
||||||
return "ui", self.dimen
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self.callback()
|
self.callback()
|
||||||
self.invert = false
|
else
|
||||||
UIManager:setDirty(self.show_parent, function()
|
UIManager:scheduleIn(0.0, function()
|
||||||
return "ui", self.dimen
|
self.invert = true
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self.dimen
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self.callback()
|
||||||
|
self.invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self.dimen
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
elseif self.tap_input then
|
elseif self.tap_input then
|
||||||
self:onInput(self.tap_input)
|
self:onInput(self.tap_input)
|
||||||
elseif type(self.tap_input_func) == "function" then
|
elseif type(self.tap_input_func) == "function" then
|
||||||
|
@ -92,20 +92,24 @@ function IconButton:initGesListener()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function IconButton:onTapIconButton()
|
function IconButton:onTapIconButton()
|
||||||
UIManager:scheduleIn(0.0, function()
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
self.image.invert = true
|
|
||||||
UIManager:setDirty(self.show_parent, function()
|
|
||||||
return "ui", self[1].dimen
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
-- make sure button reacts before doing callback
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self.callback()
|
self.callback()
|
||||||
self.image.invert = false
|
else
|
||||||
UIManager:setDirty(self.show_parent, function()
|
UIManager:scheduleIn(0.0, function()
|
||||||
return "ui", self[1].dimen
|
self.image.invert = true
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self[1].dimen
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
-- make sure button reacts before doing callback
|
||||||
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self.callback()
|
||||||
|
self.image.invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self[1].dimen
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -211,17 +211,21 @@ end
|
|||||||
|
|
||||||
function KeyValueItem:onTap()
|
function KeyValueItem:onTap()
|
||||||
if self.callback then
|
if self.callback then
|
||||||
self[1].invert = true
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
UIManager:setDirty(self.show_parent, function()
|
|
||||||
return "ui", self[1].dimen
|
|
||||||
end)
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self.callback()
|
self.callback()
|
||||||
self[1].invert = false
|
else
|
||||||
|
self[1].invert = true
|
||||||
UIManager:setDirty(self.show_parent, function()
|
UIManager:setDirty(self.show_parent, function()
|
||||||
return "ui", self[1].dimen
|
return "ui", self[1].dimen
|
||||||
end)
|
end)
|
||||||
end)
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self.callback()
|
||||||
|
self[1].invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self[1].dimen
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -295,35 +295,47 @@ end
|
|||||||
|
|
||||||
function MenuItem:onTapSelect(arg, ges)
|
function MenuItem:onTapSelect(arg, ges)
|
||||||
local pos = self:getGesPosition(ges)
|
local pos = self:getGesPosition(ges)
|
||||||
self[1].invert = true
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
local refreshfunc = function()
|
|
||||||
return "ui", self[1].dimen
|
|
||||||
end
|
|
||||||
UIManager:setDirty(self.show_parent, refreshfunc)
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self[1].invert = false
|
|
||||||
UIManager:setDirty(self.show_parent, refreshfunc)
|
|
||||||
logger.dbg("creating coroutine for menu select")
|
logger.dbg("creating coroutine for menu select")
|
||||||
local co = coroutine.create(function()
|
local co = coroutine.create(function()
|
||||||
self.menu:onMenuSelect(self.table, pos)
|
self.menu:onMenuSelect(self.table, pos)
|
||||||
end)
|
end)
|
||||||
coroutine.resume(co)
|
coroutine.resume(co)
|
||||||
end)
|
else
|
||||||
|
self[1].invert = true
|
||||||
|
local refreshfunc = function()
|
||||||
|
return "ui", self[1].dimen
|
||||||
|
end
|
||||||
|
UIManager:setDirty(self.show_parent, refreshfunc)
|
||||||
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self[1].invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, refreshfunc)
|
||||||
|
logger.dbg("creating coroutine for menu select")
|
||||||
|
local co = coroutine.create(function()
|
||||||
|
self.menu:onMenuSelect(self.table, pos)
|
||||||
|
end)
|
||||||
|
coroutine.resume(co)
|
||||||
|
end)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function MenuItem:onHoldSelect(arg, ges)
|
function MenuItem:onHoldSelect(arg, ges)
|
||||||
local pos = self:getGesPosition(ges)
|
local pos = self:getGesPosition(ges)
|
||||||
self[1].invert = true
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
local refreshfunc = function()
|
|
||||||
return "ui", self[1].dimen
|
|
||||||
end
|
|
||||||
UIManager:setDirty(self.show_parent, refreshfunc)
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self[1].invert = false
|
|
||||||
UIManager:setDirty(self.show_parent, refreshfunc)
|
|
||||||
self.menu:onMenuHold(self.table, pos)
|
self.menu:onMenuHold(self.table, pos)
|
||||||
end)
|
else
|
||||||
|
self[1].invert = true
|
||||||
|
local refreshfunc = function()
|
||||||
|
return "ui", self[1].dimen
|
||||||
|
end
|
||||||
|
UIManager:setDirty(self.show_parent, refreshfunc)
|
||||||
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self[1].invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, refreshfunc)
|
||||||
|
self.menu:onMenuHold(self.table, pos)
|
||||||
|
end)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,18 +107,22 @@ function TouchMenuItem:onTapSelect(arg, ges)
|
|||||||
end
|
end
|
||||||
if enabled == false then return end
|
if enabled == false then return end
|
||||||
|
|
||||||
self.item_frame.invert = true
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
UIManager:setDirty(self.show_parent, function()
|
|
||||||
return "ui", self.dimen
|
|
||||||
end)
|
|
||||||
-- yield to main UI loop to invert item
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self.menu:onMenuSelect(self.item)
|
self.menu:onMenuSelect(self.item)
|
||||||
self.item_frame.invert = false
|
else
|
||||||
|
self.item_frame.invert = true
|
||||||
UIManager:setDirty(self.show_parent, function()
|
UIManager:setDirty(self.show_parent, function()
|
||||||
return "ui", self.dimen
|
return "ui", self.dimen
|
||||||
end)
|
end)
|
||||||
end)
|
-- yield to main UI loop to invert item
|
||||||
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self.menu:onMenuSelect(self.item)
|
||||||
|
self.item_frame.invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self.dimen
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -129,21 +133,25 @@ function TouchMenuItem:onHoldSelect(arg, ges)
|
|||||||
end
|
end
|
||||||
if enabled == false then return end
|
if enabled == false then return end
|
||||||
|
|
||||||
UIManager:scheduleIn(0.0, function()
|
if G_reader_settings:isFalse("flash_ui") then
|
||||||
self.item_frame.invert = true
|
|
||||||
UIManager:setDirty(self.show_parent, function()
|
|
||||||
return "ui", self.dimen
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
UIManager:scheduleIn(0.1, function()
|
|
||||||
self.menu:onMenuHold(self.item)
|
self.menu:onMenuHold(self.item)
|
||||||
end)
|
else
|
||||||
UIManager:scheduleIn(0.5, function()
|
UIManager:scheduleIn(0.0, function()
|
||||||
self.item_frame.invert = false
|
self.item_frame.invert = true
|
||||||
UIManager:setDirty(self.show_parent, function()
|
UIManager:setDirty(self.show_parent, function()
|
||||||
return "ui", self.dimen
|
return "ui", self.dimen
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
UIManager:scheduleIn(0.1, function()
|
||||||
|
self.menu:onMenuHold(self.item)
|
||||||
|
end)
|
||||||
|
UIManager:scheduleIn(0.5, function()
|
||||||
|
self.item_frame.invert = false
|
||||||
|
UIManager:setDirty(self.show_parent, function()
|
||||||
|
return "ui", self.dimen
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user