add the eraser button
This commit is contained in:
parent
3e46a557bc
commit
768b7ac6ab
|
@ -59,6 +59,10 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun toggleEraser() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun setColor(newColor: Int) {
|
fun setColor(newColor: Int) {
|
||||||
mPaintOptions.color = newColor
|
mPaintOptions.color = newColor
|
||||||
if (mIsStrokeWidthBarEnabled) {
|
if (mIsStrokeWidthBarEnabled) {
|
||||||
|
|
|
@ -60,6 +60,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
||||||
|
|
||||||
color_picker.setOnClickListener { pickColor() }
|
color_picker.setOnClickListener { pickColor() }
|
||||||
undo.setOnClickListener { my_canvas.undo() }
|
undo.setOnClickListener { my_canvas.undo() }
|
||||||
|
eraser.setOnClickListener { my_canvas.toggleEraser() }
|
||||||
storeStoragePaths()
|
storeStoragePaths()
|
||||||
|
|
||||||
if (intent?.action == Intent.ACTION_VIEW && intent.data != null) {
|
if (intent?.action == Intent.ACTION_VIEW && intent.data != null) {
|
||||||
|
@ -230,6 +231,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
||||||
|
|
||||||
fun setBackgroundColor(pickedColor: Int) {
|
fun setBackgroundColor(pickedColor: Int) {
|
||||||
undo.setColorFilter(pickedColor.getContrastColor(), PorterDuff.Mode.SRC_IN)
|
undo.setColorFilter(pickedColor.getContrastColor(), PorterDuff.Mode.SRC_IN)
|
||||||
|
eraser.setColorFilter(pickedColor.getContrastColor(), PorterDuff.Mode.SRC_IN)
|
||||||
my_canvas.setBackgroundColor(pickedColor)
|
my_canvas.setBackgroundColor(pickedColor)
|
||||||
my_canvas.mBackgroundBitmap = null
|
my_canvas.mBackgroundBitmap = null
|
||||||
suggestedFileExtension = PNG
|
suggestedFileExtension = PNG
|
||||||
|
|
|
@ -11,6 +11,14 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/white"/>
|
android:background="@android:color/white"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/eraser"
|
||||||
|
android:layout_width="@dimen/normal_icon_size"
|
||||||
|
android:layout_height="@dimen/normal_icon_size"
|
||||||
|
android:layout_toLeftOf="@+id/color_picker"
|
||||||
|
android:padding="@dimen/normal_margin"
|
||||||
|
android:src="@drawable/ic_eraser"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/color_picker"
|
android:id="@+id/color_picker"
|
||||||
android:layout_width="@dimen/normal_icon_size"
|
android:layout_width="@dimen/normal_icon_size"
|
||||||
|
|
Loading…
Reference in New Issue