2
0
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:
poire-z 2017-10-10 23:50:45 +02:00 committed by Frans de Jonge
parent 430b61ba76
commit f90973f73a
8 changed files with 128 additions and 80 deletions

View File

@ -111,6 +111,7 @@ common_settings.screen = {
require("ui/elements/screen_eink_opt_menu_table"),
require("ui/elements/menu_activate"),
require("ui/elements/screen_disable_double_tap_table"),
require("ui/elements/flash_ui"),
require("ui/elements/flash_keyboard"),
},
}

View 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,
}

View File

@ -188,6 +188,9 @@ end
function Button:onTapSelectButton()
if self.enabled and self.callback then
if G_reader_settings:isFalse("flash_ui") then
self.callback()
else
UIManager:scheduleIn(0.0, function()
self[1].invert = true
UIManager:setDirty(self.show_parent, function()
@ -201,6 +204,7 @@ function Button:onTapSelectButton()
return "ui", self[1].dimen
end)
end)
end
elseif self.tap_input then
self:onInput(self.tap_input)
elseif type(self.tap_input_func) == "function" then

View File

@ -88,6 +88,9 @@ end
function CheckButton:onTapCheckButton()
if self.enabled and self.callback then
if G_reader_settings:isFalse("flash_ui") then
self.callback()
else
UIManager:scheduleIn(0.0, function()
self.invert = true
UIManager:setDirty(self.show_parent, function()
@ -101,6 +104,7 @@ function CheckButton:onTapCheckButton()
return "ui", self.dimen
end)
end)
end
elseif self.tap_input then
self:onInput(self.tap_input)
elseif type(self.tap_input_func) == "function" then

View File

@ -92,6 +92,9 @@ function IconButton:initGesListener()
end
function IconButton:onTapIconButton()
if G_reader_settings:isFalse("flash_ui") then
self.callback()
else
UIManager:scheduleIn(0.0, function()
self.image.invert = true
UIManager:setDirty(self.show_parent, function()
@ -106,6 +109,7 @@ function IconButton:onTapIconButton()
return "ui", self[1].dimen
end)
end)
end
return true
end

View File

@ -211,6 +211,9 @@ end
function KeyValueItem:onTap()
if self.callback then
if G_reader_settings:isFalse("flash_ui") then
self.callback()
else
self[1].invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
@ -223,6 +226,7 @@ function KeyValueItem:onTap()
end)
end)
end
end
return true
end

View File

@ -295,6 +295,13 @@ end
function MenuItem:onTapSelect(arg, ges)
local pos = self:getGesPosition(ges)
if G_reader_settings:isFalse("flash_ui") then
logger.dbg("creating coroutine for menu select")
local co = coroutine.create(function()
self.menu:onMenuSelect(self.table, pos)
end)
coroutine.resume(co)
else
self[1].invert = true
local refreshfunc = function()
return "ui", self[1].dimen
@ -309,11 +316,15 @@ function MenuItem:onTapSelect(arg, ges)
end)
coroutine.resume(co)
end)
end
return true
end
function MenuItem:onHoldSelect(arg, ges)
local pos = self:getGesPosition(ges)
if G_reader_settings:isFalse("flash_ui") then
self.menu:onMenuHold(self.table, pos)
else
self[1].invert = true
local refreshfunc = function()
return "ui", self[1].dimen
@ -324,6 +335,7 @@ function MenuItem:onHoldSelect(arg, ges)
UIManager:setDirty(self.show_parent, refreshfunc)
self.menu:onMenuHold(self.table, pos)
end)
end
return true
end

View File

@ -107,6 +107,9 @@ function TouchMenuItem:onTapSelect(arg, ges)
end
if enabled == false then return end
if G_reader_settings:isFalse("flash_ui") then
self.menu:onMenuSelect(self.item)
else
self.item_frame.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
@ -119,6 +122,7 @@ function TouchMenuItem:onTapSelect(arg, ges)
return "ui", self.dimen
end)
end)
end
return true
end
@ -129,6 +133,9 @@ function TouchMenuItem:onHoldSelect(arg, ges)
end
if enabled == false then return end
if G_reader_settings:isFalse("flash_ui") then
self.menu:onMenuHold(self.item)
else
UIManager:scheduleIn(0.0, function()
self.item_frame.invert = true
UIManager:setDirty(self.show_parent, function()
@ -144,6 +151,7 @@ function TouchMenuItem:onHoldSelect(arg, ges)
return "ui", self.dimen
end)
end)
end
return true
end