Skip to content

Commit f4f2add

Browse files
committed
editing renameItemDialog style so its not that indented
1 parent 0d583c4 commit f4f2add

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/RenameItemDialog.kt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,32 @@ class RenameItemDialog(val context: Context, val path: String, val item: FileDir
2727
show()
2828
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
2929
val newName = view.item_name.value
30-
if (newName.isAValidFilename()) {
31-
val currFile = File(path, item.name)
32-
val newFile = File(path, newName)
30+
if (!newName.isAValidFilename()) {
31+
context.toast(R.string.invalid_name)
32+
return@setOnClickListener
33+
}
3334

34-
if (newFile.exists()) {
35-
context.toast(R.string.name_taken)
36-
return@setOnClickListener
37-
}
35+
val currFile = File(path, item.name)
36+
val newFile = File(path, newName)
37+
38+
if (newFile.exists()) {
39+
context.toast(R.string.name_taken)
40+
return@setOnClickListener
41+
}
3842

39-
if (context.needsStupidWritePermissions(path)) {
40-
val document = context.getFileDocument(currFile.absolutePath, Config.newInstance(context).treeUri)
41-
if (document.canWrite())
42-
document.renameTo(newName)
43+
if (context.needsStupidWritePermissions(path)) {
44+
val document = context.getFileDocument(currFile.absolutePath, Config.newInstance(context).treeUri)
45+
if (document.canWrite())
46+
document.renameTo(newName)
47+
sendSuccess(newFile)
48+
dismiss()
49+
} else {
50+
if (currFile.renameTo(newFile)) {
4351
sendSuccess(newFile)
4452
dismiss()
4553
} else {
46-
if (currFile.renameTo(newFile)) {
47-
sendSuccess(newFile)
48-
dismiss()
49-
} else {
50-
context.toast(R.string.error_occurred)
51-
}
54+
context.toast(R.string.error_occurred)
5255
}
53-
} else {
54-
context.toast(R.string.invalid_name)
5556
}
5657
})
5758
}

0 commit comments

Comments
 (0)