Commit 6318be9e authored by kareemhamdy500's avatar kareemhamdy500

make it draw_tools hide during drawing

parent 330098d2
......@@ -44,10 +44,14 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
.show()
}
private fun setupListeners() {
custom_draw_view.setOnClickListener { toggleCompleteDrawTools(draw_tools, false) }
image_show_drawing_tool.setOnClickListener { toggleCompleteDrawTools(draw_tools) }
private fun setupListeners() {
custom_draw_view.setOnTouchListener { view, event ->
custom_draw_view.onTouch(
event,
draw_tools,
::toggleCompleteDrawTools)
}
image_close_drawing.setOnClickListener { finish() }
......@@ -114,7 +118,7 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
}
}
private fun toggleCompleteDrawTools(view: View, showView: Boolean = true) {
fun toggleCompleteDrawTools(view: View, showView: Boolean = true) {
if (view.translationY == (112).toPx && showView) {
toggleDrawTools(draw_tools, false)
} else {
......@@ -231,6 +235,7 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
})
}
private val Int.toPx: Float
get() = (this * Resources.getSystem().displayMetrics.density)
}
\ No newline at end of file
......@@ -80,7 +80,7 @@ class CustomDrawView(context: Context, attrs: AttributeSet) : View(context, attr
}
fun setAlpha(newAlpha: Int) {
val alpha = (newAlpha*255)/100
val alpha = (newAlpha * 255) / 100
mPaintOptions.alpha = alpha
setColor(mPaintOptions.color)
}
......@@ -158,22 +158,26 @@ class CustomDrawView(context: Context, attrs: AttributeSet) : View(context, attr
mPaintOptions = PaintOptions(mPaintOptions.color, mPaintOptions.strokeWidth, mPaintOptions.alpha)
}
override fun onTouchEvent(event: MotionEvent): Boolean {
super.onTouchEvent(event)
fun onTouch(event: MotionEvent, drawTools: View, toggleDrawTools: (View, Boolean) -> Unit): Boolean {
val x = event.x
val y = event.y
when (event.action) {
MotionEvent.ACTION_DOWN -> {
toggleDrawTools(drawTools, false)
mStartX = x
mStartY = y
actionDown(x, y)
mUndonePaths.clear()
}
MotionEvent.ACTION_MOVE -> actionMove(x, y)
MotionEvent.ACTION_UP -> actionUp()
MotionEvent.ACTION_UP -> {
toggleDrawTools(drawTools, true)
actionUp()
}
}
invalidate()
return true
}
}
\ No newline at end of file
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
</vector>
......@@ -28,21 +28,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/image_show_drawing_tool"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="@color/color_white"
android:foreground="?selectableItemBackgroundBorderless"
android:padding="16dp"
android:src="@drawable/ic_draw_tools_shwoing_24dp"
android:tint="@color/icon_color"
app:layout_constraintEnd_toStartOf="@+id/image_send_drawing"
app:layout_constraintStart_toEndOf="@+id/image_close_drawing"
app:layout_constraintTop_toTopOf="@+id/custom_draw_view" />
<ImageView
android:id="@+id/image_send_drawing"
android:layout_width="56dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment