From e7e6a2be9c3258c452a8329db3c2d56638e99480 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 11 Jan 2013 13:46:39 +0800 Subject: [PATCH] use xpointer instead of read percent to mark read progress --- frontend/ui/reader/readerrolling.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/frontend/ui/reader/readerrolling.lua b/frontend/ui/reader/readerrolling.lua index 6904c3b40..892066332 100644 --- a/frontend/ui/reader/readerrolling.lua +++ b/frontend/ui/reader/readerrolling.lua @@ -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