From 03e4d23a228d20d7746b67962dfdafa26db60a56 Mon Sep 17 00:00:00 2001 From: Lenk Date: Tue, 13 Dec 2022 13:43:41 +0100 Subject: [PATCH] PAINTROID-498 Line Color Changing --- .../command/implementation/DefaultCommandManager.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/command/implementation/DefaultCommandManager.kt b/Paintroid/src/main/java/org/catrobat/paintroid/command/implementation/DefaultCommandManager.kt index f30b016949..140224b805 100644 --- a/Paintroid/src/main/java/org/catrobat/paintroid/command/implementation/DefaultCommandManager.kt +++ b/Paintroid/src/main/java/org/catrobat/paintroid/command/implementation/DefaultCommandManager.kt @@ -113,7 +113,7 @@ class DefaultCommandManager( notifyCommandExecuted() } - private fun handleUndo(command: Command) { + private fun handleUndo(command: Command, ignoreColorCommand: Boolean = false) { var success = true var layerCount = layerModel.layerCount val currentCommandName = command.javaClass.simpleName @@ -153,9 +153,13 @@ class DefaultCommandManager( val iterator = undoCommandList.descendingIterator() while (iterator.hasNext()) { + var nextCommand = iterator.next() + if (nextCommand is ColorChangedCommand && ignoreColorCommand) { + continue + } val currentLayer = layerModel.currentLayer canvas.setBitmap(currentLayer?.bitmap) - iterator.next().run(canvas, layerModel) + nextCommand.run(canvas, layerModel) } if (!currentCommandName.matches(mergeLayerCommandRegex)) { @@ -231,7 +235,7 @@ class DefaultCommandManager( if (undoCommandList.isNotEmpty() && undoCommandList.first != null) { val command = undoCommandList.pop() redoCommandList.addFirst(command) - handleUndo(command) + handleUndo(command, true) } return colorCommandList }