mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 22:37:59 +01:00
adding an Undo button to editor drawing
This commit is contained in:
parent
5f9378135a
commit
1776ab592d
3 changed files with 30 additions and 3 deletions
|
@ -460,6 +460,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
config.lastEditorBrushSize = it
|
config.lastEditorBrushSize = it
|
||||||
updateBrushSize(it)
|
updateBrushSize(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bottom_draw_undo.setOnClickListener {
|
||||||
|
editor_draw_canvas.undo()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBrushSize(percent: Int) {
|
private fun updateBrushSize(percent: Int) {
|
||||||
|
|
|
@ -139,4 +139,14 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
|
||||||
draw(canvas)
|
draw(canvas)
|
||||||
return bitmap
|
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:id="@+id/bottom_draw_color_clickable"
|
||||||
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
||||||
android:layout_height="@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"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toLeftOf="@+id/bottom_draw_undo"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/bottom_draw_color"
|
android:id="@+id/bottom_draw_color"
|
||||||
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
||||||
android:layout_height="@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:clickable="false"
|
||||||
android:padding="@dimen/small_margin"
|
android:padding="@dimen/small_margin"
|
||||||
android:src="@drawable/circle_background"
|
android:src="@drawable/circle_background"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
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_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue