From: masensio Date: Mon, 24 Feb 2014 12:37:48 +0000 (+0100) Subject: Merge branch 'develop' into remove_folder_size_info X-Git-Tag: oc-android-1.5.5~32^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/c8fc9cfa70774498570ea422144ef432d2ebaa3f?hp=-c Merge branch 'develop' into remove_folder_size_info --- c8fc9cfa70774498570ea422144ef432d2ebaa3f diff --combined src/com/owncloud/android/datamodel/FileDataStorageManager.java index 4ef1ba1e,5abdd892..f132d967 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@@ -237,11 -237,11 +237,11 @@@ public class FileDataStorageManager } } - if (file.isFolder()) { - updateFolderSize(file.getFileId()); - } else { - updateFolderSize(file.getParentId()); - } +// if (file.isFolder()) { +// updateFolderSize(file.getFileId()); +// } else { +// updateFolderSize(file.getParentId()); +// } return overriden; } @@@ -388,38 -388,38 +388,38 @@@ } } - updateFolderSize(folder.getFileId()); + //updateFolderSize(folder.getFileId()); } - /** - * - * @param id - */ - private void updateFolderSize(long id) { - if (id > FileDataStorageManager.ROOT_PARENT_ID) { - Log_OC.d(TAG, "Updating size of " + id); - if (getContentResolver() != null) { - getContentResolver().update(ProviderTableMeta.CONTENT_URI_DIR, - new ContentValues(), // won't be used, but cannot be null; crashes in KLP - ProviderTableMeta._ID + "=?", - new String[] { String.valueOf(id) }); - } else { - try { - getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_DIR, - new ContentValues(), // won't be used, but cannot be null; crashes in KLP - ProviderTableMeta._ID + "=?", - new String[] { String.valueOf(id) }); - - } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in update of folder size through compatibility patch " + e.getMessage()); - } - } - } else { - Log_OC.e(TAG, "not updating size for folder " + id); - } - } +// /** +// * +// * @param id +// */ +// private void updateFolderSize(long id) { +// if (id > FileDataStorageManager.ROOT_PARENT_ID) { +// Log_OC.d(TAG, "Updating size of " + id); +// if (getContentResolver() != null) { +// getContentResolver().update(ProviderTableMeta.CONTENT_URI_DIR, +// new ContentValues(), // won't be used, but cannot be null; crashes in KLP +// ProviderTableMeta._ID + "=?", +// new String[] { String.valueOf(id) }); +// } else { +// try { +// getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_DIR, +// new ContentValues(), // won't be used, but cannot be null; crashes in KLP +// ProviderTableMeta._ID + "=?", +// new String[] { String.valueOf(id) }); +// +// } catch (RemoteException e) { +// Log_OC.e(TAG, "Exception in update of folder size through compatibility patch " + e.getMessage()); +// } +// } +// } else { +// Log_OC.e(TAG, "not updating size for folder " + id); +// } +// } public void removeFile(OCFile file, boolean removeDBData, boolean removeLocalCopy) { @@@ -442,7 -442,7 +442,7 @@@ } else { getContentResolver().delete(file_uri, where, whereArgs); } - updateFolderSize(file.getParentId()); + //updateFolderSize(file.getParentId()); } if (removeLocalCopy && file.isDown() && file.getStoragePath() != null) { boolean success = new File(file.getStoragePath()).delete(); @@@ -482,7 -482,7 +482,7 @@@ } else { getContentResolver().delete(folder_uri, where, whereArgs); } - updateFolderSize(folder.getParentId()); + //updateFolderSize(folder.getParentId()); } private void removeLocalFolder(File folder) { @@@ -858,8 -858,33 +858,33 @@@ return share; } - public OCShare getShareByPath(String path) { - Cursor c = getShareCursorForValue(ProviderTableMeta.OCSHARES_PATH, path); + public OCShare getFirstShareByPathAndType(String path, ShareType type) { + Cursor c = null; + if (getContentResolver() != null) { + c = getContentResolver().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, + ProviderTableMeta.OCSHARES_PATH + "=? AND " + + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND " + + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?", + new String[] { path, Integer.toString(type.getValue()), mAccount.name }, + null); + } else { + try { + c = getContentProviderClient().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, + ProviderTableMeta.OCSHARES_PATH + "=? AND " + + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND " + + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?", + new String[] { path, Integer.toString(type.getValue()), mAccount.name }, + null); + + } catch (RemoteException e) { + Log_OC.e(TAG, "Could not get file details: " + e.getMessage()); + c = null; + } + } OCShare share = null; if (c.moveToFirst()) { share = createShareInstance(c); diff --combined src/com/owncloud/android/syncadapter/FileSyncAdapter.java index dab51ebb,349f1370..0184e1f5 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@@ -110,7 -110,7 +110,7 @@@ public class FileSyncAdapter extends Ab private SyncResult mSyncResult; /** 'True' means that the server supports the share API */ - private boolean mIsSharedSupported; + private boolean mIsShareSupported; /** @@@ -156,9 -156,6 +156,6 @@@ this.setContentProviderClient(providerClient); this.setStorageManager(new FileDataStorageManager(account, providerClient)); - AccountManager accountManager = getAccountManager(); - mIsSharedSupported = Boolean.parseBoolean(accountManager.getUserData(account, Constants.KEY_SUPPORTS_SHARE_API)); - try { this.initClientForCurrentAccount(); } catch (IOException e) { @@@ -235,6 -232,8 +232,8 @@@ RemoteOperationResult result = update.execute(getClient()); if (!result.isSuccess()) { mLastFailedResult = result; + } else { + mIsShareSupported = update.getOCVersion().isSharedSupported(); } } @@@ -269,7 -268,7 +268,7 @@@ SynchronizeFolderOperation synchFolderOp = new SynchronizeFolderOperation( folder, mCurrentSyncTime, true, - mIsSharedSupported, + mIsShareSupported, getStorageManager(), getAccount(), getContext() @@@ -352,7 -351,7 +351,7 @@@ syncDown = (parentEtagChanged || etag == null || etag.length() == 0); if(syncDown) { */ synchronizeFolder(newFile); - sendLocalBroadcast(EVENT_FULL_SYNC_FOLDER_SIZE_SYNCED, parent.getRemotePath(), null); + //sendLocalBroadcast(EVENT_FULL_SYNC_FOLDER_SIZE_SYNCED, parent.getRemotePath(), null); //} } }