summaryrefslogtreecommitdiff
path: root/android/source/res
diff options
context:
space:
mode:
authorAlexF <alexfongg@gmail.com>2015-12-16 22:53:08 +0800
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-02 19:25:41 +0000
commit1dfb68debb01dcc0aa5902f41bc17c7a97e47b26 (patch)
tree6e1237eaeb08179b4cfb29c54d4c8eb71341d736 /android/source/res
parentbb01d7bc50e59eb30c0826a000ede52b93074f75 (diff)
tdf#88389 - android document browser: external storage access
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 <quikee@gmail.com> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'android/source/res')
-rw-r--r--android/source/res/drawable/ic_menu_back.pngbin0 -> 1900 bytes
-rw-r--r--android/source/res/layout/activity_directory_browser.xml6
-rw-r--r--android/source/res/layout/fragment_directory_browser.xml71
-rw-r--r--android/source/res/values/strings.xml18
-rw-r--r--android/source/res/xml/documentprovider_preferences.xml13
5 files changed, 108 insertions, 0 deletions
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 000000000000..d3191caffd13
--- /dev/null
+++ b/android/source/res/drawable/ic_menu_back.png
Binary files differ
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/fragment_container"
+ android:layout_width="match_parent" android:layout_height="match_parent">
+
+</FrameLayout> \ 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#FFFFFF">
+
+ <LinearLayout
+ android:id="@+id/browser_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/up_image"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:src="@drawable/ic_menu_back"
+ android:scaleType="fitCenter"
+ android:adjustViewBounds="true"
+ android:contentDescription="@string/up_description"/>
+
+ <EditText
+ android:id="@+id/directory_header"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:scrollHorizontally="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:inputType="text"/>
+
+ <Button
+ android:id="@+id/directory_search_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:text="@string/search_label"/>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/browser_footer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_alignParentBottom="true">
+
+ <Button
+ android:id="@+id/cancel_button"
+ android:layout_height="wrap_content"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:text="@string/cancel_label"/>
+
+ <Button
+ android:id="@+id/confirm_button"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/confirm_label"/>
+ </LinearLayout>
+
+ <ListView
+ android:id="@+id/directory_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/browser_header"
+ android:layout_above="@id/browser_footer">
+ </ListView>
+
+
+</RelativeLayout> \ No newline at end of file
diff --git a/android/source/res/values/strings.xml b/android/source/res/values/strings.xml
index 403f5b900c3f..c4d1bae404c5 100644
--- a/android/source/res/values/strings.xml
+++ b/android/source/res/values/strings.xml
@@ -51,12 +51,18 @@
<string name="close_document_locations">Close document locations</string>
<string name="local_documents">Local documents</string>
<string name="local_file_system">Local file system</string>
+ <string name="external_sd_file_system">External SD</string>
+ <string name="otg_file_system">OTG device (experimental)</string>
<string name="owncloud">ownCloud</string>
<string name="owncloud_wrong_connection">Cannot connect to ownCloud server. Check your configuration.</string>
<string name="owncloud_unauthorized">Cannot log into ownCloud server. Check your configuration.</string>
<string name="owncloud_unspecified_error">Unspecified error connecting to ownCloud server. Check your configuration and/or try later.</string>
+ <string name="ext_document_provider_error">Invalid root file. Check your configuration.</string>
+ <string name="legacy_extsd_missing_error">Invalid root file. Check your external sd card and/or configuration.</string>
+ <string name="otg_missing_error">Invalid root file. Check your OTG device and/or configuration.</string>
+
<!-- Edit action names -->
<string name="action_bold">Bold</string>
<string name="action_underline">Underline</string>
@@ -75,6 +81,10 @@
<!-- Document provider settings -->
<string name="storage_provider_settings">Storage provider settings</string>
<string name="owncloud_settings">ownCloud settings</string>
+ <string name="physical_storage_settings">Physical storage settings</string>
+ <string name="external_sd_path">External SD path</string>
+ <string name="otg_device_path">OTG device path</string>
+ <string name="otg_warning">Experimental Feature: Use only if OTG device is writable.</string>
<string name="server_url">Server URL</string>
<string name="server_url_and_port">URL and port of the ownCloud server.</string>
<string name="user_name">User name</string>
@@ -82,5 +92,13 @@
<string name="action_undo">Undo</string>
<string name="action_redo">Redo</string>
+ <!-- Directory browser strings -->
+ <string name="up_description">To parent directory</string>
+ <string name="confirm_label">Confirm</string>
+ <string name="cancel_label">Cancel</string>
+ <string name="search_label">Go</string>
+ <string name="directory_browser_label">Choose Directory</string>
+ <string name="bad_directory">Invalid directory path</string>
+
</resources>
diff --git a/android/source/res/xml/documentprovider_preferences.xml b/android/source/res/xml/documentprovider_preferences.xml
index a359d14c4460..4a66c6377847 100644
--- a/android/source/res/xml/documentprovider_preferences.xml
+++ b/android/source/res/xml/documentprovider_preferences.xml
@@ -23,4 +23,17 @@
android:title="@string/password"
android:defaultValue="" />
</PreferenceCategory>
+ <PreferenceCategory
+ android:title="@string/physical_storage_settings">
+ <PreferenceScreen
+ android:title="@string/external_sd_path"
+ android:key="pref_extsd_path_uri">
+ </PreferenceScreen>
+ <PreferenceScreen
+ android:title="@string/otg_device_path"
+ android:key="pref_otg_path_uri"
+ android:summary="@string/otg_warning">
+ </PreferenceScreen>
+ </PreferenceCategory>
+
</PreferenceScreen>