mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-18 09:17:22 +02:00
do not split the filename at Save As to filename and extension
This commit is contained in:
parent
c5db35da8d
commit
4420dc0b60
@ -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 {
|
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_save_as, null).apply {
|
||||||
file_path.text = activity.humanizePath(realPath)
|
file_path.text = activity.humanizePath(realPath)
|
||||||
|
|
||||||
val fullName = noteTitle
|
file_name.setText(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_path.setOnClickListener {
|
file_path.setOnClickListener {
|
||||||
FilePickerDialog(activity, realPath, false, false, true) {
|
FilePickerDialog(activity, realPath, false, false, true) {
|
||||||
file_path.text = activity.humanizePath(it)
|
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)
|
activity.setupDialogStuff(view, this, R.string.save_as)
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||||
val filename = view.file_name.value
|
val filename = view.file_name.value
|
||||||
val extension = view.file_extension.value
|
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
context.toast(R.string.filename_cannot_be_empty)
|
context.toast(R.string.filename_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullFileName = filename
|
val newFile = File(realPath, filename)
|
||||||
if (extension.trim().isNotEmpty())
|
|
||||||
fullFileName += ".$extension"
|
|
||||||
|
|
||||||
val newFile = File(realPath, fullFileName)
|
|
||||||
if (!newFile.name.isAValidFilename()) {
|
if (!newFile.name.isAValidFilename()) {
|
||||||
context.toast(R.string.filename_invalid_characters)
|
context.toast(R.string.filename_invalid_characters)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
|
@ -31,18 +31,4 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textCursorDrawable="@null"/>
|
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>
|
</LinearLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user