summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2021-04-06 14:26:06 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2021-04-07 08:37:06 +0200
commit423c5d4eaa15fe5cbef75ac45061d317004a6475 (patch)
tree6239d23d06924a9a133cfc88bc3fa1b16213a452
parent1bce9854282b1ee63564d1807f881656678332ca (diff)
android: Drop custom file abstraction + UI
Android Viewer had its own file abstraction layer. From the (now deleted) IFile.java: > An abstraction of the File class, intended to be implemented by different > Document Providers. > > It represents a file or a directory in the context of a certain Document > Provider. It wraps the file-related operations and provides access to the > final document as a local File, downloading it if necessary. However, Android already provides such an abstraction by what is called "documents provider" there as well, s. [1]. Android Viewer has previously been adapted to support and make use of that. Therefore, drop the custom implementation to avoid duplication and having to reimplement functionality already provided otherwise. Also, drop the custom UI elements to display and select files implemented on top of the custom file abstraction. Support for using the system file picker (via the corresponding Intents) has been added earlier and is now the only available option to open files from within the app. [1] https://developer.android.com/training/data-storage/shared/documents-files Change-Id: Ide529e836a32fd7e880e5a72d971af9f9c7e74bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113667 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit a23bd42e9b2f6401c710ac95afcc3aa8f360d65c)
-rw-r--r--android/source/AndroidManifest.xml17
-rw-r--r--android/source/res/layout/activity_directory_browser.xml6
-rw-r--r--android/source/res/layout/activity_document_browser.xml27
-rw-r--r--android/source/res/layout/file_explorer_grid_item.xml42
-rw-r--r--android/source/res/layout/file_grid.xml25
-rw-r--r--android/source/res/layout/file_list.xml20
-rw-r--r--android/source/res/layout/file_list_item.xml58
-rw-r--r--android/source/res/layout/fragment_directory_browser.xml71
-rw-r--r--android/source/res/menu/context_menu.xml7
-rw-r--r--android/source/res/menu/navigation_menu.xml34
-rw-r--r--android/source/res/menu/view_menu.xml54
-rw-r--r--android/source/res/values-de/strings.xml63
-rw-r--r--android/source/res/values-tr/strings.xml54
-rw-r--r--android/source/res/values/arrays.xml47
-rw-r--r--android/source/res/values/integers.xml6
-rw-r--r--android/source/res/values/strings.xml64
-rw-r--r--android/source/res/xml/documentprovider_preferences.xml22
-rw-r--r--android/source/res/xml/libreoffice_preferences.xml31
-rw-r--r--android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java146
-rw-r--r--android/source/src/java/org/libreoffice/storage/DocumentProviderFactory.java125
-rw-r--r--android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java99
-rw-r--r--android/source/src/java/org/libreoffice/storage/IDocumentProvider.java69
-rw-r--r--android/source/src/java/org/libreoffice/storage/IFile.java116
-rw-r--r--android/source/src/java/org/libreoffice/storage/IOUtils.java56
-rw-r--r--android/source/src/java/org/libreoffice/storage/external/BrowserSelectorActivity.java153
-rw-r--r--android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserActivity.java42
-rw-r--r--android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserFragment.java199
-rw-r--r--android/source/src/java/org/libreoffice/storage/external/ExternalFile.java163
-rw-r--r--android/source/src/java/org/libreoffice/storage/external/ExtsdDocumentsProvider.java175
-rw-r--r--android/source/src/java/org/libreoffice/storage/external/IExternalDocumentProvider.java22
-rw-r--r--android/source/src/java/org/libreoffice/storage/external/OTGDocumentsProvider.java90
-rw-r--r--android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java73
-rw-r--r--android/source/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java60
-rw-r--r--android/source/src/java/org/libreoffice/storage/local/LocalFile.java103
-rw-r--r--android/source/src/java/org/libreoffice/ui/FileUtilities.java108
-rw-r--r--android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java876
36 files changed, 51 insertions, 3272 deletions
diff --git a/android/source/AndroidManifest.xml b/android/source/AndroidManifest.xml
index ae37c4fe8054..53a064fb901b 100644
--- a/android/source/AndroidManifest.xml
+++ b/android/source/AndroidManifest.xml
@@ -110,23 +110,6 @@
</intent-filter>
</activity>
- <!-- Document Provider Settings Activity -->
- <activity android:name=".storage.DocumentProviderSettingsActivity"
- android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
- android:label="@string/storage_provider_settings">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
-
- <activity android:name=".storage.external.BrowserSelectorActivity" >
- </activity>
-
- <activity android:name=".storage.external.DirectoryBrowserActivity"
- android:label="@string/directory_browser_label"
- android:windowSoftInputMode="stateHidden">
- </activity>
-
<activity android:name=".PresentationActivity"
android:screenOrientation="landscape" >
<meta-data
diff --git a/android/source/res/layout/activity_directory_browser.xml b/android/source/res/layout/activity_directory_browser.xml
deleted file mode 100644
index b03c6bbb1224..000000000000
--- a/android/source/res/layout/activity_directory_browser.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?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/activity_document_browser.xml b/android/source/res/layout/activity_document_browser.xml
index b3b4ace2a465..f2985511dd61 100644
--- a/android/source/res/layout/activity_document_browser.xml
+++ b/android/source/res/layout/activity_document_browser.xml
@@ -86,24 +86,6 @@
android:padding="16dp"
android:textStyle="bold" />
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="14sp"
- android:padding="7dp"
- android:id="@+id/text_directory_path"
- android:background="@color/background_normal"
- />
-
-
- <!--Document browser-->
- <android.support.v7.widget.RecyclerView
- android:id="@+id/file_recycler_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/background_normal"
- android:orientation="vertical" />
-
<!--Icon and text to open system file picker via Intent -->
<LinearLayout
android:id="@+id/system_file_picker_layout"
@@ -129,14 +111,6 @@
</android.support.v4.widget.NestedScrollView>
<!-- The navigation drawer -->
- <android.support.design.widget.NavigationView
- android:id="@+id/navigation_drawer"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="start"
- android:background="@color/background_normal"
- app:menu="@menu/navigation_menu"
- android:theme="@style/LibreOfficeTheme.NavigationView" />
</android.support.v4.widget.DrawerLayout>
@@ -145,7 +119,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
- android:visibility="invisible"
app:backgroundTint="@color/background_normal"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="parent"
diff --git a/android/source/res/layout/file_explorer_grid_item.xml b/android/source/res/layout/file_explorer_grid_item.xml
deleted file mode 100644
index e64fdc23a6a7..000000000000
--- a/android/source/res/layout/file_explorer_grid_item.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- This file is part of the LibreOffice project.
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="4dp"
- android:paddingBottom="4dp"
- android:orientation="vertical" >
-
- <ImageView
- android:id="@+id/file_item_icon"
- tools:src="@drawable/ic_folder_black_24dp"
- tools:tint="@color/text_color_secondary"
- android:layout_width="100dp"
- android:layout_height="100dp"
- android:scaleType="fitStart"
- android:layout_gravity="center"
- android:contentDescription="@string/file_icon_desc" >
- </ImageView>
-
- <TextView
- android:id="@+id/file_item_name"
- tools:text="file or dirname"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="10dp"
- android:paddingRight="10dp"
- android:paddingTop="10dp"
- android:layout_gravity="center"
- android:textSize="15sp"
- android:textStyle="bold"
- android:textColor="@android:color/secondary_text_light"
- android:maxLines="2">
- </TextView>
-
-</LinearLayout>
diff --git a/android/source/res/layout/file_grid.xml b/android/source/res/layout/file_grid.xml
deleted file mode 100644
index 1885bd34ed6a..000000000000
--- a/android/source/res/layout/file_grid.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- This file is part of the LibreOffice project.
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <GridView
- android:id="@+id/file_explorer_grid_view"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:columnWidth="120dp"
- android:numColumns="auto_fit"
- android:verticalSpacing="10dp"
- android:horizontalSpacing="10dp"
- android:stretchMode="columnWidth"
- android:gravity="center">
- </GridView>
-
-</LinearLayout>
diff --git a/android/source/res/layout/file_list.xml b/android/source/res/layout/file_list.xml
deleted file mode 100644
index 48dfb1e31267..000000000000
--- a/android/source/res/layout/file_list.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- This file is part of the LibreOffice project.
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <ListView
- android:id="@+id/file_explorer_list_view"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- </ListView>
-
-</LinearLayout>
diff --git a/android/source/res/layout/file_list_item.xml b/android/source/res/layout/file_list_item.xml
deleted file mode 100644
index 518885d4b296..000000000000
--- a/android/source/res/layout/file_list_item.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- This file is part of the LibreOffice project.
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="48dp"
- android:orientation="horizontal"
- android:layout_marginStart="@dimen/list_item_margin"
- android:layout_marginLeft="@dimen/list_item_margin"
- android:layout_marginEnd="@dimen/list_item_margin"
- android:layout_marginRight="@dimen/list_item_margin">
- <ImageView
- android:id="@+id/file_item_icon"
- tools:src="@drawable/ic_folder_black_24dp"
- tools:tint="@color/text_color_secondary"
- android:layout_height="match_parent"
- android:layout_width="@dimen/file_icon_width"
- android:layout_marginEnd="@dimen/file_icon_margin_end"
- android:layout_marginRight="@dimen/file_icon_margin_end"
- android:layout_gravity="center"
- android:contentDescription="@string/file_icon_desc" />
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="48dp"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/file_item_name"
- tools:text="file or dirname"
- style="@style/ListItemText"
- android:layout_height="match_parent"
- android:layout_width="0dp"
- android:layout_weight="2"
- android:ellipsize="end"
- android:maxLines="1"/>
- <TextView
- android:id="@+id/file_item_size"
- tools:text="filesize"
- style="@style/ListItemText"
- android:layout_height="match_parent"
- android:layout_width="0dp"
- android:layout_weight="1" />
- <TextView
- android:id="@+id/file_item_date"
- tools:text="date/time"
- style="@style/ListItemText"
- android:layout_height="match_parent"
- android:layout_width="0dp"
- android:layout_weight="2"
- android:ellipsize="end"
- android:gravity="end"
- android:maxLines="1"/>
- </LinearLayout>
-</LinearLayout>
diff --git a/android/source/res/layout/fragment_directory_browser.xml b/android/source/res/layout/fragment_directory_browser.xml
deleted file mode 100644
index 37a61fa3518c..000000000000
--- a/android/source/res/layout/fragment_directory_browser.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?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:maxLines="1"
- 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/menu/context_menu.xml b/android/source/res/menu/context_menu.xml
deleted file mode 100644
index 43824875d867..000000000000
--- a/android/source/res/menu/context_menu.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
- <item android:id="@+id/context_menu_open"
- android:title="@string/open"/>
- <item android:id="@+id/context_menu_share"
- android:title="@string/share"/>
-</menu>
diff --git a/android/source/res/menu/navigation_menu.xml b/android/source/res/menu/navigation_menu.xml
deleted file mode 100644
index ef6354b5dcff..000000000000
--- a/android/source/res/menu/navigation_menu.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <group
- android:checkableBehavior="single"
- android:id="@+id/group_providers">
-
- <item android:id="@+id/menu_provider_documents"
- android:title="@string/local_documents"
- android:icon="@drawable/ic_folder_black_24dp" />
-
- <item android:id="@+id/menu_provider_filesystem"
- android:title="@string/local_file_system"
- android:icon="@drawable/ic_storage_black_24dp"/>
-
- <item android:id="@+id/menu_provider_extsd"
- android:title="@string/external_sd_file_system"
- android:icon="@drawable/ic_sd_card_black_24dp"/>
-
- <item android:id="@+id/menu_provider_otg"
- android:title="@string/otg_file_system"
- android:icon="@drawable/ic_usb_black_24dp"/>
-
- <item android:id="@+id/menu_system_file_dialog"
- android:title="@string/system_file_selector"
- android:icon="@drawable/ic_folder_black_24dp" />
-
- </group>
-
- <group android:orderInCategory="100">
- <item android:id="@+id/menu_storage_preferences"
- android:title="@string/storage_provider_settings"
- android:icon="@drawable/ic_settings_black_24dp"/>
- </group>
-</menu>
diff --git a/android/source/res/menu/view_menu.xml b/android/source/res/menu/view_menu.xml
index 67f059647989..a40bdf5802c9 100644
--- a/android/source/res/menu/view_menu.xml
+++ b/android/source/res/menu/view_menu.xml
@@ -2,60 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
- <item
- android:id="@+id/menu_filter"
- android:title="@string/filter"
- android:icon="@drawable/ic_filter_list_black_24dp"
- app:showAsAction="ifRoom">
- <menu>
- <group
- android:checkableBehavior="single">
- <item
- android:id="@+id/menu_filter_everything"
- android:title="@string/filter_everything" />
- <item
- android:id="@+id/menu_filter_documents"
- android:title="@string/filter_documents" />
- <item
- android:id="@+id/menu_filter_spreadsheets"
- android:title="@string/filter_spreadsheets" />
- <item
- android:id="@+id/menu_filter_presentations"
- android:title="@string/filter_presentations" />
- <item
- android:id="@+id/menu_filter_drawings"
- android:title="@string/filter_drawings" />
- </group>
- </menu>
- </item>
-
- <item
- android:id="@+id/menu_sort"
- android:title="@string/sort"
- android:icon="@drawable/ic_sort_black_24dp"
- app:showAsAction="ifRoom">
- <menu>
- <group android:checkableBehavior="single">
- <item android:id="@+id/menu_sort_size_asc"
- android:title="@string/sort_smallest" />
-
- <item android:id="@+id/menu_sort_size_desc"
- android:title="@string/sort_largest" />
-
- <item android:id="@+id/menu_sort_az"
- android:title="@string/sort_az"/>
-
- <item android:id="@+id/menu_sort_za"
- android:title="@string/sort_za"/>
-
- <item android:id="@+id/menu_sort_modified_newest"
- android:title="@string/sort_newest"/>
-
- <item android:id="@+id/menu_sort_modified_oldest"
- android:title="@string/sort_oldest"/>
- </group>
- </menu>
- </item>
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"/>
diff --git a/android/source/res/values-de/strings.xml b/android/source/res/values-de/strings.xml
index 53854e94929d..639ddca4d9ef 100644
--- a/android/source/res/values-de/strings.xml
+++ b/android/source/res/values-de/strings.xml
@@ -21,67 +21,25 @@
<string name="new_drawing">Neue Zeichnung</string>
<string name="default_document_name">unbenannt</string>
- <string name="system_file_selector">System-Dateidialog</string>
<string name="select_file_to_open">Datei zum Öffnen auswählen</string>
<string name="browser_app_name">LibreOffice Browser</string>
<string name="menu_search">Suchen</string>
- <string name="list_view">Liste</string>
- <string name="grid_view">Gitter</string>
<string name="filter">Filtern nach</string>
<string name="search_not_found">Suchbegriff nicht gefunden</string>
- <string name="sort">Sortieren nach</string>
- <string name="sort_smallest">Kleinste zuerst</string>
- <string name="sort_largest">Größte zuerst</string>
- <string name="sort_az">A-Z</string>
- <string name="sort_za">Z-A</string>
- <string name="sort_oldest">Älteste zuerst</string>
- <string name="sort_newest">Neueste zuerst</string>
- <string name="menu_sort_size">Nach Größe sortieren</string>
- <string name="menu_sort_az">Von A bis Z sortieren</string>
- <string name="menu_sort_modified">Nach Datum sortieren</string>
<string name="menu_preferences">Einstellungen</string>
<string name="file_icon_desc">Datei-Icon</string>
<string name="title_recents">Zuletzt verwendete Dateien</string>
<string name="title_browser">Alle Dateien</string>
- <!-- Pref keys as resources ; Not currently used -->
- <string name="EXPLORER_VIEW_TYPE_KEY">EXPLORER_VIEW_TYPE</string>
- <string name="CURRENT_DIRECTORY_KEY">CURRENT_DIRECTORY</string>
- <string name="pref_category_explorer">Dateimanager-Einstellungen</string>
<string name="pref_category_general">Allgemein</string>
<string name="pref_experimental_editing">Experimenteller Modus</string>
<string name="pref_experimental_editing_summary">Den experimentellen Editier-Modus aktivieren. Verwendung auf eigene Gefahr.</string>
- <string name="pref_show_hidden_files">Versteckte Dateien/Ordner</string>
- <string name="pref_show_hidden_files_summary">Anzeige versteckter Dateien/Ordner aktivieren</string>
<string name="pref_developer_mode">Entwickler-Modus</string>
<string name="pref_developer_mode_summary">Entwickler-Modus, in dem in der App UNO-Kommandos gesendet werden können. Verwendung auf eigene Gefahr.</string>
<string name="action_about">Info</string>
<string name="action_parts">Abschnitte</string>
<string name="action_settings">Einstellungen</string>
- <string name="open">Öffnen</string>
- <string name="share">Teilen</string>
- <string name="share_via">Teilen via</string>
-
- <!-- Document browser filters -->
- <string name="filter_everything">Alles</string>
- <string name="filter_documents">Dokumente</string>
- <string name="filter_spreadsheets">Tabellendokumente</string>
- <string name="filter_presentations">Präsentationen</string>
- <string name="filter_drawings">Zeichnungen</string>
-
- <!-- Document provider names -->
- <string name="document_locations">Dokumentenorte</string>
- <string name="close_document_locations">Dokumentenorte schließen</string>
- <string name="local_documents">Dokumentenverzeichnis</string>
- <string name="local_file_system">Lokales Dateisystem</string>
- <string name="external_sd_file_system">Externe SD</string>
- <string name="otg_file_system">OTG-Gerät (experimentell)</string>
- <string name="usb_connected_configure">USB verbunden, richten Sie Ihr Gerät ein.</string>
-
- <string name="ext_document_provider_error">Ungültige Wurzel-Datei. Prüfen Sie die SD-Karten-Einstellungen.</string>
- <string name="legacy_extsd_missing_error">Ungültige Wurzel-Datei. Prüfen Sie die externe SD-Karte und/oder die Einstellungen</string>
- <string name="otg_missing_error">Ungültige Wurzel-Datei. Prüfen Sie Ihr OTG-Gerät und/oder die Einstellungen.</string>
<!-- Edit action names -->
<string name="action_bold">Fett</string>
@@ -100,25 +58,10 @@
<string name="message_save_incomplete">Speichern unvollständig. Gab es Änderungen?</string>
<string name="message_saving_failed">Speichern des Dokuments ist fehlgeschlagen.</string>
- <!-- Document provider settings -->
- <string name="storage_provider_settings">Speicheranbieter-Einstellungen</string>
- <string name="physical_storage_settings">Einstellungen für physikalischen Speicher</string>
- <string name="external_sd_path">Pfad zur externen SD-Karte</string>
- <string name="otg_device_path">Pfad zum OTG-Gerät</string>
- <string name="otg_warning">Experimentelles Feature: Nur verwenden, wenn OTG-Gerät beschreibbar ist.</string>
<string name="password">Passwort</string>
<string name="action_undo">Rückgängig</string>
<string name="action_redo">Wiederherstellen</string>
- <!-- Directory browser strings -->
- <string name="up_description">Nach oben</string>
- <string name="confirm_label">Bestätigen</string>
- <string name="cancel_label">Abbrechen</string>
- <string name="search_label">Los</string>
- <string name="directory_browser_label">Verzeichnis auswählen</string>
- <string name="bad_directory">Ungültiger Verzeichnispfad</string>
- <string name="current_dir">Aktuelles Verzeichnis: %1$s</string>
-
<!-- Save Alert dialog strings -->
<string name="save_alert_dialog_title">Dokument vor dem Schließen speichern?</string>
<string name="save_document">SPEICHERN</string>
@@ -207,12 +150,6 @@
<string name="alert_cancel">Abbrechen</string>
<string name="unable_to_go_further">Kann nicht weiter gehen.</string>
<string name="current_uno_command">Aktuelles UNO-Kommando</string>
- <string name="pref_sort_summary">Sortiermodus für Dateien auswählen: A-Z, nach Größe oder nach Datum.</string>
- <string name="pref_viewmode_summary">Dateien als Gitter oder als Liste anzeigen.</string>
- <string name="pref_file_explorer_title">Dateimanager-Layout</string>
- <string name="pref_sort_title">Datei-Reihenfolge</string>
- <string name="pref_filter_title">Standard-Dateifilter</string>
- <string name="pref_filter_summary">Wählen Sie, welcher Dateifilter standardmäßig verwendet werden soll.</string>
<string name="display_language">Anzeigesprache</string>
<string name="display_language_summary">Wählen Sie die Standard-Anzeigesprache</string>
<string name="unable_to_export_pdf">PDF-Export nicht möglich</string>
diff --git a/android/source/res/values-tr/strings.xml b/android/source/res/values-tr/strings.xml
index 494e0575d0d1..fe2ee5958dcc 100644
--- a/android/source/res/values-tr/strings.xml
+++ b/android/source/res/values-tr/strings.xml
@@ -23,62 +23,20 @@
<string name="browser_app_name">LibreOffice Tarayıcı</string>
<string name="menu_search">Ara</string>
- <string name="list_view">Liste</string>
- <string name="grid_view">Grid</string>
- <string name="filter">Åžununla filtrele:</string>
<string name="search_not_found">Söz dizimi bulunamadı.</string>
- <string name="sort">Şununla sırala:</string>
- <string name="sort_smallest">Küçükten büyüğe</string>
- <string name="sort_largest">Büyükten küçüğe</string>
- <string name="sort_az">A-Z</string>
- <string name="sort_za">Z-A</string>
- <string name="sort_oldest">Eskiden yeniye</string>
- <string name="sort_newest">Yeniden eskiye</string>
- <string name="menu_sort_size">Boyuta Göre Sırala</string>
- <string name="menu_sort_az">Alfabetik Sırala</string>
- <string name="menu_sort_modified">Tarihe Göre Sırala</string>
<string name="menu_preferences">Seçenekler</string>
<string name="file_icon_desc">dosya_simgesi</string>
<string name="title_recents">Son açılan dosyalar</string>
<string name="title_browser">Tüm dosyalar</string>
- <!-- Pref keys as resources ; Not currently used -->
- <string name="EXPLORER_VIEW_TYPE_KEY">EXPLORER_VIEW_TYPE</string>
- <string name="CURRENT_DIRECTORY_KEY">CURRENT_DIRECTORY</string>
- <string name="pref_category_explorer">Dosya Gezgini Ayarları</string>
<string name="pref_category_general">Genel</string>
<string name="pref_experimental_editing">Deneysel Mod</string>
<string name="pref_experimental_editing_summary">Deneysel düzenleme modunu etkinleştirin. Kullanım riski size aittir.</string>
- <string name="pref_show_hidden_files">Gizli Dosyalar ve Dizinler</string>
- <string name="pref_show_hidden_files_summary">Gizli dosyalar ve dizinleri göstermeyi etkinleştir.</string>
<string name="pref_developer_mode">GeliÅŸtirici Modu</string>
<string name="pref_developer_mode_summary">Geliştirici modunu etkinleştirerek UNO komutları gönderin. Kullanım riski size aittir.</string>
<string name="action_about">Hakkında</string>
<string name="action_parts">Bölümler</string>
<string name="action_settings">Ayarlar</string>
- <string name="open">Aç</string>
- <string name="share">PaylaÅŸ</string>
- <string name="share_via">Åžununla paylaÅŸ</string>
-
- <!-- Document browser filters -->
- <string name="filter_everything">Hepsi</string>
- <string name="filter_documents">Kelime Ä°ÅŸlemci</string>
- <string name="filter_spreadsheets">Hesap Tablosu</string>
- <string name="filter_presentations">Sunum</string>
- <string name="filter_drawings">Çizimler</string>
-
- <!-- Document provider names -->
- <string name="document_locations">Belge dizinleri</string>
- <string name="close_document_locations">Belge dizinlerini kapat</string>
- <string name="local_documents">Belgeler</string>
- <string name="local_file_system">Yerel dosya sistemi</string>
- <string name="external_sd_file_system">Harici SD</string>
- <string name="otg_file_system">OTG cihazı (deneysel)</string>
- <string name="usb_connected_configure">USB bağlantısı yapıldı, cihazınızın ayarlarını yapınız.</string>
-
- <string name="ext_document_provider_error">Geçersiz dizin. SD kart ayarlarınızı kontrol ediniz.</string>
- <string name="legacy_extsd_missing_error">Geçersiz dizin. SD kartınızı veya SD kart ayarlarınızı kontrol ediniz.</string>
- <string name="otg_missing_error">Geçersiz dizin. OTG cihazınızı veya OTG cihazı ayarlarınızı kontrol ediniz.</string>
<!-- Edit action names -->
<string name="action_bold">Kalın</string>
@@ -96,12 +54,6 @@
<string name="message_saving">Belge kaydediliyor…</string>
<string name="message_save_incomplete">Kayıt tamamlanmadı. Değişiklik yapıldı mı?</string>
- <!-- Document provider settings -->
- <string name="storage_provider_settings">Depolama sağlayıcısı ayarları</string>
- <string name="physical_storage_settings">Fiziksel depolama ayarları</string>
- <string name="external_sd_path">Harici SD yolu</string>
- <string name="otg_device_path">OTG cihazı yolu</string>
- <string name="otg_warning">Deneysel özellik: OTG cihazı yazılabilir ise kullanın</string>
<string name="password">Parola</string>
<string name="action_undo">Geri Al</string>
<string name="action_redo">Yinele</string>
@@ -203,12 +155,6 @@
<string name="alert_cancel">Ä°ptal</string>
<string name="unable_to_go_further">Daha fazla ilerlenemiyor.</string>
<string name="current_uno_command">Åžuan ki UNO komutu</string>
- <string name="pref_sort_summary">Dosyaların nasıl sıralanacağını seçiniz. A-Z, Z-A ya da boyuta göre.</string>
- <string name="pref_viewmode_summary">Dosyaları grid veya liste şeklinde görüntüle.</string>
- <string name="pref_file_explorer_title">Dosya Gezgini</string>
- <string name="pref_sort_title">Dosya Sıralaması</string>
- <string name="pref_filter_title">Varsayılan Dosya Filtrelemesi</string>
- <string name="pref_filter_summary">Varsayılan dosya filtrelemesini seç</string>
<string name="display_language">Uygulama Dili</string>
<string name="display_language_summary">Varsayılan dili değiştir</string>
<string name="unable_to_export_pdf">Pdf dışa aktarılamıyor.</string>
diff --git a/android/source/res/values/arrays.xml b/android/source/res/values/arrays.xml
index edea6443b419..832bca781572 100644
--- a/android/source/res/values/arrays.xml
+++ b/android/source/res/values/arrays.xml
@@ -1,62 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <integer-array name="FilterTypeValues">
- <item >-1</item>
- <item >0</item>
- <item >1</item>
- <item >2</item>
- </integer-array>
- <string-array name="FilterTypeStringValues">
- <item >-1</item>
- <item >0</item>
- <item >1</item>
- <item >2</item>
- <item >3</item>
- </string-array>
<string-array name="SupportedLanguagesValues">
<item>SYSTEM_DEFAULT_LANGUAGE</item>
<item >de</item>
<item >en</item>
<item >tr</item>
</string-array>
- <string-array name="SortModeStringValues">
- <item >0</item>
- <item >1</item>
- <item >2</item>
- <item >3</item>
- <item >4</item>
- <item >5</item>
- </string-array>
- <!-- View Mode names,values -->
- <string-array name="ViewModeNames">
- <item >@string/grid_view</item>
- <item >@string/list_view</item>
- </string-array>
- <string-array name="ViewModeStringValues">
- <item >0</item>
- <item >1</item>
- </string-array>
- <string-array name="FilterTypeNames">
- <item>@string/filter_everything</item>
- <item>@string/filter_documents</item>
- <item>@string/filter_spreadsheets</item>
- <item>@string/filter_presentations</item>
- <item>@string/filter_drawings</item>
- </string-array>
<string-array name="SupportedLanguages">
<item>(System Default)</item>
<item>Deutsch</item>
<item>English</item>
<item>Turkçe</item>
</string-array>
- <string-array name="SortModeNames">
- <item >@string/sort_az</item>
- <item >@string/sort_za</item>
- <item >@string/sort_oldest</item>
- <item >@string/sort_newest</item>
- <item >@string/sort_largest</item>
- <item >@string/sort_smallest</item>
- </string-array>
-
-
</resources>
diff --git a/android/source/res/values/integers.xml b/android/source/res/values/integers.xml
deleted file mode 100644
index aeb71c3997d1..000000000000
--- a/android/source/res/values/integers.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <integer name="grid_view_integer">0</integer>
-
-</resources> \ No newline at end of file
diff --git a/android/source/res/values/strings.xml b/android/source/res/values/strings.xml
index ddb396555dfc..5e7ad1e3ded7 100644
--- a/android/source/res/values/strings.xml
+++ b/android/source/res/values/strings.xml
@@ -21,67 +21,24 @@
<string name="new_drawing">New Drawing</string>
<string name="default_document_name">untitled</string>
- <string name="system_file_selector">System File Dialog</string>
<string name="select_file_to_open">Select file to open</string>
<string name="browser_app_name">LibreOffice Browser</string>
<string name="menu_search">Search</string>
- <string name="list_view">List</string>
- <string name="grid_view">Grid</string>
- <string name="filter">Filter by</string>
<string name="search_not_found">Keyword not found</string>
- <string name="sort">Sort by</string>
- <string name="sort_smallest">Smallest first</string>
- <string name="sort_largest">Largest first</string>
- <string name="sort_az">A-Z</string>
- <string name="sort_za">Z-A</string>
- <string name="sort_oldest">Oldest first</string>
- <string name="sort_newest">Newest first</string>
- <string name="menu_sort_size">Sort By Size</string>
- <string name="menu_sort_az">Sort A-Z</string>
- <string name="menu_sort_modified">Sort by Date</string>
<string name="menu_preferences">Preferences</string>
<string name="file_icon_desc">fileicon</string>
<string name="title_recents">Recent files</string>
<string name="title_browser">All files</string>
- <!-- Pref keys as resources ; Not currently used -->
- <string name="EXPLORER_VIEW_TYPE_KEY">EXPLORER_VIEW_TYPE</string>
- <string name="CURRENT_DIRECTORY_KEY">CURRENT_DIRECTORY</string>
- <string name="pref_category_explorer">File Explorer Settings</string>
<string name="pref_category_general">General</string>
<string name="pref_experimental_editing">Experimental Mode</string>
<string name="pref_experimental_editing_summary">Enable the experimental editing mode. Use at your own risk.</string>
- <string name="pref_show_hidden_files">Hidden Files/Folders</string>
- <string name="pref_show_hidden_files_summary">Enable to show hidden files/folders</string>
<string name="pref_developer_mode">Developer Mode</string>
<string name="pref_developer_mode_summary">Enable developer mode where you can send UNO commands within app. Use at your own risk.</string>
<string name="action_about">About</string>
<string name="action_parts">Parts</string>
<string name="action_settings">Settings</string>
- <string name="open">Open</string>
- <string name="share">Share</string>
- <string name="share_via">Share via</string>
-
- <!-- Document browser filters -->
- <string name="filter_everything">Everything</string>
- <string name="filter_documents">Documents</string>
- <string name="filter_spreadsheets">Spreadsheets</string>
- <string name="filter_presentations">Presentations</string>
- <string name="filter_drawings">Drawings</string>
-
- <!-- Document provider names -->
- <string name="document_locations">Document locations</string>
- <string name="close_document_locations">Close document locations</string>
- <string name="local_documents">Documents directory</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="usb_connected_configure">USB connected, configure your device.</string>
-
- <string name="ext_document_provider_error">Invalid root file. Check your sd card 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>
@@ -100,25 +57,10 @@
<string name="message_saving_failed">Saving the document failed.</string>
<string name="message_save_incomplete">Save incomplete. Were there any changes?</string>
- <!-- Document provider settings -->
- <string name="storage_provider_settings">Storage provider 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="password">Password</string>
<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>
- <string name="current_dir">Current Directory: %1$s</string>
-
<!-- Save Alert dialog strings -->
<string name="save_alert_dialog_title">Save the document before closing?</string>
<string name="save_document">SAVE</string>
@@ -207,12 +149,6 @@
<string name="alert_cancel">Cancel</string>
<string name="unable_to_go_further">Unable to go further.</string>
<string name="current_uno_command">Current UNO command</string>
- <string name="pref_sort_summary">Select how to order files: A-Z, by size or by date.</string>
- <string name="pref_viewmode_summary">View files as a grid or in a list.</string>
- <string name="pref_file_explorer_title">File explorer layout</string>
- <string name="pref_sort_title">File Order</string>
- <string name="pref_filter_title">Default File Filter</string>
- <string name="pref_filter_summary">Set which file filter should be used by default.</string>
<string name="display_language">Display Language</string>
<string name="display_language_summary">Set the default display language</string>
<string name="unable_to_export_pdf">Unable to export to pdf</string>
diff --git a/android/source/res/xml/documentprovider_preferences.xml b/android/source/res/xml/documentprovider_preferences.xml
deleted file mode 100644
index 1f4acc7b2f01..000000000000
--- a/android/source/res/xml/documentprovider_preferences.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- This file is part of the LibreOffice project.
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
- -->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
- <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>
diff --git a/android/source/res/xml/libreoffice_preferences.xml b/android/source/res/xml/libreoffice_preferences.xml
index d418dd559f86..052efacb2e3e 100644
--- a/android/source/res/xml/libreoffice_preferences.xml
+++ b/android/source/res/xml/libreoffice_preferences.xml
@@ -1,37 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
- android:title="@string/pref_category_explorer"
- android:key="PREF_CATEGORY_EXPLORER">
- <ListPreference
- android:title="@string/pref_filter_title"
- android:summary="@string/pref_filter_summary"
- android:entries="@array/FilterTypeNames"
- android:entryValues="@array/FilterTypeStringValues"
- android:defaultValue="-1"
- android:key="FILTER_MODE"/>
- <ListPreference
- android:summary="@string/pref_sort_summary"
- android:key="SORT_MODE"
- android:title="@string/pref_sort_title"
- android:entries="@array/SortModeNames"
- android:defaultValue="0"
- android:entryValues="@array/SortModeStringValues"/>
- <ListPreference
- android:entries="@array/ViewModeNames"
- android:entryValues="@array/ViewModeStringValues"
- android:defaultValue="@integer/grid_view_integer"
- android:title="@string/pref_file_explorer_title"
- android:key="EXPLORER_VIEW_TYPE"
- android:summary="@string/pref_viewmode_summary" />
-
- <CheckBoxPreference
- android:title="@string/pref_show_hidden_files"
- android:key="ENABLE_SHOW_HIDDEN_FILES"
- android:summary="@string/pref_show_hidden_files_summary"
- android:defaultValue="false" />
- </PreferenceCategory>
- <PreferenceCategory
android:title="@string/pref_category_general"
android:key="PREF_CATEGORY_GENERAL">
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index aed1cf946a69..6af44912bb52 100644
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -1,6 +1,5 @@
package org.libreoffice;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.ClipboardManager;
@@ -11,14 +10,11 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
-import android.database.Cursor;
import android.graphics.RectF;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.provider.OpenableColumns;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.DrawerLayout;
@@ -38,8 +34,6 @@ import android.widget.Toast;
import org.libreoffice.overlay.CalcHeadersController;
import org.libreoffice.overlay.DocumentOverlay;
-import org.libreoffice.storage.DocumentProviderFactory;
-import org.libreoffice.storage.IFile;
import org.libreoffice.ui.FileUtilities;
import org.libreoffice.ui.LibreOfficeUIActivity;
import org.mozilla.gecko.gfx.GeckoLayerClient;
@@ -51,7 +45,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
@@ -80,9 +73,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
private static boolean mIsDeveloperMode;
private static boolean mbISReadOnlyMode;
- private int providerId;
- private URI documentUri;
-
private DrawerLayout mDrawerLayout;
Toolbar toolbarTop;
@@ -129,7 +119,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
private static boolean isDocumentChanged = false;
private boolean isUNOCommandsToolbarOpen = false;
private boolean isNewDocument = false;
- private long lastModified = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -212,13 +201,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
} else if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_FILE)) {
mInputFile = new File(getIntent().getData().getPath());
+ mbISReadOnlyMode = true;
Log.d(LOGTAG, "SCHEME_FILE: getPath(): " + getIntent().getData().getPath());
toolbarTop.setTitle(mInputFile.getName());
- // Gather data to rebuild IFile object later
- providerId = getIntent().getIntExtra(
- "org.libreoffice.document_provider_id", 0);
- documentUri = (URI) getIntent().getSerializableExtra(
- "org.libreoffice.document_uri");
}
} else {
mInputFile = new File(DEFAULT_DOC_PATH);
@@ -234,8 +219,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
mDrawerList.setOnItemClickListener(new DocumentPartClickListener());
}
- lastModified = mInputFile.lastModified();
-
mToolbarController.setupToolbars();
TabHost host = findViewById(R.id.toolbarTabHost);
@@ -363,14 +346,12 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
}
/**
- * Save the document and invoke save on document provider to upload the file
- * to the cloud if necessary.
+ * Save the document.
*/
public void saveDocument() {
if (!mInputFile.exists()) {
// Needed for handling null in case new document is not created.
mInputFile = new File(DEFAULT_DOC_PATH);
- lastModified = mInputFile.lastModified();
}
Toast.makeText(this, R.string.message_saving, Toast.LENGTH_SHORT).show();
// local save
@@ -378,98 +359,51 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
}
public void saveFileToOriginalSource() {
- if (documentUri != null) {
- // case where file was opened using IDocumentProvider from within LO app
- saveFilesToCloud();
- } else {
- // case where file URI was passed via Intent
- if (isReadOnlyMode() || mInputFile == null || getIntent().getData() == null || !getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT))
- return;
-
- Uri uri = getIntent().getData();
- FileInputStream inputStream = null;
- OutputStream outputStream = null;
+ if (isReadOnlyMode() || mInputFile == null || getIntent().getData() == null || !getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT))
+ return;
- try {
- inputStream = new FileInputStream(mInputFile);
- // OutputStream for the actual (original) location
- outputStream = getContentResolver().openOutputStream(uri);
-
- byte[] buffer = new byte[4096];
- int readBytes = inputStream.read(buffer);
- while (readBytes != -1) {
- outputStream.write(buffer, 0, readBytes);
- readBytes = inputStream.read(buffer);
- }
+ Uri uri = getIntent().getData();
+ FileInputStream inputStream = null;
+ OutputStream outputStream = null;
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(LibreOfficeMainActivity.this, R.string.message_saved,
- Toast.LENGTH_SHORT).show();
- }
- });
- setDocumentChanged(false);
- } catch (Exception e) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(LibreOfficeMainActivity.this, R.string.message_saving_failed,
- Toast.LENGTH_SHORT).show();
- }
- });
- e.printStackTrace();
- } finally {
- try {
- if (inputStream != null)
- inputStream.close();
- if (outputStream != null)
- outputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ try {
+ inputStream = new FileInputStream(mInputFile);
+ // OutputStream for the actual (original) location
+ outputStream = getContentResolver().openOutputStream(uri);
+
+ byte[] buffer = new byte[4096];
+ int readBytes = inputStream.read(buffer);
+ while (readBytes != -1) {
+ outputStream.write(buffer, 0, readBytes);
+ readBytes = inputStream.read(buffer);
}
- }
- }
- public void saveFilesToCloud(){
- final Activity activity = LibreOfficeMainActivity.this;
- final AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
- @Override
- protected Void doInBackground(Void... params) {
- try {
- // rebuild the IFile object from the data passed in the Intent
- IFile mStorageFile = DocumentProviderFactory.getInstance()
- .getProvider(providerId).createFromUri(LibreOfficeMainActivity.this, documentUri);
- // call document provider save operation
- mStorageFile.saveDocument(mInputFile);
- }
- catch (final RuntimeException e) {
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(activity, e.getMessage(),
- Toast.LENGTH_SHORT).show();
- }
- });
- Log.e(LOGTAG, e.getMessage(), e.getCause());
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(LibreOfficeMainActivity.this, R.string.message_saved,
+ Toast.LENGTH_SHORT).show();
}
- return null;
- }
-
- @Override
- protected void onPostExecute(Void param) {
- Toast.makeText(activity, R.string.message_saved,
+ });
+ setDocumentChanged(false);
+ } catch (Exception e) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(LibreOfficeMainActivity.this, R.string.message_saving_failed,
Toast.LENGTH_SHORT).show();
- setDocumentChanged(false);
+ }
+ });
+ e.printStackTrace();
+ } finally {
+ try {
+ if (inputStream != null)
+ inputStream.close();
+ if (outputStream != null)
+ outputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
}
- };
-
- if (lastModified < mInputFile.lastModified()) {
- task.execute();
- lastModified = mInputFile.lastModified();
- } else {
- Toast.makeText(activity, R.string.message_save_incomplete, Toast.LENGTH_LONG).show();
}
}
diff --git a/android/source/src/java/org/libreoffice/storage/DocumentProviderFactory.java b/android/source/src/java/org/libreoffice/storage/DocumentProviderFactory.java
deleted file mode 100644
index 07387f1e5511..000000000000
--- a/android/source/src/java/org/libreoffice/storage/DocumentProviderFactory.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.libreoffice.storage;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.libreoffice.storage.external.ExtsdDocumentsProvider;
-import org.libreoffice.storage.external.OTGDocumentsProvider;
-import org.libreoffice.storage.local.LocalDocumentsDirectoryProvider;
-import org.libreoffice.storage.local.LocalDocumentsProvider;
-
-import android.content.Context;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-
-/**
- * Keeps the instances of the available IDocumentProviders in the system.
- * Instances are maintained in a sorted list and providers have to be
- * accessed from their position.
- *
- * The factory follows the Singleton pattern, there is only one instance of it
- * in the application and it must be retrieved with
- * DocumentProviderFactory.getInstance().
- */
-public final class DocumentProviderFactory {
- public static int EXTSD_PROVIDER_INDEX = 2;
- public static int OTG_PROVIDER_INDEX = 3;
-
- /**
- * Private factory instance for the Singleton pattern.
- */
- private static DocumentProviderFactory instance = null;
-
- private IDocumentProvider[] providers;
-
- private String[] providerNames;
-
- private DocumentProviderFactory() {
- // private to prevent external instances of the factory
- }
-
- /**
- * Initializes the factory with some context. If this method is called for
- * twice or more times those calls will have no effect.
- *
- * @param context
- * Application context for the factory.
- */
- public static void initialize(Context context) {
- if (instance == null) {
- // initialize instance
- instance = new DocumentProviderFactory();
-
- // initialize document providers list
- instance.providers = new IDocumentProvider[4];
- instance.providers[0] = new LocalDocumentsDirectoryProvider(0);
- instance.providers[1] = new LocalDocumentsProvider(1);
- instance.providers[OTG_PROVIDER_INDEX] = new OTGDocumentsProvider(OTG_PROVIDER_INDEX, context);
- instance.providers[EXTSD_PROVIDER_INDEX] = new ExtsdDocumentsProvider(EXTSD_PROVIDER_INDEX, context);
-
- // initialize document provider names list
- instance.providerNames = new String[instance.providers.length];
- for (int i = 0; i < instance.providers.length; i++) {
- instance.providerNames[i] = context.getString(instance
- .getProvider(i).getNameResource());
- }
- }
- }
-
- /**
- * Retrieve the unique instance of the factory.
- *
- * @return the unique factory object or null if it is not yet initialized.
- */
- public static DocumentProviderFactory getInstance() {
- return instance;
- }
-
- /**
- * Retrieve the provider associated to a certain id.
- *
- * @param id
- * @return document provider with that id.
- */
- public IDocumentProvider getProvider(int id) {
- // as for now, id == position in providers array
- return providers[id];
- }
-
- /**
- * Returns a sorted list of the names of the providers. Order is meaningful
- * to retrieve the actual provider object with getProvider().
- *
- * @return Array with the names of the available providers.
- */
- public String[] getNames() {
- return providerNames;
- }
-
- /**
- * Returns the default provider.
- *
- * @return default provider.
- */
- public IDocumentProvider getDefaultProvider() {
- return providers[0];
- }
-
- public Set<OnSharedPreferenceChangeListener> getChangeListeners() {
- Set<OnSharedPreferenceChangeListener> listeners =
- new HashSet<OnSharedPreferenceChangeListener>();
- for (IDocumentProvider provider : providers) {
- if (provider instanceof OnSharedPreferenceChangeListener)
- listeners.add((OnSharedPreferenceChangeListener) provider);
- }
- return listeners;
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java b/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java
deleted file mode 100644
index 55656f9d6c55..000000000000
--- a/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.libreoffice.storage;
-
-import java.util.Set;
-
-import org.libreoffice.R;
-import org.libreoffice.storage.external.BrowserSelectorActivity;
-
-import android.content.Intent;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-import android.preference.PreferenceManager;
-import android.preference.PreferenceScreen;
-import android.support.v7.app.AppCompatActivity;
-
-public class DocumentProviderSettingsActivity extends AppCompatActivity {
-
- public static final String KEY_PREF_EXTERNAL_SD_PATH_URI = "pref_extsd_path_uri";
- public static final String KEY_PREF_OTG_PATH_URI = "pref_otg_path_uri";
-
- private Set<OnSharedPreferenceChangeListener> listeners;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Display the fragment as the main content.
- getFragmentManager().beginTransaction()
- .replace(android.R.id.content, new SettingsFragment()).commit();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- listeners = DocumentProviderFactory.getInstance().getChangeListeners();
- for (OnSharedPreferenceChangeListener listener : listeners) {
- PreferenceManager.getDefaultSharedPreferences(this)
- .registerOnSharedPreferenceChangeListener(listener);
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- for (OnSharedPreferenceChangeListener listener : listeners) {
- PreferenceManager.getDefaultSharedPreferences(this)
- .unregisterOnSharedPreferenceChangeListener(listener);
- }
- }
-
- public static class SettingsFragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.documentprovider_preferences);
-
- PreferenceScreen extSDPreference =
- (PreferenceScreen)findPreference(KEY_PREF_EXTERNAL_SD_PATH_URI);
- PreferenceScreen otgPreference =
- (PreferenceScreen)findPreference(KEY_PREF_OTG_PATH_URI);
-
- extSDPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- startBrowserSelectorActivity(KEY_PREF_EXTERNAL_SD_PATH_URI,
- BrowserSelectorActivity.MODE_EXT_SD);
- return true;
- }
- });
- otgPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- startBrowserSelectorActivity(KEY_PREF_OTG_PATH_URI,
- BrowserSelectorActivity.MODE_OTG);
- return true;
- }
- });
-
- }
-
- private void startBrowserSelectorActivity(String prefKey, String mode) {
- Intent i = new Intent(getActivity(), BrowserSelectorActivity.class);
- i.putExtra(BrowserSelectorActivity.PREFERENCE_KEY_EXTRA, prefKey);
- i.putExtra(BrowserSelectorActivity.MODE_EXTRA, mode);
- startActivity(i);
- }
-
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/IDocumentProvider.java b/android/source/src/java/org/libreoffice/storage/IDocumentProvider.java
deleted file mode 100644
index 4e82e250de55..000000000000
--- a/android/source/src/java/org/libreoffice/storage/IDocumentProvider.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.libreoffice.storage;
-
-import android.content.Context;
-
-import java.net.URI;
-
-/**
- * Represents a Document Provider, an object able to provide documents from a
- * certain source (e.g. local documents, DropBox, Google Docs).
- */
-public interface IDocumentProvider {
-
- /**
- * Provides the content root element for the Document Provider.
- *
- * @return Content root element.
- * @throws RuntimeException in case of error.
- * @param context
- */
- IFile getRootDirectory(Context context);
-
- /**
- * Transforms some URI into the IFile object that represents that content.
- *
- *
- * @param context
- * @param uri
- * URI pointing to some content object that has been previously
- * retrieved with IFile.getUri().
- * @return IFile object pointing to the content represented by uri.
- * @throws RuntimeException in case of error.
- */
- IFile createFromUri(Context context, URI uri);
-
- /**
- * Get internationalized name for this provider. This name is intended to be
- * shown in the UI.
- *
- * @return string resource pointing to the provider name.
- */
- int getNameResource();
-
- /**
- * Provides the unique ID for a document provider instance in a program.
- *
- * This ID should be set when the instance is built. It could be used to
- * tell two instances of the same document provider apart.
- *
- * @return Unique ID for a document provider instance.
- */
- int getId();
-
- /**
- * Checks if the Document Provider is available or not.
- *
- * @return A boolean value based on provider availability.
- * @param context
- */
- boolean checkProviderAvailability(Context context);
-}
diff --git a/android/source/src/java/org/libreoffice/storage/IFile.java b/android/source/src/java/org/libreoffice/storage/IFile.java
deleted file mode 100644
index c9cfa7f1198d..000000000000
--- a/android/source/src/java/org/libreoffice/storage/IFile.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.libreoffice.storage;
-
-import android.content.Context;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.net.URI;
-import java.util.Date;
-import java.util.List;
-
-/**
- * An abstraction of the File class, intended to be implemented by different
- * Document Providers.
- *
- * It represents a file or a directory in the context of a certain Document
- * Provider. It wraps the file-related operations and provides access to the
- * final document as a local File, downloading it if necessary.
- */
-public interface IFile {
-
- /**
- * Provides a URI that represents this IFile object.
- *
- * @return URI that represents this IFile object in the context of the
- * Document Provider that created it. The URI can be transformed
- * back into an IFile object with IDocumentProvider.createFromUri().
- */
- URI getUri();
-
- /**
- * Returns the name of the file or directory represented by this file.
- *
- * @return This file's name.
- */
- String getName();
-
- /**
- * Indicates if this file represents a directory in the context of the
- * Document Provider which originated it.
- *
- * @return true if this file is a directory, false otherwise.
- */
- boolean isDirectory();
-
- /**
- * Returns the file size in bytes.
- *
- * @return file size in bytes, 0 if the file does not exist.
- */
- long getSize();
-
- /**
- * Returns the time when this file was last modified, measured in
- * milliseconds since January 1st, 1970, midnight.
- *
- * @return time when this file was last modified, or 0 if the file does not
- * exist.
- */
- Date getLastModified();
-
- /**
- * Returns a list containing the files in the directory represented by this
- * file.
- *
- * @return list of files contained by this directory, or an empty list if
- * this is not a directory.
- * @throws RuntimeException in case of error.
- */
- List<IFile> listFiles();
-
- /**
- * Gets the list of files contained in the directory represented by this
- * file, and filters it through some FilenameFilter.
- *
- * @param filter
- * the filter to match names against.
- * @return filtered list of files contained by this directory, or an empty
- * list if this is not a directory.
- * @throws RuntimeException in case of error.
- */
- List<IFile> listFiles(FileFilter filter);
-
- /**
- * Returns the pparent of this file.
- *
- * @return this file's parent or null if it does not have it.
- * @param context
- */
- IFile getParent(Context context);
-
- /**
- * Returns the document wrapped by this IFile as a local file. The result
- * for a directory is not defined.
- *
- * @return local file containing the document wrapped by this object.
- * @throws RuntimeException in case of error.
- */
- File getDocument();
-
- /**
- * Replaces the wrapped document with a new version of it.
- *
- * @param file
- * A local file pointing to the new version of the document.
- */
- void saveDocument(File file);
-}
diff --git a/android/source/src/java/org/libreoffice/storage/IOUtils.java b/android/source/src/java/org/libreoffice/storage/IOUtils.java
deleted file mode 100644
index f345f5cbed3b..000000000000
--- a/android/source/src/java/org/libreoffice/storage/IOUtils.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.libreoffice.storage;
-
-import android.util.Log;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * File IO related methods.
- */
-public class IOUtils {
- private static final int BUFFER_SIZE = 1024 * 8;
- private static final String LOGTAG = IOUtils.class.getSimpleName();
-
- public static File getFileFromURIString(String URIpath) throws IllegalArgumentException{
- try{
- return new File(new URI(URIpath));
- } catch (URISyntaxException e) {
- //should not happen as all URIs are system generated
- Log.wtf(LOGTAG, e.getReason());
- return null;
- }
- }
-
- public static boolean isInvalidFile(File f) {
- return f == null || !f.exists() || f.getTotalSpace() == 0
- || !f.canRead() || !f.canWrite();
- }
-
- public static int copy(InputStream input, OutputStream output) throws Exception {
- byte[] buffer = new byte[BUFFER_SIZE];
-
- BufferedInputStream in = new BufferedInputStream(input, BUFFER_SIZE);
- BufferedOutputStream out = new BufferedOutputStream(output, BUFFER_SIZE);
-
- int count = 0, n = 0;
- try {
- while ((n = in.read(buffer, 0, BUFFER_SIZE)) != -1) {
- out.write(buffer, 0, n);
- count += n;
- }
- out.flush();
- } finally {
- if (out != null) out.close();
- if (in != null) in.close();
- }
-
- return count;
- }
-
-}
diff --git a/android/source/src/java/org/libreoffice/storage/external/BrowserSelectorActivity.java b/android/source/src/java/org/libreoffice/storage/external/BrowserSelectorActivity.java
deleted file mode 100644
index 07b64623b701..000000000000
--- a/android/source/src/java/org/libreoffice/storage/external/BrowserSelectorActivity.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.libreoffice.storage.external;
-
-import android.annotation.TargetApi;
-import android.content.ContentResolver;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.UriPermission;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
-
-import org.libreoffice.R;
-import org.libreoffice.storage.DocumentProviderFactory;
-
-import java.util.Set;
-
-/**
- * Activity to select which directory browser to use.
- * Android 5+ will use the DocumentTree intent to locate a browser.
- * Android 4+ & OTG will use the internal directory browser.
- */
-public class BrowserSelectorActivity extends AppCompatActivity {
- public static final String PREFERENCE_KEY_EXTRA = "org.libreoffice.pref_key_extra";
- public static final String MODE_EXTRA = "org.libreoffice.mode_extra";
- public static final String MODE_OTG = "OTG";
- public static final String MODE_EXT_SD = "EXT_SD";
-
- private static final String LOGTAG = BrowserSelectorActivity.class.getSimpleName();
- private static final int REQUEST_DOCUMENT_TREE = 1;
- private static final int REQUEST_INTERNAL_BROWSER = 2;
- private Set<SharedPreferences.OnSharedPreferenceChangeListener> listeners;
- private String preferenceKey;
- private SharedPreferences preferences;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- preferenceKey = getIntent().getStringExtra(PREFERENCE_KEY_EXTRA);
- preferences = PreferenceManager.getDefaultSharedPreferences(this);
- String mode = getIntent().getStringExtra(MODE_EXTRA);
-
- if(mode.equals(MODE_EXT_SD)) {
- findSDCard();
- } else if (mode.equals(MODE_OTG)) {
- findOTGDevice();
- }
- }
-
- private void findOTGDevice() {
- useInternalBrowser(DocumentProviderFactory.OTG_PROVIDER_INDEX);
- }
-
- private void findSDCard() {
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- useDocumentTreeBrowser();
- } else {
- useInternalBrowser(DocumentProviderFactory.EXTSD_PROVIDER_INDEX);
- }
- }
-
- private void useInternalBrowser(int providerIndex) {
- IExternalDocumentProvider provider =
- (IExternalDocumentProvider) DocumentProviderFactory.getInstance()
- .getProvider(providerIndex);
- String previousDirectoryPath = preferences.getString(preferenceKey, provider.guessRootURI(this));
- Intent i = new Intent(this, DirectoryBrowserActivity.class);
- i.putExtra(DirectoryBrowserActivity.DIRECTORY_PATH_EXTRA, previousDirectoryPath);
- startActivityForResult(i, REQUEST_INTERNAL_BROWSER);
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- private void useDocumentTreeBrowser() {
- Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
- startActivityForResult(i, REQUEST_DOCUMENT_TREE);
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- //listeners are registered here as onActivityResult is called before onResume
- super.onActivityResult(requestCode, resultCode, data);
-
- registerListeners();
- if(resultCode == RESULT_OK) {
- switch(requestCode) {
- case REQUEST_DOCUMENT_TREE:
- Uri treeUri = data.getData();
- preferences.edit()
- .putString(preferenceKey, treeUri.toString())
- .apply();
-
- updatePersistedUriPermission(treeUri);
- getContentResolver().takePersistableUriPermission(treeUri,
- Intent.FLAG_GRANT_READ_URI_PERMISSION |
- Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- break;
-
- case REQUEST_INTERNAL_BROWSER:
- Uri fileUri = data.getData();
- preferences.edit()
- .putString(preferenceKey, fileUri.toString())
- .apply();
- break;
- default:
- }
- }
- unregisterListeners();
- Log.d(LOGTAG, "Preference saved: " +
- preferences.getString(preferenceKey, getString(R.string.directory_not_saved)));
- finish();
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- private void updatePersistedUriPermission(Uri treeUri) {
- freePreviousUriPermissions();
-
- //TODO: Use non-emulator Android 5+ device to check if needed
- /*this.grantUriPermission(this.getPackageName(),
- treeUri,
- Intent.FLAG_GRANT_READ_URI_PERMISSION |
- Intent.FLAG_GRANT_WRITE_URI_PERMISSION); */
-
- getContentResolver().takePersistableUriPermission(treeUri,
- Intent.FLAG_GRANT_READ_URI_PERMISSION |
- Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- private void freePreviousUriPermissions() {
- ContentResolver cr = getContentResolver();
- for (UriPermission uriPermission : cr.getPersistedUriPermissions()) {
- cr.releasePersistableUriPermission(uriPermission.getUri(), 0);
- }
- }
-
- private void registerListeners() {
- listeners = DocumentProviderFactory.getInstance().getChangeListeners();
- for (SharedPreferences.OnSharedPreferenceChangeListener listener : listeners) {
- PreferenceManager.getDefaultSharedPreferences(this)
- .registerOnSharedPreferenceChangeListener(listener);
- }
- }
-
- private void unregisterListeners() {
- for (SharedPreferences.OnSharedPreferenceChangeListener listener : listeners) {
- PreferenceManager.getDefaultSharedPreferences(this)
- .unregisterOnSharedPreferenceChangeListener(listener);
- }
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserActivity.java b/android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserActivity.java
deleted file mode 100644
index 1cf9f52fa7c0..000000000000
--- a/android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserActivity.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.libreoffice.storage.external;
-
-
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-
-import org.libreoffice.R;
-
-/**
- * Container for DirectoryBrowserFragment
- */
-public class DirectoryBrowserActivity extends AppCompatActivity {
- public static final String DIRECTORY_PATH_EXTRA = "org.libreoffice.directory_path_extra";
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Intent data = getIntent();
- String initialPath = data.getStringExtra(DIRECTORY_PATH_EXTRA);
-
- setContentView(R.layout.activity_directory_browser);
- FragmentManager fm = getFragmentManager();
- Fragment fragment = DirectoryBrowserFragment.newInstance(initialPath);
- fm.beginTransaction()
- .add(R.id.fragment_container, fragment)
- .commit();
- }
-
- @Override
- public void onBackPressed() {
- FragmentManager fm = getFragmentManager();
- if(fm.getBackStackEntryCount() > 0) {
- fm.popBackStack();
- } else {
- super.onBackPressed();
- }
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserFragment.java b/android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserFragment.java
deleted file mode 100644
index 18165650a617..000000000000
--- a/android/source/src/java/org/libreoffice/storage/external/DirectoryBrowserFragment.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package org.libreoffice.storage.external;
-
-import android.app.Activity;
-import android.app.Fragment;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Environment;
-import android.support.annotation.Nullable;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import org.libreoffice.R;
-import org.libreoffice.storage.IOUtils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Comparator;
-
-/**
- * A simple directory browser.
- */
-public class DirectoryBrowserFragment extends Fragment {
- private static final String LOGTAG = DirectoryBrowserFragment.class.getSimpleName();
- private static final String INITIAL_PATH_URI_KEY = "initial_path";
- private File currentDirectory;
- private FileArrayAdapter directoryAdapter;
-
- public static DirectoryBrowserFragment newInstance(String initialPathURI) {
- Bundle args = new Bundle();
- args.putString(INITIAL_PATH_URI_KEY, initialPathURI);
- DirectoryBrowserFragment fragment = new DirectoryBrowserFragment();
- fragment.setArguments(args);
- Log.d(LOGTAG, "Saved path: " + initialPathURI);
-
- return fragment;
- }
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- String initialPathURI = getArguments().getString(INITIAL_PATH_URI_KEY);
- setupCurrentDirectory(initialPathURI);
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View v = inflater.inflate(R.layout.fragment_directory_browser, container, false);
-
- final EditText directoryHeader = v.findViewById(R.id.directory_header);
- Button directorySearchButton = v.findViewById(R.id.directory_search_button);
- Button positiveButton = v.findViewById(R.id.confirm_button);
- Button negativeButton = v.findViewById(R.id.cancel_button);
- ImageView upImage = v.findViewById(R.id.up_image);
- ListView directoryListView = v.findViewById(R.id.directory_list);
-
- directoryHeader.setText(currentDirectory.getPath());
- directorySearchButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String currentPath = currentDirectory.getAbsolutePath();
- String enteredPath = directoryHeader.getText().toString();
- File testDirectory = new File(enteredPath);
- if(enteredPath.equals(currentPath)) ;
- else if (isInvalidFileDirectory(testDirectory)) {
- Toast.makeText(getActivity(), R.string.bad_directory, Toast.LENGTH_SHORT)
- .show();
- }
- else {
- changeDirectory(testDirectory);
- }
- }
- });
-
- positiveButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent data = new Intent();
- data.setData(Uri.fromFile(currentDirectory));
- getActivity().setResult(Activity.RESULT_OK, data);
- getActivity().finish();
- }
- });
-
- negativeButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- getActivity().setResult(Activity.RESULT_CANCELED, null);
- getActivity().finish();
- }
- });
-
- upImage.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- changeDirectory(currentDirectory.getParentFile());
- }
- });
-
- directoryAdapter = new FileArrayAdapter(getActivity(), new ArrayList<File>());
- directoryAdapter.populateFileList(currentDirectory);
- directoryListView.setAdapter(directoryAdapter);
- directoryListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- changeDirectory(directoryAdapter.getItem(position));
- }
- });
-
- return v;
- }
-
- private void changeDirectory(File destination) {
- if(destination == null) {
- Toast.makeText(getActivity(), R.string.unable_to_go_further, Toast.LENGTH_SHORT)
- .show();
- } else {
- Fragment fragment = DirectoryBrowserFragment.newInstance(destination.toURI().toString());
- getActivity().getFragmentManager().beginTransaction()
- .replace(R.id.fragment_container, fragment)
- .addToBackStack(null)
- .commit();
- }
- }
-
- private void setupCurrentDirectory(String initialPathURI) {
- File initialDirectory = null;
- if(initialPathURI != null && !initialPathURI.isEmpty()) {
- initialDirectory = IOUtils.getFileFromURIString(initialPathURI);
- }
-
- if(isInvalidFileDirectory(initialDirectory)) {
- initialDirectory = Environment.getExternalStorageDirectory();
- }
- currentDirectory = initialDirectory;
- }
-
- private boolean isInvalidFileDirectory(File f) {
- return f == null || !f.exists() || !f.isDirectory() ||!f.canRead();
- }
-
- private class FileArrayAdapter extends ArrayAdapter<File> {
- private Comparator<File> caseInsensitiveNaturalOrderComparator;
-
- public FileArrayAdapter(Context context, ArrayList<File> files) {
- super(context, 0, files);
- caseInsensitiveNaturalOrderComparator = new AlphabeticalFileComparator();
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = getActivity().getLayoutInflater()
- .inflate(android.R.layout.simple_list_item_1, null);
- }
-
- File f = this.getItem(position);
- TextView tv = convertView.findViewById(android.R.id.text1);
- tv.setText(f.getName());
-
- return convertView;
- }
-
- public void sortAlphabetically() {
- this.sort(caseInsensitiveNaturalOrderComparator);
- }
-
- public void populateFileList(File directory) {
- for(File f : directory.listFiles()){
- if(f.isDirectory()){
- directoryAdapter.add(f);
- }
- }
- directoryAdapter.sortAlphabetically();
- }
- }
-
- private class AlphabeticalFileComparator implements Comparator<File> {
- @Override
- public int compare(File lhs, File rhs) {
- String lhsName = lhs.getName();
- String rhsName = rhs.getName();
-
- return lhsName.compareToIgnoreCase(rhsName);
- }
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/external/ExternalFile.java b/android/source/src/java/org/libreoffice/storage/external/ExternalFile.java
deleted file mode 100644
index aff33e4413ef..000000000000
--- a/android/source/src/java/org/libreoffice/storage/external/ExternalFile.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.libreoffice.storage.external;
-
-import android.content.Context;
-import android.support.v4.provider.DocumentFile;
-import android.util.Log;
-
-import org.libreoffice.storage.IFile;
-import org.libreoffice.storage.IOUtils;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Implementation of IFile for the external file system, for Android 4.4+
- *
- * Uses the DocumentFile class.
- *
- * The DocumentFile class obfuscates the path of the files it wraps,
- * preventing usage of LOK's documentLoad method. A copy of the DocumentFile's contents
- * will be created in the cache when files are opened, allowing use of documentLoad.
- */
-public class ExternalFile implements IFile{
- private final static String LOGTAG = "ExternalFile";
-
- private ExtsdDocumentsProvider provider;
- private DocumentFile docFile;
- private File duplicateFile;
- private Context context;
-
- public ExternalFile(ExtsdDocumentsProvider provider, DocumentFile docFile, Context context) {
- this.provider = provider;
- this.context = context;
- this.docFile = docFile;
- }
-
- @Override
- public URI getUri() {
- try{
- return new URI(docFile.toString());
- } catch (URISyntaxException e) {
- Log.e(LOGTAG, e.getMessage(), e.getCause());
- return null;
- }
- }
-
- @Override
- public String getName() {
- return docFile.getName();
- }
-
- @Override
- public boolean isDirectory() {
- return docFile.isDirectory();
- }
-
- @Override
- public long getSize() {
- return docFile.length();
- }
-
- @Override
- public Date getLastModified() {
- return new Date(docFile.lastModified());
- }
-
- @Override
- public List<IFile> listFiles() {
- List<IFile> children = new ArrayList<IFile>();
- for (DocumentFile child : docFile.listFiles()) {
- children.add(new ExternalFile(provider, child, context));
- }
- return children;
- }
-
- @Override
- public List<IFile> listFiles(FileFilter filter) {
- File file;
- try{
- List<IFile> children = new ArrayList<IFile>();
- for (DocumentFile child : docFile.listFiles()) {
- file = new File(new URI(child.getUri().toString()));
- if(filter.accept(file))
- children.add(new ExternalFile(provider, child, context));
- }
- return children;
-
- }catch (Exception e){
- e.printStackTrace();
- }
- /* if something goes wrong */
- return listFiles();
-
- }
-
- @Override
- public IFile getParent(Context context) {
- // this is the root node
- if(docFile.getParentFile() == null) return null;
-
- return new ExternalFile(provider, docFile.getParentFile(), this.context);
- }
-
- @Override
- public File getDocument() {
- if(isDirectory()) {
- return null;
- } else {
- duplicateFile = duplicateInCache();
- return duplicateFile;
- }
- }
-
- private File duplicateInCache() {
- try{
- InputStream istream = context.getContentResolver().
- openInputStream(docFile.getUri());
-
- File storageFolder = provider.getCacheDir();
- File fileCopy = new File(storageFolder, docFile.getName());
- OutputStream ostream = new FileOutputStream(fileCopy);
-
- IOUtils.copy(istream, ostream);
- return fileCopy;
- } catch (Exception e) {
- Log.e(LOGTAG, e.getMessage(), e.getCause());
- return null;
- }
- }
-
- @Override
- public void saveDocument(File file) {
- try{
- OutputStream ostream = context.getContentResolver().
- openOutputStream(docFile.getUri());
- InputStream istream = new FileInputStream(file);
-
- IOUtils.copy(istream, ostream);
-
- } catch (Exception e) {
- Log.e(LOGTAG, e.getMessage(), e.getCause());
- }
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object)
- return true;
- if (!(object instanceof ExternalFile))
- return false;
- ExternalFile file = (ExternalFile) object;
- return file.getUri().equals(getUri());
- }
-
-}
diff --git a/android/source/src/java/org/libreoffice/storage/external/ExtsdDocumentsProvider.java b/android/source/src/java/org/libreoffice/storage/external/ExtsdDocumentsProvider.java
deleted file mode 100644
index e45929374bbd..000000000000
--- a/android/source/src/java/org/libreoffice/storage/external/ExtsdDocumentsProvider.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package org.libreoffice.storage.external;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Environment;
-import android.preference.PreferenceManager;
-import android.support.v4.content.ContextCompat;
-import android.support.v4.provider.DocumentFile;
-import android.util.Log;
-
-import org.libreoffice.R;
-import org.libreoffice.storage.DocumentProviderSettingsActivity;
-import org.libreoffice.storage.IFile;
-
-import java.io.File;
-import java.net.URI;
-
-/**
- * Implementation of IDocumentProvider for the external file system, for android 4.4+
- *
- * The DocumentFile class is required when accessing files in external storage
- * for Android 4.4+. The ExternalFile class is used to handle this.
- *
- * Android 4.4 & 5+ use different types of root directory paths,
- * 5 using a DirectoryTree Uri and 4.4 using a normal File path.
- * As such, different methods are required to obtain the rootDirectory IFile.
- * 4.4 has to guess the location of the rootDirectory as well.
- */
-public class ExtsdDocumentsProvider implements IExternalDocumentProvider,
- OnSharedPreferenceChangeListener{
- private static final String LOGTAG = ExtsdDocumentsProvider.class.getSimpleName();
-
- private int id;
- private File cacheDir;
- private String rootPathURI;
-
- public ExtsdDocumentsProvider(int id, Context context) {
- this.id = id;
- setupRootPathUri(context);
- setupCache(context);
- }
-
- private void setupRootPathUri(Context context) {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- rootPathURI = preferences.getString(
- DocumentProviderSettingsActivity.KEY_PREF_EXTERNAL_SD_PATH_URI, guessRootURI(context));
- }
-
- public String guessRootURI(Context context) {
- // TODO: unfortunately the getExternalFilesDirs function relies on devices to actually
- // follow guidelines re external storage. Of course device manufacturers don't and as such
- // you cannot rely on it returning the actual paths (neither the compat, nor the native variant)
- File[] possibleRemovables = ContextCompat.getExternalFilesDirs(context,null);
- // the primary dir that is already covered by the "LocalDocumentsProvider"
- // might be emulated/part of internal memory or actual SD card
- // TODO: change to not confuse android's "external storage" with "expandable storage"
- String primaryExternal = Environment.getExternalStorageDirectory().getAbsolutePath();
-
- for (File option: possibleRemovables) {
- // Returned paths may be null if a storage device is unavailable.
- if (null == option) {
- Log.w(LOGTAG,"path was a null option :-/"); continue; }
- String optionPath = option.getAbsolutePath();
- if(optionPath.contains(primaryExternal)) {
- Log.v(LOGTAG, "did get file path - but is same as primary storage ("+ primaryExternal +")");
- continue;
- }
-
- return option.toURI().toString();
- }
-
- // TODO: do some manual probing of possible directories (/storage/sdcard1 and similar)
- Log.i(LOGTAG, "no secondary storage reported");
- return null;
- }
-
- private void setupCache(Context context) {
- // TODO: probably we should do smarter cache management
- cacheDir = new File(context.getExternalCacheDir(), "externalFiles");
- if (cacheDir.exists()) {
- deleteRecursive(cacheDir);
- }
- cacheDir.mkdirs();
- }
-
- private static void deleteRecursive(File file) {
- if (file.isDirectory()) {
- for (File child : file.listFiles())
- deleteRecursive(child);
- }
- file.delete();
- }
-
- public File getCacheDir() {
- return cacheDir;
- }
-
- @Override
- public IFile getRootDirectory(Context context) {
- if(android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
- return android4RootDirectory(context);
- } else {
- return android5RootDirectory(context);
- }
- }
-
- private ExternalFile android4RootDirectory(Context context) {
- try{
- File f = new File(new URI(rootPathURI));
- return new ExternalFile(this, DocumentFile.fromFile(f), context);
- } catch (Exception e) {
- //invalid rootPathURI
- throw buildRuntimeExceptionForInvalidFileURI(context);
- }
- }
-
- private ExternalFile android5RootDirectory(Context context) {
- try {
- return new ExternalFile(this,
- DocumentFile.fromTreeUri(context, Uri.parse(rootPathURI)),
- context);
- } catch (Exception e) {
- //invalid rootPathURI
- throw buildRuntimeExceptionForInvalidFileURI(context);
- }
- }
-
- private RuntimeException buildRuntimeExceptionForInvalidFileURI(Context context) {
- // ToDo: discarding the original exception / catch-all handling is bad style
- return new RuntimeException(context.getString(R.string.ext_document_provider_error));
- }
-
- @Override
- public IFile createFromUri(Context context, URI javaURI) {
- //TODO: refactor when new DocumentFile API exist
- //uri must be of a DocumentFile file, not directory.
- Uri androidUri = Uri.parse(javaURI.toString());
- return new ExternalFile(this,
- DocumentFile.fromSingleUri(context, androidUri),
- context);
- }
-
- @Override
- public int getNameResource() {
- return R.string.external_sd_file_system;
- }
-
- @Override
- public int getId() {
- return id;
- }
-
- @Override
- public boolean checkProviderAvailability(Context context) {
- // too many devices (or I am just unlucky) don't report the mounted state properly, and other
- // devices also consider dedicated part of internal storage to be "mounted" so cannot use
- // getExternalStorageState().equals(Environment.MEDIA_MOUNTED) && isExternalStorageRemovable()
- // but they refer to the primary external storage anyway, so what currently is covered by the
- // "LocalDocumentsProvider"
- return rootPathURI!=null && ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
- if (key.equals(DocumentProviderSettingsActivity.KEY_PREF_EXTERNAL_SD_PATH_URI)) {
- rootPathURI = preferences.getString(key, "");
- }
- }
-
-}
diff --git a/android/source/src/java/org/libreoffice/storage/external/IExternalDocumentProvider.java b/android/source/src/java/org/libreoffice/storage/external/IExternalDocumentProvider.java
deleted file mode 100644
index a439417b60cd..000000000000
--- a/android/source/src/java/org/libreoffice/storage/external/IExternalDocumentProvider.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.libreoffice.storage.external;
-
-import android.content.Context;
-
-import org.libreoffice.storage.IDocumentProvider;
-
-
-/**
- * Interface for external document providers.
- */
-public interface IExternalDocumentProvider extends IDocumentProvider {
-
- /**
- * Used to obtain the default directory to display when
- * browsing using the internal DirectoryBrowser.
- *
- * @return a guess of the root file's URI.
- * @param context
- */
- String guessRootURI(Context context);
-
-}
diff --git a/android/source/src/java/org/libreoffice/storage/external/OTGDocumentsProvider.java b/android/source/src/java/org/libreoffice/storage/external/OTGDocumentsProvider.java
deleted file mode 100644
index 4341bc3541e6..000000000000
--- a/android/source/src/java/org/libreoffice/storage/external/OTGDocumentsProvider.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.libreoffice.storage.external;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.preference.PreferenceManager;
-import android.util.Log;
-
-import org.libreoffice.R;
-import org.libreoffice.storage.DocumentProviderSettingsActivity;
-import org.libreoffice.storage.IFile;
-import org.libreoffice.storage.IOUtils;
-import org.libreoffice.storage.local.LocalFile;
-
-import java.io.File;
-import java.net.URI;
-
-/**
- * TODO: OTG currently uses LocalFile. Change to an IFile that handles abrupt OTG unmounting
- */
-public class OTGDocumentsProvider implements IExternalDocumentProvider,
- SharedPreferences.OnSharedPreferenceChangeListener {
-
- private static final String LOGTAG = OTGDocumentsProvider.class.getSimpleName();
-
- private String rootPathURI;
- private int id;
-
- public OTGDocumentsProvider(int id, Context context) {
- this.id = id;
- setupRootPath(context);
- }
-
- private void setupRootPath(Context context) {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- rootPathURI = preferences.getString(
- DocumentProviderSettingsActivity.KEY_PREF_OTG_PATH_URI, "");
- }
-
- @Override
- public IFile createFromUri(Context context, URI uri) {
- return new LocalFile(uri);
- }
-
- @Override
- public int getNameResource() {
- return R.string.otg_file_system;
- }
-
- @Override
- public int getId() {
- return id;
- }
-
- @Override
- public IFile getRootDirectory(Context context) {
- // TODO: handle this with more fine-grained exceptions
- if(rootPathURI.equals("")) {
- Log.e(LOGTAG, "rootPathURI is empty");
- throw new RuntimeException(context.getString(R.string.ext_document_provider_error));
- }
-
- File f = IOUtils.getFileFromURIString(rootPathURI);
- if(IOUtils.isInvalidFile(f)) {
- Log.e(LOGTAG, "rootPathURI is invalid - missing device?");
- throw new RuntimeException(context.getString(R.string.otg_missing_error));
- }
-
- return new LocalFile(f);
- }
-
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (key.equals(DocumentProviderSettingsActivity.KEY_PREF_OTG_PATH_URI)) {
- rootPathURI = sharedPreferences.getString(key, "");
- }
- }
-
- @Override
- public String guessRootURI(Context context) {
- return "";
- }
-
- @Override
- public boolean checkProviderAvailability(Context context) {
- // check if system supports USB Host
- return rootPathURI.length()>0 && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST);
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java b/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
deleted file mode 100644
index 15522e93a45e..000000000000
--- a/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.libreoffice.storage.local;
-
-import java.io.File;
-
-import org.libreoffice.storage.IFile;
-import org.libreoffice.R;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.os.Environment;
-import android.support.v4.content.ContextCompat;
-import android.util.Log;
-
-/**
- * A convenience IDocumentProvider to browse the /sdcard/Documents directory.
- *
- * Extends LocalDocumentsProvider to overwrite getRootDirectory and set it to
- * /sdcard/Documents. Most documents will probably be stored there so there is
- * no need for the user to browse the filesystem from the root every time.
- */
-public class LocalDocumentsDirectoryProvider extends LocalDocumentsProvider {
-
- public LocalDocumentsDirectoryProvider(int id) {
- super(id);
- }
-
- private static File getDocumentsDir() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- // DIRECTORY_DOCUMENTS is 19 or later only
- return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
- } else {
- return new File(Environment.getExternalStorageDirectory() + "/Documents");
- }
- }
-
- @Override
- public IFile getRootDirectory(Context context) {
- File documentsDirectory = getDocumentsDir();
- if (!documentsDirectory.exists()) {
- if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
- if(!documentsDirectory.mkdirs()) {
- // fallback to the toplevel dir - might be due to the dir not mounted/used as USB-Mass-Storage or similar
- // TODO: handle unavailability of the storage/failure of the mkdir properly
- Log.e("LocalDocumentsProvider", "not sure how we ended up here - if we have read permissions to use it in the first place, we also should have the write-permissions..");
- documentsDirectory = Environment.getExternalStorageDirectory();
- }
- }
- }
- return new LocalFile(documentsDirectory);
- }
-
- @Override
- public int getNameResource() {
- return R.string.local_documents;
- }
-
- @Override
- public boolean checkProviderAvailability(Context context) {
- File documentsDirectory = getDocumentsDir();
- return documentsDirectory.exists() && ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java b/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java
deleted file mode 100644
index 1a10fad424db..000000000000
--- a/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.libreoffice.storage.local;
-
-import java.net.URI;
-
-import org.libreoffice.storage.IDocumentProvider;
-import org.libreoffice.storage.IFile;
-
-import org.libreoffice.R;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Environment;
-import android.support.v4.content.ContextCompat;
-
-/**
- * Implementation of IDocumentProvider for the local file system.
- */
-public class LocalDocumentsProvider implements IDocumentProvider {
-
- private int id;
-
- public LocalDocumentsProvider(int id) {
- this.id = id;
- }
-
- @Override
- public IFile getRootDirectory(Context context) {
- return new LocalFile(Environment.getExternalStorageDirectory());
- }
-
- @Override
- public IFile createFromUri(Context context, URI uri) {
- return new LocalFile(uri);
- }
-
- @Override
- public int getNameResource() {
- return R.string.local_file_system;
- }
-
- @Override
- public int getId() {
- return id;
- }
-
- @Override
- public boolean checkProviderAvailability(Context context) {
- return ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
- }
-}
diff --git a/android/source/src/java/org/libreoffice/storage/local/LocalFile.java b/android/source/src/java/org/libreoffice/storage/local/LocalFile.java
deleted file mode 100644
index 4ff5bbf119f4..000000000000
--- a/android/source/src/java/org/libreoffice/storage/local/LocalFile.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.libreoffice.storage.local;
-
-import android.content.Context;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.libreoffice.storage.IFile;
-
-/**
- * Implementation of IFile for the local file system.
- */
-public class LocalFile implements IFile {
-
- private File file;
-
- public LocalFile(File file) {
- this.file = file;
- }
-
- public LocalFile(URI uri) {
- this.file = new File(uri);
- }
-
- public URI getUri() {
- return file.toURI();
- }
-
- public String getName() {
- return file.getName();
- }
-
- @Override
- public boolean isDirectory() {
- return file.isDirectory();
- }
-
- @Override
- public long getSize() {
- return file.length();
- }
-
- @Override
- public Date getLastModified() {
- return new Date(file.lastModified());
- }
-
- @Override
- public List<IFile> listFiles() {
- List<IFile> children = new ArrayList<IFile>();
- for (File child : file.listFiles()) {
- children.add(new LocalFile(child));
- }
- return children;
- }
-
- @Override
- public List<IFile> listFiles(FileFilter filter) {
- List<IFile> children = new ArrayList<IFile>();
- for (File child : file.listFiles(filter)) {
- children.add(new LocalFile(child));
- }
- return children;
- }
-
- @Override
- public IFile getParent(Context context) {
- return new LocalFile(file.getParentFile());
- }
-
- @Override
- public File getDocument() {
- return file;
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object)
- return true;
- if (!(object instanceof LocalFile))
- return false;
- LocalFile file = (LocalFile) object;
- return file.getUri().equals(getUri());
- }
-
- @Override
- public void saveDocument(File file) {
- // do nothing; file is local
- }
-}
diff --git a/android/source/src/java/org/libreoffice/ui/FileUtilities.java b/android/source/src/java/org/libreoffice/ui/FileUtilities.java
index 5a4224f2ceb9..5bcc48d31141 100644
--- a/android/source/src/java/org/libreoffice/ui/FileUtilities.java
+++ b/android/source/src/java/org/libreoffice/ui/FileUtilities.java
@@ -8,17 +8,9 @@
*/
package org.libreoffice.ui;
-import org.libreoffice.storage.IFile;
-
import java.io.File;
-import java.io.FileFilter;
-import java.io.FilenameFilter;
-import java.text.Collator;
import java.util.Map;
-import java.util.Collections;
-import java.util.List;
import java.util.HashMap;
-import java.util.Comparator;
import android.content.ContentResolver;
import android.database.Cursor;
@@ -41,17 +33,6 @@ public class FileUtilities {
static final int UNKNOWN = 10;
- static final int SORT_AZ = 0;
- static final int SORT_ZA = 1;
- /** Oldest Files First*/
- static final int SORT_OLDEST = 2;
- /** Newest Files First*/
- static final int SORT_NEWEST = 3;
- /** Largest Files First */
- static final int SORT_LARGEST = 4;
- /** Smallest Files First */
- static final int SORT_SMALLEST = 5;
-
public static final String DEFAULT_WRITER_EXTENSION = ".odt";
public static final String DEFAULT_IMPRESS_EXTENSION = ".odp";
public static final String DEFAULT_SPREADSHEET_EXTENSION = ".ods";
@@ -183,81 +164,6 @@ public class FileUtilities {
return true;
}
- static FileFilter getFileFilter(final int mode) {
- return new FileFilter() {
- public boolean accept(File pathname) {
- if (pathname.isDirectory())
- return true;
- if (lookupExtension(pathname.getName()) == UNKNOWN)
- return false;
- return doAccept(pathname.getName(), mode, "");
- }
- };
- }
-
- static FilenameFilter getFilenameFilter(final int mode) {
- return new FilenameFilter() {
- public boolean accept(File dir, String filename) {
- if (new File(dir , filename).isDirectory())
- return true;
- return doAccept(filename, mode, "");
- }
- };
- }
-
- static void sortFiles(List<IFile> files, int sortMode) {
- if (files == null)
- return;
- // Compare filenames in the default locale
- final Collator mCollator = Collator.getInstance();
- switch (sortMode) {
- case SORT_AZ:
- Collections.sort(files , new Comparator<IFile>() {
- public int compare(IFile lhs, IFile rhs) {
- return mCollator.compare(lhs.getName(), rhs.getName());
- }
- });
- break;
- case SORT_ZA:
- Collections.sort(files , new Comparator<IFile>() {
- public int compare(IFile lhs, IFile rhs) {
- return mCollator.compare(rhs.getName(), lhs.getName());
- }
- });
- break;
- case SORT_OLDEST:
- Collections.sort(files , new Comparator<IFile>() {
- public int compare(IFile lhs, IFile rhs) {
- return lhs.getLastModified().compareTo(rhs.getLastModified());
- }
- });
- break;
- case SORT_NEWEST:
- Collections.sort(files , new Comparator<IFile>() {
- public int compare(IFile lhs, IFile rhs) {
- return rhs.getLastModified().compareTo(lhs.getLastModified());
- }
- });
- break;
- case SORT_LARGEST:
- Collections.sort(files , new Comparator<IFile>() {
- public int compare(IFile lhs, IFile rhs) {
- return Long.valueOf(rhs.getSize()).compareTo(lhs.getSize());
- }
- });
- break;
- case SORT_SMALLEST:
- Collections.sort(files , new Comparator<IFile>() {
- public int compare(IFile lhs, IFile rhs) {
- return Long.valueOf(lhs.getSize()).compareTo(rhs.getSize());
- }
- });
- break;
- default:
- Log.e(LOGTAG, "uncatched sortMode: " + sortMode);
- }
- }
-
static boolean isHidden(File file) {
return file.getName().startsWith(".");
}
@@ -266,20 +172,6 @@ public class FileUtilities {
return isHidden(file) && file.getName().endsWith(".png");
}
- static boolean hasThumbnail(File file) {
- String filename = file.getName();
- if (lookupExtension(filename) == DOC) // only do this for docs for now
- {
- // Will need another method to check if Thumb is up-to-date - or extend this one?
- return new File(file.getParent(), getThumbnailName(file)).isFile();
- }
- return true;
- }
-
- static String getThumbnailName(File file) {
- return "." + file.getName().split("[.]")[0] + ".png" ;
- }
-
/**
* Tries to retrieve the display (which should be the document name)
* for the given URI using the given resolver.
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
index 3236b53e7dc5..9f89bbedc525 100644
--- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -9,85 +9,48 @@
package org.libreoffice.ui;
-import android.Manifest;
-import android.app.Activity;
import android.content.ActivityNotFoundException;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
-import android.database.Cursor;
import android.graphics.drawable.Icon;
-import android.hardware.usb.UsbManager;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.provider.OpenableColumns;
-import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.NavigationView;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
-import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
-import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLongClickListener;
-import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.OvershootInterpolator;
-import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.libreoffice.AboutDialogFragment;
-import org.libreoffice.LOKitShell;
import org.libreoffice.LibreOfficeMainActivity;
import org.libreoffice.LocaleHelper;
import org.libreoffice.R;
import org.libreoffice.SettingsActivity;
import org.libreoffice.SettingsListenerModel;
-import org.libreoffice.storage.DocumentProviderFactory;
-import org.libreoffice.storage.DocumentProviderSettingsActivity;
-import org.libreoffice.storage.IDocumentProvider;
-import org.libreoffice.storage.IFile;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FilenameFilter;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.SimpleDateFormat;
+
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
public class LibreOfficeUIActivity extends AppCompatActivity implements SettingsListenerModel.OnSettingsPreferenceChangedListener, View.OnClickListener{
public enum DocumentType {
@@ -99,37 +62,13 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
}
private String LOGTAG = LibreOfficeUIActivity.class.getSimpleName();
- private SharedPreferences prefs;
- private int filterMode = FileUtilities.ALL;
- private int viewMode;
- private int sortMode;
- private boolean showHiddenFiles;
- private String displayLanguage;
-
- // dynamic permissions IDs
- private static final int PERMISSION_WRITE_EXTERNAL_STORAGE = 0;
-
- FileFilter fileFilter;
- FilenameFilter filenameFilter;
- private List<IFile> filePaths = new ArrayList<IFile>();
- private DocumentProviderFactory documentProviderFactory;
- private IDocumentProvider documentProvider;
- private IFile homeDirectory;
- private IFile currentDirectory;
- private int currentlySelectedFile;
private DocumentType newDocType = DocumentType.INVALID;
- private static final String CURRENT_DIRECTORY_KEY = "CURRENT_DIRECTORY";
- private static final String DOC_PROVIDER_KEY = "CURRENT_DOCUMENT_PROVIDER";
- private static final String FILTER_MODE_KEY = "FILTER_MODE";
- public static final String EXPLORER_VIEW_TYPE_KEY = "EXPLORER_VIEW_TYPE";
public static final String EXPLORER_PREFS_KEY = "EXPLORER_PREFS";
- public static final String SORT_MODE_KEY = "SORT_MODE";
private static final String RECENT_DOCUMENTS_KEY = "RECENT_DOCUMENT_URIS";
// delimiter used for storing multiple URIs in a string
private static final String RECENT_DOCUMENTS_DELIMITER = " ";
- private static final String ENABLE_SHOW_HIDDEN_FILES_KEY = "ENABLE_SHOW_HIDDEN_FILES";
private static final String DISPLAY_LANGUAGE = "DISPLAY_LANGUAGE";
public static final String NEW_DOC_TYPE_KEY = "NEW_DOC_TYPE_KEY";
@@ -178,19 +117,9 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
"image/svg+xml",
};
- public static final int GRID_VIEW = 0;
- public static final int LIST_VIEW = 1;
-
private static final int REQUEST_CODE_OPEN_FILECHOOSER = 12345;
private static final int REQUEST_CODE_CREATE_NEW_DOCUMENT = 12346;
- private DrawerLayout drawerLayout;
- private NavigationView navigationDrawer;
- private ActionBar actionBar;
- private ActionBarDrawerToggle drawerToggle;
- private RecyclerView fileRecyclerView;
- private RecyclerView recentRecyclerView;
-
private Animation fabOpenAnimation;
private Animation fabCloseAnimation;
private boolean isFabMenuOpen = false;
@@ -203,28 +132,15 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
private LinearLayout writerLayout;
private LinearLayout impressLayout;
private LinearLayout calcLayout;
- private LinearLayout systemFilePickerLayout;
- private TextView openFileView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // initialize document provider factory
- DocumentProviderFactory.initialize(this);
- documentProviderFactory = DocumentProviderFactory.getInstance();
-
- PreferenceManager.setDefaultValues(this, R.xml.documentprovider_preferences, false);
readPreferences();
SettingsListenerModel.getInstance().setListener(this);
- // Registering the USB detect broadcast receiver
- IntentFilter filter = new IntentFilter();
- filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
- filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
- registerReceiver(mUSBReceiver, filter);
- // init UI and populate with contents from the provider
-
+ // init UI
createUI();
fabOpenAnimation = AnimationUtils.loadAnimation(this, R.anim.fab_open);
fabCloseAnimation = AnimationUtils.loadAnimation(this, R.anim.fab_close);
@@ -236,15 +152,14 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
}
public void createUI() {
-
setContentView(R.layout.activity_document_browser);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
- actionBar = getSupportActionBar();
+ ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setIcon(R.drawable.lo_icon);
}
editFAB = findViewById(R.id.editFAB);
@@ -261,11 +176,13 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
impressLayout = findViewById(R.id.impressLayout);
calcLayout = findViewById(R.id.calcLayout);
drawLayout = findViewById(R.id.drawLayout);
- openFileView = findViewById(R.id.open_file_view);
+ TextView openFileView = findViewById(R.id.open_file_view);
openFileView.setOnClickListener(this);
- recentRecyclerView = findViewById(R.id.list_recent);
+ RecyclerView recentRecyclerView = findViewById(R.id.list_recent);
+
+ SharedPreferences prefs = getSharedPreferences(EXPLORER_PREFS_KEY, MODE_PRIVATE);
String recentPref = prefs.getString(RECENT_DOCUMENTS_KEY, "");
List<String> recentFileStrings = Arrays.asList(recentPref.split(RECENT_DOCUMENTS_DELIMITER));
@@ -280,95 +197,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
recentRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
recentRecyclerView.setAdapter(new RecentFilesAdapter(this, recentFiles));
-
- fileRecyclerView = findViewById(R.id.file_recycler_view);
- systemFilePickerLayout = findViewById(R.id.system_file_picker_layout);
- //This should be tested because it possibly disables view recycling
- fileRecyclerView.setNestedScrollingEnabled(false);
- openDirectory(currentDirectory);
- registerForContextMenu(fileRecyclerView);
-
- //Setting up navigation drawer
- drawerLayout = findViewById(R.id.drawer_layout);
- navigationDrawer = findViewById(R.id.navigation_drawer);
-
- final ArrayList<CharSequence> providerNames = new ArrayList<CharSequence>(
- Arrays.asList(documentProviderFactory.getNames())
- );
-
- // Loop through the document providers menu items and check if they are available or not
- for (int index = 0; index < providerNames.size(); index++) {
- MenuItem item = navigationDrawer.getMenu().getItem(index);
- item.setEnabled(documentProviderFactory.getProvider(index).checkProviderAvailability(this));
- }
-
- navigationDrawer.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
- @Override
- public boolean onNavigationItemSelected(@NonNull MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.menu_storage_preferences: {
- startActivity(new Intent(LibreOfficeUIActivity.this, DocumentProviderSettingsActivity.class));
- return true;
- }
-
- case R.id.menu_provider_documents: {
- switchToDocumentProvider(documentProviderFactory.getProvider(0));
- return true;
- }
-
- case R.id.menu_provider_filesystem: {
- switchToDocumentProvider(documentProviderFactory.getProvider(1));
- return true;
- }
-
- case R.id.menu_provider_extsd: {
- switchToDocumentProvider(documentProviderFactory.getProvider(2));
- return true;
- }
-
- case R.id.menu_provider_otg: {
- switchToDocumentProvider(documentProviderFactory.getProvider(3));
- return true;
- }
-
- case R.id.menu_system_file_dialog: {
- switchToSystemFileDialogLayout();
- return true;
- }
-
- default:
- return false;
- }
-
-
- }
- });
- drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
- R.string.document_locations, R.string.close_document_locations) {
-
- @Override
- public void onDrawerOpened(View drawerView) {
- super.onDrawerOpened(drawerView);
- supportInvalidateOptionsMenu();
- navigationDrawer.requestFocus(); // Make keypad navigation easier
- if (isFabMenuOpen) {
- collapseFabMenu(); //Collapse FAB Menu when drawer is opened
- }
- }
-
- @Override
- public void onDrawerClosed(View drawerView) {
- super.onDrawerClosed(drawerView);
- supportInvalidateOptionsMenu();
- }
- };
- drawerToggle.setDrawerIndicatorEnabled(true);
- drawerLayout.addDrawerListener(drawerToggle);
- drawerToggle.syncState();
-
- // initially show layout with item to open system file picker
- switchToSystemFileDialogLayout();
}
private void expandFabMenu() {
@@ -398,42 +226,8 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
}
@Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
-
- drawerToggle.syncState();
- }
-
- private void refreshView() {
- // enable home icon as "up" if required
- if (currentDirectory != null && homeDirectory != null && !currentDirectory.equals(homeDirectory)) {
- drawerToggle.setDrawerIndicatorEnabled(false);
- } else {
- drawerToggle.setDrawerIndicatorEnabled(true);
- }
-
- FileUtilities.sortFiles(filePaths, sortMode);
- // refresh view
- fileRecyclerView.setLayoutManager(isViewModeList() ? new LinearLayoutManager(this) : new GridLayoutManager(this, 3));
- fileRecyclerView.setAdapter(new ExplorerItemAdapter(this, filePaths));
- // close drawer if it was open
- drawerLayout.closeDrawer(navigationDrawer);
- if (isFabMenuOpen) {
- collapseFabMenu();
- }
- }
-
- @Override
public void onBackPressed() {
- if (drawerLayout.isDrawerOpen(navigationDrawer)) {
- drawerLayout.closeDrawer(navigationDrawer);
- if (isFabMenuOpen) {
- collapseFabMenu();
- }
- } else if (currentDirectory != null && homeDirectory != null && !currentDirectory.equals(homeDirectory)) {
- // navigate upwards in directory hierarchy
- openParentDirectory();
- } else if (isFabMenuOpen) {
+ if (isFabMenuOpen) {
collapseFabMenu();
} else {
super.onBackPressed();
@@ -441,32 +235,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
}
@Override
- public void onCreateContextMenu(ContextMenu menu, View v,
- ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, v, menuInfo);
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.context_menu, menu);
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.context_menu_open:
- open(currentlySelectedFile);
- return true;
- case R.id.context_menu_share:
- share(currentlySelectedFile);
- return true;
- default:
- return super.onContextItemSelected(item);
- }
- }
-
- private boolean isViewModeList(){
- return viewMode == LIST_VIEW;
- }
-
- @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_OPEN_FILECHOOSER && resultCode == RESULT_OK) {
final Uri fileUri = data.getData();
@@ -495,172 +263,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
}
}
-
- private void switchToDocumentProvider(IDocumentProvider provider) {
- fileRecyclerView.setVisibility(View.VISIBLE);
- systemFilePickerLayout.setVisibility(View.GONE);
-
- new AsyncTask<IDocumentProvider, Void, Void>() {
- @Override
- protected Void doInBackground(IDocumentProvider... provider) {
- // switch document provider:
- // these operations may imply network access and must be run in
- // a different thread
- try {
- homeDirectory = provider[0].getRootDirectory(LibreOfficeUIActivity.this);
- List<IFile> paths = homeDirectory.listFiles(FileUtilities
- .getFileFilter(filterMode));
- filePaths = new ArrayList<IFile>();
- for(IFile file: paths) {
- if(showHiddenFiles){
- filePaths.add(file);
- } else {
- if(!file.getName().startsWith(".")){
- filePaths.add(file);
- }
- }
- }
- }
- catch (final RuntimeException e) {
- final Activity activity = LibreOfficeUIActivity.this;
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(activity, e.getMessage(),
- Toast.LENGTH_SHORT).show();
- }
- });
- startActivity(new Intent(activity, DocumentProviderSettingsActivity.class));
- Log.e(LOGTAG, "failed to switch document provider "+ e.getMessage(), e.getCause());
- return null;
- }
- //no exception
- documentProvider = provider[0];
- currentDirectory = homeDirectory;
- return null;
- }
-
- @Override
- protected void onPostExecute(Void result) {
- refreshView();
- }
- }.execute(provider);
- }
-
- private void switchToSystemFileDialogLayout() {
- fileRecyclerView.setVisibility(View.GONE);
- findViewById(R.id.text_directory_path).setVisibility(View.GONE);
- systemFilePickerLayout.setVisibility(View.VISIBLE);
- refreshView();
- }
-
- public void openDirectory(IFile dir) {
- if (dir == null)
- return;
-
- //show recent files if in home directory
- if (dir.equals(homeDirectory)) {
- recentRecyclerView.setVisibility(View.VISIBLE);
- findViewById(R.id.header_browser).setVisibility((View.VISIBLE));
- findViewById(R.id.header_recents).setVisibility((View.VISIBLE));
- actionBar.setTitle(R.string.app_name);
- findViewById(R.id.text_directory_path).setVisibility(View.GONE);
- } else {
- recentRecyclerView.setVisibility(View.GONE);
- findViewById(R.id.header_browser).setVisibility((View.GONE));
- findViewById(R.id.header_recents).setVisibility((View.GONE));
- actionBar.setTitle(dir.getName());
- findViewById(R.id.text_directory_path).setVisibility(View.VISIBLE);
- ((TextView)findViewById(R.id.text_directory_path)).setText(getString(R.string.current_dir,
- dir.getUri().getPath()));
- }
-
- new AsyncTask<IFile, Void, Void>() {
- @Override
- protected Void doInBackground(IFile... dir) {
- // get list of files:
- // this operation may imply network access and must be run in
- // a different thread
- currentDirectory = dir[0];
- try {
- List<IFile> paths = currentDirectory.listFiles(FileUtilities
- .getFileFilter(filterMode));
- filePaths = new ArrayList<IFile>();
- for(IFile file: paths) {
- if(showHiddenFiles){
- filePaths.add(file);
- } else {
- if(!file.getName().startsWith(".")){
- filePaths.add(file);
- }
- }
- }
- }
- catch (final RuntimeException e) {
- final Activity activity = LibreOfficeUIActivity.this;
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(activity, e.getMessage(),
- Toast.LENGTH_SHORT).show();
- }
- });
- Log.e(LOGTAG, e.getMessage(), e.getCause());
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(Void result) {
- refreshView();
- }
- }.execute(dir);
- }
-
- public void open(final IFile document) {
- new AsyncTask<IFile, Void, File>() {
- @Override
- protected File doInBackground(IFile... document) {
- // this operation may imply network access and must be run in
- // a different thread
- try {
- return document[0].getDocument();
- }
- catch (final RuntimeException e) {
- final Activity activity = LibreOfficeUIActivity.this;
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(activity, e.getMessage(),
- Toast.LENGTH_SHORT).show();
- }
- });
- Log.e(LOGTAG, e.getMessage(), e.getCause());
- return null;
- }
- }
-
- @Override
- protected void onPostExecute(File file) {
- if (file != null) {
- Intent i = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
- String packageName = getApplicationContext().getPackageName();
- ComponentName componentName = new ComponentName(packageName,
- LibreOfficeMainActivity.class.getName());
- i.setComponent(componentName);
-
- // these extras allow to rebuild the IFile object in LOMainActivity
- i.putExtra("org.libreoffice.document_provider_id",
- documentProvider.getId());
- i.putExtra("org.libreoffice.document_uri",
- document.getUri());
-
- startActivity(i);
- }
- }
- }.execute(document);
- }
-
public void openDocument(final Uri documentUri) {
// "forward" to LibreOfficeMainActivity to open the file
Intent intent = new Intent(Intent.ACTION_VIEW, documentUri);
@@ -722,212 +324,17 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
startActivity(intent);
}
- private void open(int position) {
- IFile file = filePaths.get(position);
- if (!file.isDirectory()) {
- open(file);
- } else {
- openDirectory(file);
- }
- }
-
- private void openParentDirectory() {
- new AsyncTask<Void, Void, IFile>() {
- @Override
- protected IFile doInBackground(Void... dir) {
- // this operation may imply network access and must be run in
- // a different thread
- return currentDirectory.getParent(LibreOfficeUIActivity.this);
- }
-
- @Override
- protected void onPostExecute(IFile result) {
- openDirectory(result);
- }
- }.execute();
- }
-
- private void share(int position) {
-
- new AsyncTask<IFile, Void, File>() {
- @Override
- protected File doInBackground(IFile... document) {
- // this operation may imply network access and must be run in
- // a different thread
- try {
- return document[0].getDocument();
- } catch (final RuntimeException e) {
- final Activity activity = LibreOfficeUIActivity.this;
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(activity, e.getMessage(),
- Toast.LENGTH_SHORT).show();
- }
- });
- Log.e(LOGTAG, e.getMessage(), e.getCause());
- return null;
- }
- }
-
- @Override
- protected void onPostExecute(File file) {
- if (file != null) {
- Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
- Uri uri = Uri.fromFile(file);
- sharingIntent.setType(FileUtilities.getMimeType(file.getName()));
- sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, uri);
- sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
- file.getName());
- startActivity(Intent.createChooser(sharingIntent,
- getString(R.string.share_via)));
- }
- }
- }.execute(filePaths.get(position));
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.view_menu, menu);
- switch (sortMode) {
- case FileUtilities.SORT_SMALLEST: {
- menu.findItem(R.id.menu_sort_size_asc).setChecked(true);
- }
- break;
-
- case FileUtilities.SORT_LARGEST: {
- menu.findItem(R.id.menu_sort_size_desc).setChecked(true);
- }
- break;
-
- case FileUtilities.SORT_AZ: {
- menu.findItem(R.id.menu_sort_az).setChecked(true);
- }
- break;
-
- case FileUtilities.SORT_ZA: {
- menu.findItem(R.id.menu_sort_za).setChecked(true);
- }
- break;
-
- case FileUtilities.SORT_NEWEST: {
- menu.findItem(R.id.menu_sort_modified_newest).setChecked(true);
- }
- break;
-
- case FileUtilities.SORT_OLDEST: {
- menu.findItem(R.id.menu_sort_modified_oldest).setChecked(true);
- }
- break;
- }
-
- switch (filterMode) {
- case FileUtilities.ALL:
- menu.findItem(R.id.menu_filter_everything).setChecked(true);
- break;
-
- case FileUtilities.DOC:
- menu.findItem(R.id.menu_filter_documents).setChecked(true);
- break;
-
- case FileUtilities.CALC:
- menu.findItem(R.id.menu_filter_presentations).setChecked(true);
- break;
-
- case FileUtilities.IMPRESS:
- menu.findItem(R.id.menu_filter_presentations).setChecked(true);
- break;
-
- case FileUtilities.DRAWING:
- menu.findItem(R.id.menu_filter_drawings).setChecked(true);
- break;
- }
-
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- // Will close the drawer if the home button is pressed
- if (drawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
-
switch (item.getItemId()) {
- case android.R.id.home:
- if (!currentDirectory.equals(homeDirectory)){
- openParentDirectory();
- }
- break;
-
- case R.id.menu_filter_everything:
- item.setChecked(true);
- filterMode = FileUtilities.ALL;
- openDirectory(currentDirectory);
- break;
-
- case R.id.menu_filter_documents:
- item.setChecked(true);
- filterMode = FileUtilities.DOC;
- openDirectory(currentDirectory);
- break;
-
- case R.id.menu_filter_spreadsheets:
- item.setChecked(true);
- filterMode = FileUtilities.CALC;
- openDirectory(currentDirectory);
- break;
-
- case R.id.menu_filter_presentations:
- item.setChecked(true);
- filterMode = FileUtilities.IMPRESS;
- openDirectory(currentDirectory);
- break;
-
- case R.id.menu_filter_drawings:
- item.setChecked(true);
- filterMode = FileUtilities.DRAWING;
- openDirectory(currentDirectory);
- break;
-
- case R.id.menu_sort_size_asc: {
- sortMode = FileUtilities.SORT_SMALLEST;
- this.onResume();
- }
- break;
-
- case R.id.menu_sort_size_desc: {
- sortMode = FileUtilities.SORT_LARGEST;
- this.onResume();
- }
- break;
-
- case R.id.menu_sort_az: {
- sortMode = FileUtilities.SORT_AZ;
- this.onResume();
- }
- break;
-
- case R.id.menu_sort_za: {
- sortMode = FileUtilities.SORT_ZA;
- this.onResume();
- }
- break;
-
- case R.id.menu_sort_modified_newest: {
- sortMode = FileUtilities.SORT_NEWEST;
- this.onResume();
- }
- break;
-
- case R.id.menu_sort_modified_oldest: {
- sortMode = FileUtilities.SORT_OLDEST;
- this.onResume();
- }
- break;
-
case R.id.action_about: {
AboutDialogFragment aboutDialogFragment = new AboutDialogFragment();
aboutDialogFragment.show(getSupportFragmentManager(), "AboutDialogFragment");
@@ -940,154 +347,28 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
default:
return super.onOptionsItemSelected(item);
}
- return true;
}
public void readPreferences(){
- prefs = getSharedPreferences(EXPLORER_PREFS_KEY, MODE_PRIVATE);
- sortMode = prefs.getInt(SORT_MODE_KEY, FileUtilities.SORT_AZ);
SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
- viewMode = Integer.valueOf(defaultPrefs.getString(EXPLORER_VIEW_TYPE_KEY, ""+ GRID_VIEW));
- filterMode = Integer.valueOf(defaultPrefs.getString(FILTER_MODE_KEY , "-1"));
- showHiddenFiles = defaultPrefs.getBoolean(ENABLE_SHOW_HIDDEN_FILES_KEY, false);
- displayLanguage = defaultPrefs.getString(DISPLAY_LANGUAGE, LocaleHelper.SYSTEM_DEFAULT_LANGUAGE);
-
- Intent i = this.getIntent();
- if (i.hasExtra(CURRENT_DIRECTORY_KEY)) {
- try {
- currentDirectory = documentProvider.createFromUri(this, new URI(
- i.getStringExtra(CURRENT_DIRECTORY_KEY)));
- } catch (URISyntaxException e) {
- currentDirectory = documentProvider.getRootDirectory(this);
- }
- Log.d(LOGTAG, CURRENT_DIRECTORY_KEY);
- }
-
- if (i.hasExtra(FILTER_MODE_KEY)) {
- filterMode = i.getIntExtra( FILTER_MODE_KEY, FileUtilities.ALL);
- Log.d(LOGTAG, FILTER_MODE_KEY);
- }
-
- if (i.hasExtra(EXPLORER_VIEW_TYPE_KEY)) {
- viewMode = i.getIntExtra( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
- Log.d(LOGTAG, EXPLORER_VIEW_TYPE_KEY);
- }
-
+ final String displayLanguage = defaultPrefs.getString(DISPLAY_LANGUAGE, LocaleHelper.SYSTEM_DEFAULT_LANGUAGE);
LocaleHelper.setLocale(this, displayLanguage);
}
@Override
public void settingsPreferenceChanged(SharedPreferences sharedPreferences, String key) {
readPreferences();
- refreshView();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- // TODO Auto-generated method stub
- super.onSaveInstanceState(outState);
-
- if(currentDirectory != null) {
- outState.putString(CURRENT_DIRECTORY_KEY, currentDirectory.getUri().toString());
- Log.d(LOGTAG, currentDirectory.toString() + Integer.toString(filterMode) + Integer.toString(viewMode));
- }
- outState.putInt(FILTER_MODE_KEY, filterMode);
- outState.putInt(EXPLORER_VIEW_TYPE_KEY , viewMode);
- if(documentProvider != null)
- outState.putInt(DOC_PROVIDER_KEY, documentProvider.getId());
-
- outState.putBoolean(ENABLE_SHOW_HIDDEN_FILES_KEY , showHiddenFiles);
-
- //prefs.edit().putInt(EXPLORER_VIEW_TYPE, viewType).commit();
- Log.d(LOGTAG, "savedInstanceState");
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onRestoreInstanceState(savedInstanceState);
- if (savedInstanceState.isEmpty()){
- return;
- }
- if (documentProvider == null) {
- Log.d(LOGTAG, "onRestoreInstanceState - documentProvider is null");
- documentProvider = DocumentProviderFactory.getInstance()
- .getProvider(savedInstanceState.getInt(DOC_PROVIDER_KEY));
- }
- try {
- currentDirectory = documentProvider.createFromUri(this, new URI(
- savedInstanceState.getString(CURRENT_DIRECTORY_KEY)));
- } catch (URISyntaxException e) {
- currentDirectory = documentProvider.getRootDirectory(this);
- }
- filterMode = savedInstanceState.getInt(FILTER_MODE_KEY, FileUtilities.ALL);
- viewMode = savedInstanceState.getInt(EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
- showHiddenFiles = savedInstanceState.getBoolean(ENABLE_SHOW_HIDDEN_FILES_KEY, false);
- //openDirectory(currentDirectory);
- Log.d(LOGTAG, "onRestoreInstanceState");
- Log.d(LOGTAG, currentDirectory.toString() + Integer.toString(filterMode) + Integer.toString(viewMode));
- }
-
- private final BroadcastReceiver mUSBReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
- Toast.makeText(context, R.string.usb_connected_configure, Toast.LENGTH_SHORT).show();
- startActivity(new Intent(context, DocumentProviderSettingsActivity.class));
- Log.d(LOGTAG, "USB device attached");
- } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
- Log.d(LOGTAG, "USB device detached");
- }
- }
- };
- @Override
- protected void onPause() {
- super.onPause();
- Log.d(LOGTAG, "onPause");
}
@Override
protected void onResume() {
super.onResume();
Log.d(LOGTAG, "onResume");
- Log.d(LOGTAG, "sortMode="+ sortMode + " filterMode=" + filterMode);
createUI();
}
- @Override
- protected void onStart() {
- super.onStart();
- if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
- Log.i(LOGTAG, "no permission to read external storage - asking for permission");
- ActivityCompat.requestPermissions(this,
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- PERMISSION_WRITE_EXTERNAL_STORAGE);
- } else {
- switchToDocumentProvider(documentProviderFactory.getDefaultProvider());
- setEditFABVisibility(View.VISIBLE);
- }
- Log.d(LOGTAG, "onStart");
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- Log.d(LOGTAG, "onStop");
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- unregisterReceiver(mUSBReceiver);
- Log.d(LOGTAG, "onDestroy");
- }
-
- private int dpToPx(int dp){
- final float scale = getApplicationContext().getResources().getDisplayMetrics().density;
- return (int) (dp * scale + 0.5f);
- }
-
private void addDocumentToRecents(Uri fileUri) {
+ SharedPreferences prefs = getSharedPreferences(EXPLORER_PREFS_KEY, MODE_PRIVATE);
if (Build.VERSION.SDK_INT < 19) {
// ContentResolver#takePersistableUriPermission only available from SDK level 19 on
Log.i(LOGTAG, "Recently used files not supported, requires SDK version >= 19.");
@@ -1211,141 +492,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
break;
}
}
-
-
- class ExplorerItemAdapter extends RecyclerView.Adapter<ExplorerItemAdapter.ViewHolder> {
-
- private Activity mActivity;
- private List<IFile> filePaths;
- private final long KB = 1024;
- private final long MB = 1048576;
-
- ExplorerItemAdapter(Activity activity, List<IFile> filePaths) {
- this.mActivity = activity;
- this.filePaths = filePaths;
- }
-
- @Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View item = LayoutInflater.from(parent.getContext())
- .inflate(isViewModeList() ? R.layout.file_list_item : R.layout.file_explorer_grid_item, parent, false);
- return new ViewHolder(item);
- }
-
- @Override
- public void onBindViewHolder(final ViewHolder holder, final int position) {
- final IFile file = filePaths.get(position);
-
- holder.itemView.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- open(holder.getAdapterPosition());
- }
- });
- holder.itemView.setOnLongClickListener(new OnLongClickListener() {
-
- @Override
- public boolean onLongClick(View view) {
- //to be picked out by floating context menu (workaround-ish)
- currentlySelectedFile = holder.getAdapterPosition();
- //must return false so the click is not consumed
- return false;
- }
- });
-
- holder.filenameView.setText(file.getName());
- switch (FileUtilities.getType(file.getName())) {
- case FileUtilities.DOC:
- holder.iconView.setImageResource(R.drawable.writer);
- break;
- case FileUtilities.CALC:
- holder.iconView.setImageResource(R.drawable.calc);
- break;
- case FileUtilities.DRAWING:
- holder.iconView.setImageResource(R.drawable.draw);
- break;
- case FileUtilities.IMPRESS:
- holder.iconView.setImageResource(R.drawable.impress);
- break;
- }
-
- if (file.isDirectory()) {
- //Eventually have thumbnails of each sub file on a black circle
- //For now just a folder icon
- holder.iconView.setImageResource(R.drawable.ic_folder_black_24dp);
- holder.iconView.setColorFilter(ContextCompat.getColor(mActivity, R.color.text_color_secondary));
- }
-
- // Date and Size field only exist when we are displaying items in a list.
- if(isViewModeList()) {
- if (!file.isDirectory()) {
- String size;
- long length = filePaths.get(position).getSize();
- if (length < KB) {
- size = Long.toString(length) + "B";
- } else if (length < MB) {
- size = Long.toString(length / KB) + "KB";
- } else {
- size = Long.toString(length / MB) + "MB";
- }
- holder.fileSizeView.setText(size);
- }
- SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy hh:ss");
- Date date = file.getLastModified();
- //TODO format date
- holder.fileDateView.setText(df.format(date));
- }
- }
-
- @Override
- public int getItemCount() {
- return filePaths.size();
- }
-
- class ViewHolder extends RecyclerView.ViewHolder {
-
- View itemView;
- TextView filenameView, fileSizeView, fileDateView;
- ImageView iconView;
-
- ViewHolder(View itemView) {
- super(itemView);
- this.itemView = itemView;
- filenameView = itemView.findViewById(R.id.file_item_name);
- iconView = itemView.findViewById(R.id.file_item_icon);
- // Check if view mode is List, only then initialise Size and Date field
- if (isViewModeList()) {
- fileSizeView = itemView.findViewById(R.id.file_item_size);
- fileDateView = itemView.findViewById(R.id.file_item_date);
- }
- }
- }
- }
-
- private void setEditFABVisibility(final int visibility){
- LOKitShell.getMainHandler().post(new Runnable() {
- @Override
- public void run() {
- editFAB.setVisibility(visibility);
- }
- });
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- switch(requestCode){
- case PERMISSION_WRITE_EXTERNAL_STORAGE:
- if(permissions.length>0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
- switchToDocumentProvider(documentProviderFactory.getDefaultProvider());
- setEditFABVisibility(View.VISIBLE);
- } else {
- setEditFABVisibility(View.INVISIBLE);
- }
- break;
- default:
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
- }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */