diff --git a/frontend/apps/filemanager/filemanager.lua b/frontend/apps/filemanager/filemanager.lua index 9e3c0e622..f38919c5c 100644 --- a/frontend/apps/filemanager/filemanager.lua +++ b/frontend/apps/filemanager/filemanager.lua @@ -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", diff --git a/frontend/device/android/device.lua b/frontend/device/android/device.lua index a86a4f6bc..aa0af7aaa 100644 --- a/frontend/device/android/device.lua +++ b/frontend/device/android/device.lua @@ -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, diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index 552aa5d33..e80c05a5f 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -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