- fix wrong mapping from room to group

- take type into account when checking if already shared

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2019-01-10 14:25:43 +01:00
parent b425bba679
commit 5431eeab6c
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 18 additions and 18 deletions

View file

@ -82,6 +82,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;
@ -110,11 +111,12 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
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);
@ -189,6 +191,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
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());
@ -242,7 +245,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
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:

View file

@ -553,13 +553,17 @@ public class FileDisplayActivity extends HookActivity
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 {
@ -567,19 +571,12 @@ public class FileDisplayActivity extends HookActivity
}
}
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);