From b08d925d877b5d3a98d59766a6ca7bfb069ee721 Mon Sep 17 00:00:00 2001 From: Adrian Moreno Date: Tue, 26 Jul 2016 17:56:18 +0200 Subject: [PATCH] Added clear canvas functionality Method "clearCanvas" added to class MyCanvas. It will clear the path list and update the canvas status on screen. --- app/src/main/java/com/simplemobiletools/draw/MyCanvas.java | 7 +++++++ .../simplemobiletools/draw/activities/MainActivity.java | 3 +++ app/src/main/res/menu/menu.xml | 4 ++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 15 insertions(+) diff --git a/app/src/main/java/com/simplemobiletools/draw/MyCanvas.java b/app/src/main/java/com/simplemobiletools/draw/MyCanvas.java index a53c11e..5402400 100644 --- a/app/src/main/java/com/simplemobiletools/draw/MyCanvas.java +++ b/app/src/main/java/com/simplemobiletools/draw/MyCanvas.java @@ -85,6 +85,13 @@ public class MyCanvas extends View { canvas.drawPath(mPath, mPaint); } + public void clearCanvas(){ + mPath = new Path(); + mPaths = new LinkedHashMap<>(); + pathsUpdated(); + invalidate(); + } + private void actionDown(float x, float y) { mPath.reset(); mPath.moveTo(x, y); diff --git a/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java index 7da1661..3981cac 100644 --- a/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java @@ -84,6 +84,9 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange case R.id.settings: startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); return true; + case R.id.clear: + mMyCanvas.clearCanvas(); + return true; case R.id.about: startActivity(new Intent(getApplicationContext(), AboutActivity.class)); return true; diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml index 628228b..c5b4435 100644 --- a/app/src/main/res/menu/menu.xml +++ b/app/src/main/res/menu/menu.xml @@ -15,6 +15,10 @@ android:id="@+id/settings" android:title="@string/settings" app:showAsAction="never"/> + Settings + Clear Dark theme