2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

use last_xpointer to keep reading progress for crereader

This commit is contained in:
Qingping Hou 2013-01-11 12:15:46 -05:00
parent 0377155509
commit d8542fa9f7
3 changed files with 19 additions and 10 deletions

View File

@ -160,12 +160,14 @@ end
function CREReader:getLastPageOrPos()
local last_percent = self.settings:readSetting("last_percent")
local last_xp = self.settings:readSetting("last_xpointer")
if last_xp then
return last_xp
end
-- read last_percent for backward compatibility
if last_percent then
if self.view_mode == "scroll" then
return math.floor((last_percent * self.doc:getFullHeight()) / 10000)
else
return math.floor((last_percent * self.doc:getPages()) / 10000)
end
return math.floor((last_percent * self.doc:getPages()) / 10000)
else
return (self.view_mode == "scroll" and 0) or 1
end
@ -180,7 +182,9 @@ function CREReader:saveSpecialSettings()
end
function CREReader:saveLastPageOrPos()
self.settings:saveSetting("last_percent", self.percent)
-- last_percent is deprecated
self.settings:saveSetting("last_percent", nil)
self.settings:saveSetting("last_xpointer", self.doc:getXPointer())
end
----------------------------------------------------

View File

@ -38,7 +38,11 @@ function openFile(filename)
if ok then
reader:loadSettings(filename)
page_num = reader:getLastPageOrPos()
reader:goto(tonumber(page_num), true)
if type(page_num) == "string" then
reader:goto(page_num, true, "xpointer")
else
reader:goto(page_num, true)
end
G_reader_settings:saveSetting("lastfile", filename)
return reader:inputLoop()
else

View File

@ -2517,9 +2517,6 @@ function UniReader:inputLoop()
self.show_overlap = 0
Screen:setRotationMode(0)
self:setDefaults()
if self.doc ~= nil then
self.doc:close()
end
if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
self.globalzoom_mode = self.ZOOM_FIT_TO_CONTENT_WIDTH
elseif self.pan_by_page then
@ -2547,6 +2544,10 @@ function UniReader:inputLoop()
end
self.bbox.enabled = false
if self.doc ~= nil then
self.doc:close()
end
return keep_running
end