diff --git a/app/build.gradle b/app/build.gradle index 795bd43ec..1cebf1a0c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.10.5' + compile 'com.simplemobiletools:commons:2.10.12' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 1c0c1ced1..c61dbe85d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -15,12 +15,12 @@ import com.bumptech.glide.signature.StringSignature import com.simplemobiletools.commons.asynctasks.CopyMoveTask import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.PropertiesDialog +import com.simplemobiletools.commons.dialogs.RenameFolderDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.dialogs.CopyDialog import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog -import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.directory_item.view.* @@ -165,13 +165,11 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList) -> Unit) { - init { - val view = LayoutInflater.from(activity).inflate(R.layout.rename_directory, null).apply { - directory_name.setText(dir.name) - directory_path.text = "${activity.humanizePath(dir.parent)}/" - } - - AlertDialog.Builder(activity) - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) - .create().apply { - window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - activity.setupDialogStuff(view, this, R.string.rename_folder) - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ - val newDirName = view.directory_name.value - if (newDirName.isEmpty()) { - context.toast(R.string.rename_folder_empty) - return@setOnClickListener - } - - if (!newDirName.isAValidFilename()) { - context.toast(R.string.invalid_name) - return@setOnClickListener - } - - val updatedFiles = ArrayList() - updatedFiles.add(dir.absolutePath) - val newDir = File(dir.parent, newDirName) - - if (newDir.exists()) { - context.toast(R.string.rename_folder_exists) - return@setOnClickListener - } - - if (context.needsStupidWritePermissions(dir.absolutePath)) { - activity.handleSAFDialog(dir) { - val document = context.getFileDocument(dir.absolutePath, context.config.treeUri) ?: return@handleSAFDialog - if (document.canWrite()) - document.renameTo(newDirName) - sendSuccess(updatedFiles, newDir) - dismiss() - } - } else if (dir.renameTo(newDir)) { - sendSuccess(updatedFiles, newDir) - dismiss() - } else { - context.toast(R.string.rename_folder_error) - } - }) - } - } - - private fun sendSuccess(updatedFiles: ArrayList, newDir: File) { - activity.toast(R.string.renaming_folder) - val files = if (newDir.isDirectory) newDir.listFiles() else arrayOf() - files.mapTo(updatedFiles) { it.absolutePath } - - updatedFiles.add(newDir.absolutePath) - callback.invoke(updatedFiles) - } -} diff --git a/app/src/main/res/layout/rename_directory.xml b/app/src/main/res/layout/rename_directory.xml deleted file mode 100644 index 8ccc8f383..000000000 --- a/app/src/main/res/layout/rename_directory.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - -