add 'Check update' menu and OTA update functionality

This commit is contained in:
chrox
2014-08-01 12:36:32 +08:00
parent 27da93ad76
commit d9f5edf54a
8 changed files with 256 additions and 55 deletions

View File

@@ -2,8 +2,10 @@ local InputContainer = require("ui/widget/container/inputcontainer")
local CenterContainer = require("ui/widget/container/centercontainer")
local InfoMessage = require("ui/widget/infomessage")
local InputDialog = require("ui/widget/inputdialog")
local ConfirmBox = require("ui/widget/confirmbox")
local TouchMenu = require("ui/widget/touchmenu")
local GestureRange = require("ui/gesturerange")
local OTAManager = require("ui/otamanager")
local UIManager = require("ui/uimanager")
local Device = require("ui/device")
local Geom = require("ui/geometry")
@@ -136,6 +138,26 @@ function ReaderMenu:setUpdateItemTable()
table.insert(self.tab_item_table.setting, Language:getLangMenuTable())
-- info tab
table.insert(self.tab_item_table.info, {
text = _("Check update"),
callback = function()
local ota_version = OTAManager:checkUpdate()
if ota_version == 0 then
UIManager:show(InfoMessage:new{
text = _("Your koreader is updated."),
})
elseif ota_version == nil then
UIManager:show(InfoMessage:new{
text = _("OTA server is not available."),
})
elseif ota_version then
UIManager:show(ConfirmBox:new{
text = _("Do you want to update to version ")..ota_version.."?",
ok_callback = function() OTAManager:zsync() end
})
end
end
})
table.insert(self.tab_item_table.info, {
text = _("Version"),
callback = function()