Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3886 #3898

Merged
merged 14 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
import com.amaze.filemanager.adapters.holders.SpecialViewHolder;
import com.amaze.filemanager.application.AppConfig;
import com.amaze.filemanager.fileoperations.filesystem.OpenMode;
import com.amaze.filemanager.filesystem.PasteHelper;
import com.amaze.filemanager.filesystem.files.CryptUtil;
import com.amaze.filemanager.ui.ItemPopupMenu;
import com.amaze.filemanager.ui.activities.MainActivity;
import com.amaze.filemanager.ui.activities.superclasses.PreferenceActivity;
import com.amaze.filemanager.ui.colors.ColorUtils;
import com.amaze.filemanager.ui.drag.RecyclerAdapterDragListener;
Expand All @@ -62,6 +64,7 @@
import com.amaze.filemanager.ui.views.CircleGradientDrawable;
import com.amaze.filemanager.utils.AnimUtils;
import com.amaze.filemanager.utils.GlideConstants;
import com.amaze.filemanager.utils.MainActivityActionMode;
import com.amaze.filemanager.utils.Utils;
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader;
import com.bumptech.glide.load.DataSource;
Expand All @@ -85,6 +88,7 @@
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.PopupMenu;
import android.widget.Toast;

import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -763,6 +767,7 @@ private void bindViewHolderList(@NonNull final ItemViewHolder holder, int positi

holder.baseItemView.setOnLongClickListener(
p1 -> {
if (hasPendingPasteOperation()) return false;
if (!isBackButton) {
if (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_DEFAULT
|| (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_TO_MOVE_COPY
Expand Down Expand Up @@ -976,6 +981,7 @@ private void bindViewHolderGrid(@NonNull final ItemViewHolder holder, int positi

holder.baseItemView.setOnLongClickListener(
p1 -> {
if (hasPendingPasteOperation()) return false;
if (!isBackButton) {
if (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_DEFAULT
|| (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_TO_MOVE_COPY
Expand Down Expand Up @@ -1366,6 +1372,7 @@ public boolean onResourceReady(
}

private void showPopup(@NonNull View view, @NonNull final LayoutElementParcelable rowItem) {
if (hasPendingPasteOperation()) return;
Context currentContext = this.context;
if (mainFragment.getMainActivity().getAppTheme().getSimpleTheme(mainFragment.requireContext())
== AppTheme.BLACK) {
Expand Down Expand Up @@ -1428,6 +1435,31 @@ private void showPopup(@NonNull View view, @NonNull final LayoutElementParcelabl
popupMenu.show();
}

/**
* Helps in deciding whether to allow file modification or not, depending on the state of the
* copy/paste operation.
*
* @return true if there is an unfinished copy/paste operation, false otherwise.
*/
private boolean hasPendingPasteOperation() {
MainActivity mainActivity = mainFragment.getMainActivity();
if (mainActivity == null) return false;
MainActivityActionMode mainActivityActionMode = mainActivity.mainActivityActionMode;
PasteHelper pasteHelper = mainActivityActionMode.getPasteHelper();

if (pasteHelper != null
&& pasteHelper.getSnackbar() != null
&& pasteHelper.getSnackbar().isShown()) {
Toast.makeText(
mainFragment.requireContext(),
mainFragment.getString(R.string.complete_paste_warning),
Toast.LENGTH_LONG)
.show();
return true;
}
return false;
}

private boolean getBoolean(String key) {
return preferenceActivity.getBoolean(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
/**
* AsyncTask that moves files from source to destination by trying to rename files first, if they're
* in the same filesystem, else starting the copy service. Be advised - do not start this AsyncTask
* directly but use {@link PrepareCopyTask} instead
* directly but use {@link PreparePasteTask} instead
*/
public class MoveFiles implements Callable<MoveFilesReturn> {

Expand Down
Loading