Merge pull request #12685 from nextcloud/Bugfix/better-share-feedback-and-handling

Fix check if share already exists and give feedback
This commit is contained in:
Andy Scherzinger 2024-03-18 15:54:59 +01:00 committed by GitHub
commit 22415f6695
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -880,7 +880,7 @@ public abstract class FileActivity extends DrawerActivity
String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1);
ArrayList<String> existingSharees = new ArrayList<>();
for (OCShare share : getStorageManager().getSharesWithForAFile(getFile().getRemotePath(),
for (OCShare share : getStorageManager().getSharesWithForAFile(getFileFromDetailFragment().getRemotePath(),
getAccount().name)) {
existingSharees.add(share.getShareType() + "_" + share.getShareWith());
}
@ -890,10 +890,23 @@ public abstract class FileActivity extends DrawerActivity
if (!existingSharees.contains(shareType + "_" + shareWith)) {
doShareWith(shareWith, shareType);
} else {
DisplayUtils.showSnackMessage(this, getString(R.string.sharee_already_added_to_file));
}
}
}
/**
* returns the file that is selected for sharing, getFile() only returns the containing folder
*/
private OCFile getFileFromDetailFragment() {
FileDetailFragment fragment = getFileDetailFragment();
if (fragment != null) {
return fragment.getFile();
}
return getFile();
}
/**
* open the new sharing process fragment to create the share
*

View file

@ -786,6 +786,7 @@
<string name="uploads_view_upload_status_virus_detected">Virus detected. Upload cannot be completed!</string>
<string name="tags">Tags</string>
<string name="sharee_add_failed">Adding sharee failed</string>
<string name="sharee_already_added_to_file">Adding share failed. This file or folder has already been shared with this person or group.</string>
<string name="unsharing_failed">Unsharing failed</string>
<string name="updating_share_failed">Updating share failed</string>
<string name="prefs_e2e_mnemonic">E2E mnemonic</string>