X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/c49cc06d3de203308ef7726338aff4a93be89cdd..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 4d07b56e..f3dd3e55 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -31,7 +31,6 @@ import java.util.Set; import java.util.Vector; import android.accounts.Account; -import android.content.ContentProvider; import android.content.ContentProviderClient; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; @@ -143,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(); @@ -154,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()) { @@ -751,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(); @@ -779,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()); } @@ -900,8 +895,8 @@ public class FileDataStorageManager { file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG))); file.setShareViaLink(c.getInt( c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_LINK)) == 1 ? true : false); - file.setShareViaUsers(c.getInt( - c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_USERS)) == 1 ? true : false); + file.setShareWithSharee(c.getInt( + c.getColumnIndex(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1 ? true : false); file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK))); file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS))); file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID))); @@ -1086,7 +1081,7 @@ public class FileDataStorageManager { private void resetShareFlagsInAllFiles() { ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false); - cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, false); + cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, ""); String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?"; String[] whereArgs = new String[]{mAccount.name}; @@ -1107,7 +1102,7 @@ public class FileDataStorageManager { private void resetShareFlagsInFolder(OCFile folder) { ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false); - cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, false); + cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, ""); String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PARENT + "=?"; @@ -1129,7 +1124,7 @@ public class FileDataStorageManager { private void resetShareFlagInAFile(String filePath){ ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false); - cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, false); + cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, ""); String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH+ "=?"; @@ -1268,7 +1263,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0); cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag()); cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0); - cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, file.isSharedViaUsers() ? 1 : 0); + cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); @@ -1349,9 +1344,9 @@ public class FileDataStorageManager { String filePath = ""; for (OCShare share: shares) { if (filePath != share.getPath()){ + filePath = share.getPath(); resetShareFlagInAFile(filePath); operations = prepareRemoveSharesInFile(filePath, operations); - filePath = share.getPath(); } } @@ -1410,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 @@ -1454,7 +1423,7 @@ public class FileDataStorageManager { Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); + } } @@ -1509,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( @@ -1582,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);