From: David A. Velasco Date: Thu, 15 Oct 2015 07:26:24 +0000 (+0200) Subject: Sync user and group shares into database X-Git-Tag: oc-android-1.9^2~30^2~56 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/0db4fc9b17d0988c64a2949093dbb37230e1db2d?ds=sidebyside Sync user and group shares into database --- diff --git a/res/drawable-hdpi/shared_via_link.png b/res/drawable-hdpi/shared_via_link.png new file mode 100644 index 00000000..f4279f3a Binary files /dev/null and b/res/drawable-hdpi/shared_via_link.png differ diff --git a/res/drawable-hdpi/shared_via_users.png b/res/drawable-hdpi/shared_via_users.png new file mode 100644 index 00000000..9ec18ced Binary files /dev/null and b/res/drawable-hdpi/shared_via_users.png differ diff --git a/res/drawable-hdpi/shared_with_me.png b/res/drawable-hdpi/shared_with_me.png deleted file mode 100644 index 9ec18ced..00000000 Binary files a/res/drawable-hdpi/shared_with_me.png and /dev/null differ diff --git a/res/drawable-hdpi/sharedlink.png b/res/drawable-hdpi/sharedlink.png deleted file mode 100644 index f4279f3a..00000000 Binary files a/res/drawable-hdpi/sharedlink.png and /dev/null differ diff --git a/res/drawable-mdpi/shared_via_link.png b/res/drawable-mdpi/shared_via_link.png new file mode 100644 index 00000000..1d27294e Binary files /dev/null and b/res/drawable-mdpi/shared_via_link.png differ diff --git a/res/drawable-mdpi/shared_via_users.png b/res/drawable-mdpi/shared_via_users.png new file mode 100644 index 00000000..0b17c765 Binary files /dev/null and b/res/drawable-mdpi/shared_via_users.png differ diff --git a/res/drawable-mdpi/shared_with_me.png b/res/drawable-mdpi/shared_with_me.png deleted file mode 100644 index 0b17c765..00000000 Binary files a/res/drawable-mdpi/shared_with_me.png and /dev/null differ diff --git a/res/drawable-mdpi/sharedlink.png b/res/drawable-mdpi/sharedlink.png deleted file mode 100644 index 1d27294e..00000000 Binary files a/res/drawable-mdpi/sharedlink.png and /dev/null differ diff --git a/res/drawable-xhdpi/shared_via_link.png b/res/drawable-xhdpi/shared_via_link.png new file mode 100644 index 00000000..11f8afa1 Binary files /dev/null and b/res/drawable-xhdpi/shared_via_link.png differ diff --git a/res/drawable-xhdpi/shared_via_users.png b/res/drawable-xhdpi/shared_via_users.png new file mode 100644 index 00000000..ef7779ca Binary files /dev/null and b/res/drawable-xhdpi/shared_via_users.png differ diff --git a/res/drawable-xhdpi/shared_with_me.png b/res/drawable-xhdpi/shared_with_me.png deleted file mode 100644 index ef7779ca..00000000 Binary files a/res/drawable-xhdpi/shared_with_me.png and /dev/null differ diff --git a/res/drawable-xhdpi/sharedlink.png b/res/drawable-xhdpi/sharedlink.png deleted file mode 100644 index 11f8afa1..00000000 Binary files a/res/drawable-xhdpi/sharedlink.png and /dev/null differ diff --git a/res/layout/grid_image.xml b/res/layout/grid_image.xml index 383c6154..15a9baf0 100644 --- a/res/layout/grid_image.xml +++ b/res/layout/grid_image.xml @@ -38,30 +38,13 @@ android:scaleType="centerCrop" android:src="@drawable/ic_menu_archive"/> - - - - - - + android:layout_margin="4dp" + android:src="@drawable/shared_via_link" /> - - - - - - + android:src="@drawable/shared_via_link" /> - - - - - - - + sharedFiles) { - cleanSharedFiles(); + resetShareFlagsInAllFiles(); if (sharedFiles != null) { ArrayList operations = @@ -1221,7 +1228,8 @@ 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_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0); + 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_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); @@ -1311,7 +1319,7 @@ public class FileDataStorageManager { OCFile file = getFileByPath(path); if (file != null) { if (share.getShareType().equals(ShareType.PUBLIC_LINK)) { - file.setShareByLink(true); + file.setShareViaLink(true); sharedFiles.add(file); } } @@ -1322,7 +1330,7 @@ public class FileDataStorageManager { public void saveSharesInFolder(ArrayList shares, OCFile folder) { - cleanSharedFilesInFolder(folder); + resetShareFlagsInFolder(folder); ArrayList operations = new ArrayList(); operations = prepareRemoveSharesInFolder(folder, operations); @@ -1348,18 +1356,6 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getIdRemoteShared()); cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name); - /* - if (shareExists(share.getIdRemoteShared())) { - // updating an existing share resource - operations.add( - ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI_SHARE). - withValues(cv). - withSelection( ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?", - new String[] { String.valueOf(share.getIdRemoteShared()) }) - .build()); - - } else { - */ // adding a new share resource operations.add( ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE). @@ -1372,15 +1368,13 @@ public class FileDataStorageManager { // apply operations in batch if (operations.size() > 0) { - @SuppressWarnings("unused") - ContentProviderResult[] results = null; Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider"); try { if (getContentResolver() != null) { - results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); + getContentResolver().applyBatch(MainApp.getAuthority(), operations); } else { - results = getContentProviderClient().applyBatch(operations); + getContentProviderClient().applyBatch(operations); } } catch (OperationApplicationException e) { @@ -1390,7 +1384,6 @@ public class FileDataStorageManager { Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); } } - //} } diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index 8c7101bb..e9facf15 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -43,6 +43,8 @@ public class OCFile implements Parcelable, Comparable { } }; + private final static String PERMISSION_SHARED_WITH_ME = "S"; // TODO move to better location + public static final String PATH_SEPARATOR = "/"; public static final String ROOT_PATH = PATH_SEPARATOR; @@ -493,11 +495,12 @@ public class OCFile implements Parcelable, Comparable { this.mEtag = (etag != null ? etag : ""); } - public boolean isShareByLink() { + + public boolean isSharedViaLink() { return mShareByLink; } - public void setShareByLink(boolean shareByLink) { + public void setShareViaLink(boolean shareByLink) { this.mShareByLink = shareByLink; } @@ -597,12 +600,16 @@ public class OCFile implements Parcelable, Comparable { mEtagInConflict = etagInConflict; } - public boolean isShareWithUser() { + public boolean isSharedViaUsers() { return mShareWithUser; } - public void setShareWithUser(boolean shareWithUser) { + public void setShareViaUsers(boolean shareWithUser) { this.mShareWithUser = shareWithUser; } + public boolean isSharedWithMe() { + String permissions = getPermissions(); + return (permissions != null && permissions.contains(PERMISSION_SHARED_WITH_ME)); + } } diff --git a/src/com/owncloud/android/db/ProviderMeta.java b/src/com/owncloud/android/db/ProviderMeta.java index f15dd9ec..893e247a 100644 --- a/src/com/owncloud/android/db/ProviderMeta.java +++ b/src/com/owncloud/android/db/ProviderMeta.java @@ -31,7 +31,7 @@ import com.owncloud.android.MainApp; public class ProviderMeta { public static final String DB_NAME = "filelist"; - public static final int DB_VERSION = 11; + public static final int DB_VERSION = 12; private ProviderMeta() { } @@ -66,7 +66,8 @@ public class ProviderMeta { public static final String FILE_LAST_SYNC_DATE_FOR_DATA = "last_sync_date_for_data"; public static final String FILE_KEEP_IN_SYNC = "keep_in_sync"; public static final String FILE_ETAG = "etag"; - public static final String FILE_SHARE_BY_LINK = "share_by_link"; + public static final String FILE_SHARED_VIA_LINK = "share_by_link"; + public static final String FILE_SHARED_VIA_USERS = "shared_via_users"; public static final String FILE_PUBLIC_LINK = "public_link"; public static final String FILE_PERMISSIONS = "permissions"; public static final String FILE_REMOTE_ID = "remote_id"; @@ -96,6 +97,5 @@ public class ProviderMeta { public static final String OCSHARES_DEFAULT_SORT_ORDER = OCSHARES_FILE_SOURCE + " collate nocase asc"; - } } diff --git a/src/com/owncloud/android/files/FileMenuFilter.java b/src/com/owncloud/android/files/FileMenuFilter.java index 01ca41fd..364d1618 100644 --- a/src/com/owncloud/android/files/FileMenuFilter.java +++ b/src/com/owncloud/android/files/FileMenuFilter.java @@ -195,7 +195,7 @@ public class FileMenuFilter { // UNSHARE FILE // TODO add check on SHARE available on server side? - if ( !shareAllowed || (mFile == null || !mFile.isShareByLink())) { + if ( !shareAllowed || (mFile == null || !mFile.isSharedViaLink())) { toHide.add(R.id.action_unshare_file); } else { toShow.add(R.id.action_unshare_file); @@ -209,7 +209,7 @@ public class FileMenuFilter { } // UNSHARE FILE, with Users - if ( !shareAllowed || !shareWithUsersEnable || (mFile == null || !mFile.isShareWithUser())) { + if ( !shareAllowed || !shareWithUsersEnable || (mFile == null || !mFile.isSharedViaUsers())) { toHide.add(R.id.action_unshare_with_users); } else { toShow.add(R.id.action_unshare_with_users); diff --git a/src/com/owncloud/android/operations/CreateShareOperation.java b/src/com/owncloud/android/operations/CreateShareOperation.java index a7270eb8..ebae9bd8 100644 --- a/src/com/owncloud/android/operations/CreateShareOperation.java +++ b/src/com/owncloud/android/operations/CreateShareOperation.java @@ -172,7 +172,7 @@ public class CreateShareOperation extends SyncOperation { getClient().getCredentials().getUsername(), file.getFileName())); } file.setPublicLink(share.getShareLink()); - file.setShareByLink(true); + file.setShareViaLink(true); getStorageManager().saveFile(file); Log_OC.d(TAG, "Public Link = " + file.getPublicLink()); diff --git a/src/com/owncloud/android/operations/GetSharesOperation.java b/src/com/owncloud/android/operations/GetSharesOperation.java deleted file mode 100644 index 09a8e344..00000000 --- a/src/com/owncloud/android/operations/GetSharesOperation.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * ownCloud Android client application - * - * @author masensio - * @author David A. Velasco - * Copyright (C) 2015 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 . - * - */ - -package com.owncloud.android.operations; - -import java.util.ArrayList; - -import com.owncloud.android.MainApp; -import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; -import com.owncloud.android.lib.resources.shares.OCShare; -import com.owncloud.android.lib.resources.shares.GetRemoteSharesOperation; -import com.owncloud.android.operations.common.SyncOperation; - -/** - * Access to remote operation to get the share files/folders - * Save the data in Database - */ - -public class GetSharesOperation extends SyncOperation { - - private static final String TAG = GetSharesOperation.class.getSimpleName(); - - @Override - protected RemoteOperationResult run(OwnCloudClient client) { - GetRemoteSharesOperation operation = new GetRemoteSharesOperation(); - RemoteOperationResult result = operation.execute(client); - - if (result.isSuccess()) { - - // Update DB with the response - Log_OC.d(TAG, "Share list size = " + result.getData().size()); - ArrayList shares = new ArrayList(); - for(Object obj: result.getData()) { - shares.add((OCShare) obj); - } - - getStorageManager().saveSharesDB(shares); - } - - return result; - } - -} diff --git a/src/com/owncloud/android/operations/GetUsersOrGroupsOperation.java b/src/com/owncloud/android/operations/GetUsersOrGroupsOperation.java index 6ac4adef..d7a60296 100644 --- a/src/com/owncloud/android/operations/GetUsersOrGroupsOperation.java +++ b/src/com/owncloud/android/operations/GetUsersOrGroupsOperation.java @@ -21,7 +21,7 @@ package com.owncloud.android.operations; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.resources.users.GetRemoteUsersOrGroupsOperation; +import com.owncloud.android.lib.resources.shares.GetRemoteShareesOperation; import com.owncloud.android.operations.common.SyncOperation; /** @@ -54,9 +54,9 @@ public class GetUsersOrGroupsOperation extends SyncOperation{ @Override protected RemoteOperationResult run(OwnCloudClient client) { - GetRemoteUsersOrGroupsOperation operation = - new GetRemoteUsersOrGroupsOperation(mSearchString, - mLimit, mOffset, mGetGroups); + GetRemoteShareesOperation operation = + new GetRemoteShareesOperation(mSearchString, + mLimit, mOffset); RemoteOperationResult result = operation.execute(client); return result; diff --git a/src/com/owncloud/android/operations/RefreshFolderOperation.java b/src/com/owncloud/android/operations/RefreshFolderOperation.java index 61b13fc8..54dd7535 100644 --- a/src/com/owncloud/android/operations/RefreshFolderOperation.java +++ b/src/com/owncloud/android/operations/RefreshFolderOperation.java @@ -391,7 +391,8 @@ public class RefreshFolderOperation extends RemoteOperation { Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server"); } updatedFile.setPublicLink(localFile.getPublicLink()); - updatedFile.setShareByLink(localFile.isShareByLink()); + updatedFile.setShareViaLink(localFile.isSharedViaLink()); + updatedFile.setShareViaUsers(localFile.isSharedViaUsers()); updatedFile.setEtagInConflict(localFile.getEtagInConflict()); } else { // remote eTag will not be updated unless file CONTENTS are synchronized @@ -456,12 +457,19 @@ public class RefreshFolderOperation extends RemoteOperation { } + /** + * Syncs the Share resources for the files contained in the folder refreshed (children, not deeper descendants). + * + * @param client Handler of a session with an OC server. + * @return The result of the remote operation retrieving the Share resources in the folder refreshed by + * the operation. + */ private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) { RemoteOperationResult result = null; // remote request GetRemoteSharesForFileOperation operation = - new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), false, true); + new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), true, true); result = operation.execute(client); if (result.isSuccess()) { diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index b8da4a1f..136bb8bc 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -339,7 +339,8 @@ public class SynchronizeFolderOperation extends SyncOperation { Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server"); } updatedFile.setPublicLink(localFile.getPublicLink()); - updatedFile.setShareByLink(localFile.isShareByLink()); + updatedFile.setShareViaLink(localFile.isSharedViaLink()); + updatedFile.setShareViaUsers(localFile.isSharedViaUsers()); updatedFile.setEtagInConflict(localFile.getEtagInConflict()); } else { // remote eTag will not be updated unless file CONTENTS are synchronized diff --git a/src/com/owncloud/android/operations/UnshareLinkOperation.java b/src/com/owncloud/android/operations/UnshareLinkOperation.java index 1b662261..38593883 100644 --- a/src/com/owncloud/android/operations/UnshareLinkOperation.java +++ b/src/com/owncloud/android/operations/UnshareLinkOperation.java @@ -22,7 +22,6 @@ package com.owncloud.android.operations; import android.content.Context; -import com.owncloud.android.MainApp; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.OwnCloudClient; @@ -70,7 +69,7 @@ public class UnshareLinkOperation extends SyncOperation { Log_OC.d(TAG, "Share id = " + share.getIdRemoteShared() + " deleted"); OCFile file = getStorageManager().getFileByPath(mRemotePath); - file.setShareByLink(false); + file.setShareViaLink(false); file.setPublicLink(""); getStorageManager().saveFile(file); getStorageManager().removeShare(share); diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java index 609c07ca..e3950f7d 100644 --- a/src/com/owncloud/android/providers/FileContentProvider.java +++ b/src/com/owncloud/android/providers/FileContentProvider.java @@ -94,8 +94,10 @@ public class FileContentProvider extends ContentProvider { ProviderTableMeta.FILE_ACCOUNT_OWNER); mFileProjectionMap.put(ProviderTableMeta.FILE_ETAG, ProviderTableMeta.FILE_ETAG); - mFileProjectionMap.put(ProviderTableMeta.FILE_SHARE_BY_LINK, - ProviderTableMeta.FILE_SHARE_BY_LINK); + mFileProjectionMap.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, + ProviderTableMeta.FILE_SHARED_VIA_LINK); + mFileProjectionMap.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, + ProviderTableMeta.FILE_SHARED_VIA_USERS); mFileProjectionMap.put(ProviderTableMeta.FILE_PUBLIC_LINK, ProviderTableMeta.FILE_PUBLIC_LINK); mFileProjectionMap.put(ProviderTableMeta.FILE_PERMISSIONS, @@ -308,9 +310,7 @@ public class FileContentProvider extends ContentProvider { } long rowId = db.insert(ProviderTableMeta.FILE_TABLE_NAME, null, values); if (rowId > 0) { - Uri insertedFileUri = - ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, rowId); - return insertedFileUri; + return ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, rowId); } else { throw new SQLException("ERROR " + uri); } @@ -362,7 +362,7 @@ public class FileContentProvider extends ContentProvider { ); doubleCheckShare.close(); } - updateFilesTableAccordingToShareInsertion(db, uri, values); + updateFilesTableAccordingToShareInsertion(db, values); return insertedShareUri; @@ -373,21 +373,23 @@ public class FileContentProvider extends ContentProvider { } private void updateFilesTableAccordingToShareInsertion( - SQLiteDatabase db, Uri uri, ContentValues shareValues + SQLiteDatabase db, ContentValues newShare ) { ContentValues fileValues = new ContentValues(); - fileValues.put( - ProviderTableMeta.FILE_SHARE_BY_LINK, - ShareType.PUBLIC_LINK.getValue() == - shareValues.getAsInteger(ProviderTableMeta.OCSHARES_SHARE_TYPE) ? 1 : 0 - ); - String whereShare = ProviderTableMeta.FILE_PATH + "=? AND " + + int newShareType = newShare.getAsInteger(ProviderTableMeta.OCSHARES_SHARE_TYPE); + if (newShareType == ShareType.PUBLIC_LINK.getValue()) { + fileValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, 1); + } else if (newShareType == ShareType.USER.getValue() || newShareType == ShareType.GROUP.getValue()) { + fileValues.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, 1); + } + + String where = ProviderTableMeta.FILE_PATH + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?"; - String[] whereArgsShare = new String[] { - shareValues.getAsString(ProviderTableMeta.OCSHARES_PATH), - shareValues.getAsString(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER) + String[] whereArgs = new String[] { + newShare.getAsString(ProviderTableMeta.OCSHARES_PATH), + newShare.getAsString(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER) }; - db.update(ProviderTableMeta.FILE_TABLE_NAME, fileValues, whereShare, whereArgsShare); + db.update(ProviderTableMeta.FILE_TABLE_NAME, fileValues, where, whereArgs); } @@ -579,13 +581,14 @@ public class FileContentProvider extends ContentProvider { + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + " INTEGER, " + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + " INTEGER, " + ProviderTableMeta.FILE_ETAG + " TEXT, " - + ProviderTableMeta.FILE_SHARE_BY_LINK + " INTEGER, " + + ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER, " + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT, " + ProviderTableMeta.FILE_PERMISSIONS + " TEXT null," + ProviderTableMeta.FILE_REMOTE_ID + " TEXT null," + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER," //boolean + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER," //boolean - + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT);" + + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT," + + ProviderTableMeta.FILE_SHARED_VIA_USERS + " INTEGER);" ); // Create table ocshares @@ -684,7 +687,7 @@ public class FileContentProvider extends ContentProvider { db.beginTransaction(); try { db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + - " ADD COLUMN " + ProviderTableMeta.FILE_SHARE_BY_LINK + " INTEGER " + + " ADD COLUMN " + ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER " + " DEFAULT 0"); db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + @@ -793,6 +796,24 @@ public class FileContentProvider extends ContentProvider { db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + " ADD COLUMN " + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT " + " DEFAULT NULL"); + + upgraded = true; + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + if (!upgraded) + Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + + ", newVersion == " + newVersion); + + if (oldVersion < 12 && newVersion >= 12) { + Log_OC.i("SQL", "Entering in the #12 ADD in onUpgrade"); + db.beginTransaction(); + try { + db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + + " ADD COLUMN " + ProviderTableMeta.FILE_SHARED_VIA_USERS + " INTEGER " + + " DEFAULT 0"); upgraded = true; db.setTransactionSuccessful(); } finally { diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index d0abff29..1f07d4a8 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -63,7 +63,6 @@ import com.owncloud.android.utils.MimetypeIconUtil; * instance. */ public class FileListListAdapter extends BaseAdapter implements ListAdapter { - private final static String PERMISSION_SHARED_WITH_ME = "S"; private Context mContext; private OCFile mFile = null; @@ -235,13 +234,21 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { case GRID_IMAGE: // sharedIcon ImageView sharedIconV = (ImageView) view.findViewById(R.id.sharedIcon); - if (file.isShareByLink()) { + if (file.isSharedViaLink()) { + sharedIconV.setImageResource(R.drawable.shared_via_link); + sharedIconV.setVisibility(View.VISIBLE); + sharedIconV.bringToFront(); + } else if (file.isSharedViaUsers() || file.isSharedWithMe() ) { + sharedIconV.setImageResource(R.drawable.shared_via_users); sharedIconV.setVisibility(View.VISIBLE); sharedIconV.bringToFront(); } else { sharedIconV.setVisibility(View.GONE); } + /*ImageView sharedWithMeIcon = (ImageView) view.findViewById(R.id.sharedWithMeIcon); + sharedWithMeIcon.bringToFront();*/ + // local state ImageView localStateView = (ImageView) view.findViewById(R.id.localFileIndicator); localStateView.bringToFront(); @@ -292,17 +299,6 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { localStateView.setVisibility(View.VISIBLE); } - // share with me icon - ImageView sharedWithMeIconV = (ImageView) - view.findViewById(R.id.sharedWithMeIcon); - sharedWithMeIconV.bringToFront(); - if (checkIfFileIsSharedWithMe(file) && - (!file.isFolder() || !mGridMode)) { - sharedWithMeIconV.setVisibility(View.VISIBLE); - } else { - sharedWithMeIconV.setVisibility(View.GONE); - } - break; } @@ -361,7 +357,10 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { // Folder fileIcon.setImageResource( MimetypeIconUtil.getFolderTypeIconId( - checkIfFileIsSharedWithMe(file), file.isShareByLink())); + file.isSharedWithMe() || file.isSharedViaUsers(), + file.isSharedViaLink() + ) + ); } } @@ -433,20 +432,6 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { } - /** - * Check if parent folder does not include 'S' permission and if file/folder - * is shared with me - * - * @param file: OCFile - * @return boolean: True if it is shared with me and false if it is not - */ - private boolean checkIfFileIsSharedWithMe(OCFile file) { - return (mFile.getPermissions() != null - && !mFile.getPermissions().contains(PERMISSION_SHARED_WITH_ME) - && file.getPermissions() != null - && file.getPermissions().contains(PERMISSION_SHARED_WITH_ME)); - } - public void setSortOrder(Integer order, boolean ascending) { SharedPreferences.Editor editor = mAppPreferences.edit(); editor.putInt("sortOrder", order); diff --git a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java index 60675f46..a339ed74 100644 --- a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java @@ -185,7 +185,6 @@ public class LocalFileListAdapter extends BaseAdapter implements ListAdapter { view.findViewById(R.id.favoriteIcon).setVisibility(View.GONE); view.findViewById(R.id.sharedIcon).setVisibility(View.GONE); - view.findViewById(R.id.sharedWithMeIcon).setVisibility(View.GONE); } return view; diff --git a/src/com/owncloud/android/utils/MimetypeIconUtil.java b/src/com/owncloud/android/utils/MimetypeIconUtil.java index bd8c5d91..5fc4c8cf 100644 --- a/src/com/owncloud/android/utils/MimetypeIconUtil.java +++ b/src/com/owncloud/android/utils/MimetypeIconUtil.java @@ -69,15 +69,15 @@ public class MimetypeIconUtil { /** * Returns the resource identifier of an image to use as icon associated to a type of folder. * - * @param isSharedWithUser flag if the folder is shared with the user - * @param isShareByLink flag if the folder is shared by link + * @param isSharedViaUsers flag if the folder is shared via the users system + * @param isSharedViaLink flag if the folder is publicly shared via link * @return Identifier of an image resource. */ - public static int getFolderTypeIconId(boolean isSharedWithUser, boolean isShareByLink) { - if (isSharedWithUser) { - return R.drawable.shared_with_me_folder; - } else if (isShareByLink) { + public static int getFolderTypeIconId(boolean isSharedViaUsers, boolean isSharedViaLink) { + if (isSharedViaLink) { return R.drawable.folder_public; + } else if (isSharedViaUsers) { + return R.drawable.shared_with_me_folder; } return R.drawable.ic_menu_archive;