Commit 89d4f617 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Fixes formatting issues on draw module classes and update gradle version.

parent d34e779d
......@@ -10,7 +10,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}"
classpath 'com.google.gms:google-services:4.2.0'
......
......@@ -45,6 +45,14 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
}
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 {
......@@ -53,7 +61,7 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
}
private fun setupDrawTools() {
image_draw_eraser.setOnLongClickListener{
image_draw_eraser.setOnLongClickListener {
custom_draw_view.clearCanvas()
return@setOnLongClickListener true
}
......@@ -117,6 +125,15 @@ class DrawingActivity : DaggerAppCompatActivity(), DrawView {
}
}
private 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)
}
......@@ -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)
}
......@@ -154,24 +154,31 @@ class CustomDrawView(context: Context, attrs: AttributeSet) : View(context, attr
mPaths.put(mPath, mPaintOptions)
mPath = MyPath()
mPaintOptions = PaintOptions(mPaintOptions.color, mPaintOptions.strokeWidth, mPaintOptions.alpha)
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
}
......
#Wed Oct 10 10:41:36 UYT 2018
#Tue May 14 21:15:38 BRT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionSha256Sum=b7aedd369a26b177147bcb715f8b1fc4fe32b0a6ade0d7fd8ee5ed0c6f731f2c
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