Skip to content

Commit

Permalink
[MERGE/#46] merge develop into ocr-feat-text-recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Jan 12, 2023
2 parents de49094 + 2d2d1ce commit b76028e
Show file tree
Hide file tree
Showing 151 changed files with 1,435 additions and 188 deletions.
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {
id "org.jlleitschuh.gradle.ktlint" version "10.3.0"
}

apply plugin: 'kotlin-kapt'

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

Expand Down Expand Up @@ -122,7 +124,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.0.0'

// firebase storage
implementation 'com.google.firebase:firebase-storage'
// implementation 'com.google.firebase:firebase-storage'

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@
android:screenOrientation="portrait" />
<activity
android:name="com.keyneez.presentation.signup.SignupActivity"
android:exported="false"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.keyneez.presentation.main.MainActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name="com.keyneez.presentation.main.detail.DetailActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.keyneez.presentation.main.search.SearchActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/java/com/keyneez/data/entity/IdData.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.keyneez.data.entity

data class LikeData(
data class SearchData(
val background: Int,
val date: String,
val title: String
val title: String,
val liked: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.keyneez.data.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseGetContentDeatilDto(
@SerialName("content_key")
val key: Int?,
@SerialName("content_title")
val title: String?,
@SerialName("content_link")
val link: String?,
@SerialName("content_img")
val img: String?,
@SerialName("place")
val place: String?,
@SerialName("introduction")
val introduction: String?,
@SerialName("benefit")
val benefit: String?,
@SerialName("usage")
val usage: String?,
@SerialName("start_at")
val start: String?,
@SerialName("end_at")
val end: String?,
@SerialName("liked")
val liked: Boolean,
@SerialName("category")
val category: List<String>
) {
@Serializable
data class Category(
val category: String?
)
}
27 changes: 27 additions & 0 deletions app/src/main/java/com/keyneez/data/model/response/ResponseIdDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.keyneez.data.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseIdDto(
@SerialName("user_key") val key: Int,
@SerialName("user_name") val name: String,
@SerialName("user_age") val age: String?,
@SerialName("user_gender") val gender: String?,
@SerialName("user_phone") val phone: String,
@SerialName("user_birth") val birth: String,
@SerialName("user_school") val school: String?,
@SerialName("user_character") val userCharacter: Int?,
@SerialName("user_password") val password: String?,
@SerialName("user_benefit") val benefit: Boolean?,
@SerialName("user_ocr") val ocrImg: String?,
@SerialName("ocr_dir") val ocrDir: Boolean?,
val Characters: Character?
) {
@Serializable
data class Character(
val character: String?,
@SerialName("character_img") val characterImg: String?
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.keyneez.data.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseLikeDto(
@SerialName("content_key")
val key: Int,
@SerialName("content_title")
val title: String,
@SerialName("start_at")
val start: String?,
@SerialName("end_at")
val end: String?,
@SerialName("content_img")
val background: String
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package com.keyneez.data.repository

interface ContentRepository
import com.keyneez.data.model.response.ResponseGetContentDeatilDto
import com.keyneez.data.model.response.ResponseLikeDto
import com.keyneez.data.model.response.wrapper.BaseResponse

interface ContentRepository {
suspend fun getLike(): Result<BaseResponse<List<ResponseLikeDto>>>

suspend fun getDetail(contentId: Int): Result<BaseResponse<ResponseGetContentDeatilDto>>
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
package com.keyneez.data.repository

import com.keyneez.data.model.response.ResponseGetContentDeatilDto
import com.keyneez.data.model.response.ResponseLikeDto
import com.keyneez.data.model.response.wrapper.BaseResponse
import com.keyneez.data.source.ContentDataSource
import javax.inject.Inject

class ContentRepositoryImpl @Inject constructor(
private val contentDataSource: ContentDataSource
) : ContentRepository
) : ContentRepository {

override suspend fun getLike(): Result<BaseResponse<List<ResponseLikeDto>>> =
kotlin.runCatching { contentDataSource.getLike() }

override suspend fun getDetail(contentId: Int): Result<BaseResponse<ResponseGetContentDeatilDto>> =
kotlin.runCatching { contentDataSource.getDetail(contentId) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.keyneez.data.model.request.RequestPatchPwdSignupDto
import com.keyneez.data.model.request.RequestPatchUserTypeDto
import com.keyneez.data.model.request.RequestPostDanalSignupDto
import com.keyneez.data.model.request.RequestPostPwdCheckDto
import com.keyneez.data.model.response.ResponseIdDto
import com.keyneez.data.model.response.ResponsePatchPwdSignupDto
import com.keyneez.data.model.response.ResponsePatchUserTypeDto
import com.keyneez.data.model.response.ResponsePostDanalSignupDto
Expand All @@ -21,6 +22,8 @@ interface UserRepository {
requestPostDanalSignupDto: RequestPostDanalSignupDto
): Result<BaseResponse<ResponsePostDanalSignupDto>>

suspend fun getId(): Result<BaseResponse<ResponseIdDto>>

suspend fun patchUserTypeSignup(
requestPatchUserTypeDto: RequestPatchUserTypeDto
): Result<BaseResponse<ResponsePatchUserTypeDto>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.keyneez.data.model.request.RequestPatchPwdSignupDto
import com.keyneez.data.model.request.RequestPatchUserTypeDto
import com.keyneez.data.model.request.RequestPostDanalSignupDto
import com.keyneez.data.model.request.RequestPostPwdCheckDto
import com.keyneez.data.model.response.ResponseIdDto
import com.keyneez.data.model.response.ResponsePatchPwdSignupDto
import com.keyneez.data.model.response.ResponsePatchUserTypeDto
import com.keyneez.data.model.response.ResponsePostDanalSignupDto
Expand Down Expand Up @@ -33,6 +34,9 @@ class UserRepositoryImpl @Inject constructor(
): Result<BaseResponse<ResponsePostDanalSignupDto>> =
kotlin.runCatching { userDataSource.postDanalSignup(requestPostDanalSignupDto) }

override suspend fun getId(): Result<BaseResponse<ResponseIdDto>> =
kotlin.runCatching { userDataSource.getId() }

override suspend fun patchUserTypeSignup(
requestPatchUserTypeDto: RequestPatchUserTypeDto
): Result<BaseResponse<ResponsePatchUserTypeDto>> =
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/java/com/keyneez/data/service/ContentService.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
package com.keyneez.data.service

interface ContentService
import com.keyneez.data.model.response.ResponseGetContentDeatilDto
import com.keyneez.data.model.response.ResponseLikeDto
import com.keyneez.data.model.response.wrapper.BaseResponse
import retrofit2.http.GET
import retrofit2.http.Path

interface ContentService {
@GET("content/liked")
suspend fun getLike(): BaseResponse<List<ResponseLikeDto>>

@GET("content/view/{content_id}")
suspend fun getDetail(
@Path("content_id") contentId: Int
): BaseResponse<ResponseGetContentDeatilDto>
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/keyneez/data/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import com.keyneez.data.model.request.RequestPatchPwdSignupDto
import com.keyneez.data.model.request.RequestPatchUserTypeDto
import com.keyneez.data.model.request.RequestPostDanalSignupDto
import com.keyneez.data.model.request.RequestPostPwdCheckDto
import com.keyneez.data.model.response.ResponseIdDto
import com.keyneez.data.model.response.ResponsePatchPwdSignupDto
import com.keyneez.data.model.response.ResponsePatchUserTypeDto
import com.keyneez.data.model.response.ResponsePostDanalSignupDto
import com.keyneez.data.model.response.wrapper.BaseResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST

Expand All @@ -19,6 +21,9 @@ interface UserService {
@Body request: RequestPostDanalSignupDto
): BaseResponse<ResponsePostDanalSignupDto>

@GET("user")
suspend fun getId(): BaseResponse<ResponseIdDto>

// ์œ ์ € ์ƒ์„ฑ (์„ฑํ–ฅ, ๊ด€์‹ฌ์‚ฌ)
@PATCH("user/signup")
suspend fun patchUserTypeSignup(
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/com/keyneez/data/source/ContentDataSource.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.keyneez.data.source

import com.keyneez.data.model.response.ResponseGetContentDeatilDto
import com.keyneez.data.model.response.ResponseLikeDto
import com.keyneez.data.model.response.wrapper.BaseResponse
import com.keyneez.data.service.ContentService
import javax.inject.Inject

class ContentDataSource @Inject constructor(
private val contentService: ContentService
)
) {

suspend fun getLike(): BaseResponse<List<ResponseLikeDto>> = contentService.getLike()

suspend fun getDetail(contentId: Int): BaseResponse<ResponseGetContentDeatilDto> =
contentService.getDetail(contentId)
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/keyneez/data/source/UserDataSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.keyneez.data.model.request.RequestPatchPwdSignupDto
import com.keyneez.data.model.request.RequestPatchUserTypeDto
import com.keyneez.data.model.request.RequestPostDanalSignupDto
import com.keyneez.data.model.request.RequestPostPwdCheckDto
import com.keyneez.data.model.response.ResponseIdDto
import com.keyneez.data.model.response.ResponsePatchPwdSignupDto
import com.keyneez.data.model.response.ResponsePatchUserTypeDto
import com.keyneez.data.model.response.ResponsePostDanalSignupDto
Expand All @@ -19,6 +20,8 @@ class UserDataSource @Inject constructor(
): BaseResponse<ResponsePostDanalSignupDto> =
userService.postDanalSignup(requestPostDanalSignupDto)

suspend fun getId(): BaseResponse<ResponseIdDto> = userService.getId()

suspend fun patchUserTypeSignup(
requestPatchUserTypeDto: RequestPatchUserTypeDto
): BaseResponse<ResponsePatchUserTypeDto> =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
package com.keyneez.presentation.main.detail

import android.os.Bundle
import androidx.activity.viewModels
import com.keyneez.util.binding.BindingActivity
import com.keyneez.util.extension.setOnSingleClickListener
import com.lab.keyneez.R
import com.lab.keyneez.databinding.ActivityHomeDetailBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class DetailActivity :
BindingActivity<ActivityHomeDetailBinding>(R.layout.activity_home_detail) {
val detailViewModel: DetailViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.vm = detailViewModel

initContentId()
initBackClickListener()
initShareClickListener()
initHeartClickListener()
}

private fun initContentId() {
detailViewModel.getDetail(2)
}

private fun initBackClickListener() {
binding.btnDetailBack.setOnSingleClickListener { }
binding.btnDetailBack.setOnSingleClickListener {
finish()
}
}

private fun initShareClickListener() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
package com.keyneez.presentation.main.detail

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.keyneez.data.model.response.ResponseGetContentDeatilDto
import com.keyneez.data.repository.ContentRepository
import com.keyneez.util.UiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject

class DetailViewModel : ViewModel()
@HiltViewModel
class DetailViewModel @Inject constructor(
private val contentRepository: ContentRepository
) : ViewModel() {

private val _detailContent = MutableLiveData<ResponseGetContentDeatilDto>()
val detailContent: LiveData<ResponseGetContentDeatilDto>
get() = _detailContent

private val _stateMessage = MutableLiveData<UiState>()
val stateMessage: LiveData<UiState>
get() = _stateMessage

fun getDetail(contentId: Int) {
viewModelScope.launch {
contentRepository.getDetail(contentId)
.onSuccess { response ->
if (response.data == null) {
Timber.d("GET DETAIL LIST IS NULL")
_stateMessage.value = UiState.Failure(100)
return@onSuccess
}
Timber.d("GET DETAIL LIST SUCCESS")
Timber.d("response : $response")
_detailContent.value = response.data!!
_stateMessage.value = UiState.Success
}.onFailure { throwable ->
Timber.e("$throwable")
}
}
}
}
Loading

0 comments on commit b76028e

Please sign in to comment.