2017-09-18 17:04:36 +00:00
|
|
|
local DateWidget = require("ui/widget/datewidget")
|
2014-11-21 14:41:14 +00:00
|
|
|
local Device = require("device")
|
2017-08-15 17:54:02 +00:00
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
2014-11-21 14:41:14 +00:00
|
|
|
local Language = require("ui/language")
|
2016-06-26 00:53:08 +00:00
|
|
|
local NetworkMgr = require("ui/network/manager")
|
2014-11-21 14:41:14 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2017-08-15 17:54:02 +00:00
|
|
|
local TimeWidget = require("ui/widget/timewidget")
|
2014-11-21 14:41:14 +00:00
|
|
|
local _ = require("gettext")
|
2017-08-15 17:54:02 +00:00
|
|
|
local Screen = Device.screen
|
|
|
|
local T = require("ffi/util").template
|
2014-11-21 14:41:14 +00:00
|
|
|
|
|
|
|
local common_settings = {}
|
|
|
|
|
|
|
|
if Device:hasFrontlight() then
|
|
|
|
local ReaderFrontLight = require("apps/reader/modules/readerfrontlight")
|
2017-03-03 06:41:10 +00:00
|
|
|
common_settings.frontlight = {
|
2014-11-21 14:41:14 +00:00
|
|
|
text = _("Frontlight"),
|
|
|
|
callback = function()
|
|
|
|
ReaderFrontLight:onShowFlDialog()
|
|
|
|
end,
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
2014-11-21 14:41:14 +00:00
|
|
|
end
|
2014-11-28 18:53:48 +00:00
|
|
|
|
2019-02-15 00:18:30 +00:00
|
|
|
if Device:canToggleMassStorage() then
|
|
|
|
local MassStorage = require("ui/elements/mass_storage")
|
|
|
|
|
|
|
|
-- mass storage settings
|
|
|
|
common_settings.mass_storage_settings = {
|
|
|
|
text = _("USB mass storage"),
|
|
|
|
sub_item_table = MassStorage:getSettingsMenuTable()
|
|
|
|
}
|
|
|
|
|
|
|
|
-- mass storage actions
|
|
|
|
common_settings.mass_storage_actions = {
|
|
|
|
text = _("Start USB storage"),
|
|
|
|
callback = function() MassStorage:start() end,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2017-09-18 17:04:36 +00:00
|
|
|
if Device:setDateTime() then
|
2017-08-15 17:54:02 +00:00
|
|
|
common_settings.time = {
|
2017-09-18 17:04:36 +00:00
|
|
|
text = _("Time and date"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Set time"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2017-09-18 17:04:36 +00:00
|
|
|
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"),
|
2018-08-11 20:47:33 +00:00
|
|
|
title_text = _("Set time"),
|
2017-09-18 17:04:36 +00:00
|
|
|
callback = function(time)
|
|
|
|
if Device:setDateTime(nil, nil, nil, 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,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Set date"),
|
2018-09-04 21:55:58 +00:00
|
|
|
keep_menu_open = true,
|
2017-09-18 17:04:36 +00:00
|
|
|
callback = function()
|
|
|
|
local now_t = os.date("*t")
|
|
|
|
local curr_year = now_t.year
|
|
|
|
local curr_month = now_t.month
|
|
|
|
local curr_day = now_t.day
|
|
|
|
local date_widget = DateWidget:new{
|
|
|
|
year = curr_year,
|
|
|
|
month = curr_month,
|
|
|
|
day = curr_day,
|
|
|
|
ok_text = _("Set date"),
|
2018-08-11 20:47:33 +00:00
|
|
|
title_text = _("Set date"),
|
2017-09-18 17:04:36 +00:00
|
|
|
callback = function(time)
|
|
|
|
now_t = os.date("*t")
|
|
|
|
if Device:setDateTime(time.year, time.month, time.day, now_t.hour, now_t.min, now_t.sec) then
|
|
|
|
now_t = os.date("*t")
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = T(_("Current date: %1-%2-%3"), now_t.year, string.format("%02d", now_t.month),
|
|
|
|
string.format("%02d", now_t.day))
|
|
|
|
})
|
|
|
|
else
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("Date couldn't be set"),
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(date_widget)
|
|
|
|
end,
|
2017-08-15 17:54:02 +00:00
|
|
|
}
|
2017-09-18 17:04:36 +00:00
|
|
|
}
|
2017-08-15 17:54:02 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-03-26 22:03:18 +00:00
|
|
|
if Device:isCervantes() or Device:isKobo() or Device:isSDL() or Device:isSonyPRSTUX() then
|
|
|
|
common_settings.autosuspend = {
|
|
|
|
text = _("Autosuspend timeout"),
|
|
|
|
enabled_func = function()
|
|
|
|
-- NOTE: Pilfered from frontend/pluginloader.lua
|
|
|
|
local plugins_disabled = G_reader_settings:readSetting("plugins_disabled") or {}
|
|
|
|
return plugins_disabled["autosuspend"] ~= true
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
local curr_items = G_reader_settings:readSetting("auto_suspend_timeout_seconds") or 60*60
|
|
|
|
local autosuspend_spin = SpinWidget:new {
|
|
|
|
width = Screen:getWidth() * 0.6,
|
|
|
|
value = curr_items / 60,
|
|
|
|
value_min = 5,
|
|
|
|
value_max = 240,
|
|
|
|
value_hold_step = 15,
|
|
|
|
ok_text = _("Set timeout"),
|
|
|
|
title_text = _("Timeout in minutes"),
|
|
|
|
callback = function(autosuspend_spin)
|
|
|
|
G_reader_settings:saveSetting("auto_suspend_timeout_seconds", autosuspend_spin.value * 60)
|
|
|
|
-- NOTE: Will only take effect after a restart, as we don't have a method to set this live...
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("This will take effect on next restart."),
|
|
|
|
})
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(autosuspend_spin)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-03-26 22:09:08 +00:00
|
|
|
if Device:isKobo() then
|
|
|
|
common_settings.sleepcover = {
|
|
|
|
text = _("Ignore sleepcover events"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("ignore_power_sleepcover")
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:flipNilOrFalse("ignore_power_sleepcover")
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2017-03-03 06:41:10 +00:00
|
|
|
common_settings.night_mode = {
|
2014-11-21 14:41:14 +00:00
|
|
|
text = _("Night mode"),
|
|
|
|
checked_func = function() return G_reader_settings:readSetting("night_mode") end,
|
|
|
|
callback = function()
|
|
|
|
local night_mode = G_reader_settings:readSetting("night_mode") or false
|
|
|
|
Screen:toggleNightMode()
|
2015-02-01 15:21:34 +00:00
|
|
|
UIManager:setDirty(nil, "full")
|
2014-11-21 14:41:14 +00:00
|
|
|
G_reader_settings:saveSetting("night_mode", not night_mode)
|
|
|
|
end
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
2017-03-03 06:41:10 +00:00
|
|
|
common_settings.network = {
|
2014-11-21 14:41:14 +00:00
|
|
|
text = _("Network"),
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
2018-05-13 19:27:52 +00:00
|
|
|
NetworkMgr:getMenuTable(common_settings)
|
2017-09-17 18:29:49 +00:00
|
|
|
|
2017-03-03 06:41:10 +00:00
|
|
|
common_settings.screen = {
|
2014-11-21 14:41:14 +00:00
|
|
|
text = _("Screen"),
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
2019-02-28 17:32:11 +00:00
|
|
|
common_settings.screen_dpi = require("ui/elements/screen_dpi_menu_table")
|
|
|
|
common_settings.screen_eink_opt = require("ui/elements/screen_eink_opt_menu_table")
|
|
|
|
common_settings.menu_activate = require("ui/elements/menu_activate")
|
|
|
|
common_settings.screen_disable_double_tab = require("ui/elements/screen_disable_double_tap_table")
|
|
|
|
|
2019-01-08 01:59:47 +00:00
|
|
|
if Device:canToggleGSensor() then
|
2019-02-28 17:32:11 +00:00
|
|
|
common_settings.screen_toggle_gsensor = require("ui/elements/screen_toggle_gsensor")
|
2019-01-08 01:59:47 +00:00
|
|
|
end
|
2019-02-28 17:32:11 +00:00
|
|
|
|
2017-10-01 17:23:06 +00:00
|
|
|
if Screen.isColorScreen() then
|
2019-02-28 17:32:11 +00:00
|
|
|
common_settings.color_rendering = require("ui/elements/screen_color_menu_table")
|
2017-10-01 17:23:06 +00:00
|
|
|
end
|
2019-01-17 20:44:15 +00:00
|
|
|
|
2017-09-17 18:29:49 +00:00
|
|
|
if Device:isAndroid() then
|
2019-01-17 20:44:15 +00:00
|
|
|
-- android common settings
|
|
|
|
local isAndroid, android = pcall(require, "android")
|
|
|
|
if not isAndroid then return end
|
|
|
|
|
|
|
|
-- keep screen on
|
2019-02-28 17:32:11 +00:00
|
|
|
common_settings.keep_screen_on = {
|
|
|
|
text = _("Keep screen on"),
|
|
|
|
checked_func = function() return G_reader_settings:isTrue("enable_android_wakelock") end,
|
|
|
|
callback = function() require("ui/elements/screen_android"):toggleWakelock() end,
|
|
|
|
}
|
2019-01-17 20:44:15 +00:00
|
|
|
|
|
|
|
-- fullscreen
|
|
|
|
if Device.firmware_rev <= 16 then
|
2019-02-28 17:32:11 +00:00
|
|
|
common_settings.fullscreen = {
|
|
|
|
text = _("Fullscreen"),
|
|
|
|
checked_func = function() return android.isFullscreen() end,
|
|
|
|
callback = function() require("ui/elements/screen_android"):toggleFullscreen() end,
|
|
|
|
}
|
2019-01-17 20:44:15 +00:00
|
|
|
end
|
2017-09-17 18:29:49 +00:00
|
|
|
end
|
|
|
|
|
2019-02-28 19:42:00 +00:00
|
|
|
if Device:isTouchDevice() then
|
|
|
|
common_settings.taps_and_gestures = {
|
|
|
|
text = _("Taps and gestures"),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-02-28 21:38:24 +00:00
|
|
|
common_settings.navigation = {
|
|
|
|
text = _("Navigation"),
|
|
|
|
}
|
|
|
|
local back_to_exit_str = {
|
|
|
|
prompt = {_("Prompt"), _("prompt")},
|
|
|
|
always = {_("Always"), _("always")},
|
|
|
|
disable ={_("Disable"), _("disable")},
|
|
|
|
}
|
|
|
|
common_settings.back_to_exit = {
|
|
|
|
text_func = function()
|
|
|
|
local back_to_exit = G_reader_settings:readSetting("back_to_exit") or "prompt"
|
|
|
|
return T(_("Back to exit (%1)"),
|
|
|
|
back_to_exit_str[back_to_exit][2])
|
|
|
|
end,
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = back_to_exit_str.prompt[1],
|
|
|
|
checked_func = function()
|
|
|
|
local setting = G_reader_settings:readSetting("back_to_exit")
|
|
|
|
return setting == "prompt" or setting == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("back_to_exit", "prompt")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = back_to_exit_str.always[1],
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("back_to_exit")
|
|
|
|
== "always"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("back_to_exit", "always")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = back_to_exit_str.disable[1],
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("back_to_exit")
|
|
|
|
== "disable"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("back_to_exit", "disable")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
common_settings.back_in_filemanager = {
|
|
|
|
text = _("Back in file browser"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text_func = function()
|
|
|
|
local back_to_exit = G_reader_settings:readSetting("back_to_exit") or "prompt"
|
|
|
|
return T(_("Back to exit (%1)"),
|
|
|
|
back_to_exit_str[back_to_exit][2])
|
|
|
|
end,
|
|
|
|
checked_func = function()
|
|
|
|
local back_in_filemanager = G_reader_settings:readSetting("back_in_filemanager")
|
|
|
|
return back_in_filemanager == nil or back_in_filemanager == "default"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("back_in_filemanager", "default")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Go to parent folder"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("back_in_filemanager")
|
|
|
|
== "parent_folder"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("back_in_filemanager", "parent_folder")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
common_settings.enable_back_history = {
|
|
|
|
text = _("Enable back history"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:nilOrTrue("enable_back_history")
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:flipNilOrTrue("enable_back_history")
|
|
|
|
end,
|
|
|
|
}
|
2018-04-09 07:22:16 +00:00
|
|
|
if Device:hasKeys() then
|
2019-02-28 21:38:24 +00:00
|
|
|
common_settings.invert_page_turn_buttons = {
|
|
|
|
text = _("Invert page turn buttons"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("input_invert_page_turn_keys")
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:flipNilOrFalse("input_invert_page_turn_keys")
|
|
|
|
Device:invertButtons()
|
|
|
|
end,
|
2018-04-09 07:22:16 +00:00
|
|
|
}
|
|
|
|
end
|
2019-02-28 21:38:24 +00:00
|
|
|
|
2018-01-30 11:12:52 +00:00
|
|
|
common_settings.document = {
|
|
|
|
text = _("Document"),
|
2016-07-14 17:38:00 +00:00
|
|
|
sub_item_table = {
|
|
|
|
{
|
2018-01-30 11:12:52 +00:00
|
|
|
text = _("Save document (write highlights into PDF)"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Prompt"),
|
|
|
|
checked_func = function()
|
|
|
|
local setting = G_reader_settings:readSetting("save_document")
|
|
|
|
return setting == "prompt" or setting == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:delSetting("save_document")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Always"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("save_document")
|
|
|
|
== "always"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("save_document", "always")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Disable"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("save_document")
|
|
|
|
== "disable"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("save_document", "disable")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
2016-07-14 17:38:00 +00:00
|
|
|
},
|
|
|
|
{
|
2018-05-13 11:07:23 +00:00
|
|
|
text = _("End of document action"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Ask with pop-up dialog"),
|
|
|
|
checked_func = function()
|
|
|
|
local setting = G_reader_settings:readSetting("end_document_action")
|
|
|
|
return setting == "pop-up" or setting == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("end_document_action", "pop-up")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Do nothing"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("end_document_action") == "nothing"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("end_document_action", "nothing")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Book status"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("end_document_action") == "book_status"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("end_document_action", "book_status")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Open next file"),
|
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:readSetting("collate")
|
|
|
|
~= "access"
|
|
|
|
end,
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("end_document_action") == "next_file"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("end_document_action", "next_file")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Return to file browser"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("end_document_action") == "file_browser"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("end_document_action", "file_browser")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Book status and return to file browser"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("end_document_action") == "book_status_file_browser"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("end_document_action", "book_status_file_browser")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
2016-07-14 17:38:00 +00:00
|
|
|
},
|
2019-01-17 21:12:38 +00:00
|
|
|
{
|
|
|
|
text = _("Highlight action"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Ask with popup dialog"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:nilOrFalse("default_highlight_action")
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("default_highlight_action", nil)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Highlight"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("default_highlight_action") == "highlight"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("default_highlight_action", "highlight")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Translate"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("default_highlight_action") == "translate"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("default_highlight_action", "translate")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Wikipedia"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("default_highlight_action") == "wikipedia"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("default_highlight_action", "wikipedia")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2016-07-14 17:38:00 +00:00
|
|
|
},
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
2017-03-03 06:41:10 +00:00
|
|
|
common_settings.language = Language:getLangMenuTable()
|
2014-11-21 14:41:14 +00:00
|
|
|
|
|
|
|
return common_settings
|