mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Bookmarks/Highlights: left button, show note in book (#8600)
Bookmark list: added title bar left button for multiple actions Highlighted text: show note on tap
This commit is contained in:
@@ -6,6 +6,7 @@ local Geom = require("ui/geometry")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local TextViewer = require("ui/widget/textviewer")
|
||||
local TimeVal = require("ui/timeval")
|
||||
local Translator = require("ui/translator")
|
||||
local UIManager = require("ui/uimanager")
|
||||
@@ -502,7 +503,7 @@ function ReaderHighlight:onTapPageSavedHighlight(ges)
|
||||
for index, box in pairs(boxes) do
|
||||
if inside_box(pos, box) then
|
||||
logger.dbg("Tap on highlight")
|
||||
return self:onShowHighlightDialog(page, i)
|
||||
return self:onShowHighlightNoteOrDialog(page, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -553,7 +554,7 @@ function ReaderHighlight:onTapXPointerSavedHighlight(ges)
|
||||
for index, box in pairs(boxes) do
|
||||
if inside_box(pos, box) then
|
||||
logger.dbg("Tap on highlight")
|
||||
return self:onShowHighlightDialog(page, i)
|
||||
return self:onShowHighlightNoteOrDialog(page, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -651,12 +652,46 @@ function ReaderHighlight:updateHighlight(page, index, side, direction, move_by_c
|
||||
UIManager:setDirty(self.dialog, "ui")
|
||||
end
|
||||
|
||||
function ReaderHighlight:onShowHighlightDialog(page, index)
|
||||
function ReaderHighlight:onShowHighlightNoteOrDialog(page, index)
|
||||
local item = self.view.highlight.saved[page][index]
|
||||
local is_auto_text = self.ui.bookmark:isHighlightAutoText({
|
||||
local bookmark_note = self.ui.bookmark:getBookmarkNote({
|
||||
page = self.ui.document.info.has_pages and item.pos0.page or item.pos0,
|
||||
datetime = item.datetime,
|
||||
})
|
||||
if bookmark_note then
|
||||
local textviewer
|
||||
textviewer = TextViewer:new{
|
||||
title = _("Note"),
|
||||
text = bookmark_note,
|
||||
width = math.floor(math.min(Screen:getWidth(), Screen:getHeight()) * 0.8),
|
||||
height = math.floor(math.max(Screen:getWidth(), Screen:getHeight()) * 0.4),
|
||||
justified = G_reader_settings:nilOrTrue("dict_justify"),
|
||||
buttons_table = {
|
||||
{
|
||||
{
|
||||
text = _("Close"),
|
||||
callback = function()
|
||||
UIManager:close(textviewer)
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Edit highlight"),
|
||||
callback = function()
|
||||
UIManager:close(textviewer)
|
||||
self:onShowHighlightDialog(page, index, false)
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
UIManager:show(textviewer)
|
||||
else
|
||||
self:onShowHighlightDialog(page, index, true)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderHighlight:onShowHighlightDialog(page, index, is_auto_text)
|
||||
local buttons = {
|
||||
{
|
||||
{
|
||||
@@ -1589,7 +1624,7 @@ end
|
||||
|
||||
function ReaderHighlight:addNote()
|
||||
local page, index = self:saveHighlight()
|
||||
self:editHighlight(page, index)
|
||||
self:editHighlight(page, index, true)
|
||||
UIManager:close(self.edit_highlight_dialog)
|
||||
self.edit_highlight_dialog = nil
|
||||
self.ui:handleEvent(Event:new("AddNote"))
|
||||
@@ -1647,13 +1682,13 @@ function ReaderHighlight:deleteHighlight(page, i, bookmark_item)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderHighlight:editHighlight(page, i)
|
||||
function ReaderHighlight:editHighlight(page, i, is_new_note)
|
||||
local item = self.view.highlight.saved[page][i]
|
||||
self.ui.bookmark:renameBookmark({
|
||||
page = self.ui.document.info.has_pages and page or item.pos0,
|
||||
datetime = item.datetime,
|
||||
pboxes = item.pboxes
|
||||
}, true)
|
||||
}, true, is_new_note)
|
||||
end
|
||||
|
||||
function ReaderHighlight:editHighlightStyle(page, i)
|
||||
|
||||
Reference in New Issue
Block a user