mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-02-17 12:10:47 +01:00
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
|
package com.simplemobiletools.draw
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.sax.RootElement
|
import android.sax.RootElement
|
||||||
import android.util.Xml
|
import android.util.Xml
|
||||||
|
import com.simplemobiletools.draw.activities.MainActivity
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.*
|
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)
|
val svg = parseSvg(file)
|
||||||
|
|
||||||
canvas.clearCanvas()
|
canvas.clearCanvas()
|
||||||
canvas.setBackgroundColor(svg.background!!.color)
|
activity.setBackgroundColor(svg.background!!.color)
|
||||||
|
|
||||||
svg.paths.forEach {
|
svg.paths.forEach {
|
||||||
val path = MyPath()
|
val path = MyPath()
|
||||||
|
@ -109,13 +109,17 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
|||||||
|
|
||||||
private fun openFile() {
|
private fun openFile() {
|
||||||
FilePickerDialog(this, curPath) {
|
FilePickerDialog(this, curPath) {
|
||||||
if (it.endsWith(".svg")) {
|
tryOpenFile(it)
|
||||||
Svg.loadSvg(this, File(it), my_canvas)
|
}
|
||||||
} else if (File(it).isImageSlow()) {
|
}
|
||||||
|
|
||||||
} else {
|
private fun tryOpenFile(path: String) {
|
||||||
toast(R.string.invalid_file_format)
|
if (path.endsWith(".svg")) {
|
||||||
}
|
Svg.loadSvg(this, File(path), my_canvas)
|
||||||
|
} else if (File(path).isImageSlow()) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
toast(R.string.invalid_file_format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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)
|
undo.setColorFilter(pickedColor.getContrastColor(), PorterDuff.Mode.SRC_IN)
|
||||||
my_canvas.setBackgroundColor(pickedColor)
|
my_canvas.setBackgroundColor(pickedColor)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user