Open GoogleCodeExporter opened 8 years ago
"Accidentally" :)
Yeah, what's happening here is that when you exit the app via Back, it doesn't
retain undo state. What undo does in this case is undo the re-loading of the
last drawing canvas.
Original comment by dan.sandler
on 24 Jul 2012 at 4:52
The following patch will make the undo button do nothing if there have been no strokes made since the Slate object was created. A more elegant solution might disable the undo button completely.
--- a/src/com/google/android/apps/markers/Slate.java
+++ b/src/com/google/android/apps/markers/Slate.java
@@ -611,9 +611,10 @@ public class Slate extends View {
}
public void undo() {
- mCurrentCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
- mCurrentCanvas.drawBitmap(mPreviousBitmap, 0, 0, null);
-
+ if (mUndoEnabled) {
+ mCurrentCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
+ mCurrentCanvas.drawBitmap(mPreviousBitmap, 0, 0, null);
+ }
invalidate();
}
@@ -762,6 +763,7 @@ public class Slate extends View {
float dbgX = -1, dbgY = -1;
RectF dbgRect = new RectF();
+ private boolean mUndoEnabled;
final static boolean hasPointerCoords() {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1);
@@ -799,6 +801,7 @@ public class Slate extends View {
// starting a new touch? commit the previous state of the canvas
if (action == MotionEvent.ACTION_DOWN) {
commitStroke();
+ enableUndo();
}
if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN
@@ -880,7 +883,11 @@ public class Slate extends View {
return true;
}
- public static float lerp(float a, float b, float f) {
+ private void enableUndo() {
+ mUndoEnabled = true;
+ }
+
+ public static float lerp(float a, float b, float f) {
return a + f * (b - a);
}
Original comment by Steven.L...@gmail.com
on 24 Jul 2012 at 5:45
Original issue reported on code.google.com by
Steven.L...@gmail.com
on 24 Jul 2012 at 7:24