From 768b7ac6abb81727e771db566712fc1e4da25010 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 29 Aug 2017 16:23:07 +0200 Subject: [PATCH] add the eraser button --- .../main/kotlin/com/simplemobiletools/draw/MyCanvas.kt | 4 ++++ .../com/simplemobiletools/draw/activities/MainActivity.kt | 2 ++ app/src/main/res/layout/activity_main.xml | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt b/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt index 06b2fb3..800d47e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt @@ -59,6 +59,10 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { invalidate() } + fun toggleEraser() { + + } + fun setColor(newColor: Int) { mPaintOptions.color = newColor if (mIsStrokeWidthBarEnabled) { diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt index 8543be5..1b45ef0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt @@ -60,6 +60,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener { color_picker.setOnClickListener { pickColor() } undo.setOnClickListener { my_canvas.undo() } + eraser.setOnClickListener { my_canvas.toggleEraser() } storeStoragePaths() if (intent?.action == Intent.ACTION_VIEW && intent.data != null) { @@ -230,6 +231,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener { fun setBackgroundColor(pickedColor: Int) { undo.setColorFilter(pickedColor.getContrastColor(), PorterDuff.Mode.SRC_IN) + eraser.setColorFilter(pickedColor.getContrastColor(), PorterDuff.Mode.SRC_IN) my_canvas.setBackgroundColor(pickedColor) my_canvas.mBackgroundBitmap = null suggestedFileExtension = PNG diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ae68c0c..d21f7fe 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,6 +11,14 @@ android:layout_height="match_parent" android:background="@android:color/white"/> + +