Loading build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 propVersionName = '3.11.47' propVersionName = '3.11.48' kotlin_version = '1.2.21' support_libs = '27.0.2' } Loading commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt +6 −6 Original line number Diff line number Diff line Loading @@ -183,8 +183,7 @@ open class BaseSimpleActivity : AppCompatActivity() { return } val destinationFolder = File(destination) if (!destinationFolder.exists() && getSomeDocumentFile(destination) == null) { if (!doesFilePathExist(destination)) { toast(R.string.invalid_destination) return } Loading @@ -203,6 +202,7 @@ open class BaseSimpleActivity : AppCompatActivity() { val updatedFiles = ArrayList<FileDirItem>(fileDirItems.size * 2) updatedFiles.addAll(fileDirItems) try { val destinationFolder = File(destination) for (oldFileDirItem in fileDirItems) { val newFile = File(destinationFolder, oldFileDirItem.name) if (!newFile.exists() && File(oldFileDirItem.path).renameTo(newFile)) { Loading Loading @@ -244,15 +244,15 @@ open class BaseSimpleActivity : AppCompatActivity() { } val file = files[index] val newFile = File(destinationFileDirItem.path, file.name) if (newFile.exists()) { FileConflictDialog(this, newFile) { resolution, applyForAll -> val newFileDirItem = FileDirItem("${destinationFileDirItem.path}/${file.name}", file.name, file.isDirectory) if (doesFilePathExist(newFileDirItem.path)) { FileConflictDialog(this, newFileDirItem) { resolution, applyForAll -> if (applyForAll) { conflictResolutions.clear() conflictResolutions[""] = resolution checkConflict(files, destinationFileDirItem, files.size, conflictResolutions, callback) } else { conflictResolutions[newFile.absolutePath] = resolution conflictResolutions[newFileDirItem.path] = resolution checkConflict(files, destinationFileDirItem, index + 1, conflictResolutions, callback) } } Loading commons/src/main/kotlin/com/simplemobiletools/commons/asynctasks/CopyMoveTask.kt +1 −1 Original line number Diff line number Diff line Loading @@ -232,9 +232,9 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal while (bytes >= 0) { out!!.write(buffer, 0, bytes) copiedSize += bytes mCurrentProgress += bytes bytes = inputStream.read(buffer) } mCurrentProgress += copiedSize if (source.size == copiedSize) { mTransferredFiles.add(source) Loading commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt +7 −4 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import java.io.File class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) { init { val view = activity.layoutInflater.inflate(R.layout.dialog_create_new_folder, null) view.folder_path.text = activity.humanizePath(path).trimEnd('/') + "/" view.folder_path.text = "${activity.humanizePath(path)}/" AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) Loading Loading @@ -45,9 +45,12 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, when { activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) { try { val documentFile = activity.getDocumentFile(path) documentFile?.createDirectory(path.getFilenameFromPath()) val documentFile = activity.getDocumentFile(path.getParentPath()) if (documentFile?.createDirectory(path.getFilenameFromPath()) != null) { sendSuccess(alertDialog, path) } else { activity.toast(R.string.unknown_error_occurred) } } catch (e: SecurityException) { activity.showErrorToast(e) } Loading commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/FileConflictDialog.kt +5 −5 Original line number Diff line number Diff line Loading @@ -11,18 +11,18 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.helpers.CONFLICT_MERGE import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE import com.simplemobiletools.commons.helpers.CONFLICT_SKIP import com.simplemobiletools.commons.models.FileDirItem import kotlinx.android.synthetic.main.dialog_file_conflict.view.* import java.io.File class FileConflictDialog(val activity: Activity, val file: File, val callback: (resolution: Int, applyForAll: Boolean) -> Unit) { class FileConflictDialog(val activity: Activity, val fileDirItem: FileDirItem, val callback: (resolution: Int, applyForAll: Boolean) -> Unit) { val view = activity.layoutInflater.inflate(R.layout.dialog_file_conflict, null)!! init { view.apply { val stringBase = if (file.isDirectory) R.string.folder_already_exists else R.string.file_already_exists conflict_dialog_title.text = String.format(activity.getString(stringBase), file.name) val stringBase = if (fileDirItem.isDirectory) R.string.folder_already_exists else R.string.file_already_exists conflict_dialog_title.text = String.format(activity.getString(stringBase), fileDirItem.name) conflict_dialog_apply_to_all.isChecked = activity.baseConfig.lastConflictApplyToAll conflict_dialog_radio_merge.beVisibleIf(file.isDirectory) conflict_dialog_radio_merge.beVisibleIf(fileDirItem.isDirectory) val resolutionButton = when (activity.baseConfig.lastConflictResolution) { CONFLICT_OVERWRITE -> conflict_dialog_radio_overwrite Loading Loading
build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 propVersionName = '3.11.47' propVersionName = '3.11.48' kotlin_version = '1.2.21' support_libs = '27.0.2' } Loading
commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt +6 −6 Original line number Diff line number Diff line Loading @@ -183,8 +183,7 @@ open class BaseSimpleActivity : AppCompatActivity() { return } val destinationFolder = File(destination) if (!destinationFolder.exists() && getSomeDocumentFile(destination) == null) { if (!doesFilePathExist(destination)) { toast(R.string.invalid_destination) return } Loading @@ -203,6 +202,7 @@ open class BaseSimpleActivity : AppCompatActivity() { val updatedFiles = ArrayList<FileDirItem>(fileDirItems.size * 2) updatedFiles.addAll(fileDirItems) try { val destinationFolder = File(destination) for (oldFileDirItem in fileDirItems) { val newFile = File(destinationFolder, oldFileDirItem.name) if (!newFile.exists() && File(oldFileDirItem.path).renameTo(newFile)) { Loading Loading @@ -244,15 +244,15 @@ open class BaseSimpleActivity : AppCompatActivity() { } val file = files[index] val newFile = File(destinationFileDirItem.path, file.name) if (newFile.exists()) { FileConflictDialog(this, newFile) { resolution, applyForAll -> val newFileDirItem = FileDirItem("${destinationFileDirItem.path}/${file.name}", file.name, file.isDirectory) if (doesFilePathExist(newFileDirItem.path)) { FileConflictDialog(this, newFileDirItem) { resolution, applyForAll -> if (applyForAll) { conflictResolutions.clear() conflictResolutions[""] = resolution checkConflict(files, destinationFileDirItem, files.size, conflictResolutions, callback) } else { conflictResolutions[newFile.absolutePath] = resolution conflictResolutions[newFileDirItem.path] = resolution checkConflict(files, destinationFileDirItem, index + 1, conflictResolutions, callback) } } Loading
commons/src/main/kotlin/com/simplemobiletools/commons/asynctasks/CopyMoveTask.kt +1 −1 Original line number Diff line number Diff line Loading @@ -232,9 +232,9 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal while (bytes >= 0) { out!!.write(buffer, 0, bytes) copiedSize += bytes mCurrentProgress += bytes bytes = inputStream.read(buffer) } mCurrentProgress += copiedSize if (source.size == copiedSize) { mTransferredFiles.add(source) Loading
commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt +7 −4 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import java.io.File class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) { init { val view = activity.layoutInflater.inflate(R.layout.dialog_create_new_folder, null) view.folder_path.text = activity.humanizePath(path).trimEnd('/') + "/" view.folder_path.text = "${activity.humanizePath(path)}/" AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) Loading Loading @@ -45,9 +45,12 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, when { activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) { try { val documentFile = activity.getDocumentFile(path) documentFile?.createDirectory(path.getFilenameFromPath()) val documentFile = activity.getDocumentFile(path.getParentPath()) if (documentFile?.createDirectory(path.getFilenameFromPath()) != null) { sendSuccess(alertDialog, path) } else { activity.toast(R.string.unknown_error_occurred) } } catch (e: SecurityException) { activity.showErrorToast(e) } Loading
commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/FileConflictDialog.kt +5 −5 Original line number Diff line number Diff line Loading @@ -11,18 +11,18 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.helpers.CONFLICT_MERGE import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE import com.simplemobiletools.commons.helpers.CONFLICT_SKIP import com.simplemobiletools.commons.models.FileDirItem import kotlinx.android.synthetic.main.dialog_file_conflict.view.* import java.io.File class FileConflictDialog(val activity: Activity, val file: File, val callback: (resolution: Int, applyForAll: Boolean) -> Unit) { class FileConflictDialog(val activity: Activity, val fileDirItem: FileDirItem, val callback: (resolution: Int, applyForAll: Boolean) -> Unit) { val view = activity.layoutInflater.inflate(R.layout.dialog_file_conflict, null)!! init { view.apply { val stringBase = if (file.isDirectory) R.string.folder_already_exists else R.string.file_already_exists conflict_dialog_title.text = String.format(activity.getString(stringBase), file.name) val stringBase = if (fileDirItem.isDirectory) R.string.folder_already_exists else R.string.file_already_exists conflict_dialog_title.text = String.format(activity.getString(stringBase), fileDirItem.name) conflict_dialog_apply_to_all.isChecked = activity.baseConfig.lastConflictApplyToAll conflict_dialog_radio_merge.beVisibleIf(file.isDirectory) conflict_dialog_radio_merge.beVisibleIf(fileDirItem.isDirectory) val resolutionButton = when (activity.baseConfig.lastConflictResolution) { CONFLICT_OVERWRITE -> conflict_dialog_radio_overwrite Loading