use the activities function for filling the canvas background color
This commit is contained in:
parent
8147db004b
commit
cc78d65f80
|
@ -1,10 +1,10 @@
|
|||
package com.simplemobiletools.draw
|
||||
|
||||
import android.app.Activity
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.sax.RootElement
|
||||
import android.util.Xml
|
||||
import com.simplemobiletools.draw.activities.MainActivity
|
||||
import java.io.*
|
||||
import java.util.*
|
||||
|
||||
|
@ -46,11 +46,11 @@ object Svg {
|
|||
}
|
||||
}
|
||||
|
||||
fun loadSvg(activity: Activity, file: File, canvas: MyCanvas) {
|
||||
fun loadSvg(activity: MainActivity, file: File, canvas: MyCanvas) {
|
||||
val svg = parseSvg(file)
|
||||
|
||||
canvas.clearCanvas()
|
||||
canvas.setBackgroundColor(svg.background!!.color)
|
||||
activity.setBackgroundColor(svg.background!!.color)
|
||||
|
||||
svg.paths.forEach {
|
||||
val path = MyPath()
|
||||
|
|
|
@ -109,15 +109,19 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
|||
|
||||
private fun openFile() {
|
||||
FilePickerDialog(this, curPath) {
|
||||
if (it.endsWith(".svg")) {
|
||||
Svg.loadSvg(this, File(it), my_canvas)
|
||||
} else if (File(it).isImageSlow()) {
|
||||
tryOpenFile(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun tryOpenFile(path: String) {
|
||||
if (path.endsWith(".svg")) {
|
||||
Svg.loadSvg(this, File(path), my_canvas)
|
||||
} else if (File(path).isImageSlow()) {
|
||||
|
||||
} else {
|
||||
toast(R.string.invalid_file_format)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeBackgroundClicked() {
|
||||
val oldColor = (my_canvas.background as ColorDrawable).color
|
||||
|
@ -187,7 +191,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setBackgroundColor(pickedColor: Int) {
|
||||
fun setBackgroundColor(pickedColor: Int) {
|
||||
undo.setColorFilter(pickedColor.getContrastColor(), PorterDuff.Mode.SRC_IN)
|
||||
my_canvas.setBackgroundColor(pickedColor)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue