X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/fdcf0ebbc8a519dd53b5ac511f664e41f2ef38ee..7a3caaff9e7327edcb1f4298747c70f367dfcd9d:/src/com/owncloud/android/datamodel/FileDataStorageManager.java diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 6c0a435b..f3dd3e55 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -142,10 +142,9 @@ public class FileDataStorageManager { } - public Vector getFolderContent(OCFile f/*, boolean onlyOnDevice*/) { + public Vector getFolderContent(OCFile f, boolean onlyOnDevice) { if (f != null && f.isFolder() && f.getFileId() != -1) { - // TODO Enable when "On Device" is recovered ? - return getFolderContent(f.getFileId()/*, onlyOnDevice*/); + return getFolderContent(f.getFileId(), onlyOnDevice); } else { return new Vector(); @@ -153,13 +152,12 @@ public class FileDataStorageManager { } - public Vector getFolderImages(OCFile folder/*, boolean onlyOnDevice*/) { - Vector ret = new Vector(); + public Vector getFolderImages(OCFile folder, boolean onlyOnDevice) { + Vector ret = new Vector(); if (folder != null) { // TODO better implementation, filtering in the access to database instead of here - // TODO Enable when "On Device" is recovered ? - Vector tmp = getFolderContent(folder/*, onlyOnDevice*/); - OCFile current = null; + Vector tmp = getFolderContent(folder, onlyOnDevice); + OCFile current = null; for (int i=0; i files = getFolderContent(folder.getFileId()/*, false*/); + Vector files = getFolderContent(folder.getFileId(), false); if (files != null) { for (OCFile file : files) { if (file.isFolder()) { @@ -750,8 +747,8 @@ public class FileDataStorageManager { return ret; } - - private Vector getFolderContent(long parentId/*, boolean onlyOnDevice*/) { + + private Vector getFolderContent(long parentId, boolean onlyOnDevice) { Vector ret = new Vector(); @@ -778,10 +775,9 @@ public class FileDataStorageManager { if (c.moveToFirst()) { do { OCFile child = createFileInstance(c); - // TODO Enable when "On Device" is recovered ? - // if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){ - ret.add(child); - // } + if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){ + ret.add(child); + } } while (c.moveToNext()); } @@ -1409,33 +1405,7 @@ public class FileDataStorageManager { if (shares != null) { // prepare operations to insert or update files to save in the given folder - for (OCShare share : shares) { - ContentValues cv = new ContentValues(); - cv.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource()); - cv.put(ProviderTableMeta.OCSHARES_ITEM_SOURCE, share.getItemSource()); - cv.put(ProviderTableMeta.OCSHARES_SHARE_TYPE, share.getShareType().getValue()); - cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH, share.getShareWith()); - cv.put(ProviderTableMeta.OCSHARES_PATH, share.getPath()); - cv.put(ProviderTableMeta.OCSHARES_PERMISSIONS, share.getPermissions()); - cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate()); - cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate()); - cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken()); - cv.put( - ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, - share.getSharedWithDisplayName() - ); - cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0); - cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId()); - cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getIdRemoteShared()); - cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name); - - // adding a new share resource - operations.add( - ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE). - withValues(cv). - build() - ); - } + operations = prepareInsertShares(shares, operations); } // apply operations in batch @@ -1508,9 +1478,8 @@ public class FileDataStorageManager { + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?"; String [] whereArgs = new String[]{ "", mAccount.name }; - // TODO Enable when "On Device" is recovered ? - Vector files = getFolderContent(folder /*, false*/); - + Vector files = getFolderContent(folder, false); + for (OCFile file : files) { whereArgs[0] = file.getRemotePath(); preparedOperations.add( @@ -1581,7 +1550,7 @@ public class FileDataStorageManager { return shares; } - public void triggerMediaScan(String path) { + public static void triggerMediaScan(String path) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(new File(path))); MainApp.getAppContext().sendBroadcast(intent);