Style tweaks: notification on toggling style tweak with a gesture (#10674)

reviewable/pr10683/r1
hius07 11 months ago committed by GitHub
parent d0899f24e3
commit e1ed3a71c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,6 +25,7 @@ local lfs = require("libs/libkoreader-lfs")
local logger = require("logger") local logger = require("logger")
local util = require("util") local util = require("util")
local _ = require("gettext") local _ = require("gettext")
local C_ = _.pgettext
local Screen = Device.screen local Screen = Device.screen
local T = require("ffi/util").template local T = require("ffi/util").template
@ -582,7 +583,7 @@ You can enable individual tweaks on this book with a tap, or view more details a
end, end,
callback = function() callback = function()
-- enable/disable only for this book -- enable/disable only for this book
self:onToggleStyleTweak(item.id, item) self:onToggleStyleTweak(item.id, item, true) -- no notification
end, end,
separator = item.separator, separator = item.separator,
}) })
@ -716,7 +717,8 @@ function ReaderStyleTweak:addToMainMenu(menu_items)
} }
end end
function ReaderStyleTweak:onToggleStyleTweak(tweak_id, item) function ReaderStyleTweak:onToggleStyleTweak(tweak_id, item, no_notification)
local text
local enabled, g_enabled = self:isTweakEnabled(tweak_id) local enabled, g_enabled = self:isTweakEnabled(tweak_id)
if enabled then if enabled then
if g_enabled then if g_enabled then
@ -726,6 +728,7 @@ function ReaderStyleTweak:onToggleStyleTweak(tweak_id, item)
else else
self.doc_tweaks[tweak_id] = nil self.doc_tweaks[tweak_id] = nil
end end
text = T(C_("Style tweak", "Off: %1"), self.tweaks_in_dispatcher[tweak_id])
else else
local conflicts_with local conflicts_with
if item then if item then
@ -742,8 +745,14 @@ function ReaderStyleTweak:onToggleStyleTweak(tweak_id, item)
self:resolveConflictsBeforeEnabling(tweak_id, conflicts_with) self:resolveConflictsBeforeEnabling(tweak_id, conflicts_with)
end end
self.doc_tweaks[tweak_id] = true self.doc_tweaks[tweak_id] = true
text = T(C_("Style tweak", "On: %1"), self.tweaks_in_dispatcher[tweak_id])
end end
self:updateCssText(true) -- apply it immediately self:updateCssText(true) -- apply it immediately
if not no_notification then
UIManager:show(Notification:new{
text = text,
})
end
end end
function ReaderStyleTweak:onDispatcherRegisterActions() function ReaderStyleTweak:onDispatcherRegisterActions()

Loading…
Cancel
Save