[UX] Add Device:openLink() stub for Linux SDL (#4822)

References #4821.
pull/4824/head
Frans de Jonge 5 years ago committed by GitHub
parent 728bb187fa
commit b1ed2838c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -614,6 +614,11 @@ function ReaderLink:onGotoLink(link, neglect_current_location, allow_footnote_po
return true return true
end end
-- try opening link in native browser
if Device:openLink(link_url) then
return true
end
-- Not supported -- Not supported
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = T(_("Invalid or external link:\n%1"), link_url), text = T(_("Invalid or external link:\n%1"), link_url),

@ -64,6 +64,8 @@ local Device = {
-- set to yes on devices that support over-the-air incremental updates. -- set to yes on devices that support over-the-air incremental updates.
hasOTAUpdates = no, hasOTAUpdates = no,
openLink = no,
} }
function Device:new(o) function Device:new(o)

@ -17,6 +17,10 @@ local Device = Generic:new{
needsScreenRefreshAfterResume = no, needsScreenRefreshAfterResume = no,
hasColorScreen = yes, hasColorScreen = yes,
hasEinkScreen = no, hasEinkScreen = no,
openLink = function(self, link)
if not link or type(link) ~= "string" then return end
return os.execute("xdg-open '"..link.."'") == 0
end,
} }
local AppImage = Device:new{ local AppImage = Device:new{

@ -236,7 +236,7 @@ function OTAManager:fetchAndProcessUpdate()
android.notification(T(_("Downloading %1"), ota_package)) android.notification(T(_("Downloading %1"), ota_package))
end end
elseif Device:isSDL() then elseif Device:isSDL() then
os.execute("xdg-open '"..link.."'") Device:openLink(link)
end end
end end
}) })

Loading…
Cancel
Save