mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
fix: disable network info menu when device is not connected
This commit is contained in:
@@ -58,7 +58,7 @@ function NetworkMgr:promptWifiOff(complete_callback)
|
||||
})
|
||||
end
|
||||
|
||||
function NetworkMgr:getWifiStatus()
|
||||
function NetworkMgr:isOnline()
|
||||
local socket = require("socket")
|
||||
return socket.dns.toip("www.example.com") ~= nil
|
||||
end
|
||||
@@ -78,9 +78,9 @@ function NetworkMgr:getWifiMenuTable()
|
||||
return {
|
||||
text = _("Wi-Fi connection"),
|
||||
enabled_func = function() return Device:isKindle() or Device:isKobo() end,
|
||||
checked_func = function() return NetworkMgr:getWifiStatus() end,
|
||||
checked_func = function() return NetworkMgr:isOnline() end,
|
||||
callback = function(menu)
|
||||
local wifi_status = NetworkMgr:getWifiStatus()
|
||||
local wifi_status = NetworkMgr:isOnline()
|
||||
local complete_callback = function()
|
||||
-- notify touch menu to update item check state
|
||||
menu:updateItems()
|
||||
@@ -151,6 +151,8 @@ end
|
||||
function NetworkMgr:getInfoMenuTable()
|
||||
return {
|
||||
text = _("Network info"),
|
||||
-- TODO: also show network info when device is authenticated to router but offline
|
||||
enabled_func = function() return self:isOnline() end,
|
||||
callback = function(menu)
|
||||
if Device.retrieveNetworkInfo then
|
||||
UIManager:show(InfoMessage:new{
|
||||
|
||||
@@ -229,7 +229,7 @@ function OTAManager:getOTAMenuTable()
|
||||
{
|
||||
text = _("Check for update"),
|
||||
callback = function()
|
||||
if NetworkMgr:getWifiStatus() == false then
|
||||
if not NetworkMgr:isOnline() then
|
||||
NetworkMgr:promptWifiOn()
|
||||
else
|
||||
OTAManager:fetchAndProcessUpdate()
|
||||
|
||||
@@ -138,7 +138,7 @@ function EvernoteExporter:addToMainMenu(tab_item_table)
|
||||
end
|
||||
|
||||
function EvernoteExporter:login()
|
||||
if NetworkMgr:getWifiStatus() == false then
|
||||
if not NetworkMgr:isOnline() then
|
||||
NetworkMgr:promptWifiOn()
|
||||
end
|
||||
self.login_dialog = LoginDialog:new{
|
||||
|
||||
@@ -224,7 +224,7 @@ function KOSync:setCustomServer(server)
|
||||
end
|
||||
|
||||
function KOSync:login()
|
||||
if NetworkMgr:getWifiStatus() == false then
|
||||
if not NetworkMgr:isOnline() then
|
||||
NetworkMgr:promptWifiOn()
|
||||
end
|
||||
self.login_dialog = LoginDialog:new{
|
||||
|
||||
Reference in New Issue
Block a user