@@ -4,13 +4,13 @@ import android.support.v7.app.AlertDialog
44import android.view.WindowManager
55import com.simplemobiletools.commons.dialogs.FilePickerDialog
66import com.simplemobiletools.commons.extensions.*
7- import com.simplemobiletools.draw.views.MyCanvas
87import com.simplemobiletools.draw.R
9- import com.simplemobiletools.draw.models.Svg
108import com.simplemobiletools.draw.activities.SimpleActivity
119import com.simplemobiletools.draw.helpers.JPG
1210import com.simplemobiletools.draw.helpers.PNG
1311import com.simplemobiletools.draw.helpers.SVG
12+ import com.simplemobiletools.draw.models.Svg
13+ import com.simplemobiletools.draw.views.MyCanvas
1414import kotlinx.android.synthetic.main.dialog_save_image.view.*
1515import java.io.File
1616import java.io.OutputStream
@@ -43,33 +43,34 @@ class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: Stri
4343 .setNegativeButton(R .string.cancel, null )
4444 .create().apply {
4545 window!! .setSoftInputMode(WindowManager .LayoutParams .SOFT_INPUT_STATE_ALWAYS_VISIBLE )
46- activity.setupDialogStuff(view, this , R .string.save_as)
47- getButton(AlertDialog .BUTTON_POSITIVE ).setOnClickListener( {
48- val filename = view.save_image_filename.value
49- if (filename.isEmpty()) {
50- activity.toast(R .string.filename_cannot_be_empty)
51- return @setOnClickListener
52- }
46+ activity.setupDialogStuff(view, this , R .string.save_as) {
47+ getButton(AlertDialog .BUTTON_POSITIVE ).setOnClickListener {
48+ val filename = view.save_image_filename.value
49+ if (filename.isEmpty()) {
50+ activity.toast(R .string.filename_cannot_be_empty)
51+ return @setOnClickListener
52+ }
5353
54- val extension = when (view.save_image_radio_group.checkedRadioButtonId) {
55- R .id.save_image_radio_png -> PNG
56- R .id.save_image_radio_svg -> SVG
57- else -> JPG
58- }
54+ val extension = when (view.save_image_radio_group.checkedRadioButtonId) {
55+ R .id.save_image_radio_png -> PNG
56+ R .id.save_image_radio_svg -> SVG
57+ else -> JPG
58+ }
5959
60- val newFile = File (realPath, " $filename .$extension " )
61- if (! newFile.name.isAValidFilename()) {
62- activity.toast(R .string.filename_invalid_characters)
63- return @setOnClickListener
64- }
60+ val newFile = File (realPath, " $filename .$extension " )
61+ if (! newFile.name.isAValidFilename()) {
62+ activity.toast(R .string.filename_invalid_characters)
63+ return @setOnClickListener
64+ }
6565
66- if (saveFile(newFile)) {
67- callback(newFile.absolutePath)
68- dismiss()
69- } else {
70- activity.toast(R .string.unknown_error_occurred)
66+ if (saveFile(newFile)) {
67+ callback(newFile.absolutePath)
68+ dismiss()
69+ } else {
70+ activity.toast(R .string.unknown_error_occurred)
71+ }
7172 }
72- })
73+ }
7374 }
7475 }
7576
0 commit comments