Add Device:Info for android and use it in report a bug infomessage.

Move local function getCodename to top, use android.app.activity.sdkVersion directly,
instead of relying on Device.firmware_rev
pull/5089/head
Martín Fernández 5 years ago
parent c60d672b04
commit 75ff5dcaae

@ -15,6 +15,31 @@ local function canUpdateApk()
return (android.prop.flavor ~= "fdroid")
end
local function getCodename()
local api = android.app.activity.sdkVersion
local codename = ""
if api > 27 then
codename = "Pie"
elseif api == 27 or api == 26 then
codename = "Oreo"
elseif api == 25 or api == 24 then
codename = "Nougat"
elseif api == 23 then
codename = "Marshmallow"
elseif api == 22 or api == 21 then
codename = "Lollipop"
elseif api == 19 then
codename = "KitKat"
elseif api < 19 and api >= 16 then
codename = "Jelly Bean"
elseif api < 16 and api >= 14 then
codename = "Ice Cream Sandwich"
end
return codename
end
local Device = Generic:new{
isAndroid = yes,
model = android.prop.product,
@ -140,34 +165,28 @@ function Device:retrieveNetworkInfo()
end
end
function Device:exit()
android.LOGI(string.format("Stopping %s main activity", android.prop.name));
android.lib.ANativeActivity_finish(android.app.activity)
end
function Device:info()
local is_eink, eink_platform = android.isEink()
local function getCodename()
local api = Device.firmware_rev
local codename = nil
local common_text = T(_("%1\n\nOS: Android %2, api %3\nBuild flavor: %4\n"),
android.prop.product, getCodename(), Device.firmware_rev, android.prop.flavor)
if api > 27 then
codename = "Pie"
elseif api == 27 or api == 26 then
codename = "Oreo"
elseif api == 25 or api == 24 then
codename = "Nougat"
elseif api == 23 then
codename = "Marshmallow"
elseif api == 22 or api == 21 then
codename = "Lollipop"
elseif api == 19 then
codename = "KitKat"
elseif api < 19 and api >= 16 then
codename = "Jelly Bean"
elseif api < 16 and api >= 14 then
codename = "Ice Cream Sandwich"
local eink_text = ""
if is_eink then
eink_text = T(_("\nE-ink display supported.\nPlatform: %1\n"), eink_platform)
end
local wakelocks_text = ""
if android.needsWakelocks() then
wakelocks_text = _("\nThis device needs CPU, screen and touchscreen always on.\nScreen timeout will be ignored while the app is in the foreground!\n")
end
return codename or ""
return common_text..eink_text..wakelocks_text
end
function Device:exit()
android.LOGI(string.format("Stopping %s main activity", android.prop.name));
android.lib.ANativeActivity_finish(android.app.activity)
end
android.LOGI(string.format("Android %s - %s (API %d) - flavor: %s",

@ -53,10 +53,14 @@ common_info.report_bug = {
text = _("Report a bug"),
keep_menu_open = true,
callback = function()
local model = Device.model
local device = Device.model
if Device:isAndroid() then
device = Device:info()
end
UIManager:show(InfoMessage:new{
text = T(_("Please report bugs to \nhttps://github.com/koreader/koreader/issues\n\nVersion:\n%1\n\nDetected device:\n%2"),
version, model),
version, device),
})
end
}

Loading…
Cancel
Save