From be2bcac28ea0be8163da0c4f22f45f4510d4aa2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Fdez?= Date: Fri, 27 Nov 2020 20:51:40 +0100 Subject: [PATCH] switch between internal and external sdcard --- frontend/apps/filemanager/filemanager.lua | 28 ++++++++++++++++++++++- frontend/device/android/device.lua | 1 + frontend/device/generic/device.lua | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/frontend/apps/filemanager/filemanager.lua b/frontend/apps/filemanager/filemanager.lua index 4baab12f0..e002133e2 100644 --- a/frontend/apps/filemanager/filemanager.lua +++ b/frontend/apps/filemanager/filemanager.lua @@ -641,7 +641,7 @@ function FileManager:tapPlus() table.insert(buttons, 3, { { text = _("Import files here"), - enabled = Device.isValidPath(self.file_chooser.path), + enabled = Device:isValidPath(self.file_chooser.path), callback = function() local current_dir = self.file_chooser.path UIManager:close(self.file_dialog) @@ -651,6 +651,32 @@ function FileManager:tapPlus() }) end + if Device:hasExternalSD() then + table.insert(buttons, 4, { + { + text_func = function() + if Device:isValidPath(self.file_chooser.path) then + return _("Switch to SDCard") + else + return _("Switch to internal storage") + end + end, + callback = function() + if Device:isValidPath(self.file_chooser.path) then + local ok, sd_path = Device:hasExternalSD() + UIManager:close(self.file_dialog) + if ok then + self.file_chooser:changeToPath(sd_path) + end + else + UIManager:close(self.file_dialog) + self.file_chooser:changeToPath(Device.home_dir) + end + end, + }, + }) + end + self.file_dialog = ButtonDialogTitle:new{ title = BD.dirpath(filemanagerutil.abbreviate(self.file_chooser.path)), title_align = "center", diff --git a/frontend/device/android/device.lua b/frontend/device/android/device.lua index f89fc8e50..afae22b90 100644 --- a/frontend/device/android/device.lua +++ b/frontend/device/android/device.lua @@ -93,6 +93,7 @@ local Device = Generic:new{ return android.openLink(link) == 0 end, canImportFiles = function() return android.app.activity.sdkVersion >= 19 end, + hasExternalSD = function() return android.getExternalSdPath() end, importFile = function(path) android.importFile(path) end, canShareText = yes, doShareText = function(text) android.sendText(text) end, diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index 30d59eced..7ba982205 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -45,6 +45,7 @@ local Device = { needsTouchScreenProbe = no, hasClipboard = yes, -- generic internal clipboard on all devices hasEinkScreen = yes, + hasExternalSD = no, -- or other storage volume that cannot be accessed using the File Manager canHWDither = no, canHWInvert = no, 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