Ability to setup clock (#3085)

* Ability to setup clock
This commit is contained in:
Robert
2017-08-15 19:54:02 +02:00
committed by Frans de Jonge
parent 76a2dbc7c5
commit 7f58a13626
9 changed files with 437 additions and 1 deletions

View File

@@ -1,9 +1,12 @@
local Device = require("device")
local InfoMessage = require("ui/widget/infomessage")
local Language = require("ui/language")
local NetworkMgr = require("ui/network/manager")
local UIManager = require("ui/uimanager")
local Screen = require("device").screen
local TimeWidget = require("ui/widget/timewidget")
local _ = require("gettext")
local Screen = Device.screen
local T = require("ffi/util").template
local common_settings = {}
@@ -17,6 +20,37 @@ if Device:hasFrontlight() then
}
end
if Device:setTime() then
common_settings.time = {
text = _("Set time"),
callback = function()
local now_t = os.date("*t")
local curr_hour = now_t.hour
local curr_min = now_t.min
local time_widget = TimeWidget:new{
hour = curr_hour,
min = curr_min,
ok_text = _("Set time"),
title_text = _("Set time"),
callback = function(time)
if Device:setTime(time.hour, time.min) then
now_t = os.date("*t")
UIManager:show(InfoMessage:new{
text = T(_("Current time: %1:%2"), string.format("%02d", now_t.hour),
string.format("%02d", now_t.min))
})
else
UIManager:show(InfoMessage:new{
text = _("Time couldn't be set"),
})
end
end
}
UIManager:show(time_widget)
end,
}
end
common_settings.night_mode = {
text = _("Night mode"),
checked_func = function() return G_reader_settings:readSetting("night_mode") end,