Merge pull request #13166 from nextcloud/crash-fix-share-link

Share Link Crash Fix
This commit is contained in:
Alper Öztürk 2024-06-28 15:04:12 +02:00 committed by GitHub
commit b9d94e8be8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 10 deletions

View file

@ -790,11 +790,14 @@ public abstract class FileActivity extends DrawerActivity
String link = "";
OCFile file = null;
for (Object object : result.getData()) {
OCShare shareLink = (OCShare) object;
if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
link = shareLink.getShareLink();
file = getStorageManager().getFileByPath(shareLink.getPath());
break;
if (object instanceof OCShare shareLink) {
ShareType shareType = shareLink.getShareType();
if (shareType != null && TAG_PUBLIC_LINK.equalsIgnoreCase(shareType.name())) {
link = shareLink.getShareLink();
file = getStorageManager().getFileByEncryptedRemotePath(shareLink.getPath());
break;
}
}
}
@ -804,8 +807,12 @@ public abstract class FileActivity extends DrawerActivity
sharingFragment.onUpdateShareInformation(result, file);
}
if (fileListFragment instanceof OCFileListFragment && file != null) {
((OCFileListFragment) fileListFragment).updateOCFile(file);
if (fileListFragment instanceof OCFileListFragment ocFileListFragment && file != null) {
if (ocFileListFragment.getAdapterFiles().contains(file)) {
ocFileListFragment.updateOCFile(file);
} else {
DisplayUtils.showSnackMessage(this, R.string.file_activity_shared_file_cannot_be_updated);
}
}
} else {
// Detect Failure (403) --> maybe needs password

View file

@ -1387,9 +1387,19 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
}
public void updateOCFile(OCFile file) {
public List<OCFile> getAdapterFiles() {
return mAdapter.getFiles();
}
public void updateOCFile(@NonNull OCFile file) {
List<OCFile> mFiles = mAdapter.getFiles();
mFiles.set(mFiles.indexOf(file), file);
int index = mFiles.indexOf(file);
if (index == -1) {
Log_OC.d(TAG, "File cannot be found in adapter's files");
return;
}
mFiles.set(index, file);
mAdapter.notifyItemChanged(file);
}

View file

@ -530,7 +530,8 @@ class PreviewImageFragment : FileFragment(), Injectable {
try {
bitmapResult = BitmapUtils.decodeSampledBitmapFromFile(
storagePath, minWidth,
storagePath,
minWidth,
minHeight
)

View file

@ -1154,6 +1154,7 @@
<string name="check_back_later_or_reload">Check back later or reload.</string>
<string name="e2e_not_yet_setup">E2E not yet setup</string>
<string name="error_file_actions">Error showing file actions</string>
<string name="file_activity_shared_file_cannot_be_updated">Shared file cannot be updated</string>
<string name="pin_home">Pin to Home screen</string>
<string name="pin_shortcut_label">Open %1$s</string>
<string name="displays_mnemonic">Displays your 12 word passphrase</string>