mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
android: import files from Storage Access Framework
This commit is contained in:
@@ -552,6 +552,20 @@ function FileManager:tapPlus()
|
||||
}
|
||||
}
|
||||
|
||||
if Device:canImportFiles() then
|
||||
table.insert(buttons, 3, {
|
||||
{
|
||||
text = _("Import files here"),
|
||||
enabled = Device.isValidPath(self.file_chooser.path),
|
||||
callback = function()
|
||||
local current_dir = self.file_chooser.path
|
||||
UIManager:close(self.file_dialog)
|
||||
Device.importFile(current_dir)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
self.file_dialog = ButtonDialogTitle:new{
|
||||
title = filemanagerutil.abbreviate(self.file_chooser.path),
|
||||
title_align = "center",
|
||||
|
||||
@@ -83,6 +83,10 @@ local Device = Generic:new{
|
||||
if not link or type(link) ~= "string" then return end
|
||||
return android.openLink(link) == 0
|
||||
end,
|
||||
canImportFiles = function() return android.app.activity.sdkVersion >= 19 end,
|
||||
importFile = function(path) android.importFile(path) end,
|
||||
isValidPath = function(path) return android.isPathInsideSandbox(path) end,
|
||||
|
||||
canExternalDictLookup = yes,
|
||||
getExternalDictLookupList = getExternalDicts,
|
||||
doExternalDictLookup = function (self, text, method, callback)
|
||||
@@ -133,7 +137,6 @@ function Device:init()
|
||||
external_dict_when_back_callback()
|
||||
external_dict_when_back_callback = nil
|
||||
end
|
||||
|
||||
local new_file = android.getIntent()
|
||||
if new_file ~= nil and lfs.attributes(new_file, "mode") == "file" then
|
||||
-- we cannot blit to a window here since we have no focus yet.
|
||||
@@ -148,6 +151,20 @@ function Device:init()
|
||||
UIManager:scheduleIn(0.2, function()
|
||||
require("apps/reader/readerui"):doShowReader(new_file)
|
||||
end)
|
||||
else
|
||||
-- check if we're resuming from importing content.
|
||||
local content_path = android.getLastImportedPath()
|
||||
if content_path ~= nil then
|
||||
local FileManager = require("apps/filemanager/filemanager")
|
||||
local UIManager = require("ui/uimanager")
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
if FileManager.instance then
|
||||
FileManager.instance:onRefresh()
|
||||
else
|
||||
FileManager:showFiles(content_path)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -45,6 +45,7 @@ local Device = {
|
||||
canUseCBB = yes, -- The C BB maintains a 1:1 feature parity with the Lua BB, except that is has NO support for BB4, and limited support for BBRGB24
|
||||
hasColorScreen = no,
|
||||
hasBGRFrameBuffer = no,
|
||||
canImportFiles = no,
|
||||
canToggleGSensor = no,
|
||||
canToggleMassStorage = no,
|
||||
canUseWAL = yes, -- requires mmap'ed I/O on the target FS
|
||||
|
||||
Reference in New Issue
Block a user