Skip to content
Open
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 @@ -152,7 +152,7 @@
path: String,
): Pair<Boolean, Int> {
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)
Expand Down Expand Up @@ -190,6 +190,17 @@
.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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a snackbar per Android guidelines https://developer.android.com/guide/topics/ui/notifiers/toasts

requireContext(),
requireContext().getString(result.second),
Toast.LENGTH_SHORT,
).show()
return@setOnClickListener

Check warning on line 201 in app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/BookmarksPrefsFragment.kt

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/src/main/java/com/amaze/filemanager/ui/fragments/preferencefragments/BookmarksPrefsFragment.kt#L201

Expression with labels increase complexity and affect maintainability.
}

dataUtils.removeBook(position[p]!!)
position.remove(p)
bookmarksList?.removePreference(p)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int contains(String[] a, ArrayList<String[]> 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this (DataUtils::constains) function is very opaque, what is it actually doing? Whats the fix doing?

i++;
}
return -1;
Expand Down
Loading