properly open svg files

This commit is contained in:
tibbi 2017-04-09 10:00:07 +02:00
parent dab7102e61
commit e919534780
6 changed files with 5 additions and 21 deletions

View File

@ -5,7 +5,6 @@ import com.simplemobiletools.draw.actions.Action
import com.simplemobiletools.draw.actions.Line
import com.simplemobiletools.draw.actions.Move
import com.simplemobiletools.draw.actions.Quad
import java.io.IOException
import java.io.ObjectInputStream
import java.io.Serializable
import java.security.InvalidParameterException
@ -16,7 +15,6 @@ class MyPath : Path(), Serializable {
private val actions = LinkedList<Action>()
@Throws(IOException::class, ClassNotFoundException::class)
private fun readObject(inputStream: ObjectInputStream) {
inputStream.defaultReadObject()
@ -25,7 +23,6 @@ class MyPath : Path(), Serializable {
}
}
@Throws(InvalidParameterException::class)
fun readObject(pathData: String) {
val tokens = pathData.split("\\s+".toRegex()).dropLastWhile(String::isEmpty).toTypedArray()
var i = 0

View File

@ -1,14 +1,11 @@
package com.simplemobiletools.draw.actions
import android.graphics.Path
import java.io.IOException
import java.io.Serializable
import java.io.Writer
interface Action : Serializable {
fun perform(path: Path)
@Throws(IOException::class)
fun perform(writer: Writer)
}

View File

@ -1,8 +1,6 @@
package com.simplemobiletools.draw.actions
import android.graphics.Path
import java.io.IOException
import java.io.Writer
import java.security.InvalidParameterException
@ -11,9 +9,8 @@ class Line : Action {
val x: Float
val y: Float
@Throws(InvalidParameterException::class)
constructor(data: String) {
if (data.startsWith("L"))
if (!data.startsWith("L"))
throw InvalidParameterException("The Line data should start with 'L'.")
try {
@ -35,7 +32,6 @@ class Line : Action {
path.lineTo(x, y)
}
@Throws(IOException::class)
override fun perform(writer: Writer) {
writer.write("L")
writer.write(x.toString())

View File

@ -1,8 +1,6 @@
package com.simplemobiletools.draw.actions
import android.graphics.Path
import java.io.IOException
import java.io.Writer
import java.security.InvalidParameterException
@ -11,9 +9,8 @@ class Move : Action {
val x: Float
val y: Float
@Throws(InvalidParameterException::class)
constructor(data: String) {
if (data.startsWith("M"))
if (!data.startsWith("M"))
throw InvalidParameterException("The Move data should start with 'M'.")
try {
@ -35,7 +32,6 @@ class Move : Action {
path.moveTo(x, y)
}
@Throws(IOException::class)
override fun perform(writer: Writer) {
writer.write("M")
writer.write(x.toString())

View File

@ -1,8 +1,6 @@
package com.simplemobiletools.draw.actions
import android.graphics.Path
import java.io.IOException
import java.io.Writer
import java.security.InvalidParameterException
@ -14,7 +12,7 @@ class Quad : Action {
val y2: Float
constructor(data: String) {
if (data.startsWith("Q"))
if (!data.startsWith("Q"))
throw InvalidParameterException("The Quad data should start with 'Q'.")
try {
@ -43,7 +41,6 @@ class Quad : Action {
path.quadTo(x1, y1, x2, y2)
}
@Throws(IOException::class)
override fun perform(writer: Writer) {
writer.write("Q")
writer.write(x1.toString())

View File

@ -20,6 +20,7 @@ import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
import com.simplemobiletools.draw.BuildConfig
import com.simplemobiletools.draw.MyCanvas
import com.simplemobiletools.draw.R
import com.simplemobiletools.draw.Svg
import com.simplemobiletools.draw.dialogs.SaveImageDialog
import com.simplemobiletools.draw.extensions.config
import kotlinx.android.synthetic.main.activity_main.*
@ -109,7 +110,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
private fun openFile() {
FilePickerDialog(this, curPath) {
if (it.endsWith(".svg")) {
Svg.loadSvg(File(it), my_canvas)
} else if (File(it).isImageSlow()) {
} else {