Skip to content

Commit

Permalink
Merge pull request #3898 from yatiksihag01/bugfix/3886
Browse files Browse the repository at this point in the history
Fixes #3886
  • Loading branch information
VishalNehra authored Sep 24, 2023
2 parents 0c48b9f + c3e69cf commit 6783e4d
Show file tree
Hide file tree
Showing 10 changed files with 546 additions and 466 deletions.
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

0 comments on commit 6783e4d

Please sign in to comment.