mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-25 07:51:26 +01:00
adding an Undo button to editor drawing
This commit is contained in:
parent
5f9378135a
commit
1776ab592d
@ -460,6 +460,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||
config.lastEditorBrushSize = it
|
||||
updateBrushSize(it)
|
||||
}
|
||||
|
||||
bottom_draw_undo.setOnClickListener {
|
||||
editor_draw_canvas.undo()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateBrushSize(percent: Int) {
|
||||
|
@ -139,4 +139,14 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
|
||||
draw(canvas)
|
||||
return bitmap
|
||||
}
|
||||
|
||||
fun undo() {
|
||||
if (mPaths.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val lastKey = mPaths.keys.lastOrNull()
|
||||
mPaths.remove(lastKey)
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
@ -24,21 +24,34 @@
|
||||
android:id="@+id/bottom_draw_color_clickable"
|
||||
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_height="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bottom_draw_undo"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bottom_draw_color"
|
||||
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_height="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:clickable="false"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:src="@drawable/circle_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bottom_draw_undo"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bottom_draw_undo"
|
||||
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_height="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_marginRight="@dimen/normal_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="false"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_undo"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user