Skip to content

Commit 6783e4d

Browse files
authored
Merge pull request #3898 from yatiksihag01/bugfix/3886
Fixes #3886
2 parents 0c48b9f + c3e69cf commit 6783e4d

File tree

10 files changed

+546
-466
lines changed

10 files changed

+546
-466
lines changed

app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@
4747
import com.amaze.filemanager.adapters.holders.SpecialViewHolder;
4848
import com.amaze.filemanager.application.AppConfig;
4949
import com.amaze.filemanager.fileoperations.filesystem.OpenMode;
50+
import com.amaze.filemanager.filesystem.PasteHelper;
5051
import com.amaze.filemanager.filesystem.files.CryptUtil;
5152
import com.amaze.filemanager.ui.ItemPopupMenu;
53+
import com.amaze.filemanager.ui.activities.MainActivity;
5254
import com.amaze.filemanager.ui.activities.superclasses.PreferenceActivity;
5355
import com.amaze.filemanager.ui.colors.ColorUtils;
5456
import com.amaze.filemanager.ui.drag.RecyclerAdapterDragListener;
@@ -62,6 +64,7 @@
6264
import com.amaze.filemanager.ui.views.CircleGradientDrawable;
6365
import com.amaze.filemanager.utils.AnimUtils;
6466
import com.amaze.filemanager.utils.GlideConstants;
67+
import com.amaze.filemanager.utils.MainActivityActionMode;
6568
import com.amaze.filemanager.utils.Utils;
6669
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader;
6770
import com.bumptech.glide.load.DataSource;
@@ -85,6 +88,7 @@
8588
import android.view.animation.Animation;
8689
import android.view.animation.AnimationUtils;
8790
import android.widget.PopupMenu;
91+
import android.widget.Toast;
8892

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

764768
holder.baseItemView.setOnLongClickListener(
765769
p1 -> {
770+
if (hasPendingPasteOperation()) return false;
766771
if (!isBackButton) {
767772
if (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_DEFAULT
768773
|| (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_TO_MOVE_COPY
@@ -976,6 +981,7 @@ private void bindViewHolderGrid(@NonNull final ItemViewHolder holder, int positi
976981

977982
holder.baseItemView.setOnLongClickListener(
978983
p1 -> {
984+
if (hasPendingPasteOperation()) return false;
979985
if (!isBackButton) {
980986
if (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_DEFAULT
981987
|| (dragAndDropPreference == PreferencesConstants.PREFERENCE_DRAG_TO_MOVE_COPY
@@ -1366,6 +1372,7 @@ public boolean onResourceReady(
13661372
}
13671373

13681374
private void showPopup(@NonNull View view, @NonNull final LayoutElementParcelable rowItem) {
1375+
if (hasPendingPasteOperation()) return;
13691376
Context currentContext = this.context;
13701377
if (mainFragment.getMainActivity().getAppTheme().getSimpleTheme(mainFragment.requireContext())
13711378
== AppTheme.BLACK) {
@@ -1428,6 +1435,31 @@ private void showPopup(@NonNull View view, @NonNull final LayoutElementParcelabl
14281435
popupMenu.show();
14291436
}
14301437

1438+
/**
1439+
* Helps in deciding whether to allow file modification or not, depending on the state of the
1440+
* copy/paste operation.
1441+
*
1442+
* @return true if there is an unfinished copy/paste operation, false otherwise.
1443+
*/
1444+
private boolean hasPendingPasteOperation() {
1445+
MainActivity mainActivity = mainFragment.getMainActivity();
1446+
if (mainActivity == null) return false;
1447+
MainActivityActionMode mainActivityActionMode = mainActivity.mainActivityActionMode;
1448+
PasteHelper pasteHelper = mainActivityActionMode.getPasteHelper();
1449+
1450+
if (pasteHelper != null
1451+
&& pasteHelper.getSnackbar() != null
1452+
&& pasteHelper.getSnackbar().isShown()) {
1453+
Toast.makeText(
1454+
mainFragment.requireContext(),
1455+
mainFragment.getString(R.string.complete_paste_warning),
1456+
Toast.LENGTH_LONG)
1457+
.show();
1458+
return true;
1459+
}
1460+
return false;
1461+
}
1462+
14311463
private boolean getBoolean(String key) {
14321464
return preferenceActivity.getBoolean(key);
14331465
}

app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/movecopy/MoveFiles.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
/**
4848
* AsyncTask that moves files from source to destination by trying to rename files first, if they're
4949
* in the same filesystem, else starting the copy service. Be advised - do not start this AsyncTask
50-
* directly but use {@link PrepareCopyTask} instead
50+
* directly but use {@link PreparePasteTask} instead
5151
*/
5252
public class MoveFiles implements Callable<MoveFilesReturn> {
5353

0 commit comments

Comments
 (0)