mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fix dogear not shown properly in crereader
This commit is contained in:
@@ -348,6 +348,11 @@ function CreDocument:setBatteryState(state)
|
||||
self._document:setBatteryState(state)
|
||||
end
|
||||
|
||||
function CreDocument:isXPointerInCurrentPage(xp)
|
||||
DEBUG("CreDocument: check in page", xp)
|
||||
return self._document:isXPointerInCurrentPage(xp)
|
||||
end
|
||||
|
||||
function CreDocument:register(registry)
|
||||
registry:addProvider("txt", "application/txt", self)
|
||||
registry:addProvider("epub", "application/epub", self)
|
||||
|
||||
@@ -7,6 +7,7 @@ local Geom = require("ui/geometry")
|
||||
local Screen = require("ui/screen")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Event = require("ui/event")
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderBookmark = InputContainer:new{
|
||||
@@ -35,10 +36,10 @@ end
|
||||
|
||||
function ReaderBookmark:onToggleBookmark()
|
||||
local pn_or_xp = nil
|
||||
if self.ui.document.getXPointer then
|
||||
pn_or_xp = self.ui.document:getXPointer()
|
||||
else
|
||||
if self.ui.document.info.has_pages then
|
||||
pn_or_xp = self.view.state.page
|
||||
else
|
||||
pn_or_xp = self.ui.document:getXPointer()
|
||||
end
|
||||
self:toggleBookmark(pn_or_xp)
|
||||
self.view.dogear_visible = not self.view.dogear_visible
|
||||
@@ -55,14 +56,20 @@ function ReaderBookmark:setDogearVisibility(pn_or_xp)
|
||||
end
|
||||
|
||||
function ReaderBookmark:onPageUpdate(pageno)
|
||||
self:setDogearVisibility(pageno)
|
||||
if self.ui.document.info.has_pages then
|
||||
self:setDogearVisibility(pageno)
|
||||
else
|
||||
-- FIXME: this is a dirty hack to prevent crash in isXPointerInCurrentPage
|
||||
if pageno ~= 1 then
|
||||
self:setDogearVisibility("dummy")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderBookmark:onPosUpdate(pos)
|
||||
-- TODO: cannot check if this pos is bookmarked or not.
|
||||
self:setDogearVisibility("dummy")
|
||||
end
|
||||
|
||||
|
||||
function ReaderBookmark:onShowBookmark()
|
||||
-- build up item_table
|
||||
for k, v in ipairs(self.bookmarks) do
|
||||
@@ -124,7 +131,8 @@ end
|
||||
|
||||
function ReaderBookmark:isBookmarked(pn_or_xp)
|
||||
for k,v in ipairs(self.bookmarks) do
|
||||
if v.page == pn_or_xp then
|
||||
if (type(pn_or_xp) == "number" and v.page == pn_or_xp) or
|
||||
(type(pn_or_xp) == "string" and self.ui.document:isXPointerInCurrentPage(v.page)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -155,7 +163,8 @@ end
|
||||
|
||||
function ReaderBookmark:toggleBookmark(pn_or_xp)
|
||||
for k,v in ipairs(self.bookmarks) do
|
||||
if v.page == pn_or_xp then
|
||||
if (type(pn_or_xp) == "number" and v.page == pn_or_xp) or
|
||||
(type(pn_or_xp) == "string" and self.ui.document:isXPointerInCurrentPage(v.page)) then
|
||||
table.remove(self.bookmarks, k)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@ local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local RightContainer = require("ui/widget/container/rightcontainer")
|
||||
local ImageWidget = require("ui/widget/imagewidget")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Device = require("ui/device")
|
||||
local Geom = require("ui/geometry")
|
||||
local Screen = require("ui/screen")
|
||||
@@ -57,6 +58,7 @@ end
|
||||
|
||||
function ReaderDogear:onSetDogearVisibility(visible)
|
||||
self.view.dogear_visible = visible
|
||||
UIManager:setDirty(self.view.dialog, "partial")
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
Submodule koreader-base updated: ff06119483...aa1328ca5d
Reference in New Issue
Block a user