fix check if share already exists and give feedback

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
Jonas Mayer 2024-03-12 21:48:37 +01:00 committed by Jonas Mayer
parent b7423184f4
commit e1580af541
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>