display network settings based on device capabilities + fix android basic network info

pull/4615/head
Martín Fernández 5 years ago committed by Frans de Jonge
parent f3a36f8285
commit 04e17424d0

@ -1,9 +1,11 @@
local Generic = require("device/generic/device")
local _, android = pcall(require, "android")
local A, android = pcall(require, "android") -- luacheck: ignore
local ffi = require("ffi")
local C = ffi.C
local lfs = require("libs/libkoreader-lfs")
local logger = require("logger")
local _ = require("gettext")
local T = require("ffi/util").template
local function yes() return true end
local function no() return false end
@ -90,6 +92,15 @@ function Device:initNetworkManager(NetworkMgr)
end
end
function Device:retrieveNetworkInfo()
local ssid, ip, gw = android.getNetworkInfo()
if ip == 0 or gw == 0 then
return _("Not connected")
else
return T(_("Connected to %1\n IP address: %2\n gateway: %3"), ssid, ip, gw)
end
end
function Device:exit()
android.log_name = 'luajit-launcher'
android.LOGI("Finishing luajit launcher main activity");

@ -40,6 +40,7 @@ local Cervantes = Generic:new{
touch_probe_ev_epoch_time = true,
hasOTAUpdates = yes,
hasKeys = yes,
hasWifiManager = yes,
-- do we support usb mass storage?
canToggleMassStorage = function() return isMassStorageSupported() end,

@ -21,6 +21,8 @@ local Device = {
hasKeyboard = no,
hasKeys = no,
hasDPad = no,
hasWifiToggle = yes,
hasWifiManager = no,
isTouchDevice = no,
hasFrontlight = no,
needsTouchScreenProbe = no,

@ -25,6 +25,7 @@ local Kobo = Generic:new{
isTouchDevice = yes, -- all of them are
hasBGRFrameBuffer = yes, -- True when >16bpp (i.e., on current FW)
hasOTAUpdates = yes,
hasWifiManager = yes,
-- most Kobos have X/Y switched for the touch screen
touch_switch_xy = true,

@ -55,6 +55,7 @@ local PocketBook = Generic:new{
isPocketBook = yes,
isInBackGround = false,
hasOTAUpdates = yes,
hasWifiToggle = no,
}
function PocketBook:init()

@ -12,6 +12,7 @@ local Device = Generic:new{
hasKeyboard = yes,
hasKeys = yes,
hasDPad = yes,
hasWifiToggle = no,
isTouchDevice = yes,
needsScreenRefreshAfterResume = no,
hasColorScreen = yes,
@ -27,6 +28,8 @@ local Emulator = Device:new{
isEmulator = yes,
hasEinkScreen = yes,
hasFrontlight = yes,
hasWifiToggle = yes,
hasWifiManager = yes,
}
local Linux = Device:new{

@ -11,6 +11,7 @@ local SonyPRSTUX = Generic:new{
isSonyPRSTUX = yes,
hasKeys = yes,
hasOTAUpdates = yes,
hasWifiManager = yes,
}

@ -129,7 +129,7 @@ end
function NetworkMgr:getWifiMenuTable()
return {
text = _("Wi-Fi connection"),
enabled_func = function() return Device:isAndroid() or Device:isCervantes() or Device:isKindle() or Device:isKobo() or Device:isSonyPRSTUX() end,
enabled_func = function() return Device:hasWifiToggle() and not Device:isEmulator() end,
checked_func = function() return NetworkMgr:isWifiOn() end,
callback = function(touchmenu_instance)
local wifi_status = NetworkMgr:isWifiOn() and NetworkMgr:isConnected()
@ -195,7 +195,7 @@ function NetworkMgr:getRestoreMenuTable()
return {
text = _("Automatically restore Wi-Fi connection after resume"),
checked_func = function() return G_reader_settings:isTrue("auto_restore_wifi") end,
enabled_func = function() return Device:isKobo() or Device:isCervantes() end,
enabled_func = function() return Device:hasWifiManager() and not Device:isEmulator() end,
callback = function() G_reader_settings:flipNilOrFalse("auto_restore_wifi") end,
}
end
@ -221,7 +221,6 @@ function NetworkMgr:getInfoMenuTable()
}
end
function NetworkMgr:getBeforeWifiActionMenuTable()
local wifi_enable_action_setting = G_reader_settings:readSetting("wifi_enable_action") or "prompt"
local wifi_enable_actions = {
@ -257,18 +256,24 @@ function NetworkMgr:getDismissScanMenuTable()
return {
text = _("Dismiss Wi-Fi scan popup after connection"),
checked_func = function() return G_reader_settings:nilOrTrue("auto_dismiss_wifi_scan") end,
--enabled_func = function() return Device:isKobo() end,
enabled_func = function() return Device:hasWifiManager() and not Device:isEmulator() end,
callback = function() G_reader_settings:flipNilOrTrue("auto_dismiss_wifi_scan") end,
}
end
function NetworkMgr:getMenuTable(common_settings)
common_settings.network_wifi = self:getWifiMenuTable()
if Device:hasWifiToggle() then
common_settings.network_wifi = self:getWifiMenuTable()
end
common_settings.network_proxy = self:getProxyMenuTable()
common_settings.network_restore = self:getRestoreMenuTable()
common_settings.network_info = self:getInfoMenuTable()
common_settings.network_before_wifi_action = self:getBeforeWifiActionMenuTable()
common_settings.network_dismiss_scan = self:getDismissScanMenuTable()
if Device:hasWifiManager() then
common_settings.network_restore = self:getRestoreMenuTable()
common_settings.network_dismiss_scan = self:getDismissScanMenuTable()
common_settings.network_before_wifi_action = self:getBeforeWifiActionMenuTable()
end
end
function NetworkMgr:showNetworkMenu(complete_callback)

Loading…
Cancel
Save