adding an Undo button to editor drawing

This commit is contained in:
tibbi
2019-01-13 18:02:06 +01:00
parent 5f9378135a
commit 1776ab592d
3 changed files with 30 additions and 3 deletions

View File

@ -460,6 +460,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
config.lastEditorBrushSize = it
updateBrushSize(it)
}
bottom_draw_undo.setOnClickListener {
editor_draw_canvas.undo()
}
}
private fun updateBrushSize(percent: Int) {

View File

@ -139,4 +139,14 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
draw(canvas)
return bitmap
}
fun undo() {
if (mPaths.isEmpty()) {
return
}
val lastKey = mPaths.keys.lastOrNull()
mPaths.remove(lastKey)
invalidate()
}
}