Unverified Commit ad9e42ed authored by Filipe Brito's avatar Filipe Brito Committed by GitHub

Merge pull request #2084 from kareemhamdy100/develop

[IMPROVEMENT] Hide the drawing toolbar while drawing
parents 6642f154 67364d3e
......@@ -204,4 +204,4 @@ task compileSdk(type: Exec) {
preBuild.dependsOn compileSdk
if (isPlay) {
apply plugin: 'com.google.gms.google-services'
}
}
\ No newline at end of file
......@@ -44,7 +44,15 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
.show()
}
private fun setupListeners() {
custom_draw_view.setOnTouchListener { view, event ->
custom_draw_view.onTouch(
event,
draw_tools,
::toggleCompleteDrawTools)
}
image_close_drawing.setOnClickListener { finish() }
image_send_drawing.setOnClickListener {
......@@ -117,6 +125,15 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
}
}
fun toggleCompleteDrawTools(view: View, showView: Boolean = true) {
if (view.translationY == (112).toPx && showView) {
toggleDrawTools(draw_tools, false)
} else {
view.animate().translationY((112).toPx)
}
}
private fun colorSelector() {
image_color_black.setOnClickListener {
custom_draw_view.setColor(
......@@ -232,6 +249,7 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
})
}
private val Int.toPx: Float
get() = (this * Resources.getSystem().displayMetrics.density)
}
\ No newline at end of file
......@@ -79,7 +79,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)
}
......@@ -157,22 +157,26 @@ class CustomDrawView(context: Context, attrs: AttributeSet) : View(context, attr
mPaintOptions = PaintOptions(mPaintOptions.color, mPaintOptions.strokeWidth, mPaintOptions.alpha)
}
override fun onTouchEvent(event: MotionEvent): Boolean {
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
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