Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {

public static String DATA_USER;
public static String DATA_GROUP;
public static String DATA_ROOM;
public static String DATA_REMOTE;

private UriMatcher mUriMatcher;
Expand Down Expand Up @@ -109,11 +110,12 @@ public boolean onCreate() {
ACTION_SHARE_WITH = getContext().getResources().getString(R.string.users_and_groups_share_with);
DATA_USER = AUTHORITY + ".data.user";
DATA_GROUP = AUTHORITY + ".data.group";
DATA_ROOM = AUTHORITY + ".data.room";
DATA_REMOTE = AUTHORITY + ".data.remote";

sShareTypes.put(DATA_USER, ShareType.USER);
sShareTypes.put(DATA_GROUP, ShareType.GROUP);
sShareTypes.put(DATA_GROUP, ShareType.ROOM);
sShareTypes.put(DATA_ROOM, ShareType.ROOM);
sShareTypes.put(DATA_REMOTE, ShareType.FEDERATED);
sShareTypes.put(DATA_REMOTE, ShareType.EMAIL);

Expand Down Expand Up @@ -188,6 +190,7 @@ private Cursor searchForUsersOrGroups(Uri uri) {

Uri userBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_USER).build();
Uri groupBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_GROUP).build();
Uri roomBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_ROOM).build();
Uri remoteBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_REMOTE).build();

FileDataStorageManager manager = new FileDataStorageManager(account, getContext().getContentResolver());
Expand Down Expand Up @@ -241,7 +244,7 @@ private Cursor searchForUsersOrGroups(Uri uri) {
case ROOM:
icon = R.drawable.ic_chat_bubble;
displayName = getContext().getString(R.string.share_room_clarification, userName);
dataUri = Uri.withAppendedPath(groupBaseUri, shareWith);
dataUri = Uri.withAppendedPath(roomBaseUri, shareWith);
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,33 +552,30 @@ protected void onNewIntent(Intent intent) {
String dataString = intent.getDataString();
String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1);

ArrayList<String> shareeNames = new ArrayList<>();
for (OCShare share : getStorageManager().getSharesWithForAFile(getFile().getRemotePath(), getAccount().name)) {
shareeNames.add(share.getShareWith());
ArrayList<String> existingSharees = new ArrayList<>();
for (OCShare share : getStorageManager().getSharesWithForAFile(getFile().getRemotePath(),
getAccount().name)) {
existingSharees.add(share.getShareType() + "_" + share.getShareWith());
}

if (!shareeNames.contains(shareWith)) {
doShareWith(shareWith, data.getAuthority());
String dataAuthority = data.getAuthority();
ShareType shareType = UsersAndGroupsSearchProvider.getShareType(dataAuthority);

if (!existingSharees.contains(shareType + "_" + shareWith)) {
doShareWith(shareWith, shareType);
}

} else {
Log_OC.e(TAG, "Unexpected intent " + intent.toString());
}
}

private void doShareWith(String shareeName, String dataAuthority) {

ShareType shareType = UsersAndGroupsSearchProvider.getShareType(dataAuthority);

getFileOperationsHelper().shareFileWithSharee(
getFile(),
shareeName,
shareType,
getAppropiatePermissions(shareType)
);
private void doShareWith(String shareeName, ShareType shareType) {
getFileOperationsHelper().shareFileWithSharee(getFile(), shareeName, shareType,
getAppropriatePermissions(shareType));
}

private int getAppropiatePermissions(ShareType shareType) {
private int getAppropriatePermissions(ShareType shareType) {

// check if the Share is FEDERATED
boolean isFederated = ShareType.FEDERATED.equals(shareType);
Expand Down