Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Team-03][Android] 아이템 롱클릭 이벤트 처리, 리사이클러뷰 상단 UI 구현, 네트워크&Repository, DialogFragment , ActionLog message 구현 #163

Open
wants to merge 28 commits into
base: team-03
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1c1ad0e
fix: Modify refactor package structure
kang-proto Apr 11, 2022
ec8b7e1
Merge pull request #10 from shim506/feature/android/fix3
shim506 Apr 11, 2022
2e0b4e6
feat: Add registerCard DialogFragment and closeBtn at Navigation Drawer
kang-proto Apr 11, 2022
5d0a304
Merge pull request #11 from shim506/feature/android/dialogFragment
shim506 Apr 12, 2022
b1a47ba
Feat: toddTittle 커스텀 뷰 생성
shim506 Apr 12, 2022
d1975fa
Feat: 추가버튼 연결
shim506 Apr 12, 2022
9eef90f
feat: Test Add ToDo
kang-proto Apr 12, 2022
90208e0
Feat : TodoItem 데이터 변환
shim506 Apr 12, 2022
9c02eca
Feat: Todo 레파지토리 Add 부분 구현
shim506 Apr 12, 2022
d5eb800
Feat : Todo Add Network 작업
shim506 Apr 12, 2022
1c593c6
Merge pull request #12 from shim506/feature/android/todoAddNetework
HyungMinKang Apr 12, 2022
79ecb19
feat:Add UpdateDialog and contextMenu at toDoItem
kang-proto Apr 12, 2022
0c1bc77
Merge pull request #13 from shim506/feature/android/contextMenu
shim506 Apr 12, 2022
b2efbe0
feat: Add htmlFormatter at ActionLogMessage
kang-proto Apr 12, 2022
1e24420
Merge pull request #14 from shim506/feature/android/htmlMessage
shim506 Apr 12, 2022
226b7cf
Feat : actionLog 바뀐 명세에 맞게 수정
shim506 Apr 13, 2022
f5c3c37
Feat: remove network / repository 구현
shim506 Apr 13, 2022
c23a826
Feat : Todo item 데이터 가져오기 구현
shim506 Apr 13, 2022
47a7403
Merge pull request #15 from shim506/feature/android/networkUpdateRemove
HyungMinKang Apr 13, 2022
b0faf9e
feat: Add swipe view and itemTouchListner
kang-proto Apr 13, 2022
d573fe2
feat: Modify swipe logic
kang-proto Apr 13, 2022
abf9f27
Merge pull request #16 from shim506/feature/android/swipe
shim506 Apr 14, 2022
cd3d084
Feat: 네트워크 코드 정리
shim506 Apr 14, 2022
c605364
Feat : 삭제 기능구현
shim506 Apr 14, 2022
583f378
Revert "[Team-03][Android] ToDoItem swipe + 삭제 기능 구현"
HyungMinKang Apr 14, 2022
f1ce2e3
Merge pull request #17 from shim506/revert-16-feature/android/swipe
HyungMinKang Apr 14, 2022
71a3338
Merge branch 'dev/android' into feature/android/network2
HyungMinKang Apr 14, 2022
d7b39b6
Merge pull request #18 from shim506/feature/android/network2
HyungMinKang Apr 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.8.9'

implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'
implementation 'joda-time:joda-time:2.10.10'
implementation 'androidx.core:core-ktx:1.7.0'
Expand Down
21 changes: 1 addition & 20 deletions android/app/src/main/java/com/example/todo/model/ActionLog.kt
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
package com.example.todo.model

import com.example.todo.common.ActionType
import com.example.todo.common.ProgressType

