fix #204, allow saving files without an extension

This commit is contained in:
tibbi 2018-03-31 10:55:04 +02:00
parent 73afe2caff
commit ada298017b
4 changed files with 74 additions and 78 deletions

View File

@ -2,7 +2,6 @@ package com.simplemobiletools.filemanager.dialogs
import android.support.v7.app.AlertDialog
import android.view.View
import android.view.WindowManager
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
@ -36,7 +35,7 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.compress_as) {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
showKeyboard(view.file_name)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
val name = view.file_name.value
when {

View File

@ -2,7 +2,6 @@ package com.simplemobiletools.filemanager.dialogs
import android.support.v7.app.AlertDialog
import android.view.View
import android.view.WindowManager
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.filemanager.R
@ -19,7 +18,7 @@ class CreateNewItemDialog(val activity: BaseSimpleActivity, val path: String, va
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.create_new) {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
showKeyboard(view.item_name)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
val name = view.item_name.value
if (name.isEmpty()) {

View File

@ -1,7 +1,6 @@
package com.simplemobiletools.filemanager.dialogs
import android.support.v7.app.AlertDialog
import android.view.WindowManager
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog
@ -43,8 +42,8 @@ class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callb
.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.save_as) {
showKeyboard(view.save_as_name)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.save_as_name.value
val extension = view.save_as_extension.value
@ -54,12 +53,11 @@ class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callb
return@setOnClickListener
}
if (extension.isEmpty()) {
activity.toast(R.string.extension_cannot_be_empty)
return@setOnClickListener
var newFilename = filename
if (extension.isNotEmpty()) {
newFilename += ".$extension"
}
val newFilename = "$filename.$extension"
val newPath = "$realPath/$newFilename"
if (!newFilename.isAValidFilename()) {
activity.toast(R.string.filename_invalid_characters)