Skip to content

Commit

Permalink
Merge pull request #12094 from nextcloud/bugfix/share-is-no-longer-av…
Browse files Browse the repository at this point in the history
…ailable-after-renaming-folder-9652183

Bugfix Share Is No Longer Available After Renaming Folder
  • Loading branch information
AndyScherzinger authored Nov 9, 2023
2 parents 051c36a + d4737ed commit 263e6e0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,13 @@ private void onUpdateShareInformation(RemoteOperationResult result, @StringRes i
}
}

public void refreshList() {
final Fragment fileListFragment = getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_LIST_OF_FILES);
if (fileListFragment != null) {
((OCFileListFragment) fileListFragment).onRefresh();
}
}

private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
RemoteOperationResult result) {
FileDetailSharingFragment sharingFragment = getShareFileFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.owncloud.android.ui.adapter;

import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.ViewGroup;
Expand Down Expand Up @@ -94,15 +95,15 @@ public int getItemViewType(int position) {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (ShareType.fromValue(viewType)) {
case PUBLIC_LINK:
case EMAIL:
case PUBLIC_LINK, EMAIL -> {
return new LinkShareViewHolder(
FileDetailsShareLinkShareItemBinding.inflate(LayoutInflater.from(fileActivity),
parent,
false),
fileActivity,
viewThemeUtils);
case NEW_PUBLIC_LINK:
}
case NEW_PUBLIC_LINK -> {
if (encrypted) {
return new NewSecureFileDropViewHolder(
FileDetailsShareSecureFileDropAddNewItemBinding.inflate(LayoutInflater.from(fileActivity),
Expand All @@ -116,17 +117,20 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
false)
);
}
case INTERNAL:
}
case INTERNAL -> {
return new InternalShareViewHolder(
FileDetailsShareInternalShareLinkBinding.inflate(LayoutInflater.from(fileActivity), parent, false),
fileActivity);
default:
}
default -> {
return new ShareViewHolder(FileDetailsShareShareItemBinding.inflate(LayoutInflater.from(fileActivity),
parent,
false),
user,
fileActivity,
viewThemeUtils);
}
}
}

Expand All @@ -138,17 +142,13 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi

final OCShare share = shares.get(position);

if (holder instanceof LinkShareViewHolder) {
LinkShareViewHolder publicShareViewHolder = (LinkShareViewHolder) holder;
if (holder instanceof LinkShareViewHolder publicShareViewHolder) {
publicShareViewHolder.bind(share, listener);
} else if (holder instanceof InternalShareViewHolder) {
InternalShareViewHolder internalShareViewHolder = (InternalShareViewHolder) holder;
} else if (holder instanceof InternalShareViewHolder internalShareViewHolder) {
internalShareViewHolder.bind(share, listener);
} else if (holder instanceof NewLinkShareViewHolder) {
NewLinkShareViewHolder newLinkShareViewHolder = (NewLinkShareViewHolder) holder;
} else if (holder instanceof NewLinkShareViewHolder newLinkShareViewHolder) {
newLinkShareViewHolder.bind(listener);
} else if (holder instanceof NewSecureFileDropViewHolder) {
NewSecureFileDropViewHolder newSecureFileDropViewHolder = (NewSecureFileDropViewHolder) holder;
} else if (holder instanceof NewSecureFileDropViewHolder newSecureFileDropViewHolder) {
newSecureFileDropViewHolder.bind(listener);
} else {
ShareViewHolder userViewHolder = (ShareViewHolder) holder;
Expand All @@ -166,6 +166,7 @@ public int getItemCount() {
return shares.size();
}

@SuppressLint("NotifyDataSetChanged")
public void addShares(List<OCShare> sharesToAdd) {
shares.addAll(sharesToAdd);
sortShares();
Expand All @@ -174,22 +175,21 @@ public void addShares(List<OCShare> sharesToAdd) {

@Override
public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
if (callContext instanceof ImageView) {
ImageView iv = (ImageView) callContext;
if (callContext instanceof ImageView iv) {
iv.setImageDrawable(avatarDrawable);
}
}

@Override
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
if (callContext instanceof ImageView) {
ImageView iv = (ImageView) callContext;
if (callContext instanceof ImageView iv) {
// needs to be changed once federated users have avatars
return String.valueOf(iv.getTag()).equals(tag.split("@")[0]);
}
return false;
}

@SuppressLint("NotifyDataSetChanged")
public void remove(OCShare share) {
shares.remove(share);
notifyDataSetChanged();
Expand All @@ -210,8 +210,8 @@ protected final void sortShares() {
}
}

Collections.sort(links, (o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));
Collections.sort(users, (o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));
links.sort((o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));
users.sort((o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));

shares = links;
shares.addAll(users);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,15 +932,15 @@ public void toggleFileLock(OCFile file, boolean shouldBeLocked) {
}

public void renameFile(OCFile file, String newFilename) {
// RenameFile
Intent service = new Intent(fileActivity, OperationsService.class);

service.setAction(OperationsService.ACTION_RENAME);
service.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
mWaitingForOpId = fileActivity.getOperationsServiceBinder().queueNewOperation(service);

fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
fileActivity.refreshList();
}


Expand Down
2 changes: 1 addition & 1 deletion scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 77 warnings</span>
<span class="mdl-layout-title">Lint Report: 75 warnings</span>

0 comments on commit 263e6e0

Please sign in to comment.