mirror of
				https://github.com/SimpleMobileTools/Simple-Draw.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	use the activities function for filling the canvas background color
This commit is contained in:
		| @@ -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,13 +109,17 @@ 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) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|             } else { | ||||
|                 toast(R.string.invalid_file_format) | ||||
|             } | ||||
|     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) | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -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) | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user