summaryrefslogtreecommitdiff
path: root/android/source/src/java/org/libreoffice/storage/local
diff options
context:
space:
mode:
Diffstat (limited to 'android/source/src/java/org/libreoffice/storage/local')
-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
3 files changed, 0 insertions, 236 deletions
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
- }
-}