From f24f89b47841a4cfd5753ec157b2c7a43b9dc063 Mon Sep 17 00:00:00 2001 From: yashwanthgajji Date: Sat, 30 Nov 2024 11:32:37 -0500 Subject: [PATCH 1/5] added delete permanently to the preferences in settings --- .../fragments/preferencefragments/PreferencesConstants.kt | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/behavior_prefs.xml | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/PreferencesConstants.kt b/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/PreferencesConstants.kt index 5a02a269b2..891c66b485 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/PreferencesConstants.kt +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/PreferencesConstants.kt @@ -77,6 +77,7 @@ object PreferencesConstants { const val PREFERENCE_ZIP_EXTRACT_PATH = "extractpath" const val PREFERENCE_TEXTEDITOR_NEWSTACK = "texteditor_newstack" const val PREFERENCE_DELETE_CONFIRMATION = "delete_confirmation" + const val PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION = "delete_permanently_without_confirmation" const val PREFERENCE_DISABLE_PLAYER_INTENT_FILTERS = "disable_player_intent_filters" const val PREFERENCE_TRASH_BIN_RETENTION_NUM_OF_FILES = "retention_num_of_files" const val PREFERENCE_TRASH_BIN_RETENTION_DAYS = "retention_days" @@ -122,4 +123,5 @@ object PreferencesConstants { const val KEY_TRASH_BIN_CLEANUP_INTERVAL_HOURS = "trash_bin_cleanup_interval_hours" const val DEFAULT_PREFERENCE_DELETE_CONFIRMATION = true + const val DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION = false } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7d3f97ae2a..5982f78a7c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -800,6 +800,8 @@ You only need to do this once, until the next time you select a new location for Unable to get package info from file \"%s\". Either the specified file is not an APK, or the package file is corrupt. Delete confirmation Ask for confirmation before deleting files. Disabling this is highly discouraged! + Delete permanently + Delete files permanently without asking confirmation. Enabling this is highly discouraged! SSH/SFTP FTP Secure FTP diff --git a/app/src/main/res/xml/behavior_prefs.xml b/app/src/main/res/xml/behavior_prefs.xml index 980f26e466..428cf7acb5 100644 --- a/app/src/main/res/xml/behavior_prefs.xml +++ b/app/src/main/res/xml/behavior_prefs.xml @@ -30,6 +30,13 @@ app:key="delete_confirmation" app:summary="@string/preference_delete_confirmation_summary" app:title="@string/preference_delete_confirmation" /> + Date: Sat, 30 Nov 2024 22:11:32 -0500 Subject: [PATCH 2/5] permanently delete logic --- .../amaze/filemanager/ui/ItemPopupMenu.java | 15 ++++++++-- .../filemanager/ui/fragments/TabFragment.java | 30 +++++++++++++++---- .../utils/MainActivityActionMode.kt | 27 +++++++++++++---- .../filemanager/utils/MainActivityHelper.java | 10 +++++++ 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java index 2320ddb3c4..a1fdaf3a8c 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java +++ b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java @@ -157,8 +157,19 @@ public boolean onMenuItemClick(MenuItem item) { case R.id.delete: ArrayList positions = new ArrayList<>(); positions.add(rowItem); - GeneralDialogCreation.deleteFilesDialog( - context, mainActivity, positions, utilitiesProvider.getAppTheme()); + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + boolean deletePermanently = sharedPreferences.getBoolean( + PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, + PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION + ); + if (deletePermanently) { + Toast.makeText(context, context.getString(R.string.deleting), Toast.LENGTH_SHORT) + .show(); + mainActivity.mainActivityHelper.deleteFilesPermanently(positions); + } else { + GeneralDialogCreation.deleteFilesDialog( + context, mainActivity, positions, utilitiesProvider.getAppTheme()); + } return true; case R.id.restore: ArrayList p2 = new ArrayList<>(); diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java index 9cfe88053c..1bada9abc4 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java @@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; import com.amaze.filemanager.R; +import com.amaze.filemanager.adapters.data.LayoutElementParcelable; import com.amaze.filemanager.application.AppConfig; import com.amaze.filemanager.database.TabHandler; import com.amaze.filemanager.database.models.explorer.Tab; @@ -59,6 +60,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; +import android.widget.Toast; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; @@ -506,11 +508,29 @@ private void initLeftAndRightDragListeners(boolean destroy) { new DragToTrashListener( () -> { if (mainFragment != null) { - GeneralDialogCreation.deleteFilesDialog( - requireContext(), - requireMainActivity(), - mainFragment.adapter.getCheckedItems(), - requireMainActivity().getAppTheme()); + SharedPreferences sharedPreferences = + PreferenceManager.getDefaultSharedPreferences(requireContext()); + boolean deletePermanently = sharedPreferences.getBoolean( + PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, + PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION + ); + if (deletePermanently) { + Toast.makeText( + requireContext(), + requireContext().getString(R.string.deleting), + Toast.LENGTH_SHORT + ).show(); + requireMainActivity().mainActivityHelper.deleteFilesPermanently( + mainFragment.adapter.getCheckedItems() + ); + } else { + GeneralDialogCreation.deleteFilesDialog( + requireContext(), + requireMainActivity(), + mainFragment.adapter.getCheckedItems(), + requireMainActivity().getAppTheme() + ); + } } else { AppConfig.toast(requireContext(), getString(R.string.operation_unsuccesful)); } diff --git a/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt b/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt index 4af20b454a..6f94cc3f5c 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt +++ b/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt @@ -30,6 +30,7 @@ import android.widget.Toast import androidx.appcompat.view.ActionMode import androidx.appcompat.widget.AppCompatTextView import androidx.drawerlayout.widget.DrawerLayout +import androidx.preference.PreferenceManager import com.amaze.filemanager.R import com.amaze.filemanager.adapters.data.LayoutElementParcelable import com.amaze.filemanager.fileoperations.filesystem.OpenMode @@ -38,6 +39,7 @@ import com.amaze.filemanager.filesystem.PasteHelper import com.amaze.filemanager.filesystem.files.FileUtils import com.amaze.filemanager.ui.activities.MainActivity import com.amaze.filemanager.ui.dialogs.GeneralDialogCreation +import com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants import com.amaze.filemanager.ui.selection.SelectionPopupMenu.Companion.invokeSelectionDropdown import java.io.File import java.lang.ref.WeakReference @@ -237,12 +239,27 @@ class MainActivityActionMode(private val mainActivityReference: WeakReference { - GeneralDialogCreation.deleteFilesDialog( - mainActivity, - mainActivity, - checkedItems, - mainActivity.utilsProvider.appTheme, + val sharedPreferences = + PreferenceManager.getDefaultSharedPreferences(mainActivity) + val deletePermanently = sharedPreferences.getBoolean( + PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, + PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION ) + if (deletePermanently) { + Toast.makeText( + mainActivity, + mainActivity.getString(R.string.deleting), + Toast.LENGTH_SHORT + ).show() + mainActivity.mainActivityHelper.deleteFilesPermanently(checkedItems) + } else { + GeneralDialogCreation.deleteFilesDialog( + mainActivity, + mainActivity, + checkedItems, + mainActivity.utilsProvider.appTheme, + ) + } true } R.id.restore -> { diff --git a/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java b/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java index 8eeaabe7ef..c1a4ef1df5 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java +++ b/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java @@ -38,6 +38,7 @@ import com.afollestad.materialdialogs.MaterialDialog; import com.amaze.filemanager.R; +import com.amaze.filemanager.adapters.data.LayoutElementParcelable; import com.amaze.filemanager.application.AppConfig; import com.amaze.filemanager.asynchronous.asynctasks.DeleteTask; import com.amaze.filemanager.asynchronous.management.ServiceWatcherUtil; @@ -685,6 +686,15 @@ public void deleteFiles(ArrayList files, boolean doDeleteP else Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show(); } + public void deleteFilesPermanently(ArrayList files) { + final ArrayList itemsToDelete = new ArrayList<>(); + for (int i = 0; i < files.size(); i++) { + final LayoutElementParcelable layoutElement = files.get(i); + itemsToDelete.add(layoutElement.generateBaseFile()); + } + deleteFiles(itemsToDelete, true); + } + public void extractFile(@NonNull File file) { final File parent = file.getParentFile(); if (parent == null) { From 1be7ec0aa51e6e16308fbfa18c6e4b608af05f7f Mon Sep 17 00:00:00 2001 From: yashwanthgajji Date: Thu, 5 Dec 2024 20:34:59 -0500 Subject: [PATCH 3/5] spotless changes --- .../amaze/filemanager/ui/ItemPopupMenu.java | 14 +++--- .../filemanager/ui/fragments/TabFragment.java | 47 +++++++++---------- .../utils/MainActivityActionMode.kt | 11 +++-- .../filemanager/utils/MainActivityHelper.java | 14 +++--- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java index a1fdaf3a8c..826cb14078 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java +++ b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java @@ -157,18 +157,18 @@ public boolean onMenuItemClick(MenuItem item) { case R.id.delete: ArrayList positions = new ArrayList<>(); positions.add(rowItem); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - boolean deletePermanently = sharedPreferences.getBoolean( + SharedPreferences sharedPreferences = + PreferenceManager.getDefaultSharedPreferences(context); + boolean deletePermanently = + sharedPreferences.getBoolean( PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, - PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION - ); + PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION); if (deletePermanently) { - Toast.makeText(context, context.getString(R.string.deleting), Toast.LENGTH_SHORT) - .show(); + Toast.makeText(context, context.getString(R.string.deleting), Toast.LENGTH_SHORT).show(); mainActivity.mainActivityHelper.deleteFilesPermanently(positions); } else { GeneralDialogCreation.deleteFilesDialog( - context, mainActivity, positions, utilitiesProvider.getAppTheme()); + context, mainActivity, positions, utilitiesProvider.getAppTheme()); } return true; case R.id.restore: diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java index 1bada9abc4..7fda33a207 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java @@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory; import com.amaze.filemanager.R; -import com.amaze.filemanager.adapters.data.LayoutElementParcelable; import com.amaze.filemanager.application.AppConfig; import com.amaze.filemanager.database.TabHandler; import com.amaze.filemanager.database.models.explorer.Tab; @@ -508,29 +507,29 @@ private void initLeftAndRightDragListeners(boolean destroy) { new DragToTrashListener( () -> { if (mainFragment != null) { - SharedPreferences sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(requireContext()); - boolean deletePermanently = sharedPreferences.getBoolean( - PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, - PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION - ); - if (deletePermanently) { - Toast.makeText( - requireContext(), - requireContext().getString(R.string.deleting), - Toast.LENGTH_SHORT - ).show(); - requireMainActivity().mainActivityHelper.deleteFilesPermanently( - mainFragment.adapter.getCheckedItems() - ); - } else { - GeneralDialogCreation.deleteFilesDialog( - requireContext(), - requireMainActivity(), - mainFragment.adapter.getCheckedItems(), - requireMainActivity().getAppTheme() - ); - } + SharedPreferences sharedPreferences = + PreferenceManager.getDefaultSharedPreferences(requireContext()); + boolean deletePermanently = + sharedPreferences.getBoolean( + PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, + PreferencesConstants + .DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION); + if (deletePermanently) { + Toast.makeText( + requireContext(), + requireContext().getString(R.string.deleting), + Toast.LENGTH_SHORT) + .show(); + requireMainActivity() + .mainActivityHelper + .deleteFilesPermanently(mainFragment.adapter.getCheckedItems()); + } else { + GeneralDialogCreation.deleteFilesDialog( + requireContext(), + requireMainActivity(), + mainFragment.adapter.getCheckedItems(), + requireMainActivity().getAppTheme()); + } } else { AppConfig.toast(requireContext(), getString(R.string.operation_unsuccesful)); } diff --git a/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt b/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt index 6f94cc3f5c..7847025441 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt +++ b/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt @@ -241,15 +241,16 @@ class MainActivityActionMode(private val mainActivityReference: WeakReference { val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mainActivity) - val deletePermanently = sharedPreferences.getBoolean( - PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, - PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION - ) + val deletePermanently = + sharedPreferences.getBoolean( + PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, + PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, + ) if (deletePermanently) { Toast.makeText( mainActivity, mainActivity.getString(R.string.deleting), - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() mainActivity.mainActivityHelper.deleteFilesPermanently(checkedItems) } else { diff --git a/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java b/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java index c1a4ef1df5..db83fb222c 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java +++ b/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java @@ -686,14 +686,14 @@ public void deleteFiles(ArrayList files, boolean doDeleteP else Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show(); } - public void deleteFilesPermanently(ArrayList files) { - final ArrayList itemsToDelete = new ArrayList<>(); - for (int i = 0; i < files.size(); i++) { - final LayoutElementParcelable layoutElement = files.get(i); - itemsToDelete.add(layoutElement.generateBaseFile()); - } - deleteFiles(itemsToDelete, true); + public void deleteFilesPermanently(ArrayList files) { + final ArrayList itemsToDelete = new ArrayList<>(); + for (int i = 0; i < files.size(); i++) { + final LayoutElementParcelable layoutElement = files.get(i); + itemsToDelete.add(layoutElement.generateBaseFile()); } + deleteFiles(itemsToDelete, true); + } public void extractFile(@NonNull File file) { final File parent = file.getParentFile(); From ab9310ab78c050c920fed357b0f9c6ac996ece81 Mon Sep 17 00:00:00 2001 From: yashwanthgajji Date: Mon, 16 Dec 2024 22:35:45 -0500 Subject: [PATCH 4/5] corrected functionality --- .../amaze/filemanager/ui/ItemPopupMenu.java | 15 ++-------- .../ui/dialogs/GeneralDialogCreation.java | 10 ++++++- .../filemanager/ui/fragments/TabFragment.java | 29 ++++-------------- .../utils/MainActivityActionMode.kt | 30 ++++--------------- .../filemanager/utils/MainActivityHelper.java | 10 ------- 5 files changed, 22 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java index 826cb14078..2320ddb3c4 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java +++ b/app/src/main/java/com/amaze/filemanager/ui/ItemPopupMenu.java @@ -157,19 +157,8 @@ public boolean onMenuItemClick(MenuItem item) { case R.id.delete: ArrayList positions = new ArrayList<>(); positions.add(rowItem); - SharedPreferences sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(context); - boolean deletePermanently = - sharedPreferences.getBoolean( - PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, - PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION); - if (deletePermanently) { - Toast.makeText(context, context.getString(R.string.deleting), Toast.LENGTH_SHORT).show(); - mainActivity.mainActivityHelper.deleteFilesPermanently(positions); - } else { - GeneralDialogCreation.deleteFilesDialog( - context, mainActivity, positions, utilitiesProvider.getAppTheme()); - } + GeneralDialogCreation.deleteFilesDialog( + context, mainActivity, positions, utilitiesProvider.getAppTheme()); return true; case R.id.restore: ArrayList p2 = new ArrayList<>(); diff --git a/app/src/main/java/com/amaze/filemanager/ui/dialogs/GeneralDialogCreation.java b/app/src/main/java/com/amaze/filemanager/ui/dialogs/GeneralDialogCreation.java index 0c7a553e25..eb412d18f1 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/dialogs/GeneralDialogCreation.java +++ b/app/src/main/java/com/amaze/filemanager/ui/dialogs/GeneralDialogCreation.java @@ -209,6 +209,10 @@ public static void deleteFilesDialog( sharedPreferences.getBoolean( PreferencesConstants.PREFERENCE_DELETE_CONFIRMATION, PreferencesConstants.DEFAULT_PREFERENCE_DELETE_CONFIRMATION); + boolean deletePermanently = + sharedPreferences.getBoolean( + PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, + PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION); View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_delete, null); TextView deleteDisclaimerTextView = dialogView.findViewById(R.id.dialog_delete_disclaimer); final AppCompatCheckBox deletePermanentlyCheckbox = @@ -216,7 +220,11 @@ public static void deleteFilesDialog( if (positions.get(0).generateBaseFile().isLocal()) { // FIXME: make sure dialog is not shown for zero items // allow trash bin delete only for local files for now - deletePermanentlyCheckbox.setVisibility(View.VISIBLE); + if (deletePermanently) { + deletePermanentlyCheckbox.setVisibility(View.GONE); + } else { + deletePermanentlyCheckbox.setVisibility(View.VISIBLE); + } } else { deleteDisclaimerTextView.setText(context.getString(R.string.dialog_delete_disclaimer)); } diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java index 7fda33a207..9cfe88053c 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java @@ -59,7 +59,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; -import android.widget.Toast; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; @@ -507,29 +506,11 @@ private void initLeftAndRightDragListeners(boolean destroy) { new DragToTrashListener( () -> { if (mainFragment != null) { - SharedPreferences sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(requireContext()); - boolean deletePermanently = - sharedPreferences.getBoolean( - PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, - PreferencesConstants - .DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION); - if (deletePermanently) { - Toast.makeText( - requireContext(), - requireContext().getString(R.string.deleting), - Toast.LENGTH_SHORT) - .show(); - requireMainActivity() - .mainActivityHelper - .deleteFilesPermanently(mainFragment.adapter.getCheckedItems()); - } else { - GeneralDialogCreation.deleteFilesDialog( - requireContext(), - requireMainActivity(), - mainFragment.adapter.getCheckedItems(), - requireMainActivity().getAppTheme()); - } + GeneralDialogCreation.deleteFilesDialog( + requireContext(), + requireMainActivity(), + mainFragment.adapter.getCheckedItems(), + requireMainActivity().getAppTheme()); } else { AppConfig.toast(requireContext(), getString(R.string.operation_unsuccesful)); } diff --git a/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt b/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt index 7847025441..4af20b454a 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt +++ b/app/src/main/java/com/amaze/filemanager/utils/MainActivityActionMode.kt @@ -30,7 +30,6 @@ import android.widget.Toast import androidx.appcompat.view.ActionMode import androidx.appcompat.widget.AppCompatTextView import androidx.drawerlayout.widget.DrawerLayout -import androidx.preference.PreferenceManager import com.amaze.filemanager.R import com.amaze.filemanager.adapters.data.LayoutElementParcelable import com.amaze.filemanager.fileoperations.filesystem.OpenMode @@ -39,7 +38,6 @@ import com.amaze.filemanager.filesystem.PasteHelper import com.amaze.filemanager.filesystem.files.FileUtils import com.amaze.filemanager.ui.activities.MainActivity import com.amaze.filemanager.ui.dialogs.GeneralDialogCreation -import com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants import com.amaze.filemanager.ui.selection.SelectionPopupMenu.Companion.invokeSelectionDropdown import java.io.File import java.lang.ref.WeakReference @@ -239,28 +237,12 @@ class MainActivityActionMode(private val mainActivityReference: WeakReference { - val sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(mainActivity) - val deletePermanently = - sharedPreferences.getBoolean( - PreferencesConstants.PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, - PreferencesConstants.DEFAULT_PREFERENCE_DELETE_PERMANENTLY_WITHOUT_CONFIRMATION, - ) - if (deletePermanently) { - Toast.makeText( - mainActivity, - mainActivity.getString(R.string.deleting), - Toast.LENGTH_SHORT, - ).show() - mainActivity.mainActivityHelper.deleteFilesPermanently(checkedItems) - } else { - GeneralDialogCreation.deleteFilesDialog( - mainActivity, - mainActivity, - checkedItems, - mainActivity.utilsProvider.appTheme, - ) - } + GeneralDialogCreation.deleteFilesDialog( + mainActivity, + mainActivity, + checkedItems, + mainActivity.utilsProvider.appTheme, + ) true } R.id.restore -> { diff --git a/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java b/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java index db83fb222c..8eeaabe7ef 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java +++ b/app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java @@ -38,7 +38,6 @@ import com.afollestad.materialdialogs.MaterialDialog; import com.amaze.filemanager.R; -import com.amaze.filemanager.adapters.data.LayoutElementParcelable; import com.amaze.filemanager.application.AppConfig; import com.amaze.filemanager.asynchronous.asynctasks.DeleteTask; import com.amaze.filemanager.asynchronous.management.ServiceWatcherUtil; @@ -686,15 +685,6 @@ public void deleteFiles(ArrayList files, boolean doDeleteP else Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show(); } - public void deleteFilesPermanently(ArrayList files) { - final ArrayList itemsToDelete = new ArrayList<>(); - for (int i = 0; i < files.size(); i++) { - final LayoutElementParcelable layoutElement = files.get(i); - itemsToDelete.add(layoutElement.generateBaseFile()); - } - deleteFiles(itemsToDelete, true); - } - public void extractFile(@NonNull File file) { final File parent = file.getParentFile(); if (parent == null) { From 66077021b50c647579014668f9f0ac6c62f7e59d Mon Sep 17 00:00:00 2001 From: yashwanthgajji Date: Thu, 19 Dec 2024 01:00:20 -0500 Subject: [PATCH 5/5] strings corrected --- app/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5982f78a7c..1840277664 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -800,8 +800,8 @@ You only need to do this once, until the next time you select a new location for Unable to get package info from file \"%s\". Either the specified file is not an APK, or the package file is corrupt. Delete confirmation Ask for confirmation before deleting files. Disabling this is highly discouraged! - Delete permanently - Delete files permanently without asking confirmation. Enabling this is highly discouraged! + Delete permanently (Disable Trashbin) + Delete files permanently without moving to trashbin. Enabling this is highly discouraged! SSH/SFTP FTP Secure FTP