import android.widget.Toast;
import com.owncloud.android.authentication.AccountAuthenticator;
-import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileUploader;
private ArrayList<Parcelable> mStreamsToUpload;
private boolean mCreateDir;
private String mUploadPath;
- private DataStorageManager mStorageManager;
+ private FileDataStorageManager mStorageManager;
private OCFile mFile;
private final static int DIALOG_NO_ACCOUNT = 0;
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// click on folder in the list
Log_OC.d(TAG, "on item click");
- Vector<OCFile> tmpfiles = mStorageManager.getDirectoryContent(mFile);
+ Vector<OCFile> tmpfiles = mStorageManager.getFolderContent(mFile);
if (tmpfiles.size() <= 0) return;
// filter on dirtype
Vector<OCFile> files = new Vector<OCFile>();
for (OCFile f : tmpfiles)
- if (f.isDirectory())
+ if (f.isFolder())
files.add(f);
if (files.size() < position) {
throw new IndexOutOfBoundsException("Incorrect item selected");
mFile = mStorageManager.getFileByPath(full_path);
if (mFile != null) {
- Vector<OCFile> files = mStorageManager.getDirectoryContent(mFile);
+ Vector<OCFile> files = mStorageManager.getFolderContent(mFile);
List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();
for (OCFile f : files) {
HashMap<String, Object> h = new HashMap<String, Object>();
- if (f.isDirectory()) {
+ if (f.isFolder()) {
h.put("dirname", f.getFileName());
data.add(h);
}
+++ /dev/null
-/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
- * Copyright (C) 2012-2013 ownCloud Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.datamodel;
-
-import java.util.List;
-import java.util.Vector;
-
-public interface DataStorageManager {
-
- public static final int ROOT_PARENT_ID = 0;
-
- public OCFile getFileByPath(String path);
-
- public OCFile getFileById(long id);
-
- public boolean fileExists(String path);
-
- public boolean fileExists(long id);
-
- public boolean saveFile(OCFile file);
-
- public void saveFiles(List<OCFile> files);
-
- public Vector<OCFile> getDirectoryContent(OCFile f);
-
- public void removeFile(OCFile file, boolean removeLocalCopy);
-
- public void removeDirectory(OCFile dir, boolean removeDBData, boolean removeLocalContent);
-
- public void moveDirectory(OCFile dir, String newPath);
-
- public Vector<OCFile> getDirectoryImages(OCFile mParentFolder);
-
- public void calculateFolderSize(long id);
-
-}
import java.util.List;
import java.util.Vector;
-import com.owncloud.android.DisplayUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.db.ProviderMeta;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import android.net.Uri;
import android.os.RemoteException;
-public class FileDataStorageManager implements DataStorageManager {
+public class FileDataStorageManager {
+
+ public static final int ROOT_PARENT_ID = 0;
private ContentResolver mContentResolver;
- private ContentProviderClient mContentProvider;
+ private ContentProviderClient mContentProviderClient;
private Account mAccount;
- private static String TAG = "FileDataStorageManager";
+ private static String TAG = FileDataStorageManager.class.getSimpleName();
+
public FileDataStorageManager(Account account, ContentResolver cr) {
- mContentProvider = null;
+ mContentProviderClient = null;
mContentResolver = cr;
mAccount = account;
}
public FileDataStorageManager(Account account, ContentProviderClient cp) {
- mContentProvider = cp;
+ mContentProviderClient = cp;
mContentResolver = null;
mAccount = account;
}
- @Override
+
+ public void setAccount(Account account) {
+ mAccount = account;
+ }
+
+ public Account getAccount() {
+ return mAccount;
+ }
+
+ public void setContentResolver(ContentResolver cr) {
+ mContentResolver = cr;
+ }
+
+ public ContentResolver getContentResolver() {
+ return mContentResolver;
+ }
+
+ public void setContentProviderClient(ContentProviderClient cp) {
+ mContentProviderClient = cp;
+ }
+
+ public ContentProviderClient getContentProviderClient() {
+ return mContentProviderClient;
+ }
+
+
public OCFile getFileByPath(String path) {
Cursor c = getCursorForValue(ProviderTableMeta.FILE_PATH, path);
OCFile file = null;
file = createFileInstance(c);
}
c.close();
- if (file == null && OCFile.PATH_SEPARATOR.equals(path)) {
+ if (file == null && OCFile.ROOT_PATH.equals(path)) {
return createRootDir(); // root should always exist
}
return file;
}
- private OCFile createRootDir() {
- OCFile file = new OCFile(OCFile.PATH_SEPARATOR);
- file.setMimetype("DIR");
- file.setParentId(DataStorageManager.ROOT_PARENT_ID);
- saveFile(file);
- return file;
- }
-
- @Override
public OCFile getFileById(long id) {
Cursor c = getCursorForValue(ProviderTableMeta._ID, String.valueOf(id));
OCFile file = null;
return file;
}
- @Override
public boolean fileExists(long id) {
return fileExists(ProviderTableMeta._ID, String.valueOf(id));
}
- @Override
public boolean fileExists(String path) {
return fileExists(ProviderTableMeta.FILE_PATH, path);
}
- @Override
+
+ public Vector<OCFile> getFolderContent(OCFile f) {
+ if (f != null && f.isFolder() && f.getFileId() != -1) {
+ return getFolderContent(f.getFileId());
+
+ } else {
+ return new Vector<OCFile>();
+ }
+ }
+
+
+ public Vector<OCFile> getFolderImages(OCFile folder) {
+ Vector<OCFile> ret = new Vector<OCFile>();
+ if (folder != null) {
+ // TODO better implementation, filtering in the access to database (if possible) instead of here
+ Vector<OCFile> tmp = getFolderContent(folder);
+ OCFile current = null;
+ for (int i=0; i<tmp.size(); i++) {
+ current = tmp.get(i);
+ if (current.isImage()) {
+ ret.add(current);
+ }
+ }
+ }
+ return ret;
+ }
+
+
public boolean saveFile(OCFile file) {
boolean overriden = false;
ContentValues cv = new ContentValues();
//if (file.getParentId() != DataStorageManager.ROOT_PARENT_ID)
cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
- if (!file.isDirectory())
+ if (!file.isFolder())
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
new String[] { String.valueOf(file.getFileId()) });
} else {
try {
- getContentProvider().update(ProviderTableMeta.CONTENT_URI,
+ getContentProviderClient().update(ProviderTableMeta.CONTENT_URI,
cv, ProviderTableMeta._ID + "=?",
new String[] { String.valueOf(file.getFileId()) });
} catch (RemoteException e) {
ProviderTableMeta.CONTENT_URI_FILE, cv);
} else {
try {
- result_uri = getContentProvider().insert(
+ result_uri = getContentProviderClient().insert(
ProviderTableMeta.CONTENT_URI_FILE, cv);
} catch (RemoteException e) {
Log_OC.e(TAG,
}
}
- if (file.isDirectory()) {
+ if (file.isFolder()) {
calculateFolderSize(file.getFileId());
if (file.needsUpdatingWhileSaving()) {
- for (OCFile f : getDirectoryContent(file))
+ for (OCFile f : getFolderContent(file))
saveFile(f);
}
}
- if (changesSizeOfAncestors || file.isDirectory()) {
+ if (changesSizeOfAncestors || file.isFolder()) {
updateSizesToTheRoot(file.getParentId());
}
}
- @Override
public void saveFiles(List<OCFile> files) {
Iterator<OCFile> filesIt = files.iterator();
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype());
cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
- if (file.getParentId() != DataStorageManager.ROOT_PARENT_ID)
+ if (file.getParentId() != FileDataStorageManager.ROOT_PARENT_ID)
cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
- if (!file.isDirectory())
+ if (!file.isFolder())
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
OCFile oldFile = getFileByPath(file.getRemotePath());
file.setFileId(oldFile.getFileId());
- if (file.isDirectory()) {
+ if (file.isFolder()) {
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength());
file.setFileLength(oldFile.getFileLength());
}
if (file.getStoragePath() == null && oldFile.getStoragePath() != null)
file.setStoragePath(oldFile.getStoragePath());
- if (!file.isDirectory())
+ if (!file.isFolder())
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
else {
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength());
results = getContentResolver().applyBatch(ProviderMeta.AUTHORITY_FILES, operations);
} else {
- results = getContentProvider().applyBatch(operations);
+ results = getContentProviderClient().applyBatch(operations);
}
} catch (OperationApplicationException e) {
}
for (OCFile aFile : files) {
- if (aFile.isDirectory() && aFile.needsUpdatingWhileSaving())
- saveFiles(getDirectoryContent(aFile));
+ if (aFile.isFolder() && aFile.needsUpdatingWhileSaving())
+ saveFiles(getFolderContent(aFile));
}
}
- public void setAccount(Account account) {
- mAccount = account;
- }
- public Account getAccount() {
- return mAccount;
+ /**
+ * Calculate and save the folderSize on DB
+ * @param id
+ */
+ public void calculateFolderSize(long id) {
+ long folderSize = 0;
+
+ Vector<OCFile> files = getFolderContent(id);
+
+ for (OCFile f: files)
+ {
+ folderSize = folderSize + f.getFileLength();
+ }
+
+ updateSize(id, folderSize);
}
-
- public void setContentResolver(ContentResolver cr) {
- mContentResolver = cr;
+
+
+ public void removeFile(OCFile file, boolean removeLocalCopy) {
+ Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
+ if (getContentProviderClient() != null) {
+ try {
+ getContentProviderClient().delete(file_uri,
+ ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
+ new String[]{mAccount.name});
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ } else {
+ getContentResolver().delete(file_uri,
+ ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
+ new String[]{mAccount.name});
+ }
+ if (file.isDown() && removeLocalCopy) {
+ new File(file.getStoragePath()).delete();
+ }
+ if (file.isFolder() && removeLocalCopy) {
+ File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
+ if (f.exists() && f.isDirectory() && (f.list() == null || f.list().length == 0)) {
+ f.delete();
+ }
+ }
+
+ if (file.getFileLength() > 0) {
+ updateSizesToTheRoot(file.getParentId());
+ }
}
- public ContentResolver getContentResolver() {
- return mContentResolver;
+ public void removeFolder(OCFile folder, boolean removeDBData, boolean removeLocalContent) {
+ // TODO consider possible failures
+ if (folder != null && folder.isFolder() && folder.getFileId() != -1) {
+ Vector<OCFile> children = getFolderContent(folder);
+ if (children.size() > 0) {
+ OCFile child = null;
+ for (int i=0; i<children.size(); i++) {
+ child = children.get(i);
+ if (child.isFolder()) {
+ removeFolder(child, removeDBData, removeLocalContent);
+ } else {
+ if (removeDBData) {
+ removeFile(child, removeLocalContent);
+ } else if (removeLocalContent) {
+ if (child.isDown()) {
+ new File(child.getStoragePath()).delete();
+ }
+ }
+ }
+ }
+ }
+ if (removeDBData) {
+ removeFile(folder, true);
+ }
+
+ if (folder.getFileLength() > 0) {
+ updateSizesToTheRoot(folder.getParentId());
+ }
+ }
}
- public void setContentProvider(ContentProviderClient cp) {
- mContentProvider = cp;
- }
- public ContentProviderClient getContentProvider() {
- return mContentProvider;
- }
-
- @Override
- public Vector<OCFile> getDirectoryContent(OCFile f) {
- if (f != null && f.isDirectory() && f.getFileId() != -1) {
- return getDirectoryContent(f.getFileId());
+ /**
+ * Updates database for a folder that was moved to a different location.
+ *
+ * TODO explore better (faster) implementations
+ * TODO throw exceptions up !
+ */
+ public void moveFolder(OCFile folder, String newPath) {
+ // TODO check newPath
+
+ if (folder != null && folder.isFolder() && folder.fileExists() && !OCFile.ROOT_PATH.equals(folder.getFileName())) {
+ /// 1. get all the descendants of 'dir' in a single QUERY (including 'dir')
+ Cursor c = null;
+ if (getContentProviderClient() != null) {
+ try {
+ c = getContentProviderClient().query(ProviderTableMeta.CONTENT_URI,
+ null,
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ",
+ new String[] { mAccount.name, folder.getRemotePath() + "%" }, ProviderTableMeta.FILE_PATH + " ASC ");
+ } catch (RemoteException e) {
+ Log_OC.e(TAG, e.getMessage());
+ }
+ } else {
+ c = getContentResolver().query(ProviderTableMeta.CONTENT_URI,
+ null,
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ",
+ new String[] { mAccount.name, folder.getRemotePath() + "%" }, ProviderTableMeta.FILE_PATH + " ASC ");
+ }
+
+ /// 2. prepare a batch of update operations to change all the descendants
+ ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(c.getCount());
+ int lengthOfOldPath = folder.getRemotePath().length();
+ String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
+ int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
+ if (c.moveToFirst()) {
+ do {
+ ContentValues cv = new ContentValues(); // don't take the constructor out of the loop and clear the object
+ OCFile child = createFileInstance(c);
+ cv.put(ProviderTableMeta.FILE_PATH, newPath + child.getRemotePath().substring(lengthOfOldPath));
+ if (child.getStoragePath() != null && child.getStoragePath().startsWith(defaultSavePath)) {
+ cv.put(ProviderTableMeta.FILE_STORAGE_PATH, defaultSavePath + newPath + child.getStoragePath().substring(lengthOfOldStoragePath));
+ }
+ operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
+ withValues(cv).
+ withSelection( ProviderTableMeta._ID + "=?",
+ new String[] { String.valueOf(child.getFileId()) })
+ .build());
+ } while (c.moveToNext());
+ }
+ c.close();
+
+ /// 3. apply updates in batch
+ try {
+ if (getContentResolver() != null) {
+ getContentResolver().applyBatch(ProviderMeta.AUTHORITY_FILES, operations);
+
+ } else {
+ getContentProviderClient().applyBatch(operations);
+ }
+
+ } catch (OperationApplicationException e) {
+ Log_OC.e(TAG, "Fail to update descendants of " + folder.getFileId() + " in database", e);
+
+ } catch (RemoteException e) {
+ Log_OC.e(TAG, "Fail to update desendants of " + folder.getFileId() + " in database", e);
+ }
- } else {
- return new Vector<OCFile>();
}
}
- private Vector<OCFile> getDirectoryContent(long parentId) {
+
+ private Vector<OCFile> getFolderContent(long parentId) {
Vector<OCFile> ret = new Vector<OCFile>();
String.valueOf(parentId));
Cursor c = null;
- if (getContentProvider() != null) {
+ if (getContentProviderClient() != null) {
try {
- c = getContentProvider().query(req_uri, null,
+ c = getContentProviderClient().query(req_uri, null,
ProviderTableMeta.FILE_PARENT + "=?" ,
new String[] { String.valueOf(parentId)}, null);
} catch (RemoteException e) {
}
+ private OCFile createRootDir() {
+ OCFile file = new OCFile(OCFile.ROOT_PATH);
+ file.setMimetype("DIR");
+ file.setParentId(FileDataStorageManager.ROOT_PARENT_ID);
+ saveFile(file);
+ return file;
+ }
private boolean fileExists(String cmp_key, String value) {
Cursor c;
new String[] { value, mAccount.name }, null);
} else {
try {
- c = getContentProvider().query(
+ c = getContentProviderClient().query(
ProviderTableMeta.CONTENT_URI,
null,
cmp_key + "=? AND "
new String[] { value, mAccount.name }, null);
} else {
try {
- c = getContentProvider().query(
+ c = getContentProviderClient().query(
ProviderTableMeta.CONTENT_URI,
null,
key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER
.getColumnIndex(ProviderTableMeta.FILE_PARENT)));
file.setMimetype(c.getString(c
.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)));
- if (!file.isDirectory()) {
+ if (!file.isFolder()) {
file.setStoragePath(c.getString(c
.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
if (file.getStoragePath() == null) {
return file;
}
- @Override
- public void removeFile(OCFile file, boolean removeLocalCopy) {
- Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
- if (getContentProvider() != null) {
- try {
- getContentProvider().delete(file_uri,
- ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
- new String[]{mAccount.name});
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- } else {
- getContentResolver().delete(file_uri,
- ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
- new String[]{mAccount.name});
- }
- if (file.isDown() && removeLocalCopy) {
- new File(file.getStoragePath()).delete();
- }
- if (file.isDirectory() && removeLocalCopy) {
- File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
- if (f.exists() && f.isDirectory() && (f.list() == null || f.list().length == 0)) {
- f.delete();
- }
- }
-
- if (file.getFileLength() > 0) {
- updateSizesToTheRoot(file.getParentId());
- }
- }
-
- @Override
- public void removeDirectory(OCFile dir, boolean removeDBData, boolean removeLocalContent) {
- // TODO consider possible failures
- if (dir != null && dir.isDirectory() && dir.getFileId() != -1) {
- Vector<OCFile> children = getDirectoryContent(dir);
- if (children.size() > 0) {
- OCFile child = null;
- for (int i=0; i<children.size(); i++) {
- child = children.get(i);
- if (child.isDirectory()) {
- removeDirectory(child, removeDBData, removeLocalContent);
- } else {
- if (removeDBData) {
- removeFile(child, removeLocalContent);
- } else if (removeLocalContent) {
- if (child.isDown()) {
- new File(child.getStoragePath()).delete();
- }
- }
- }
- }
- }
- if (removeDBData) {
- removeFile(dir, true);
- }
-
- if (dir.getFileLength() > 0) {
- updateSizesToTheRoot(dir.getParentId());
- }
- }
- }
-
-
- /**
- * Updates database for a folder that was moved to a different location.
- *
- * TODO explore better (faster) implementations
- * TODO throw exceptions up !
- */
- @Override
- public void moveDirectory(OCFile dir, String newPath) {
- // TODO check newPath
-
- if (dir != null && dir.isDirectory() && dir.fileExists() && !dir.getFileName().equals(OCFile.PATH_SEPARATOR)) {
- /// 1. get all the descendants of 'dir' in a single QUERY (including 'dir')
- Cursor c = null;
- if (getContentProvider() != null) {
- try {
- c = getContentProvider().query(ProviderTableMeta.CONTENT_URI,
- null,
- ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ",
- new String[] { mAccount.name, dir.getRemotePath() + "%" }, ProviderTableMeta.FILE_PATH + " ASC ");
- } catch (RemoteException e) {
- Log_OC.e(TAG, e.getMessage());
- }
- } else {
- c = getContentResolver().query(ProviderTableMeta.CONTENT_URI,
- null,
- ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ",
- new String[] { mAccount.name, dir.getRemotePath() + "%" }, ProviderTableMeta.FILE_PATH + " ASC ");
- }
-
- /// 2. prepare a batch of update operations to change all the descendants
- ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(c.getCount());
- int lengthOfOldPath = dir.getRemotePath().length();
- String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
- int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
- if (c.moveToFirst()) {
- do {
- ContentValues cv = new ContentValues(); // don't take the constructor out of the loop and clear the object
- OCFile child = createFileInstance(c);
- cv.put(ProviderTableMeta.FILE_PATH, newPath + child.getRemotePath().substring(lengthOfOldPath));
- if (child.getStoragePath() != null && child.getStoragePath().startsWith(defaultSavePath)) {
- cv.put(ProviderTableMeta.FILE_STORAGE_PATH, defaultSavePath + newPath + child.getStoragePath().substring(lengthOfOldStoragePath));
- }
- operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
- withValues(cv).
- withSelection( ProviderTableMeta._ID + "=?",
- new String[] { String.valueOf(child.getFileId()) })
- .build());
- } while (c.moveToNext());
- }
- c.close();
-
- /// 3. apply updates in batch
- try {
- if (getContentResolver() != null) {
- getContentResolver().applyBatch(ProviderMeta.AUTHORITY_FILES, operations);
-
- } else {
- getContentProvider().applyBatch(operations);
- }
-
- } catch (OperationApplicationException e) {
- Log_OC.e(TAG, "Fail to update descendants of " + dir.getFileId() + " in database", e);
-
- } catch (RemoteException e) {
- Log_OC.e(TAG, "Fail to update desendants of " + dir.getFileId() + " in database", e);
- }
-
- }
- }
-
- @Override
- public Vector<OCFile> getDirectoryImages(OCFile directory) {
- Vector<OCFile> ret = new Vector<OCFile>();
- if (directory != null) {
- // TODO better implementation, filtering in the access to database (if possible) instead of here
- Vector<OCFile> tmp = getDirectoryContent(directory);
- OCFile current = null;
- for (int i=0; i<tmp.size(); i++) {
- current = tmp.get(i);
- if (current.isImage()) {
- ret.add(current);
- }
- }
- }
- return ret;
- }
-
- /**
- * Calculate and save the folderSize on DB
- * @param id
- */
- @Override
- public void calculateFolderSize(long id) {
- long folderSize = 0;
-
- Vector<OCFile> files = getDirectoryContent(id);
-
- for (OCFile f: files)
- {
- folderSize = folderSize + f.getFileLength();
- }
-
- updateSize(id, folderSize);
- }
-
/**
* Update the size value of an OCFile in DB
*/
new String[] { String.valueOf(id) });
} else {
try {
- result = getContentProvider().update(ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?",
+ result = getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?",
new String[] { String.valueOf(id) });
} catch (RemoteException e) {
Log_OC.e(TAG,"Fail to update size column into database " + e.getMessage());
OCFile file;
- while (parentId != DataStorageManager.ROOT_PARENT_ID) {
+ while (parentId != FileDataStorageManager.ROOT_PARENT_ID) {
// Update the size of the parent
calculateFolderSize(parentId);
};
public static final String PATH_SEPARATOR = "/";
+ public static final String ROOT_PATH = PATH_SEPARATOR;
private static final String TAG = OCFile.class.getSimpleName();
}
/**
- * Use this to find out if this file is a Directory
+ * Use this to find out if this file is a folder.
*
- * @return true if it is a directory
+ * @return true if it is a folder
*/
- public boolean isDirectory() {
+ public boolean isFolder() {
return mMimeType != null && mMimeType.equals("DIR");
}
*/
public String getFileName() {
File f = new File(getRemotePath());
- return f.getName().length() == 0 ? PATH_SEPARATOR : f.getName();
+ return f.getName().length() == 0 ? ROOT_PATH : f.getName();
}
/**
*/
public void setFileName(String name) {
Log_OC.d(TAG, "OCFile name changin from " + mRemotePath);
- if (name != null && name.length() > 0 && !name.contains(PATH_SEPARATOR) && !mRemotePath.equals(PATH_SEPARATOR)) {
+ if (name != null && name.length() > 0 && !name.contains(PATH_SEPARATOR) && !mRemotePath.equals(ROOT_PATH)) {
String parent = (new File(getRemotePath())).getParent();
parent = (parent.endsWith(PATH_SEPARATOR)) ? parent : parent + PATH_SEPARATOR;
mRemotePath = parent + name;
- if (isDirectory()) {
+ if (isFolder()) {
mRemotePath += PATH_SEPARATOR;
}
Log_OC.d(TAG, "OCFile name changed to " + mRemotePath);
* not a directory
*/
public void addFile(OCFile file) throws IllegalStateException {
- if (isDirectory()) {
+ if (isFolder()) {
file.mParentId = mId;
mNeedsUpdating = true;
return;
@Override
public int compareTo(OCFile another) {
- if (isDirectory() && another.isDirectory()) {
+ if (isFolder() && another.isFolder()) {
return getRemotePath().toLowerCase().compareTo(another.getRemotePath().toLowerCase());
- } else if (isDirectory()) {
+ } else if (isFolder()) {
return -1;
- } else if (another.isDirectory()) {
+ } else if (another.isFolder()) {
return 1;
}
return getRemotePath().toLowerCase().compareTo(another.getRemotePath().toLowerCase());
if (account == null || file == null) return false;
String targetKey = buildRemoteName(account, file);
synchronized (mPendingDownloads) {
- if (file.isDirectory()) {
+ if (file.isFolder()) {
// this can be slow if there are many downloads :(
Iterator<String> it = mPendingDownloads.keySet().iterator();
boolean found = false;
return false;
String targetKey = buildRemoteName(account, file);
synchronized (mPendingUploads) {
- if (file.isDirectory()) {
+ if (file.isFolder()) {
// this can be slow if there are many uploads :(
Iterator<String> it = mPendingUploads.keySet().iterator();
boolean found = false;
import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
import com.owncloud.android.Log_OC;
-import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import eu.alefzero.webdav.WebdavClient;
protected String mRemotePath;
protected boolean mCreateFullPath;
- protected DataStorageManager mStorageManager;
+ protected FileDataStorageManager mStorageManager;
/**
* Constructor
* @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet.
* @param storageManager Reference to the local database corresponding to the account where the file is contained.
*/
- public CreateFolderOperation(String remotePath, boolean createFullPath, DataStorageManager storageManager) {
+ public CreateFolderOperation(String remotePath, boolean createFullPath, FileDataStorageManager storageManager) {
mRemotePath = remotePath;
mCreateFullPath = createFullPath;
mStorageManager = storageManager;
import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
import com.owncloud.android.Log_OC;
-import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import eu.alefzero.webdav.WebdavClient;
OCFile mFileToRemove;
boolean mDeleteLocalCopy;
- DataStorageManager mDataStorageManager;
+ FileDataStorageManager mDataStorageManager;
/**
* @param deleteLocalCopy When 'true', and a local copy of the file exists, it is also removed.
* @param storageManager Reference to the local database corresponding to the account where the file is contained.
*/
- public RemoveFileOperation(OCFile fileToRemove, boolean deleteLocalCopy, DataStorageManager storageManager) {
+ public RemoveFileOperation(OCFile fileToRemove, boolean deleteLocalCopy, FileDataStorageManager storageManager) {
mFileToRemove = fileToRemove;
mDeleteLocalCopy = deleteLocalCopy;
mDataStorageManager = storageManager;
delete = new DeleteMethod(client.getBaseUri() + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));
int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT);
if (delete.succeeded() || status == HttpStatus.SC_NOT_FOUND) {
- if (mFileToRemove.isDirectory()) {
- mDataStorageManager.removeDirectory(mFileToRemove, true, mDeleteLocalCopy);
+ if (mFileToRemove.isFolder()) {
+ mDataStorageManager.removeFolder(mFileToRemove, true, mDeleteLocalCopy);
} else {
mDataStorageManager.removeFile(mFileToRemove, mDeleteLocalCopy);
}
import android.accounts.Account;
import com.owncloud.android.Log_OC;
-import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.utils.FileStorageUtils;
private Account mAccount;
private String mNewName;
private String mNewRemotePath;
- private DataStorageManager mStorageManager;
+ private FileDataStorageManager mStorageManager;
/**
* @param newName New name to set as the name of file.
* @param storageManager Reference to the local database corresponding to the account where the file is contained.
*/
- public RenameFileOperation(OCFile file, Account account, String newName, DataStorageManager storageManager) {
+ public RenameFileOperation(OCFile file, Account account, String newName, FileDataStorageManager storageManager) {
mFile = file;
mAccount = account;
mNewName = newName;
String parent = (new File(mFile.getRemotePath())).getParent();
parent = (parent.endsWith(OCFile.PATH_SEPARATOR)) ? parent : parent + OCFile.PATH_SEPARATOR;
mNewRemotePath = parent + mNewName;
- if (mFile.isDirectory()) {
+ if (mFile.isFolder()) {
mNewRemotePath += OCFile.PATH_SEPARATOR;
}
int status = client.executeMethod(move, RENAME_READ_TIMEOUT, RENAME_CONNECTION_TIMEOUT);
if (move.succeeded()) {
- if (mFile.isDirectory()) {
+ if (mFile.isFolder()) {
saveLocalDirectory();
} else {
private void saveLocalDirectory() {
- mStorageManager.moveDirectory(mFile, mNewRemotePath);
+ mStorageManager.moveFolder(mFile, mNewRemotePath);
String localPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
File localDir = new File(localPath);
if (localDir.exists()) {
import android.content.Intent;
import com.owncloud.android.Log_OC;
-import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.files.services.FileUploader;
private OCFile mLocalFile;
private OCFile mServerFile;
- private DataStorageManager mStorageManager;
+ private FileDataStorageManager mStorageManager;
private Account mAccount;
private boolean mSyncFileContents;
private boolean mLocalChangeAlreadyKnown;
public SynchronizeFileOperation(
OCFile localFile,
OCFile serverFile, // make this null to let the operation checks the server; added to reuse info from SynchronizeFolderOperation
- DataStorageManager storageManager,
+ FileDataStorageManager storageManager,
Account account,
boolean syncFileContents,
boolean localChangeAlreadyKnown,
import android.content.Intent;
import com.owncloud.android.Log_OC;
-import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.syncadapter.FileSyncService;
private boolean mUpdateFolderProperties;
/** Access to the local database */
- private DataStorageManager mStorageManager;
+ private FileDataStorageManager mStorageManager;
/** Account where the file to synchronize belongs */
private Account mAccount;
long currentSyncTime,
boolean updateFolderProperties,
boolean syncFullAccount,
- DataStorageManager dataStorageManager,
+ FileDataStorageManager dataStorageManager,
Account account,
Context context ) {
mLocalFolder = folder;
if (status == HttpStatus.SC_NOT_FOUND) {
if (mStorageManager.fileExists(mLocalFolder.getFileId())) {
String currentSavePath = FileStorageUtils.getSavePath(mAccount.name);
- mStorageManager.removeDirectory(mLocalFolder, true, (mLocalFolder.isDown() && mLocalFolder.getStoragePath().startsWith(currentSavePath)));
+ mStorageManager.removeFolder(mLocalFolder, true, (mLocalFolder.isDown() && mLocalFolder.getStoragePath().startsWith(currentSavePath)));
}
}
result = new RemoteOperationResult(false, status, query.getResponseHeaders());
mStorageManager.saveFile(remoteFolder);
}
- mChildren = mStorageManager.getDirectoryContent(mLocalFolder);
+ mChildren = mStorageManager.getFolderContent(mLocalFolder);
} else {
// read info of folder contents
* Removes obsolete children in the folder after saving all the new data.
*/
private void removeObsoleteFiles() {
- mChildren = mStorageManager.getDirectoryContent(mLocalFolder);
+ mChildren = mStorageManager.getFolderContent(mLocalFolder);
OCFile file;
for (int i=0; i < mChildren.size(); ) {
file = mChildren.get(i);
if (file.getLastSyncDateForProperties() != mCurrentSyncTime) {
- if (file.isDirectory()) {
+ if (file.isFolder()) {
Log_OC.d(TAG, "removing folder: " + file);
- mStorageManager.removeDirectory(file, true, true);
+ mStorageManager.removeFolder(file, true, true);
} else {
Log_OC.d(TAG, "removing file: " + file);
mStorageManager.removeFile(file, true);
* @param file File to associate a possible 'lost' local file.
*/
private void searchForLocalFileInDefaultPath(OCFile file) {
- if (file.getStoragePath() == null && !file.isDirectory()) {
+ if (file.getStoragePath() == null && !file.isFolder()) {
File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
if (f.exists()) {
file.setStoragePath(f.getAbsolutePath());
\r
import com.owncloud.android.authentication.AccountUtils;\r
import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;\r
-import com.owncloud.android.datamodel.DataStorageManager;\r
+import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.network.OwnCloudClientUtils;\r
\r
import android.accounts.Account;\r
private Account account;\r
private ContentProviderClient contentProvider;\r
//private Date lastUpdated;\r
- private DataStorageManager mStoreManager;\r
+ private FileDataStorageManager mStoreManager;\r
\r
private WebdavClient mClient = null;\r
\r
this.contentProvider = contentProvider;\r
}\r
\r
- public void setStorageManager(DataStorageManager storage_manager) {\r
+ public void setStorageManager(FileDataStorageManager storage_manager) {\r
mStoreManager = storage_manager;\r
}\r
\r
- public DataStorageManager getStorageManager() {\r
+ public FileDataStorageManager getStorageManager() {\r
return mStoreManager;\r
}\r
\r
updateOCVersion();
mCurrentSyncTime = System.currentTimeMillis();
if (!mCancellation) {
- synchronizeFolder(getStorageManager().getFileByPath(OCFile.PATH_SEPARATOR), true);
+ synchronizeFolder(getStorageManager().getFileByPath(OCFile.ROOT_PATH), true);
} else {
Log_OC.d(TAG, "Leaving synchronization before synchronizing the root folder because cancelation request");
int i;
for (i=0; i < files.size() && !mCancellation; i++) {
OCFile newFile = files.get(i);
- if (newFile.isDirectory()) {
+ if (newFile.isFolder()) {
synchronizeFolder(newFile, false);
}
}
package com.owncloud.android.ui.activity;
import com.owncloud.android.Log_OC;
-import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileUploader;
finish();
} else {
/// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
- DataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+ FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
file = storageManager.getFileByPath(file.getRemotePath()); // file = null if not in the current Account
if (file != null) {
setFile(file);
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountAuthenticator;
-import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
private ArrayAdapter<String> mDirectories;
/** Access point to the cached database for the current ownCloud {@link Account} */
- private DataStorageManager mStorageManager = null;
+ private FileDataStorageManager mStorageManager = null;
private SyncBroadcastReceiver mSyncBroadcastReceiver;
private UploadFinishReceiver mUploadFinishReceiver;
}
if (file == null) {
// fall back to root folder
- file = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); // never returns null
+ file = mStorageManager.getFileByPath(OCFile.ROOT_PATH); // never returns null
}
setFile(file);
setNavigationListWithFolder(file);
initFragmentsWithFile();
} else {
- updateFragmentsVisibility(!file.isDirectory());
- updateNavigationElementsInActionBar(file.isDirectory() ? null : file);
+ updateFragmentsVisibility(!file.isFolder());
+ updateNavigationElementsInActionBar(file.isFolder() ? null : file);
}
private void setNavigationListWithFolder(OCFile file) {
mDirectories.clear();
OCFile fileIt = file;
- while(fileIt != null && fileIt.getFileName() != OCFile.PATH_SEPARATOR) {
- if (fileIt.isDirectory()) {
+ while(fileIt != null && fileIt.getFileName() != OCFile.ROOT_PATH) {
+ if (fileIt.isFolder()) {
mDirectories.add(fileIt.getFileName());
}
fileIt = mStorageManager.getFileById(fileIt.getParentId());
private Fragment chooseInitialSecondFragment(OCFile file) {
Fragment secondFragment = null;
- if (file != null && !file.isDirectory()) {
+ if (file != null && !file.isFolder()) {
if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)
&& file.getLastSyncDateForProperties() > 0 // temporal fix
) {
/**
* Pushes a directory to the drop down list
* @param directory to push
- * @throws IllegalArgumentException If the {@link OCFile#isDirectory()} returns false.
+ * @throws IllegalArgumentException If the {@link OCFile#isFolder()} returns false.
*/
public void pushDirname(OCFile directory) {
- if(!directory.isDirectory()){
+ if(!directory.isFolder()){
throw new IllegalArgumentException("Only directories may be pushed!");
}
mDirectories.insert(directory.getFileName(), 0);
browseToRoot();
} else {
- if (currentFile == null && !getFile().isDirectory()) {
+ if (currentFile == null && !getFile().isFolder()) {
// currently selected file was removed in the server, and now we know it
cleanSecondFragment();
currentFile = currentDir;
* {@inheritDoc}
*/
@Override
- public DataStorageManager getStorageManager() {
+ public FileDataStorageManager getStorageManager() {
return mStorageManager;
}
while (mDirectories.getCount() > 1) {
popDirname();
}
- OCFile root = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
+ OCFile root = mStorageManager.getFileByPath(OCFile.ROOT_PATH);
listOfFiles.listDirectory(root);
setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(root);
public void browseTo(OCFile folder) {
- if (folder == null || !folder.isDirectory()) {
+ if (folder == null || !folder.isFolder()) {
throw new IllegalArgumentException("Trying to browse to invalid folder " + folder);
}
OCFileListFragment listOfFiles = getListOfFilesFragment();
private OCFile getCurrentDir() {
OCFile file = getFile();
if (file != null) {
- if (file.isDirectory()) {
+ if (file.isFolder()) {
return file;
} else if (mStorageManager != null) {
return mStorageManager.getFileById(file.getParentId());
import com.owncloud.android.DisplayUtils;\r
import com.owncloud.android.R;\r
import com.owncloud.android.authentication.AccountUtils;\r
-import com.owncloud.android.datamodel.DataStorageManager;\r
+import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.datamodel.OCFile;\r
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
private Context mContext;\r
private OCFile mFile = null;\r
private Vector<OCFile> mFiles = null;\r
- private DataStorageManager mStorageManager;\r
+ private FileDataStorageManager mStorageManager;\r
private Account mAccount;\r
private TransferServiceGetter mTransferServiceGetter;\r
//total size of a directory (recursive)\r
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);\r
ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
\r
- if (!file.isDirectory()) {\r
+ if (!file.isFolder()) {\r
fileSizeV.setVisibility(View.VISIBLE);\r
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));\r
lastModV.setVisibility(View.VISIBLE);\r
* @param directory New file to adapt. Can be NULL, meaning "no content to adapt".\r
* @param updatedStorageManager Optional updated storage manager; used to replace mStorageManager if is different (and not NULL)\r
*/\r
- public void swapDirectory(OCFile directory, DataStorageManager updatedStorageManager) {\r
+ public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager) {\r
mFile = directory;\r
if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {\r
mStorageManager = updatedStorageManager;\r
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
}\r
if (mStorageManager != null) {\r
- mFiles = mStorageManager.getDirectoryContent(mFile);\r
+ mFiles = mStorageManager.getFolderContent(mFile);\r
} else {\r
mFiles = null;\r
}\r
private void renameFile() {
OCFile file = getFile();
String fileName = file.getFileName();
- int extensionStart = file.isDirectory() ? -1 : fileName.lastIndexOf(".");
+ int extensionStart = file.isFolder() ? -1 : fileName.lastIndexOf(".");
int selectionEnd = (extensionStart >= 0) ? extensionStart : fileName.length();
EditNameDialog dialog = EditNameDialog.newInstance(getString(R.string.rename_dialog_title), fileName, 0, selectionEnd, this);
dialog.show(getFragmentManager(), "nameeditdialog");
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileHandler;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.operations.OnRemoteOperationListener;
import com.owncloud.android.operations.RemoteOperation;
-import com.owncloud.android.operations.RemoteOperationResult;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.TransferServiceGetter;
import com.owncloud.android.ui.adapter.FileListListAdapter;
int moveCount = 0;
if(mFile != null){
- DataStorageManager storageManager = mContainerActivity.getStorageManager();
+ FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
String parentPath = null;
if (mFile.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {
parentDir = storageManager.getFileByPath(parentPath);
moveCount++;
} else {
- parentDir = storageManager.getFileByPath(OCFile.PATH_SEPARATOR); // never returns null; keep the path in root folder
+ parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH); // never returns null; keep the path in root folder
}
while (parentDir == null) {
parentPath = new File(parentPath).getParent();
public void onItemClick(AdapterView<?> l, View v, int position, long id) {
OCFile file = (OCFile) mAdapter.getItem(position);
if (file != null) {
- if (file.isDirectory()) {
+ if (file.isFolder()) {
// update state and view of this fragment
listDirectory(file);
// then, notify parent activity to let it update its state and view, and other fragments
List<Integer> toDisable = new ArrayList<Integer>();
MenuItem item = null;
- if (targetFile.isDirectory()) {
+ if (targetFile.isFolder()) {
// contextual menu for folders
toHide.add(R.id.action_open_file_with);
toHide.add(R.id.action_download_file);
switch (item.getItemId()) {
case R.id.action_rename_file: {
String fileName = mTargetFile.getFileName();
- int extensionStart = mTargetFile.isDirectory() ? -1 : fileName.lastIndexOf(".");
+ int extensionStart = mTargetFile.isFolder() ? -1 : fileName.lastIndexOf(".");
int selectionEnd = (extensionStart >= 0) ? extensionStart : fileName.length();
EditNameDialog dialog = EditNameDialog.newInstance(getString(R.string.rename_dialog_title), fileName, 0, selectionEnd, this);
dialog.show(getFragmentManager(), EditNameDialog.TAG);
int messageStringId = R.string.confirmation_remove_alert;
int posBtnStringId = R.string.confirmation_remove_remote;
int neuBtnStringId = -1;
- if (mTargetFile.isDirectory()) {
+ if (mTargetFile.isFolder()) {
messageStringId = R.string.confirmation_remove_folder_alert;
posBtnStringId = R.string.confirmation_remove_remote_and_local;
neuBtnStringId = R.string.confirmation_remove_folder_local;
* @param directory File to be listed
*/
public void listDirectory(OCFile directory) {
- DataStorageManager storageManager = mContainerActivity.getStorageManager();
+ FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
if (storageManager != null) {
// Check input parameters for null
// If that's not a directory -> List its parent
- if(!directory.isDirectory()){
+ if(!directory.isFolder()){
Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString());
directory = storageManager.getFileById(directory.getParentId());
}
/**
* Getter for the current DataStorageManager in the container activity
*/
- public DataStorageManager getStorageManager();
+ public FileDataStorageManager getStorageManager();
/**
@Override
public void onNeutral(String callerTag) {
File f = null;
- if (mTargetFile.isDirectory()) {
+ if (mTargetFile.isFolder()) {
// TODO run in a secondary thread?
- mContainerActivity.getStorageManager().removeDirectory(mTargetFile, false, true);
+ mContainerActivity.getStorageManager().removeFolder(mTargetFile, false, true);
} else if (mTargetFile.isDown() && (f = new File(mTargetFile.getStoragePath())).exists()) {
f.delete();
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
- private DataStorageManager mStorageManager;
+ private FileDataStorageManager mStorageManager;
private ViewPager mViewPager;
private PreviewImagePagerAdapter mPreviewImagePagerAdapter;
OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
if (parentFolder == null) {
// should not be necessary
- parentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
+ parentFolder = mStorageManager.getFileByPath(OCFile.ROOT_PATH);
}
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), mStorageManager);
mViewPager = (ViewPager) findViewById(R.id.fragmentPager);
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;
-import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.fragment.FileFragment;
private Set<Object> mObsoleteFragments;
private Set<Integer> mObsoletePositions;
private Set<Integer> mDownloadErrors;
- private DataStorageManager mStorageManager;
+ private FileDataStorageManager mStorageManager;
private Map<Integer, FileFragment> mCachedFragments;
* @param parentFolder Folder where images will be searched for.
* @param storageManager Bridge to database.
*/
- public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder, Account account, DataStorageManager storageManager) {
+ public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder, Account account, FileDataStorageManager storageManager) {
super(fragmentManager);
if (fragmentManager == null) {
mAccount = account;
mStorageManager = storageManager;
- mImageFiles = mStorageManager.getDirectoryImages(parentFolder);
+ mImageFiles = mStorageManager.getFolderImages(parentFolder);
mObsoleteFragments = new HashSet<Object>();
mObsoletePositions = new HashSet<Integer>();
mDownloadErrors = new HashSet<Integer>();
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
-import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
private static final String TAG = PreviewVideoActivity.class.getSimpleName();
- private DataStorageManager mStorageManager;
+ private FileDataStorageManager mStorageManager;
private int mSavedPlaybackPosition; // in the unit time handled by MediaPlayer.getCurrentPosition()
private boolean mAutoplay; // when 'true', the playback starts immediately with the activity