[UX] Gesture manager: add action - cycle default highlight action (#4791)

Cf. https://github.com/koreader/koreader/issues/4727
This commit is contained in:
Galunid
2019-03-14 15:33:04 +01:00
committed by Frans de Jonge
parent 930731d67c
commit f637555d93
2 changed files with 28 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event")
local InfoMessage = require("ui/widget/infomessage")
local Notification = require("ui/widget/notification")
local InputContainer = require("ui/widget/container/inputcontainer")
local TimeVal = require("ui/timeval")
local Translator = require("ui/translator")
@@ -843,6 +844,29 @@ function ReaderHighlight:onHoldRelease()
return true
end
function ReaderHighlight:onCycleHighlightAction()
local next_actions = {
highlight = "translate",
translate = "wikipedia",
wikipedia = nil
}
local current_action = G_reader_settings:readSetting("default_highlight_action")
if not current_action then
G_reader_settings:saveSetting("default_highlight_action", "highlight")
UIManager:show(Notification:new{
text = _("Default highlight action changed to 'highlight'."),
timeout = 1,
})
else
local next_action = next_actions[current_action]
G_reader_settings:saveSetting("default_highlight_action", next_action)
UIManager:show(Notification:new{
text = T(_("Default highlight action changed to '%1'."), (next_action or "default")),
timeout = 1,
})
end
end
function ReaderHighlight:highlightFromHoldPos()
if self.hold_pos then
if not self.selected_text then