mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
use xpointer instead of read percent to mark read progress
This commit is contained in:
@@ -94,10 +94,21 @@ function ReaderRolling:onReadSettings(config)
|
||||
if not soe then
|
||||
self.show_overlap_enable = soe
|
||||
end
|
||||
self:gotoPercent(config:readSetting("last_percent") or 0)
|
||||
-- we have to do a real pos change in self.ui.document._document to
|
||||
-- update status information in CREngine.
|
||||
self.ui.document:gotoPos(self.current_pos)
|
||||
-- we read last_percent just for backward compatibility
|
||||
local last_per = config:readSetting("last_percent")
|
||||
if last_per then
|
||||
self:gotoPercent(last_per)
|
||||
-- we have to do a real pos change in self.ui.document._document to
|
||||
-- update status information in CREngine.
|
||||
self.ui.document:gotoPos(self.current_pos)
|
||||
end
|
||||
local last_xp = config:readSetting("last_xpointer")
|
||||
if last_xp then
|
||||
self:gotoXPointer(last_xp)
|
||||
-- we have to do a real jump in self.ui.document._document to
|
||||
-- update status information in CREngine.
|
||||
self.ui.document:gotoXPointer(last_xp)
|
||||
end
|
||||
if self.view_mode == "page" then
|
||||
self.ui:handleEvent(Event:new("PageUpdate", self.ui.document:getCurrentPage()))
|
||||
end
|
||||
@@ -106,7 +117,9 @@ end
|
||||
function ReaderRolling:onCloseDocument()
|
||||
local cur_xp = self.ui.document:getXPointer()
|
||||
local cur_pos = self.ui.document:getPosFromXPointer(cur_xp)
|
||||
self.ui.doc_settings:saveSetting("last_percent", 10000 * cur_pos / self.doc_height)
|
||||
-- remove last_percent config since its deprecated
|
||||
self.ui.doc_settings:saveSetting("last_percent", nil)
|
||||
self.ui.doc_settings:saveSetting("last_xpointer", self.ui.document:getXPointer())
|
||||
self.ui.doc_settings:saveSetting("percent_finished", cur_pos / self.doc_height)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user