diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/BookmarksPrefsFragment.kt b/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/BookmarksPrefsFragment.kt index 3ce9e62e85..ae04ad94f8 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/BookmarksPrefsFragment.kt +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/BookmarksPrefsFragment.kt @@ -152,7 +152,7 @@ class BookmarksPrefsFragment : BasePrefsFragment() { path: String, ): Pair { return when { - name.isEmpty() -> Pair(false, R.string.invalid_name) + name.isEmpty() || path.isEmpty() -> Pair(false, R.string.invalid_name) dataUtils.containsBooks(arrayOf(name, path)) != -1 -> Pair(false, R.string.bookmark_exists) !FileUtils.isPathAccessible(path, activity.prefs) -> Pair(false, R.string.ftp_path_change_error_invalid) else -> Pair(true, 0) @@ -190,6 +190,17 @@ class BookmarksPrefsFragment : BasePrefsFragment() { .setOnClickListener { val oldName = p.title.toString() val oldPath = p.summary.toString() + + val result = isValidBookmark(editText1.text.toString(), editText2.text.toString()) + if (!result.first) { + Toast.makeText( + requireContext(), + requireContext().getString(result.second), + Toast.LENGTH_SHORT, + ).show() + return@setOnClickListener + } + dataUtils.removeBook(position[p]!!) position.remove(p) bookmarksList?.removePreference(p) diff --git a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java index 8e090417d4..ae02ba2702 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java @@ -174,7 +174,7 @@ int contains(String[] a, ArrayList b) { if (b == null) return -1; int i = 0; for (String[] x : b) { - if (x[0].equals(a[0]) && x[1].equals(a[1])) return i; + if (x[0].equals(a[0]) || x[1].equals(a[1])) return i; i++; } return -1;