data class ActionLog(
val title: String,
val actionType: ActionType,
val time: String,
val nowProgressType: ProgressType,
val prevProgressType: ProgressType
val prevProgressType: ProgressType?
) {

// override fun toString(): String {
// return when (actionType) {
// ActionType.ADD -> {
// "${nowProgressType.value}에 ${title}을 ${actionType.value}합니다"
// }
// ActionType.REMOVE -> {
// "${nowProgressType.value}에서 ${title}을 ${actionType.value}합니다"
// }
// ActionType.MOVE -> {
// "${title}을 ${prevProgressType?.value}에서 ${nowProgressType.value}로 ${actionType.value}합니다"
// }
// ActionType.UPDATE -> {
// "${title}을 ${actionType.value}합니다"
// }
// }
// }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.example.todo.common
package com.example.todo.model

import com.example.todo.R

enum class ProgressType(val value: Int) {
TO_DO(R.string.progress_todo), IN_PROGRESS(R.string.progress_ing), DONE(R.string.progress_done)
}

enum class ActionType(val value: Int) {
ADD(R.string.action_add), REMOVE((R.string.action_remove)), MOVE((R.string.action_move)), UPDATE(
R.string.action_update
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.todo.model

import com.example.todo.R

enum class ProgressType(val value: Int) {
TO_DO(R.string.progress_todo), IN_PROGRESS(R.string.progress_ing), DONE(R.string.progress_done)
}
12 changes: 9 additions & 3 deletions android/app/src/main/java/com/example/todo/model/TodoItem.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.example.todo.model

import com.example.todo.common.ProgressType

data class TodoItem(var itemId: String, val title: String, val content: String, val type: ProgressType)
data class TodoItem(
var title: String,
var content: String,
var type: ProgressType,
var itemId: Int? = null,
var next: Int? = null
) {

}



Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.example.todo.network

data class JsonActionLog(
val historyId: Int,
class ActionLogResponse : ArrayList<ActionLogResponseItem>()

data class ActionLogResponseItem(
val actionType: String,
val cardTitle: String,
val pastLocation: String,
val historyDateTime: String,
val historyId: Int,
val nowLocation: String,
val historyDate: String
val pastLocation: String?
)

data class ActionLogResponse(
val histories: List<JsonActionLog>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.todo.network

data class AddPostBody(
val title: String,
val content: String,
val currentLocation: String,
val writer: String
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.todo.network

import android.icu.text.CaseMap
import com.google.gson.annotations.SerializedName

data class JsonTodo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package com.example.todo.network

import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
import retrofit2.http.*

interface RetrofitClient {
@POST("card")
suspend fun getCardIdx(
@Body post: AddPostBody
): Response<CardIndex>

@GET("cards")
suspend fun getTodos(): List<JsonTodo>
suspend fun getTodos(): Response<TodoResponse>

@GET("histories")
suspend fun getActionLog(): ActionLogResponse
suspend fun getActionLog(): Response<ActionLogResponse>

companion object {
private const val baseUrl = "http://52.78.46.69/"
@DELETE("card/{card_id}")
suspend fun removeTodo(@Path("card_id") cardId: Int): Response<Void>

companion object {
private const val baseUrl = "http://3.37.194.187:8080/"
fun create(): RetrofitClient {
return Retrofit.Builder().baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
Expand Down
36 changes: 36 additions & 0 deletions android/app/src/main/java/com/example/todo/network/TodoResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.todo.network

import com.google.gson.annotations.SerializedName

// Insert
data class CardIndex(
val cardId: Int
)

data class TodoResponse(
val cardsClassifiedByLocation: CardsClassifiedByLocation
)

abstract class TodoResponseItem(
open val content: String,
open val id: Int,
open val nextId: Int,
open val title: String,
open val uploadDateTime: String,
open val writer: String
)

data class Todo(
val content: String,
val id: Int,
val nextId: Int,
val title: String,
val uploadDateTime: String,
val writer: String
)

data class CardsClassifiedByLocation(
val todo: List<Todo>,
val ing: List<Todo>,
val done: List<Todo>
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.example.todo.respository

import com.example.todo.model.ActionLog
import com.example.todo.network.JsonActionLog
import com.example.todo.network.ActionLogResponse
import com.example.todo.network.ActionLogResponseItem
import retrofit2.Response

interface ActionLogDataSource {
suspend fun getActionLogs(): List<JsonActionLog>
suspend fun getActionLogs(): Response<ActionLogResponse>
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.example.todo.respository

import android.content.Context
import android.util.Log
import com.example.todo.R
import com.example.todo.common.ActionType
import com.example.todo.common.ProgressType
import com.example.todo.model.ActionLog
import com.example.todo.network.JsonActionLog
import com.example.todo.network.ActionLogResponse
import com.example.todo.network.ActionLogResponseItem
import com.example.todo.network.RetrofitClient
import retrofit2.Response

class ActionLogRemoteDataSource(
private val retrofitClient: RetrofitClient,
) : ActionLogDataSource {
override suspend fun getActionLogs(): List<JsonActionLog> {
return retrofitClient.getActionLog().histories
override suspend fun getActionLogs(): Response<ActionLogResponse> {
return retrofitClient.getActionLog()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,41 @@ package com.example.todo.respository

import android.content.Context
import com.example.todo.R
import com.example.todo.common.ActionType
import com.example.todo.common.ProgressType
import com.example.todo.model.ActionLog
import com.example.todo.network.JsonActionLog
import com.example.todo.model.ActionType
import com.example.todo.model.ProgressType
import com.example.todo.network.ActionLogResponseItem

class ActionLogRepository(
private val context: Context,
private val actionLogDataSource: ActionLogDataSource
) {
suspend fun getActionLogs(): List<ActionLog> {
val jsonActionLogs = actionLogDataSource.getActionLogs()
return jsonActionLogs.map { stringActionLogToActionLog(it) }
suspend fun getActionLogs(): List<ActionLog>? {
val response = actionLogDataSource.getActionLogs()
val jsonActionLogs = if (response.isSuccessful) response.body() else null
jsonActionLogs?.let {
return it.map { log -> stringActionLogToActionLog(log) }
} ?: return null
}

private fun stringActionLogToActionLog(jsonActionLog: JsonActionLog): ActionLog {
private fun stringActionLogToActionLog(jsonActionLog: ActionLogResponseItem): ActionLog {
val actionType = stringActionTypeToEnum(jsonActionLog.actionType)
val pastProgressType = stringProgressTypeToEnum(jsonActionLog.pastLocation)
val prevProgressType =
jsonActionLog.pastLocation?.let {
stringProgressTypeToEnum(it?.let { it.toString() })
}
val nowProgressType = stringProgressTypeToEnum(jsonActionLog.nowLocation)

return ActionLog(
jsonActionLog.cardTitle,
actionType,
jsonActionLog.historyDate,
pastProgressType,
nowProgressType
jsonActionLog.historyDateTime,
nowProgressType,
prevProgressType
)
}

private fun stringProgressTypeToEnum(stringProgressType: String): ProgressType {
private fun stringProgressTypeToEnum(stringProgressType: String?): ProgressType {
return when (stringProgressType) {
context.getString(R.string.progress_todo) -> ProgressType.TO_DO
context.getString(R.string.progress_ing) -> ProgressType.IN_PROGRESS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package com.example.todo.respository

import com.example.todo.model.TodoItem
import com.example.todo.network.CardIndex
import com.example.todo.network.TodoResponse
import retrofit2.Response

interface ToDoDataSource {
fun getToDoItems(): List<TodoItem>
suspend fun getTodoId(newItem: TodoItem): Response<CardIndex>
suspend fun getInProgressId(newItem: TodoItem): Response<CardIndex>
suspend fun getDoneId(newItem: TodoItem): Response<CardIndex>
suspend fun getTodoItems(): Response<TodoResponse>
suspend fun removeItem(cardId: Int): Response<Void>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.example.todo.respository

import android.util.Log
import com.example.todo.model.TodoItem
import com.example.todo.network.AddPostBody
import com.example.todo.network.CardIndex
import com.example.todo.network.RetrofitClient
import com.example.todo.network.TodoResponse
import retrofit2.Response

class ToDoRemoteDataSource(private val retrofitClient: RetrofitClient) : ToDoDataSource {
override suspend fun getTodoId(newItem: TodoItem): Response<CardIndex> {
val body = AddPostBody(newItem.title, newItem.content, "todo", "Jay")
return retrofitClient.getCardIdx(body)
}

override suspend fun getInProgressId(newItem: TodoItem): Response<CardIndex> {
val body = AddPostBody(newItem.title, newItem.content, "inProgress", "Jay")
return retrofitClient.getCardIdx(body)
}

override suspend fun getDoneId(newItem: TodoItem): Response<CardIndex> {
val body = AddPostBody(newItem.title, newItem.content, "done", "Jay")
return retrofitClient.getCardIdx(body)
}

override suspend fun getTodoItems(): Response<TodoResponse> {
val response = retrofitClient.getTodos()
Log.d("test", response.isSuccessful.toString())
return response
}

override suspend fun removeItem(cardId: Int): Response<Void> {
val response = retrofitClient.removeTodo(cardId)
Log.d("testDelete", response.isSuccessful.toString())
return response
}
}
Loading