From d31f218b59fc1d154d4586f8c52017a9acf1a198 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 17:48:39 +0900 Subject: [PATCH 01/11] =?UTF-8?q?refactor(#331)=20-=20gradle=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit local.properties 적용 --- AOS/app/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AOS/app/build.gradle.kts b/AOS/app/build.gradle.kts index e4975705..5e20a49e 100644 --- a/AOS/app/build.gradle.kts +++ b/AOS/app/build.gradle.kts @@ -1,3 +1,5 @@ +import java.util.Properties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") @@ -12,6 +14,8 @@ android { namespace = "boostcamp.and07.mindsync" compileSdk = 34 + val properties = Properties() + properties.load(project.rootProject.file("local.properties").inputStream()) val url = properties["BASE_URL"] ?: "" val googleServerClientId = properties["GOOGLE_SERVER_CLIENT_ID"] ?: "" val kakaoClientId = properties["KAKAO_CLIENT_ID"] ?: "" From b2392f58b445c7c43561d5a402982b5e199a9485 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 17:49:04 +0900 Subject: [PATCH 02/11] =?UTF-8?q?refactor(#331)=20-=20data=20class=20DP,?= =?UTF-8?q?=20PX=20->=20value=20class=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/boostcamp/and07/mindsync/ui/util/DensityUtils.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/util/DensityUtils.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/util/DensityUtils.kt index adda668c..f6ed962f 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/util/DensityUtils.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/util/DensityUtils.kt @@ -4,8 +4,9 @@ import android.content.Context import android.util.TypedValue import kotlinx.serialization.Serializable +@JvmInline @Serializable -data class Dp(val dpVal: Float) { +value class Dp(val dpVal: Float) { operator fun plus(dpValue: Dp): Dp { return Dp(dpVal + dpValue.dpVal) } @@ -67,7 +68,8 @@ data class Dp(val dpVal: Float) { } } -data class Px(val pxVal: Float) { +@JvmInline +value class Px(val pxVal: Float) { operator fun plus(pxValue: Px): Px { return Px(pxVal + pxValue.pxVal) } From 1fdd89305b8d9692aa4a77311b5e342b81f6a2c3 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 18:13:29 +0900 Subject: [PATCH 03/11] =?UTF-8?q?refactor(#331)=20-=20isRectangle=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/boostcamp/and07/mindsync/data/model/Node.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/data/model/Node.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/data/model/Node.kt index 9976500b..c3629788 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/data/model/Node.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/data/model/Node.kt @@ -2,6 +2,8 @@ package boostcamp.and07.mindsync.data.model import boostcamp.and07.mindsync.ui.util.Dp import kotlinx.serialization.Serializable +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract @Serializable sealed class Node( @@ -15,6 +17,15 @@ sealed class Node( horizontalSpacing: Dp, totalHeight: Dp, ): Node + + @OptIn(ExperimentalContracts::class) + fun isRectangle(): Boolean { + contract { + returns(true) implies (this@Node is RectangleNode) + returns(false) implies (this@Node is CircleNode) + } + return this is RectangleNode + } } data class CircleNode( From 252c512a9e463c3d3c4fa776a93ce27496967df7 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 18:14:21 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor(#331)=20-=20MindMapRightLayoutMa?= =?UTF-8?q?nager=20=EC=BD=94=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when 분기 처리 -> isRectangle 활용 --- .../view/layout/MindMapRightLayoutManager.kt | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt index ccbefd6a..8b8860f2 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt @@ -34,11 +34,11 @@ class MindMapRightLayoutManager { ) { val childHeightSum = measureChildHeight(currentNode, tree) - val nodeWidth = - when (currentNode) { - is RectangleNode -> currentNode.path.width - is CircleNode -> currentNode.path.radius - } + val nodeWidth = if (currentNode.isRectangle()) { + currentNode.path.width + } else { + currentNode.path.radius + } val criteriaX = currentNode.path.centerX + nodeWidth / 2 + horizontalSpacing var startX: Dp @@ -49,23 +49,18 @@ class MindMapRightLayoutManager { val childHeight = measureChildHeight(child, tree) val newY = startY + (childHeight / 2) - startX = - when (child) { - is CircleNode -> criteriaX + (child.path.radius / 2) - is RectangleNode -> criteriaX + (child.path.width / 2) - } - val newChild = - when (child) { - is CircleNode -> { - val newPath = child.path.copy(centerX = startX, centerY = newY) - child.copy(path = newPath) - } - - is RectangleNode -> { - val newPath = child.path.copy(centerX = startX, centerY = newY) - child.copy(path = newPath) - } - } + startX = if (child.isRectangle()) { + criteriaX + (child.path.width / 2) + } else { + criteriaX + (child.path.radius / 2) + } + val newChild = if (child.isRectangle()) { + val newPath = child.path.copy(centerX = startX, centerY = newY) + child.copy(path = newPath) + } else { + val newPath = child.path.copy(centerX = startX, centerY = newY) + child.copy(path = newPath) + } tree.setNode(childId, newChild) recurArrangeNode(newChild, tree) From eda99dcbe866dcf8d312a455a9e6e27d8f9a03a2 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 18:15:53 +0900 Subject: [PATCH 05/11] =?UTF-8?q?refactor(#331)=20-=20MindMapFragment=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when 분기 처리 -> isRectangle 활용 --- .../mindsync/ui/mindmap/MindMapFragment.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt index 8022a300..1ab59a67 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt @@ -7,9 +7,7 @@ import androidx.lifecycle.repeatOnLifecycle import androidx.navigation.fragment.navArgs import boostcamp.and07.mindsync.R import boostcamp.and07.mindsync.data.crdt.OperationType -import boostcamp.and07.mindsync.data.model.CircleNode import boostcamp.and07.mindsync.data.model.Node -import boostcamp.and07.mindsync.data.model.RectangleNode import boostcamp.and07.mindsync.data.model.Tree import boostcamp.and07.mindsync.data.util.NodeGenerator import boostcamp.and07.mindsync.databinding.FragmentMindMapBinding @@ -98,15 +96,18 @@ class MindMapFragment : editDescriptionDialog.setSubmitListener { description -> when (operationType) { OperationType.ADD -> { - mindMapViewModel.addNode(selectedNode, NodeGenerator.makeNode(description, selectedNode.id)) + mindMapViewModel.addNode( + selectedNode, + NodeGenerator.makeNode(description, selectedNode.id), + ) } OperationType.UPDATE -> { - val newNode = - when (selectedNode) { - is CircleNode -> selectedNode.copy(description = description) - is RectangleNode -> selectedNode.copy(description = description) - } + val newNode = if (selectedNode.isRectangle()) { + selectedNode.copy(description = description) + } else { + selectedNode.copy(description = description) + } mindMapViewModel.updateNode(newNode) } From b8099c7de14d2ed227b961277cac5efdd0069418 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 18:21:33 +0900 Subject: [PATCH 06/11] =?UTF-8?q?refactor(#331)=20-=20MindMapBindingAdapte?= =?UTF-8?q?r=20=EC=BD=94=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when 분기 처리 -> isRectangle 활용 --- .../mindsync/ui/mindmap/MindMapBindingAdapter.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapBindingAdapter.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapBindingAdapter.kt index b4a91c4b..c7ff8969 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapBindingAdapter.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapBindingAdapter.kt @@ -2,16 +2,12 @@ package boostcamp.and07.mindsync.ui.mindmap import android.widget.ImageButton import androidx.databinding.BindingAdapter -import boostcamp.and07.mindsync.data.model.CircleNode import boostcamp.and07.mindsync.data.model.Node -import boostcamp.and07.mindsync.data.model.RectangleNode @BindingAdapter("app:removeBtn") fun ImageButton.setEnabled(selectedNode: Node?) { - this.isEnabled = - when (selectedNode) { - is CircleNode -> false - is RectangleNode -> true - else -> false - } + if (selectedNode != null) { + this.isEnabled = + selectedNode.isRectangle() + } } From 0097886bc883a88dc92f729a605931c47b965172 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 19:05:47 +0900 Subject: [PATCH 07/11] =?UTF-8?q?refactor(#331)=20-=20NodeView=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when 분기 처리 -> isRectangle 활용 --- .../and07/mindsync/ui/view/NodeView.kt | 178 +++++++++--------- 1 file changed, 86 insertions(+), 92 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt index 5b0ffbb2..d1528cb6 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt @@ -138,11 +138,12 @@ class NodeView( dy: Float, ) { mindMapContainer.selectNode?.let { selectedNode -> - if (selectedNode is CircleNode) return - traverseMovedNode(tree.getRootNode(), selectedNode, dx, dy) + if (selectedNode.isRectangle()) { + traverseMovedNode(tree.getRootNode(), selectedNode, dx, dy) - mindMapContainer.update(tree) - rightLayoutManager.arrangeNode(tree, selectedNode as RectangleNode) + mindMapContainer.update(tree) + rightLayoutManager.arrangeNode(tree, selectedNode) + } } lineView.updateTree(tree) invalidate() @@ -200,16 +201,15 @@ class NodeView( private fun drawAttachedNode(canvas: Canvas) { attachedNode?.let { attachedNode -> - val height = - when (attachedNode) { - is RectangleNode -> attachedNode.path.height - is CircleNode -> attachedNode.path.radius + Dp(ATTACH_CIRCLE_NODE_RANGE_VALUE) - } - val width = - when (attachedNode) { - is RectangleNode -> attachedNode.path.width - is CircleNode -> attachedNode.path.radius + Dp(ATTACH_CIRCLE_NODE_RANGE_VALUE) - } + val height: Dp + val width: Dp + if (attachedNode.isRectangle()) { + height = attachedNode.path.height + width = attachedNode.path.width + } else { + height = attachedNode.path.radius + Dp(ATTACH_CIRCLE_NODE_RANGE_VALUE) + width = height + } val radius = maxOf(height.toPx(context), width.toPx(context)) canvas.drawCircle( attachedNode.path.centerX.toPx(context), @@ -225,27 +225,23 @@ class NodeView( canvas: Canvas, node: Node, ) { - when (node) { - is CircleNode -> { - canvas.drawCircle( - node.path.centerX.toPx(context), - node.path.centerY.toPx(context), - node.path.radius.toPx(context), - drawInfo.strokePaint, - ) - } - - is RectangleNode -> { - canvas.drawRoundRect( - node.path.leftX().toPx(context), - node.path.topY().toPx(context), - node.path.rightX().toPx(context), - node.path.bottomY().toPx(context), - Dp(ROUNDED_CORNER_RADIUS).toPx(context), - Dp(ROUNDED_CORNER_RADIUS).toPx(context), - drawInfo.strokePaint, - ) - } + if (node.isRectangle()) { + canvas.drawRoundRect( + node.path.leftX().toPx(context), + node.path.topY().toPx(context), + node.path.rightX().toPx(context), + node.path.bottomY().toPx(context), + Dp(ROUNDED_CORNER_RADIUS).toPx(context), + Dp(ROUNDED_CORNER_RADIUS).toPx(context), + drawInfo.strokePaint, + ) + } else { + canvas.drawCircle( + node.path.centerX.toPx(context), + node.path.centerY.toPx(context), + node.path.radius.toPx(context), + drawInfo.strokePaint, + ) } } @@ -254,24 +250,21 @@ class NodeView( x: Float, y: Float, ): Boolean { - when (node) { - is CircleNode -> { - if (x in (node.path.centerX - node.path.radius).toPx(context)..(node.path.centerX + node.path.radius).toPx(context) && - y in (node.path.centerY - node.path.radius).toPx(context)..(node.path.centerY + node.path.radius).toPx(context) - ) { - return true - } - } - - is RectangleNode -> { - if (x in node.path.leftX().toPx(context)..node.path.rightX().toPx(context) && + if (node.isRectangle()) { + return ( + x in node.path.leftX().toPx(context)..node.path.rightX().toPx(context) && y in node.path.topY().toPx(context)..node.path.bottomY().toPx(context) - ) { - return true - } - } + ) + } else { + return ( + x in (node.path.centerX - node.path.radius).toPx(context)..(node.path.centerX + node.path.radius).toPx( + context, + ) && + y in (node.path.centerY - node.path.radius).toPx(context)..(node.path.centerY + node.path.radius).toPx( + context, + ) + ) } - return false } private fun drawNode( @@ -279,9 +272,10 @@ class NodeView( node: Node, depth: Int, ) { - when (node) { - is CircleNode -> drawCircleNode(canvas, node) - is RectangleNode -> drawRectangleNode(canvas, node, depth) + if (node.isRectangle()) { + drawRectangleNode(canvas, node, depth) + } else { + drawCircleNode(canvas, node) } drawText(canvas, node) } @@ -321,55 +315,55 @@ class NodeView( ) { val lines = node.description.split("\n") val bounds = Rect() - when (node) { - is CircleNode -> { - drawInfo.textPaint.color = Color.WHITE - if (lines.size > 1) { - var y = - node.path.centerY.toPx(context) - node.path.radius.toPx(context) + drawInfo.padding.toPx(context) - for (line in lines) { - drawInfo.textPaint.getTextBounds(line, 0, line.length, bounds) - canvas.drawText( - line, - node.path.centerX.toPx(context), - y + bounds.height(), - drawInfo.textPaint, - ) - y += bounds.height() + drawInfo.lineHeight.dpVal - } - } else { + if (node.isRectangle()) { + drawInfo.textPaint.color = Color.BLACK + if (lines.size > 1) { + var y = + node.path.centerY.toPx(context) - node.path.height.toPx(context) / 2 + drawInfo.padding.toPx( + context, + ) / 2 + for (line in lines) { + drawInfo.textPaint.getTextBounds(line, 0, line.length, bounds) canvas.drawText( - node.description, + line, node.path.centerX.toPx(context), - node.path.centerY.toPx(context) + drawInfo.lineHeight.dpVal / 2, + y + bounds.height(), drawInfo.textPaint, ) + y += bounds.height() + drawInfo.lineHeight.dpVal } + } else { + canvas.drawText( + node.description, + node.path.centerX.toPx(context), + node.path.centerY.toPx(context) + drawInfo.lineHeight.dpVal / 2, + drawInfo.textPaint, + ) } - - is RectangleNode -> { - drawInfo.textPaint.color = Color.BLACK - if (lines.size > 1) { - var y = - node.path.centerY.toPx(context) - node.path.height.toPx(context) / 2 + drawInfo.padding.toPx(context) / 2 - for (line in lines) { - drawInfo.textPaint.getTextBounds(line, 0, line.length, bounds) - canvas.drawText( - line, - node.path.centerX.toPx(context), - y + bounds.height(), - drawInfo.textPaint, - ) - y += bounds.height() + drawInfo.lineHeight.dpVal - } - } else { + } else { + drawInfo.textPaint.color = Color.WHITE + if (lines.size > 1) { + var y = + node.path.centerY.toPx(context) - node.path.radius.toPx(context) + drawInfo.padding.toPx( + context, + ) + for (line in lines) { + drawInfo.textPaint.getTextBounds(line, 0, line.length, bounds) canvas.drawText( - node.description, + line, node.path.centerX.toPx(context), - node.path.centerY.toPx(context) + drawInfo.lineHeight.dpVal / 2, + y + bounds.height(), drawInfo.textPaint, ) + y += bounds.height() + drawInfo.lineHeight.dpVal } + } else { + canvas.drawText( + node.description, + node.path.centerX.toPx(context), + node.path.centerY.toPx(context) + drawInfo.lineHeight.dpVal / 2, + drawInfo.textPaint, + ) } } } From 1ef589b884ef5b7fee9dd98f0301841356f24c6d Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 19:06:02 +0900 Subject: [PATCH 08/11] =?UTF-8?q?refactor(#331)=20-=20LineView=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when 분기 처리 -> isRectangle 활용 --- .../boostcamp/and07/mindsync/ui/view/LineView.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt index 507d2a32..9d7cd260 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt @@ -7,9 +7,7 @@ import android.graphics.Paint import android.graphics.Path import android.util.AttributeSet import android.view.View -import boostcamp.and07.mindsync.data.model.CircleNode import boostcamp.and07.mindsync.data.model.Node -import boostcamp.and07.mindsync.data.model.RectangleNode import boostcamp.and07.mindsync.data.model.Tree import boostcamp.and07.mindsync.ui.util.toPx import boostcamp.and07.mindsync.ui.view.model.DrawInfo @@ -97,11 +95,11 @@ class LineView constructor( isStart: Boolean, ): Float { val nodeCenterX = node.path.centerX.toPx(context) - val widthOffset = - when (node) { - is CircleNode -> node.path.radius.toPx(context) - is RectangleNode -> node.path.width.toPx(context) / 2 - } + val widthOffset = if (node.isRectangle()) { + node.path.width.toPx(context) / 2 + } else { + node.path.radius.toPx(context) + } return if (isStart) nodeCenterX + widthOffset else nodeCenterX - widthOffset } } From 4cf5ccafcc650e354c29f4153c6e636f346ffb6a Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 19:28:10 +0900 Subject: [PATCH 09/11] =?UTF-8?q?style(#331)=20-=20ktlintFormat=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mindsync/ui/mindmap/MindMapFragment.kt | 11 +++--- .../and07/mindsync/ui/view/LineView.kt | 11 +++--- .../and07/mindsync/ui/view/NodeView.kt | 11 +++--- .../view/layout/MindMapRightLayoutManager.kt | 37 ++++++++++--------- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt index 1ab59a67..aaf87bf0 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/mindmap/MindMapFragment.kt @@ -103,11 +103,12 @@ class MindMapFragment : } OperationType.UPDATE -> { - val newNode = if (selectedNode.isRectangle()) { - selectedNode.copy(description = description) - } else { - selectedNode.copy(description = description) - } + val newNode = + if (selectedNode.isRectangle()) { + selectedNode.copy(description = description) + } else { + selectedNode.copy(description = description) + } mindMapViewModel.updateNode(newNode) } diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt index 9d7cd260..e332083b 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt @@ -95,11 +95,12 @@ class LineView constructor( isStart: Boolean, ): Float { val nodeCenterX = node.path.centerX.toPx(context) - val widthOffset = if (node.isRectangle()) { - node.path.width.toPx(context) / 2 - } else { - node.path.radius.toPx(context) - } + val widthOffset = + if (node.isRectangle()) { + node.path.width.toPx(context) / 2 + } else { + node.path.radius.toPx(context) + } return if (isStart) nodeCenterX + widthOffset else nodeCenterX - widthOffset } } diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt index d1528cb6..b1e3ed3d 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt @@ -254,7 +254,7 @@ class NodeView( return ( x in node.path.leftX().toPx(context)..node.path.rightX().toPx(context) && y in node.path.topY().toPx(context)..node.path.bottomY().toPx(context) - ) + ) } else { return ( x in (node.path.centerX - node.path.radius).toPx(context)..(node.path.centerX + node.path.radius).toPx( @@ -263,7 +263,7 @@ class NodeView( y in (node.path.centerY - node.path.radius).toPx(context)..(node.path.centerY + node.path.radius).toPx( context, ) - ) + ) } } @@ -344,9 +344,10 @@ class NodeView( drawInfo.textPaint.color = Color.WHITE if (lines.size > 1) { var y = - node.path.centerY.toPx(context) - node.path.radius.toPx(context) + drawInfo.padding.toPx( - context, - ) + node.path.centerY.toPx(context) - node.path.radius.toPx(context) + + drawInfo.padding.toPx( + context, + ) for (line in lines) { drawInfo.textPaint.getTextBounds(line, 0, line.length, bounds) canvas.drawText( diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt index 8b8860f2..e21efc4d 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/layout/MindMapRightLayoutManager.kt @@ -34,11 +34,12 @@ class MindMapRightLayoutManager { ) { val childHeightSum = measureChildHeight(currentNode, tree) - val nodeWidth = if (currentNode.isRectangle()) { - currentNode.path.width - } else { - currentNode.path.radius - } + val nodeWidth = + if (currentNode.isRectangle()) { + currentNode.path.width + } else { + currentNode.path.radius + } val criteriaX = currentNode.path.centerX + nodeWidth / 2 + horizontalSpacing var startX: Dp @@ -49,18 +50,20 @@ class MindMapRightLayoutManager { val childHeight = measureChildHeight(child, tree) val newY = startY + (childHeight / 2) - startX = if (child.isRectangle()) { - criteriaX + (child.path.width / 2) - } else { - criteriaX + (child.path.radius / 2) - } - val newChild = if (child.isRectangle()) { - val newPath = child.path.copy(centerX = startX, centerY = newY) - child.copy(path = newPath) - } else { - val newPath = child.path.copy(centerX = startX, centerY = newY) - child.copy(path = newPath) - } + startX = + if (child.isRectangle()) { + criteriaX + (child.path.width / 2) + } else { + criteriaX + (child.path.radius / 2) + } + val newChild = + if (child.isRectangle()) { + val newPath = child.path.copy(centerX = startX, centerY = newY) + child.copy(path = newPath) + } else { + val newPath = child.path.copy(centerX = startX, centerY = newY) + child.copy(path = newPath) + } tree.setNode(childId, newChild) recurArrangeNode(newChild, tree) From 9c53dafc2f0fd66664ec3ea40d4e95c84b9cf36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=ED=95=9C?= <99114456+jaehan4707@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:12:46 +0900 Subject: [PATCH 10/11] =?UTF-8?q?docs:=20AOS-ktlint=20Create=20Properties?= =?UTF-8?q?=20File=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/AOS-ktlint.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/AOS-ktlint.yml b/.github/workflows/AOS-ktlint.yml index f415e836..116d2197 100644 --- a/.github/workflows/AOS-ktlint.yml +++ b/.github/workflows/AOS-ktlint.yml @@ -18,6 +18,14 @@ jobs: with: java-version: '17' distribution: 'adopt' - + - name: Create Properties File + env: + RELEASE_KEYSTORE: ${{ secrets.KEY_STORE_BASE_64 }} + KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }} + LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }} + run: | + echo "$RELEASE_KEYSTORE" | base64 -d > AOS/app/release.keystore + echo "$KEYSTORE_PROPERTIES" > AOS/keystore.properties + echo "$LOCAL_PROPERTIES" > AOS/local.properties - name: Run ktlint run: cd AOS && chmod +x ./gradlew &&./gradlew ktlintCheck From 36ff3ef19536b97eb93fbd3309b9691758f40507 Mon Sep 17 00:00:00 2001 From: jaehan4707 Date: Sun, 7 Apr 2024 20:59:20 +0900 Subject: [PATCH 11/11] =?UTF-8?q?style(#331)=20-=20ktlintFormat=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/boostcamp/and07/mindsync/ui/view/NodeView.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt index b1e3ed3d..89205db0 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt @@ -257,12 +257,8 @@ class NodeView( ) } else { return ( - x in (node.path.centerX - node.path.radius).toPx(context)..(node.path.centerX + node.path.radius).toPx( - context, - ) && - y in (node.path.centerY - node.path.radius).toPx(context)..(node.path.centerY + node.path.radius).toPx( - context, - ) + x in (node.path.centerX - node.path.radius).toPx(context)..(node.path.centerX + node.path.radius).toPx(context) && + y in (node.path.centerY - node.path.radius).toPx(context)..(node.path.centerY + node.path.radius).toPx(context) ) } }