do not split the filename at Save As to filename and extension

This commit is contained in:
tibbi 2017-03-09 22:03:35 +01:00
parent c5db35da8d
commit 4420dc0b60
2 changed files with 2 additions and 31 deletions

View File

@ -17,17 +17,7 @@ class SaveAsDialog(val activity: SimpleActivity, val noteTitle: String, val call
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_save_as, null).apply {
file_path.text = activity.humanizePath(realPath)
val fullName = noteTitle
val dotAt = fullName.lastIndexOf(".")
var name = fullName
if (dotAt > 0) {
name = fullName.substring(0, dotAt)
val extension = fullName.substring(dotAt + 1)
file_extension.setText(extension)
}
file_name.setText(name)
file_name.setText(noteTitle)
file_path.setOnClickListener {
FilePickerDialog(activity, realPath, false, false, true) {
file_path.text = activity.humanizePath(it)
@ -44,18 +34,13 @@ class SaveAsDialog(val activity: SimpleActivity, val noteTitle: String, val call
activity.setupDialogStuff(view, this, R.string.save_as)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val filename = view.file_name.value
val extension = view.file_extension.value
if (filename.isEmpty()) {
context.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
}
var fullFileName = filename
if (extension.trim().isNotEmpty())
fullFileName += ".$extension"
val newFile = File(realPath, fullFileName)
val newFile = File(realPath, filename)
if (!newFile.name.isAValidFilename()) {
context.toast(R.string.filename_invalid_characters)
return@setOnClickListener

View File

@ -31,18 +31,4 @@
android:singleLine="true"
android:textCursorDrawable="@null"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/file_extension_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/extension"/>
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/file_extension"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:singleLine="true"
android:textCursorDrawable="@null"/>
</LinearLayout>