From 1dfb68debb01dcc0aa5902f41bc17c7a97e47b26 Mon Sep 17 00:00:00 2001 From: AlexF Date: Wed, 16 Dec 2015 22:53:08 +0800 Subject: [PATCH] tdf#88389 - android document browser: external storage access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Background: External SD cards are only partially supported by the Android system, with a great deal of fragmentation on implementation across manufacturers and android versions. There is no official support for OTG devices. This commit adds: 1) External SD card support 2) OTG device support Caveats: 1) Not tested on Android 6. Emulator crashes when opening files on Android 6, using an unmodified build of the master branch. 2) OTG support currently works only if there is write access to the OTG directory. The user must be aware of exact OTG directory path or be able to navigate to it as well. 3) External SD card provider currently lacks file filtering. Approach: ----- Added new document providers. External SD cards: There are 2 different document providers external sd cards, one for Android 4.4 and above, and the other for older versions. 1) New Android 4.4 and above require usage of the DocumentFile wrapper class to access files in external storage. Actual file paths are no longer obtainable. As such, the underlying file will be cloned in a cache, allowing us to get an actual file path and use LOK. Some differences exist between 4.4 & 5+. The document provider handles each case separately. 2) Legacy Android 4.3 and below do not support the DocumentFile wrapper. File object can be used in these versions, allowing actual file paths to be obtained. The document provider guesses the root directory of the SD card. If the guessing fails, the user is to navigate to this directory himself. OTG: The OTG document provider resembles the legacy external SD card document provider, requiring the user to locate the directory himself. The document provider does not guess the root directory of the OTG device as the location varies with manufacturer implementation. ----- Supplementary Notes: Attempting to use the internal app cache as the file cache like in the ownCloud document provider did not work. Using the external app cache works fine though. It could be because initializing LOK wipes the internal app cache. Would be good to test the ownCloud document provider to confirm if it works. Change-Id: Ie727cca265107bc49ca7e7b57130470f7fc52e06 Reviewed-on: https://gerrit.libreoffice.org/20738 Reviewed-by: Tomaž Vajngerl Tested-by: Miklos Vajna --- android/source/AndroidManifest.xml | 10 + android/source/res/drawable/ic_menu_back.png | Bin 0 -> 1900 bytes .../res/layout/activity_directory_browser.xml | 6 + .../res/layout/fragment_directory_browser.xml | 71 +++++++ android/source/res/values/strings.xml | 18 ++ .../res/xml/documentprovider_preferences.xml | 13 ++ .../storage/DocumentProviderFactory.java | 19 +- .../DocumentProviderSettingsActivity.java | 41 +++- .../java/org/libreoffice/storage/IOUtils.java | 59 ++++++ .../external/BrowserSelectorActivity.java | 152 +++++++++++++ .../external/DirectoryBrowserActivity.java | 42 ++++ .../external/DirectoryBrowserFragment.java | 199 ++++++++++++++++++ .../storage/external/ExternalFile.java | 149 +++++++++++++ .../external/ExtsdDocumentsProvider.java | 152 +++++++++++++ .../external/IExternalDocumentProvider.java | 19 ++ .../LegacyExtSDDocumentsProvider.java | 97 +++++++++ .../external/OTGDocumentsProvider.java | 84 ++++++++ 17 files changed, 1125 insertions(+), 6 deletions(-) create mode 100644 android/source/res/drawable/ic_menu_back.png create mode 100644 android/source/res/layout/activity_directory_browser.xml create mode 100644 android/source/res/layout/fragment_directory_browser.xml create mode 100644 android/source/src/java/org/libreoffice/storage/IOUtils.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/BrowserSelectorActivity.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserActivity.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserFragment.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/ExternalFile.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/ExtsdDocumentsProvider.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/IExternalDocumentProvider.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/LegacyExtSDDocumentsProvider.java create mode 100644 android/source/src/java/org/libreoffice/storage/external/OTGDocumentsProvider.java diff --git a/android/source/AndroidManifest.xml b/android/source/AndroidManifest.xml index d49771ab9d3f..25e824074ac9 100644 --- a/android/source/AndroidManifest.xml +++ b/android/source/AndroidManifest.xml @@ -113,6 +113,16 @@ + + + + + + diff --git a/android/source/res/drawable/ic_menu_back.png b/android/source/res/drawable/ic_menu_back.png new file mode 100644 index 0000000000000000000000000000000000000000..d3191caffd13ba227bec9b34f332d73d48d32da5 GIT binary patch literal 1900 zcmb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nSvX%8fk)7U^!Jg8jXeTot8OCx9Q z-EzqNiW^+nm(t(g-!(9>SkdC&^9`qaT=4Gl+llWL1u;AXMW^oi!_`&lv!<@1q9X0e<@4ud^_8}}H`KC82$ufbYfWm@iQ~snlB0Kx;{$FFeP51GUc?B&({3I-Z(!~WnjAd+X-4y5`jiKY zo?yr4(NPP(;Sb Jk3^)c`U?-ZygvW{ literal 0 HcmV?d00001 diff --git a/android/source/res/layout/activity_directory_browser.xml b/android/source/res/layout/activity_directory_browser.xml new file mode 100644 index 000000000000..b03c6bbb1224 --- /dev/null +++ b/android/source/res/layout/activity_directory_browser.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/android/source/res/layout/fragment_directory_browser.xml b/android/source/res/layout/fragment_directory_browser.xml new file mode 100644 index 000000000000..fcf7fc6c9b47 --- /dev/null +++ b/android/source/res/layout/fragment_directory_browser.xml @@ -0,0 +1,71 @@ + + + + + + + + + +