update commons to 3.0.21

This commit is contained in:
tibbi 2017-12-01 14:43:57 +01:00
parent 7bc3fb7197
commit 488f163806
4 changed files with 31 additions and 29 deletions

View File

@ -46,7 +46,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.0.12'
implementation 'com.simplemobiletools:commons:3.0.21'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"

View File

@ -4,13 +4,13 @@ import android.support.v7.app.AlertDialog
import android.view.WindowManager
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.draw.views.MyCanvas
import com.simplemobiletools.draw.R
import com.simplemobiletools.draw.models.Svg
import com.simplemobiletools.draw.activities.SimpleActivity
import com.simplemobiletools.draw.helpers.JPG
import com.simplemobiletools.draw.helpers.PNG
import com.simplemobiletools.draw.helpers.SVG
import com.simplemobiletools.draw.models.Svg
import com.simplemobiletools.draw.views.MyCanvas
import kotlinx.android.synthetic.main.dialog_save_image.view.*
import java.io.File
import java.io.OutputStream
@ -43,33 +43,34 @@ class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: Stri
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.save_as)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val filename = view.save_image_filename.value
if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
}
activity.setupDialogStuff(view, this, R.string.save_as) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.save_image_filename.value
if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
}
val extension = when (view.save_image_radio_group.checkedRadioButtonId) {
R.id.save_image_radio_png -> PNG
R.id.save_image_radio_svg -> SVG
else -> JPG
}
val extension = when (view.save_image_radio_group.checkedRadioButtonId) {
R.id.save_image_radio_png -> PNG
R.id.save_image_radio_svg -> SVG
else -> JPG
}
val newFile = File(realPath, "$filename.$extension")
if (!newFile.name.isAValidFilename()) {
activity.toast(R.string.filename_invalid_characters)
return@setOnClickListener
}
val newFile = File(realPath, "$filename.$extension")
if (!newFile.name.isAValidFilename()) {
activity.toast(R.string.filename_invalid_characters)
return@setOnClickListener
}
if (saveFile(newFile)) {
callback(newFile.absolutePath)
dismiss()
} else {
activity.toast(R.string.unknown_error_occurred)
if (saveFile(newFile)) {
callback(newFile.absolutePath)
dismiss()
} else {
activity.toast(R.string.unknown_error_occurred)
}
}
})
}
}
}

View File

@ -119,7 +119,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
}
fun drawBitmap(activity: Activity, path: Any) {
Thread({
Thread {
val size = Point()
activity.windowManager.defaultDisplay.getSize(size)
val options = RequestOptions()
@ -141,7 +141,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
val errorMsg = String.format(activity.getString(R.string.failed_to_load_image), path)
activity.toast(errorMsg)
}
}).start()
}.start()
}
fun addPath(path: MyPath, options: PaintOptions) {

View File

@ -44,7 +44,8 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:singleLine="true"
android:textCursorDrawable="@null"/>
android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size"/>
<RadioGroup
android:id="@+id/save_image_radio_group"