From 99be11b0e2f73feda66aea9633c943cdedce87a1 Mon Sep 17 00:00:00 2001 From: mangbaam Date: Thu, 10 Nov 2022 02:53:37 +0900 Subject: [PATCH 001/929] =?UTF-8?q?Issues=20#3=20chore:=20Room=20=EB=94=94?= =?UTF-8?q?=ED=8E=9C=EB=8D=98=EC=8B=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/Dependencies.kt | 59 ++++++++++++++++++------ data/build.gradle.kts | 4 ++ 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 796a5047e..cc839124c 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -9,6 +9,7 @@ object Versions { const val ANDROID_JUNIT = "1.1.3" const val ESPRESSO = "3.4.0" const val MATERIAL = "1.7.0" + const val ROOM = "2.4.3" } object Libraries { @@ -19,34 +20,56 @@ object Libraries { private const val NAVIGATION_FRAGMENT_KTX = "androidx.navigation:navigation-fragment-ktx:${Versions.NAVIGATION_FRAGMENT}" private const val NAVIGATION_UI_KTX = "androidx.navigation:navigation-ui-ktx:${Versions.NAVIGATION_FRAGMENT}" + private const val ROOM_RUNTIME = "androidx.room:room-runtime:${Versions.ROOM}" + private const val ROOM_KTX = "androidx.room:room-ktx:${Versions.ROOM}" private const val MATERIAL = "com.google.android.material:material:${Versions.MATERIAL}" - val VIEW_LIBRARIES = arrayListOf().apply { - add(CORE) - add(APP_COMPAT) - add(CONSTRAINT_LAYOUT) - add(NAVIGATION_FRAGMENT_KTX) - add(NAVIGATION_UI_KTX) - add(MATERIAL) - } + val VIEW_LIBRARIES = arrayListOf( + CORE, + APP_COMPAT, + CONSTRAINT_LAYOUT, + NAVIGATION_FRAGMENT_KTX, + NAVIGATION_UI_KTX, + MATERIAL + ) + val DATA_LIBRARIES = arrayListOf( + ROOM_RUNTIME, + ROOM_KTX + ) } object TestImpl { private const val JUNIT4 = "junit:junit:${Versions.JUNIT}" // TODO 5 쓰는 쪽으로 바꿔야함 - val TEST_LIBRARIES = arrayListOf().apply { - add(JUNIT4) - } + val TEST_LIBRARIES = arrayListOf( + JUNIT4 + ) } object AndroidTestImpl { private const val ANDROID_JUNIT = "androidx.test.ext:junit:${Versions.ANDROID_JUNIT}" private const val ESPRESSO = "androidx.test.espresso:espresso-core:${Versions.ESPRESSO}" - val ANDROID_LIBRARIES = arrayListOf().apply { - add(ANDROID_JUNIT) - add(ESPRESSO) - } + val ANDROID_LIBRARIES = arrayListOf( + ANDROID_JUNIT, + ESPRESSO + ) +} + +object AnnotationProcessors { + private const val ROOM_COMPILER = "androidx.room:room-compiler:${Versions.ROOM}" + + val DATA_LIBRARIES = arrayListOf( + ROOM_COMPILER + ) +} + +object Kapt { + private const val ROOM_COMPILER = "androidx.room:room-compiler:${Versions.ROOM}" + + val DATA_LIBRARIES = arrayListOf( + ROOM_COMPILER + ) } fun DependencyHandler.kapt(list: List) { @@ -67,6 +90,12 @@ fun DependencyHandler.androidTestImplementation(list: List) { } } +fun DependencyHandler.annotationProcessor(list: List) { + list.forEach { dependency -> + add("annotationProcessor", dependency) + } +} + fun DependencyHandler.testImplementation(list: List) { list.forEach { dependency -> add("testImplementation", dependency) diff --git a/data/build.gradle.kts b/data/build.gradle.kts index ccaa664a2..34da8e0ff 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.library") id("org.jetbrains.kotlin.android") + id("kotlin-kapt") } android { @@ -35,5 +36,8 @@ dependencies { implementation(project(":domain")) implementation(TestImpl.TEST_LIBRARIES) + implementation(Libraries.DATA_LIBRARIES) + annotationProcessor(AnnotationProcessors.DATA_LIBRARIES) androidTestImplementation(AndroidTestImpl.ANDROID_LIBRARIES) + kapt(Kapt.DATA_LIBRARIES) } From 70590782b223294e94b33d4302cab6680c39c143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 11:38:01 +0900 Subject: [PATCH 002/929] =?UTF-8?q?Issues=20#5=20test:=20=EA=B8=B0?= =?UTF-8?q?=ED=94=84=ED=8B=B0=EC=BD=98=20=ED=8C=8C=EC=8B=B1=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lighthouse/data/GifticonParser.kt | 186 ++++++++++++++++++ .../com/lighthouse/data/TextParseTest.kt | 160 +++++++++++++++ 2 files changed, 346 insertions(+) create mode 100644 presentation/src/test/kotlin/com/lighthouse/data/GifticonParser.kt create mode 100644 presentation/src/test/kotlin/com/lighthouse/data/TextParseTest.kt diff --git a/presentation/src/test/kotlin/com/lighthouse/data/GifticonParser.kt b/presentation/src/test/kotlin/com/lighthouse/data/GifticonParser.kt new file mode 100644 index 000000000..f3a818756 --- /dev/null +++ b/presentation/src/test/kotlin/com/lighthouse/data/GifticonParser.kt @@ -0,0 +1,186 @@ +package com.lighthouse.data + +import java.text.SimpleDateFormat +import java.util.Date + +object GifticonParser { + fun parse(input: List): Parser { + val kakaoParser = KakaoParser(input) + if (kakaoParser.match) { + return kakaoParser + } + val syrupParser = SyrupParser(input) + if (syrupParser.match) { + return syrupParser + } + val cConParser = CConParser(input) + if (cConParser.match) { + return cConParser + } + val giftishowParser = GiftishowParser(input) + if (giftishowParser.match) { + return giftishowParser + } + + return DefaultParser(input) + } + + fun parse(input: String): Parser { + return parse(input.split(input, "\n")) + } +} + +abstract class Parser(input: List) { + abstract val keywords: List + + open val exactExcludes = listOf("상품명", "교환처", "사용처", "유효기간", "사용기한", "쿠폰번호", "주문번호") + + open val containExcludes = listOf() + + protected val info by lazy { + input.filter { + val value = it.lowercase().trim() + keywords.none { keyword -> value.contains(keyword) } && + value !in exactExcludes && + containExcludes.none { exclude -> value.contains(exclude) } + }.distinct() + } + + open val match by lazy { + input.any { str -> + keywords.any { keyword -> + str.lowercase().trim().contains(keyword) + } + } + } + + open val title = "" + + open val brand = "" + + private val dateRegex = "(\\d{4}.\\d{2}.\\d{2})".toRegex() + private val format = SimpleDateFormat("yyyy.MM.dd") + val date by lazy { + info.mapNotNull { str -> + dateRegex.find(str)?.groups?.get(1)?.value?.trim() + }.getOrNull(0)?.let { + format.parse(it) + } ?: Date() + } + + private val barcodeRegex = "(\\d{4}\\s\\d{4}\\s\\d{4})".toRegex() + val barcode by lazy { + info.mapNotNull { str -> + barcodeRegex.find(str)?.groups?.get(1)?.value?.trim()?.replace(" ", "") + }.getOrNull(0) ?: "" + } + + private val cashCardRegex1 = "(\\d*)원".toRegex() + private val cashCardRegex2 = "(\\d*)만원".toRegex() + + val isCashCard by lazy { + balance > 0 + } + + val balance by lazy { + info.mapNotNull { str -> + cashCardRegex1.find(str)?.groups?.get(1)?.value?.trim()?.toInt() + ?: cashCardRegex2.find(str)?.groups?.get(1)?.value?.trim()?.toInt() + }.getOrNull(0) ?: 0 + } + + open val candidateList by lazy { + info.filter { str -> + !str.all { it.isDigit() } && + barcodeRegex.find(str) == null && + dateRegex.find(str) == null + } + } +} + +class SyrupParser(input: List) : Parser(input) { + override val keywords = listOf("syrup") + + override val exactExcludes = listOf("사용기한", "사용처") + + override val containExcludes = listOf("교환수량", "기프티콘", "gifticon") + + private val brandRegex = "사용처\\s(.*)".toRegex() + + override val brand = info.mapNotNull { + brandRegex.find(it)?.groups?.get(1)?.value?.trim() + }.getOrNull(0) ?: "" + + override val candidateList = super.candidateList.map { str -> + brandRegex.find(str)?.groups?.get(1)?.value?.trim() ?: str + } +} + +class GiftishowParser(input: List) : Parser(input) { + override val keywords = listOf("기프티쇼", "giftishow") + + override val exactExcludes = listOf("상품명", "교환처", "유효기간") + + override val containExcludes = listOf() + + private val titleRegex = "상품명\\s*:(.*)".toRegex() + private val brandRegex = "교환처\\s*:(.*)".toRegex() + private val remainRegex = ":(.*)".toRegex() + + override val title = info.mapNotNull { str -> + titleRegex.find(str)?.groups?.get(1)?.value?.trim() + }.getOrNull(0) ?: info.mapNotNull { str -> + remainRegex.find(str)?.groups?.get(1)?.value?.trim() + }.getOrNull(0) ?: "" + + override val brand = info.mapNotNull { str -> + brandRegex.find(str)?.groups?.get(1)?.value?.trim() + }.getOrNull(0) ?: info.mapNotNull { str -> + remainRegex.find(str)?.groups?.get(1)?.value?.trim() + }.let { list -> + list.getOrNull((list.size - 1).coerceAtLeast(1)) + } ?: "" + + override val candidateList = super.candidateList.map { str -> + titleRegex.find(str)?.groups?.get(1)?.value?.trim() ?: brandRegex.find(str)?.groups?.get(1)?.value?.trim() + ?: remainRegex.find(str)?.groups?.get(1)?.value?.trim() ?: str + } +} + +class CConParser(input: List) : Parser(input) { + override val keywords = listOf("ccon", "c콘") + + override val exactExcludes = listOf("înumber", "inumber", "상품명", "교환처", "유효기간", "쿠폰번호") + + override val containExcludes = listOf() + + private val titleRegex = "상품명\\s+(.*)".toRegex() + private val brandRegex = "교환처\\s+(.*)".toRegex() + + override val title = info.mapNotNull { str -> + titleRegex.find(str)?.groups?.get(1)?.value?.trim() + }.getOrNull(0) ?: "" + + override val brand = info.mapNotNull { str -> + brandRegex.find(str)?.groups?.get(1)?.value?.trim() + }.getOrNull(0) ?: "" + + override val candidateList = super.candidateList.map { str -> + titleRegex.find(str)?.groups?.get(1)?.value?.trim() ?: brandRegex.find(str)?.groups?.get(1)?.value?.trim() + ?: str + } +} + +class KakaoParser(input: List) : Parser(input) { + override val keywords = listOf("kakaotalk") + + override val exactExcludes = listOf("교환처", "유효기간", "주문번호") + + override val containExcludes = listOf() +} + +class DefaultParser(input: List) : Parser(input) { + override val keywords = listOf() + + override val match = false +} diff --git a/presentation/src/test/kotlin/com/lighthouse/data/TextParseTest.kt b/presentation/src/test/kotlin/com/lighthouse/data/TextParseTest.kt new file mode 100644 index 000000000..d3d23a77c --- /dev/null +++ b/presentation/src/test/kotlin/com/lighthouse/data/TextParseTest.kt @@ -0,0 +1,160 @@ +package com.lighthouse.data + +import org.junit.Test +import java.text.SimpleDateFormat + +class TextParseTest { + private val dateFormat = SimpleDateFormat("yyyy.MM.dd") + + @Test + fun `syrup 테스트 (1)`() { + val text = listOf( + "syrup gifticon", + "다크 초콜릿 카우보이 쿠키", + "교수령 1 개", + "ARI L 2016.09.13", + "사품 스티백스", + "Syupgiticnn", + "가프타콘 엘에는 궁파 무료콘이 발다면데-" + ) + + val parser = GifticonParser.parse(text) + + assert(parser.match) + + assert(parser.date == dateFormat.parse("2016.09.13")) + + assert(parser.title == "") + + assert("다크 초콜릿 카우보이 쿠키" in parser.candidateList) + assert("교수령 1 개" in parser.candidateList) + assert("사품 스티백스" in parser.candidateList) + assert("Syupgiticnn" in parser.candidateList) + assert("가프타콘 엘에는 궁파 무료콘이 발다면데-" in parser.candidateList) + assert(parser.candidateList.size == 5) + } + + @Test + fun `syrup 테스트 (2)`() { + val text = listOf( + "syrup gifticon", + "아이스 카페 라떼 Tall", + "교환수량 1개", + "사용기한 ~ 2016.09.11", + "사용처 스타벅스", + "syrup gifticon", + "9999 6725 6650", + "마음을 전하는 또 다른 방법... 시럽기프티콘" + ) + + val parser = GifticonParser.parse(text) + + assert(parser.match) + + assert(parser.date == dateFormat.parse("2016.09.11")) + + assert(parser.title == "") + + assert(parser.brand == "스타벅스") + + assert(parser.barcode == "999967256650") + + assert("아이스 카페 라떼 Tall" in parser.candidateList) + assert("스타벅스" in parser.candidateList) + assert(parser.candidateList.size == 2) + } + + @Test + fun `giftishow 테스트`() { + val text = listOf( + "내 마음의 선물, 기프티쇼 www.gitishow.com", + "9003 6992 1874", + ": 카페아메리카노 Tal", + "giftishow", + "상품명", + "교환처 : 스타벅스", + "유효기간 : ~ 2020.05.04" + ) + + val parser = GifticonParser.parse(text) + + assert(parser.match) + + assert(parser.date == dateFormat.parse("2020.05.04")) + + assert(parser.title == "카페아메리카노 Tal") + + assert(parser.brand == "스타벅스") + + assert(parser.barcode == "900369921874") + + assert("카페아메리카노 Tal" in parser.candidateList) + assert("스타벅스" in parser.candidateList) + assert(parser.candidateList.size == 2) + } + + @Test + fun `C Con 테스트`() { + val text = listOf( + "CcON 모바일 선물쿠폰 C존", + "înumber", + "상품명", + "C콘", + "9810 5989 3232", + "스타벅스", + "교환처", + "유효기간 2019.06.17", + "카페아메리카노 Tal", + "쿠폰번호 981059893232", + "카페아메리카노 Tal", + "스타벅스" + ) + + val parser = GifticonParser.parse(text) + + assert(parser.match) + + assert(parser.date == dateFormat.parse("2019.06.17")) + + assert(parser.title == "") + + assert(parser.brand == "") + + assert(parser.barcode == "981059893232") + + assert("카페아메리카노 Tal" in parser.candidateList) + assert("스타벅스" in parser.candidateList) + assert(parser.candidateList.size == 2) + } + + @Test + fun `kakaotalk 테스트`() { + val text = listOf( + "뿌링클+콜라1.25L", + "교환처", + "유효기간", + "주문번호", + "9461 1613 3562", + "bhe", + "2020.10.27", + "929975990", + "kakaotalk선물하기" + ) + + val parser = GifticonParser.parse(text) + + assert(parser.match) + + assert(parser.date == dateFormat.parse("2020.10.27")) + + assert(parser.title == "") + + assert(parser.brand == "") + + assert(parser.barcode == "946116133562") + + assert("뿌링클+콜라1.25L" in parser.candidateList) + assert("bhe" in parser.candidateList) + assert(parser.candidateList.size == 2) + } +} From b222b068b5140b408a9731b5c8315d33a0e53dce Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Thu, 10 Nov 2022 11:55:19 +0900 Subject: [PATCH 003/929] =?UTF-8?q?Issues=20#7=20docs:=20PR=20=ED=85=9C?= =?UTF-8?q?=ED=94=8C=EB=A6=BF=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..6ddb6aae2 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,19 @@ +resolved: #number + +## 작업 내용 + +> 어떤 작업을 했는지 적어주세요! + +## 체크리스트 +- [ ] Assignees 설정 +- [ ] Labels 설정 +- [ ] Projects 설정 +- [ ] Milestone 설정 + +## 동작 화면 + +> 존재하지 않는다면 패스해주세요! + +## 버그 + +> 존재하지 않는다면 패스해주세요! \ No newline at end of file From 0327a35e43cf02353e815fb5c81a88c58a79e8f2 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Thu, 10 Nov 2022 16:12:47 +0900 Subject: [PATCH 004/929] =?UTF-8?q?Issues=20#9=20chore:=20coroutine=20depe?= =?UTF-8?q?ndency=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: lee-ji-hoon Co-authored-by: mangbaam Co-authored-by: audxo112 --- buildSrc/src/main/kotlin/Dependencies.kt | 7 +++++++ domain/build.gradle.kts | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index cc839124c..51fab1244 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -10,6 +10,7 @@ object Versions { const val ESPRESSO = "3.4.0" const val MATERIAL = "1.7.0" const val ROOM = "2.4.3" + const val COROUTINE = "1.5.1" } object Libraries { @@ -23,6 +24,8 @@ object Libraries { private const val ROOM_RUNTIME = "androidx.room:room-runtime:${Versions.ROOM}" private const val ROOM_KTX = "androidx.room:room-ktx:${Versions.ROOM}" private const val MATERIAL = "com.google.android.material:material:${Versions.MATERIAL}" + private const val COROUTINE_CORE = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINE}" + private const val COROUTINE_ANDROID = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.COROUTINE}" val VIEW_LIBRARIES = arrayListOf( CORE, @@ -36,6 +39,10 @@ object Libraries { ROOM_RUNTIME, ROOM_KTX ) + val DOMAIN_LIBRARIES = arrayListOf( + COROUTINE_CORE, + COROUTINE_ANDROID + ) } object TestImpl { diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index 03188ec98..b22d9f092 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -7,3 +7,7 @@ java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + +dependencies { + implementation(Libraries.DOMAIN_LIBRARIES) +} From 356c36032d678977b0bc3a3845794dd2e83c52e7 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Thu, 10 Nov 2022 16:13:20 +0900 Subject: [PATCH 005/929] =?UTF-8?q?Issues=20#9=20feat:=20domain=20model=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: lee-ji-hoon Co-authored-by: mangbaam Co-authored-by: audxo112 --- .../lighthouse/domain/model/BrandPlaceInfo.kt | 10 ++++++++++ .../lighthouse/domain/model/GalleryImage.kt | 10 ++++++++++ .../com/lighthouse/domain/model/Gifticon.kt | 16 ++++++++++++++++ .../domain/model/GifticonSaveRequest.kt | 18 ++++++++++++++++++ .../lighthouse/domain/model/UsageHistory.kt | 9 +++++++++ 5 files changed, 63 insertions(+) create mode 100644 domain/src/main/java/com/lighthouse/domain/model/BrandPlaceInfo.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/model/Gifticon.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/model/UsageHistory.kt diff --git a/domain/src/main/java/com/lighthouse/domain/model/BrandPlaceInfo.kt b/domain/src/main/java/com/lighthouse/domain/model/BrandPlaceInfo.kt new file mode 100644 index 000000000..a08d96704 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/model/BrandPlaceInfo.kt @@ -0,0 +1,10 @@ +package com.lighthouse.domain.model + +data class BrandPlaceInfo( + val addressName: String, + val placeName: String, + val placeUrl: String, + val brand: String, + val x: String, + val y: String +) diff --git a/domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt b/domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt new file mode 100644 index 000000000..8f9942841 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt @@ -0,0 +1,10 @@ +package com.lighthouse.domain.model + +import com.sun.jndi.toolkit.url.Uri +import java.util.Date + +data class GalleryImage( + val id: Long, + val contentUri: Uri, + val date: Date +) diff --git a/domain/src/main/java/com/lighthouse/domain/model/Gifticon.kt b/domain/src/main/java/com/lighthouse/domain/model/Gifticon.kt new file mode 100644 index 000000000..3cb3826ff --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/model/Gifticon.kt @@ -0,0 +1,16 @@ +package com.lighthouse.domain.model + +import java.util.Date + +data class Gifticon( + val id: String, + val userId: String, + val name: String, + val brand: String, + val expireAt: Date, + val barcode: String, + val isCashCard: Boolean, + val balance: Int, + val memo: String, + val isUsed: Boolean +) diff --git a/domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt b/domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt new file mode 100644 index 000000000..fec62231f --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt @@ -0,0 +1,18 @@ +package com.lighthouse.domain.model + +import com.sun.jndi.toolkit.url.Uri +import java.util.Date + +data class GifticonSaveRequest( + val userId: String, + val name: String, + val brand: String, + val expireAt: Date, + val barcode: String, + val isCashCard: Boolean, + val balance: Int, + val memo: String, + val thumbnailUri: Uri, + val originUri: Uri, + val brandUri: Uri +) diff --git a/domain/src/main/java/com/lighthouse/domain/model/UsageHistory.kt b/domain/src/main/java/com/lighthouse/domain/model/UsageHistory.kt new file mode 100644 index 000000000..cd0916fb1 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/model/UsageHistory.kt @@ -0,0 +1,9 @@ +package com.lighthouse.domain.model + +import java.util.Date + +data class UsageHistory( + val date: Date, + val address: String, + val amount: Int +) From d33f79cf0ffdbf17852aba9a19964713d8ca8e5e Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Thu, 10 Nov 2022 16:14:21 +0900 Subject: [PATCH 006/929] =?UTF-8?q?Issues=20#9=20feat:=20domain=20usecase?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: lee-ji-hoon Co-authored-by: mangbaam Co-authored-by: audxo112 --- .../domain/usecase/GetAllBrandsUseCase.kt | 11 ++++++++++ .../usecase/GetBrandPlaceInfosUseCase.kt | 10 ++++++++++ .../usecase/GetCorrespondWithPinUseCase.kt | 8 ++++++++ .../domain/usecase/GetGalleryImagesUseCase.kt | 9 +++++++++ .../domain/usecase/GetGifticonUseCase.kt | 11 ++++++++++ .../usecase/GetGifticonsByLocationUseCase.kt | 10 ++++++++++ .../domain/usecase/GetGifticonsUseCase.kt | 20 +++++++++++++++++++ .../usecase/GetNotificationGifticonUseCase.kt | 12 +++++++++++ .../domain/usecase/GetSharedDateUseCase.kt | 10 ++++++++++ .../domain/usecase/SaveGifticonsUseCase.kt | 10 ++++++++++ .../domain/usecase/SavePinUseCase.kt | 7 +++++++ .../usecase/UpdateGifticonInfoUseCase.kt | 10 ++++++++++ .../domain/usecase/UpdatePinUseCase.kt | 8 ++++++++ .../domain/usecase/UpdateSharedDateUseCase.kt | 8 ++++++++ .../usecase/UpdateUsageHistoryUseCase.kt | 8 ++++++++ 15 files changed, 152 insertions(+) create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetAllBrandsUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetCorrespondWithPinUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsByLocationUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetNotificationGifticonUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/GetSharedDateUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/SaveGifticonsUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/UpdateGifticonInfoUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/UpdatePinUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/UpdateSharedDateUseCase.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/usecase/UpdateUsageHistoryUseCase.kt diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetAllBrandsUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetAllBrandsUseCase.kt new file mode 100644 index 000000000..96b6aa0ae --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetAllBrandsUseCase.kt @@ -0,0 +1,11 @@ +package com.lighthouse.domain.usecase + +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.emptyFlow + +class GetAllBrandsUseCase { + + operator fun invoke(userId: String): Flow> { + return emptyFlow() + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt new file mode 100644 index 000000000..d69ba33ac --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt @@ -0,0 +1,10 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.BrandPlaceInfo + +class GetBrandPlaceInfosUseCase { + + operator fun invoke(brandName: String, x: Int, y: Int, rect: Int, size: Int): List { + return emptyList() + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetCorrespondWithPinUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetCorrespondWithPinUseCase.kt new file mode 100644 index 000000000..267f02c5c --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetCorrespondWithPinUseCase.kt @@ -0,0 +1,8 @@ +package com.lighthouse.domain.usecase + +class GetCorrespondWithPinUseCase { + + operator fun invoke(pin: Int): Boolean { + return false + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt new file mode 100644 index 000000000..405a86373 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt @@ -0,0 +1,9 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.GalleryImage + +class GetGalleryImagesUseCase { + operator fun invoke(): List { + return emptyList() + } +} \ No newline at end of file diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonUseCase.kt new file mode 100644 index 000000000..634b1d83d --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonUseCase.kt @@ -0,0 +1,11 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.Gifticon +import java.util.Date + +class GetGifticonUseCase { + + operator fun invoke(id: String): Gifticon { + return Gifticon("", "", "", "", Date(), "", true, 0, "", false) + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsByLocationUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsByLocationUseCase.kt new file mode 100644 index 000000000..89b458f02 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsByLocationUseCase.kt @@ -0,0 +1,10 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.GifticonSaveRequest + +class GetGifticonsByLocationUseCase { + + operator fun invoke(brandName: String, x: Int, y: Int): List { + return emptyList() + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsUseCase.kt new file mode 100644 index 000000000..752f0b790 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetGifticonsUseCase.kt @@ -0,0 +1,20 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.Gifticon +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.emptyFlow + +class GetGifticonsUseCase { + + operator fun invoke(userId: String): Flow> { + return emptyFlow() + } + + operator fun invoke(userId: String, query: String): Flow> { + return emptyFlow() + } + + operator fun invoke(userId: String, filter: List): Flow> { + return emptyFlow() + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetNotificationGifticonUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetNotificationGifticonUseCase.kt new file mode 100644 index 000000000..2c3bad44e --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetNotificationGifticonUseCase.kt @@ -0,0 +1,12 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.Gifticon +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.emptyFlow + +class GetNotificationGifticonUseCase { + + operator fun invoke(day: Int): Flow> { + return emptyFlow() + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetSharedDateUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetSharedDateUseCase.kt new file mode 100644 index 000000000..f1035ebf6 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetSharedDateUseCase.kt @@ -0,0 +1,10 @@ +package com.lighthouse.domain.usecase + +import java.util.Date + +class GetSharedDateUseCase { + + operator fun invoke(id: String): Date? { + return null + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/SaveGifticonsUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/SaveGifticonsUseCase.kt new file mode 100644 index 000000000..82bf8a28b --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/SaveGifticonsUseCase.kt @@ -0,0 +1,10 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.GifticonSaveRequest + +class SaveGifticonsUseCase { + + operator fun invoke(): List { + return emptyList() + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt new file mode 100644 index 000000000..82dc60077 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt @@ -0,0 +1,7 @@ +package com.lighthouse.domain.usecase + +class SavePinUseCase { + operator fun invoke(pin: Int): Result { + return Result.success(Unit) + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/UpdateGifticonInfoUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/UpdateGifticonInfoUseCase.kt new file mode 100644 index 000000000..236ff5326 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/UpdateGifticonInfoUseCase.kt @@ -0,0 +1,10 @@ +package com.lighthouse.domain.usecase + +import com.lighthouse.domain.model.Gifticon + +class UpdateGifticonInfoUseCase { + + operator fun invoke(gifticon: Gifticon): Result { + return Result.success(Unit) + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/UpdatePinUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/UpdatePinUseCase.kt new file mode 100644 index 000000000..11d529f05 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/UpdatePinUseCase.kt @@ -0,0 +1,8 @@ +package com.lighthouse.domain.usecase + +class UpdatePinUseCase { + + operator fun invoke(pin: Int): Result { + return Result.success(Unit) + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/UpdateSharedDateUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/UpdateSharedDateUseCase.kt new file mode 100644 index 000000000..fd733f626 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/UpdateSharedDateUseCase.kt @@ -0,0 +1,8 @@ +package com.lighthouse.domain.usecase + +class UpdateSharedDateUseCase { + + operator fun invoke(id: String): Result { + return Result.success(Unit) + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/UpdateUsageHistoryUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/UpdateUsageHistoryUseCase.kt new file mode 100644 index 000000000..43f612dc1 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/usecase/UpdateUsageHistoryUseCase.kt @@ -0,0 +1,8 @@ +package com.lighthouse.domain.usecase + +class UpdateUsageHistoryUseCase { + + operator fun invoke(id: String): Result { + return Result.success(Unit) + } +} From 454f682e81ceccd910cd90528c0b96b335aae101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 17:00:42 +0900 Subject: [PATCH 007/929] =?UTF-8?q?Issues=20#11=20fix:=20=EC=A7=80?= =?UTF-8?q?=ED=9B=88=20lint,=20kt=20lint=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/lighthouse/domain/model/GalleryImage.kt | 3 +-- .../com/lighthouse/domain/model/GifticonSaveRequest.kt | 7 +++---- .../lighthouse/domain/usecase/GetGalleryImagesUseCase.kt | 5 +++-- .../java/com/lighthouse/domain/usecase/SavePinUseCase.kt | 1 + 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt b/domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt index 8f9942841..a95f8e689 100644 --- a/domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt +++ b/domain/src/main/java/com/lighthouse/domain/model/GalleryImage.kt @@ -1,10 +1,9 @@ package com.lighthouse.domain.model -import com.sun.jndi.toolkit.url.Uri import java.util.Date data class GalleryImage( val id: Long, - val contentUri: Uri, + val contentUri: String, val date: Date ) diff --git a/domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt b/domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt index fec62231f..58a95d967 100644 --- a/domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt +++ b/domain/src/main/java/com/lighthouse/domain/model/GifticonSaveRequest.kt @@ -1,6 +1,5 @@ package com.lighthouse.domain.model -import com.sun.jndi.toolkit.url.Uri import java.util.Date data class GifticonSaveRequest( @@ -12,7 +11,7 @@ data class GifticonSaveRequest( val isCashCard: Boolean, val balance: Int, val memo: String, - val thumbnailUri: Uri, - val originUri: Uri, - val brandUri: Uri + val thumbnailUri: String, + val originUri: String, + val brandUri: String ) diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt index 405a86373..d9de4a72a 100644 --- a/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt @@ -3,7 +3,8 @@ package com.lighthouse.domain.usecase import com.lighthouse.domain.model.GalleryImage class GetGalleryImagesUseCase { + operator fun invoke(): List { - return emptyList() + return emptyList() } -} \ No newline at end of file +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt index 82dc60077..9c62ca340 100644 --- a/domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt +++ b/domain/src/main/java/com/lighthouse/domain/usecase/SavePinUseCase.kt @@ -1,6 +1,7 @@ package com.lighthouse.domain.usecase class SavePinUseCase { + operator fun invoke(pin: Int): Result { return Result.success(Unit) } From f0963fb33d3b0555aacb66fe072d4a8a0d6d6dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 19:15:18 +0900 Subject: [PATCH 008/929] =?UTF-8?q?Issues=20#11=20chore=20:=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 12 ++ app/src/main/AndroidManifest.xml | 5 + build.gradle.kts | 8 +- buildSrc/src/main/kotlin/AppConfig.kt | 2 +- buildSrc/src/main/kotlin/Dependencies.kt | 137 +++++++++++++++++++---- data/build.gradle.kts | 8 +- domain/build.gradle.kts | 4 + gradle.properties | 1 + presentation/build.gradle.kts | 14 ++- settings.gradle.kts | 2 + 10 files changed, 161 insertions(+), 32 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c5b1be414..0689901ab 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") @@ -16,6 +18,9 @@ android { versionName = AppConfig.versionName testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + + buildConfigField("String", "naver_map_api_id", getApiKey("naver_map_api_id")) + buildConfigField("String", "kakao_search_id", getApiKey("kakao_search_id")) } buildTypes { @@ -33,6 +38,9 @@ android { kotlinOptions { jvmTarget = "1.8" } + buildFeatures { + dataBinding = true + } } dependencies { @@ -40,3 +48,7 @@ dependencies { implementation(project(":presentation")) implementation(project(":data")) } + +fun getApiKey(propertyKey: String): String { + return gradleLocalProperties(rootDir).getProperty(propertyKey) +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 88eef9c4d..661dba089 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,11 @@ + + + + + Date: Thu, 10 Nov 2022 22:46:39 +0900 Subject: [PATCH 009/929] =?UTF-8?q?Issues=20#13=20chore:=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=EC=96=B4=20=EC=9E=90=EB=8F=99=20=EB=93=B1=EB=A1=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80,=20naver=5Fmap=5Fapi=5Fid=20-=20manifest?= =?UTF-8?q?=EC=97=90=20=EB=93=B1=EB=A1=9D=ED=95=98=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20manifestPlaceholders(MutableMap=EC=97=90?= =?UTF-8?q?=20=EB=93=B1=EB=A1=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/CODEOWNERS | 1 + app/build.gradle.kts | 4 ++-- app/src/main/AndroidManifest.xml | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..811298361 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @boostcampwm-2022/beep \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0689901ab..a73fc9677 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -19,8 +19,8 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - buildConfigField("String", "naver_map_api_id", getApiKey("naver_map_api_id")) - buildConfigField("String", "kakao_search_id", getApiKey("kakao_search_id")) + buildConfigField("String", "kakaoSearchId", getApiKey("kakao_search_id")) + manifestPlaceholders["naver_map_api_id"] = getApiKey("naver_map_api_id") } buildTypes { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 661dba089..738dc6dab 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,5 +17,9 @@ android:supportsRtl="true" android:theme="@style/Theme.BEEP" tools:targetApi="31"> + + \ No newline at end of file From f8043fb5cdd4f858f13ba25c63b6b04b37424187 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Thu, 10 Nov 2022 22:47:49 +0900 Subject: [PATCH 010/929] =?UTF-8?q?Issues=20#13=20feat:=20=EC=A7=80?= =?UTF-8?q?=EB=8F=84=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83,=20=EB=B0=94?= =?UTF-8?q?=ED=85=80=20recyclerView=20Item=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/map/MapActivity.kt | 20 +++++ .../presentation/ui/map/MapViewModel.kt | 5 ++ .../src/main/res/layout/activity_map.xml | 40 +++++++++ .../res/layout/item_gifticon_horizontal.xml | 88 +++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt create mode 100644 presentation/src/main/res/layout/activity_map.xml create mode 100644 presentation/src/main/res/layout/item_gifticon_horizontal.xml diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt new file mode 100644 index 000000000..b84bf2565 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt @@ -0,0 +1,20 @@ +package com.lighthouse.presentation.ui.map + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil +import androidx.lifecycle.ViewModelProvider +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.ActivityMapBinding + +class MapActivity : AppCompatActivity() { + + private lateinit var binding: ActivityMapBinding + private lateinit var viewModel: MapViewModel // TODO by viewModels + Hilt 로 리팩토링 예정 + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DataBindingUtil.setContentView(this, R.layout.activity_map) + viewModel = ViewModelProvider(this)[MapViewModel::class.java] + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt new file mode 100644 index 000000000..54d1e009a --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt @@ -0,0 +1,5 @@ +package com.lighthouse.presentation.ui.map + +import androidx.lifecycle.ViewModel + +class MapViewModel : ViewModel() diff --git a/presentation/src/main/res/layout/activity_map.xml b/presentation/src/main/res/layout/activity_map.xml new file mode 100644 index 000000000..6cac997fd --- /dev/null +++ b/presentation/src/main/res/layout/activity_map.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/item_gifticon_horizontal.xml b/presentation/src/main/res/layout/item_gifticon_horizontal.xml new file mode 100644 index 000000000..f4c983b7c --- /dev/null +++ b/presentation/src/main/res/layout/item_gifticon_horizontal.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From b0d70df52e3648c76b538dda7fcf83c1ca7217a5 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Thu, 10 Nov 2022 23:19:35 +0900 Subject: [PATCH 011/929] Issues #13 refactor: viewModel provider -> by viewModels --- .../java/com/lighthouse/presentation/ui/map/MapActivity.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt index b84bf2565..a76b94053 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt @@ -1,20 +1,19 @@ package com.lighthouse.presentation.ui.map import android.os.Bundle +import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil -import androidx.lifecycle.ViewModelProvider import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ActivityMapBinding class MapActivity : AppCompatActivity() { private lateinit var binding: ActivityMapBinding - private lateinit var viewModel: MapViewModel // TODO by viewModels + Hilt 로 리팩토링 예정 + private val viewModel: MapViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_map) - viewModel = ViewModelProvider(this)[MapViewModel::class.java] } } From c24c72ae7a8ad95529aa41f2abb83c816b26e9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 23:40:55 +0900 Subject: [PATCH 012/929] =?UTF-8?q?Issues=20#16=20style:=20layout,=20icon,?= =?UTF-8?q?=20strings=20=EB=A6=AC=EC=86=8C=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/drawable/ic_main_floating_add.xml | 5 ++ .../main/res/drawable/ic_main_menu_home.xml | 5 ++ .../main/res/drawable/ic_main_menu_list.xml | 5 ++ .../res/drawable/ic_main_menu_setting.xml | 10 ++++ .../src/main/res/layout/activity_main.xml | 54 +++++++++++++++---- .../res/layout/fragment_gifticon_list.xml | 20 +++++++ .../src/main/res/layout/fragment_home.xml | 20 +++++++ .../src/main/res/layout/fragment_setting.xml | 20 +++++++ .../main/res/menu/menu_main_navigation.xml | 17 ++++++ presentation/src/main/res/values/strings.xml | 13 +++++ 10 files changed, 160 insertions(+), 9 deletions(-) create mode 100644 presentation/src/main/res/drawable/ic_main_floating_add.xml create mode 100644 presentation/src/main/res/drawable/ic_main_menu_home.xml create mode 100644 presentation/src/main/res/drawable/ic_main_menu_list.xml create mode 100644 presentation/src/main/res/drawable/ic_main_menu_setting.xml create mode 100644 presentation/src/main/res/layout/fragment_gifticon_list.xml create mode 100644 presentation/src/main/res/layout/fragment_home.xml create mode 100644 presentation/src/main/res/layout/fragment_setting.xml create mode 100644 presentation/src/main/res/menu/menu_main_navigation.xml diff --git a/presentation/src/main/res/drawable/ic_main_floating_add.xml b/presentation/src/main/res/drawable/ic_main_floating_add.xml new file mode 100644 index 000000000..89633bb12 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_main_floating_add.xml @@ -0,0 +1,5 @@ + + + diff --git a/presentation/src/main/res/drawable/ic_main_menu_home.xml b/presentation/src/main/res/drawable/ic_main_menu_home.xml new file mode 100644 index 000000000..3cdad40ea --- /dev/null +++ b/presentation/src/main/res/drawable/ic_main_menu_home.xml @@ -0,0 +1,5 @@ + + + diff --git a/presentation/src/main/res/drawable/ic_main_menu_list.xml b/presentation/src/main/res/drawable/ic_main_menu_list.xml new file mode 100644 index 000000000..7483a9873 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_main_menu_list.xml @@ -0,0 +1,5 @@ + + + diff --git a/presentation/src/main/res/drawable/ic_main_menu_setting.xml b/presentation/src/main/res/drawable/ic_main_menu_setting.xml new file mode 100644 index 000000000..8bda53e46 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_main_menu_setting.xml @@ -0,0 +1,10 @@ + + + diff --git a/presentation/src/main/res/layout/activity_main.xml b/presentation/src/main/res/layout/activity_main.xml index 33459d337..9a2ef2396 100644 --- a/presentation/src/main/res/layout/activity_main.xml +++ b/presentation/src/main/res/layout/activity_main.xml @@ -1,10 +1,46 @@ - - - \ No newline at end of file + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_gifticon_list.xml b/presentation/src/main/res/layout/fragment_gifticon_list.xml new file mode 100644 index 000000000..336ba127b --- /dev/null +++ b/presentation/src/main/res/layout/fragment_gifticon_list.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_home.xml b/presentation/src/main/res/layout/fragment_home.xml new file mode 100644 index 000000000..e434efa17 --- /dev/null +++ b/presentation/src/main/res/layout/fragment_home.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_setting.xml b/presentation/src/main/res/layout/fragment_setting.xml new file mode 100644 index 000000000..58dbc850d --- /dev/null +++ b/presentation/src/main/res/layout/fragment_setting.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/menu/menu_main_navigation.xml b/presentation/src/main/res/menu/menu_main_navigation.xml new file mode 100644 index 000000000..b4aedb739 --- /dev/null +++ b/presentation/src/main/res/menu/menu_main_navigation.xml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index e48541cd6..541195e7a 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -1,3 +1,16 @@ BEEP + + + D-%1$d + + 목록 + + 설정 + + 최신순 + 디데이순 + 전체 + + 기프티콘 추가하기 버튼 \ No newline at end of file From d4f8509383df0d834709f3304e8d1661d1a548d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 23:42:24 +0900 Subject: [PATCH 013/929] =?UTF-8?q?Issues=20#11=20feat:=20Activity=20Extra?= =?UTF-8?q?s=20=EB=B0=8F=20Main=20Directions=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/lighthouse/presentation/extra/Extras.kt | 7 +++++++ .../presentation/ui/main/event/MainDirections.kt | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/extra/Extras.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/main/event/MainDirections.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/extra/Extras.kt b/presentation/src/main/java/com/lighthouse/presentation/extra/Extras.kt new file mode 100644 index 000000000..88b2e8f98 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/extra/Extras.kt @@ -0,0 +1,7 @@ +package com.lighthouse.presentation.extra + +object Extras { + const val ImageUri = "Extra.Image.Uri" + + const val RecognizedText = "Extra.Recognized.Text" +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/main/event/MainDirections.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/main/event/MainDirections.kt new file mode 100644 index 000000000..47e62a914 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/main/event/MainDirections.kt @@ -0,0 +1,8 @@ +package com.lighthouse.presentation.ui.main.event + +enum class MainDirections { + HOME, + LIST, + SETTING, + ADD_GIFTICON +} From 33bf3a9671a91cada7528384903fbc904a5b91d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 23:46:06 +0900 Subject: [PATCH 014/929] =?UTF-8?q?Issues=20#16=20feat:=20MainActivity=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기프티콘 목록, 홈, 설정 프레그먼트로 이동 - 기프티콘 추가 액티비티로 이동 --- .../ui/addgifticon/AddGifticonActivity.kt | 5 ++ .../ui/common/FragmentViewBindingDelegate.kt | 59 +++++++++++++ .../ui/cropgifticon/CropGifticonActivity.kt | 5 ++ .../ui/gallery/GalleryActivity.kt | 12 +++ .../ui/gallery/GalleryViewModel.kt | 37 +++++++++ .../ui/gifticonlist/GifticonListFragment.kt | 11 +++ .../presentation/ui/home/HomeFragment.kt | 15 ++++ .../presentation/ui/main/MainActivity.kt | 82 +++++++++++++++++++ .../presentation/ui/main/MainViewModel.kt | 39 +++++++++ .../ui/setting/SettingFragment.kt | 11 +++ 10 files changed, 276 insertions(+) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/AddGifticonActivity.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/common/FragmentViewBindingDelegate.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/cropgifticon/CropGifticonActivity.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/home/HomeFragment.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/main/MainActivity.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/main/MainViewModel.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/setting/SettingFragment.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/AddGifticonActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/AddGifticonActivity.kt new file mode 100644 index 000000000..e446cd46b --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/AddGifticonActivity.kt @@ -0,0 +1,5 @@ +package com.lighthouse.presentation.ui.addgifticon + +import androidx.appcompat.app.AppCompatActivity + +class AddGifticonActivity : AppCompatActivity() diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/common/FragmentViewBindingDelegate.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/common/FragmentViewBindingDelegate.kt new file mode 100644 index 000000000..96178bb00 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/common/FragmentViewBindingDelegate.kt @@ -0,0 +1,59 @@ +package com.lighthouse.presentation.ui.common + +import android.view.View +import androidx.fragment.app.Fragment +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.Observer +import androidx.viewbinding.ViewBinding +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +class FragmentViewBindingDelegate( + private val fragment: Fragment, + private val viewBindingFactory: (View) -> VB +) : ReadOnlyProperty { + + private var binding: VB? = null + + init { + fragment.lifecycle.addObserver(object : DefaultLifecycleObserver { + private val viewLifecycleOwnerObserver = Observer { + val viewLifecycleOwner = it ?: return@Observer + viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver { + override fun onDestroy(owner: LifecycleOwner) { + binding = null + } + }) + } + + override fun onCreate(owner: LifecycleOwner) { + fragment.viewLifecycleOwnerLiveData.observeForever(viewLifecycleOwnerObserver) + } + + override fun onDestroy(owner: LifecycleOwner) { + fragment.viewLifecycleOwnerLiveData.removeObserver(viewLifecycleOwnerObserver) + } + }) + } + + override fun getValue(thisRef: Fragment, property: KProperty<*>): VB { + val binding = binding + if (binding != null) { + return binding + } + + val lifecycle = fragment.viewLifecycleOwner.lifecycle + if (!lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) { + throw IllegalStateException("Fragment 의 View가 제거 됬을땐 Binding을 가져오면 안된다.") + } + + return viewBindingFactory(thisRef.requireView()).also { + this.binding = it + } + } +} + +fun Fragment.viewBindings(viewBindingFactory: (View) -> VB) = + FragmentViewBindingDelegate(this, viewBindingFactory) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/cropgifticon/CropGifticonActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/cropgifticon/CropGifticonActivity.kt new file mode 100644 index 000000000..afa39522d --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/cropgifticon/CropGifticonActivity.kt @@ -0,0 +1,5 @@ +package com.lighthouse.presentation.ui.cropgifticon + +import androidx.appcompat.app.AppCompatActivity + +class CropGifticonActivity : AppCompatActivity() diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt new file mode 100644 index 000000000..958c25f80 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt @@ -0,0 +1,12 @@ +package com.lighthouse.presentation.ui.gallery + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import java.util.* + +class GalleryActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt new file mode 100644 index 000000000..5c5a18d99 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt @@ -0,0 +1,37 @@ +package com.lighthouse.presentation.ui.gallery + +import androidx.lifecycle.ViewModel + +class GalleryViewModel : ViewModel() { +// val projection = arrayOf( +// MediaStore.Images.Media._ID, +// MediaStore.Images.Media.DATE_ADDED +// ) +// val selection = "${MediaStore.Images.Media.MIME_TYPE} in (?,?)" +// val mimeTypeMap = MimeTypeMap.getSingleton() +// val selectionArg = arrayOf( +// mimeTypeMap.getMimeTypeFromExtension("png"), +// mimeTypeMap.getMimeTypeFromExtension("jpg") +// ) +// val sortOrder = "${MediaStore.Images.Media.DATE_ADDED} DESC" +// +// val cursor = contentResolver.query( +// MediaStore.Images.Media.EXTERNAL_CONTENT_URI, +// projection, +// selection, +// selectionArg, +// sortOrder +// ) +// +// cursor?.use { +// val idColumn = it.getColumnIndexOrThrow(MediaStore.Images.Media._ID) +// val dateAddedColumn = it.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_ADDED) +// +// while (it.moveToNext()) { +// val id = it.getLong(idColumn) +// val contentUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id) +// val dateAdded = it.getLong(dateAddedColumn) +// val date = Date(dateAdded) +// } +// } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt new file mode 100644 index 000000000..76da11db8 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt @@ -0,0 +1,11 @@ +package com.lighthouse.presentation.ui.gifticonlist + +import androidx.fragment.app.Fragment +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.FragmentListBinding +import com.lighthouse.presentation.ui.common.viewBindings + +class GifticonListFragment : Fragment(R.layout.fragment_gifticon_list) { + + private val binding by viewBindings(FragmentListBinding::bind) +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/home/HomeFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/home/HomeFragment.kt new file mode 100644 index 000000000..56ea648a3 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/home/HomeFragment.kt @@ -0,0 +1,15 @@ +package com.lighthouse.presentation.ui.home + +import androidx.fragment.app.Fragment +import androidx.fragment.app.activityViewModels +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.FragmentHomeBinding +import com.lighthouse.presentation.ui.common.viewBindings +import com.lighthouse.presentation.ui.main.MainViewModel + +class HomeFragment : Fragment(R.layout.fragment_home) { + + private val binding by viewBindings(FragmentHomeBinding::bind) + + private val mainViewModel: MainViewModel by activityViewModels() +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/main/MainActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/main/MainActivity.kt new file mode 100644 index 000000000..443dd506b --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/main/MainActivity.kt @@ -0,0 +1,82 @@ +package com.lighthouse.presentation.ui.main + +import android.content.Intent +import android.os.Bundle +import androidx.activity.viewModels +import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil +import androidx.fragment.app.commit +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.ActivityMainBinding +import com.lighthouse.presentation.ui.addgifticon.AddGifticonActivity +import com.lighthouse.presentation.ui.gifticonlist.GifticonListFragment +import com.lighthouse.presentation.ui.home.HomeFragment +import com.lighthouse.presentation.ui.main.event.MainDirections +import com.lighthouse.presentation.ui.setting.SettingFragment +import kotlinx.coroutines.launch + +class MainActivity : AppCompatActivity() { + + private lateinit var binding: ActivityMainBinding + private val viewModel: MainViewModel by viewModels() + + private val gifticonListFragment by lazy { GifticonListFragment() } + private val homeFragment by lazy { HomeFragment() } + private val settingFragment by lazy { SettingFragment() } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DataBindingUtil.setContentView(this, R.layout.activity_main) + binding.apply { + lifecycleOwner = this@MainActivity + vm = viewModel + } + + moveScreen(MainDirections.HOME) + setUpDirections() + } + + private fun setUpDirections() { + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.directionsFlow.collect { directions -> + navigate(directions) + } + } + } + } + + private fun navigate(directions: MainDirections) { + when (directions) { + MainDirections.ADD_GIFTICON -> gotoAddGifticon() + else -> moveScreen(directions) + } + } + + private fun gotoAddGifticon() { + val intent = Intent(this, AddGifticonActivity::class.java) + startActivity(intent) + } + + private fun moveScreen(directions: MainDirections) { + val fragment = when (directions) { + MainDirections.LIST -> gifticonListFragment + MainDirections.HOME -> homeFragment + MainDirections.SETTING -> settingFragment + else -> null + } ?: return + supportFragmentManager.commit { + if (fragment != gifticonListFragment && gifticonListFragment.isAdded) hide(gifticonListFragment) + if (fragment != homeFragment && homeFragment.isAdded) hide(homeFragment) + if (fragment != settingFragment && settingFragment.isAdded) hide(settingFragment) + if (fragment.isAdded) { + show(fragment) + } else { + add(R.id.fl_container, fragment) + } + } + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/main/MainViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/main/MainViewModel.kt new file mode 100644 index 000000000..98be1e2e9 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/main/MainViewModel.kt @@ -0,0 +1,39 @@ +package com.lighthouse.presentation.ui.main + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.lighthouse.presentation.R +import com.lighthouse.presentation.ui.main.event.MainDirections +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.launch + +class MainViewModel : ViewModel() { + + val directionsFlow = MutableSharedFlow() + + val selectedMenuItem = MutableStateFlow(R.id.menu_home) + + fun gotoAddGifticon() { + viewModelScope.launch { + directionsFlow.emit(MainDirections.ADD_GIFTICON) + } + } + + fun gotoMenuItem(itemId: Int): Boolean { + if (selectedMenuItem.value == itemId) { + return true + } + selectedMenuItem.value = itemId + viewModelScope.launch { + val directions = when (itemId) { + R.id.menu_list -> MainDirections.LIST + R.id.menu_home -> MainDirections.HOME + R.id.menu_setting -> MainDirections.SETTING + else -> null + } ?: return@launch + directionsFlow.emit(directions) + } + return true + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/setting/SettingFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/setting/SettingFragment.kt new file mode 100644 index 000000000..f81555c5b --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/setting/SettingFragment.kt @@ -0,0 +1,11 @@ +package com.lighthouse.presentation.ui.setting + +import androidx.fragment.app.Fragment +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.FragmentSettingBinding +import com.lighthouse.presentation.ui.common.viewBindings + +class SettingFragment : Fragment(R.layout.fragment_setting) { + + private val binding by viewBindings(FragmentSettingBinding::bind) +} From 182f24e4ecad42e96c5b51af9629ea4043fb861c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 23:47:09 +0900 Subject: [PATCH 015/929] =?UTF-8?q?Issues=20#11=20feat:=20Activity=20Extra?= =?UTF-8?q?s=20=EB=B0=8F=20Main=20Directions=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lighthouse/presentation/MainActivity.kt | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 presentation/src/main/java/com/lighthouse/presentation/MainActivity.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/MainActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/MainActivity.kt deleted file mode 100644 index 87d7f26ff..000000000 --- a/presentation/src/main/java/com/lighthouse/presentation/MainActivity.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.lighthouse.presentation - -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - } -} From 3d5a8fcd30a58093e7fb9732fd5acc3727f5f021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 10 Nov 2022 23:48:36 +0900 Subject: [PATCH 016/929] =?UTF-8?q?Issues=20#16=20feat:=20MainActivity=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기프티콘 목록, 홈, 설정 프레그먼트로 이동 - 기프티콘 추가 액티비티로 이동 --- presentation/src/main/AndroidManifest.xml | 14 ++++++++++---- .../ui/gifticonlist/GifticonListFragment.kt | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 5d8774047..63d27f9df 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -1,11 +1,11 @@ + + android:name=".ui.main.MainActivity" + android:exported="true"> + @@ -16,5 +16,11 @@ android:name="android.app.lib_name" android:value="" /> + + + + + + \ No newline at end of file diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt index 76da11db8..e6bd9d5da 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gifticonlist/GifticonListFragment.kt @@ -2,10 +2,10 @@ package com.lighthouse.presentation.ui.gifticonlist import androidx.fragment.app.Fragment import com.lighthouse.presentation.R -import com.lighthouse.presentation.databinding.FragmentListBinding +import com.lighthouse.presentation.databinding.FragmentGifticonListBinding import com.lighthouse.presentation.ui.common.viewBindings class GifticonListFragment : Fragment(R.layout.fragment_gifticon_list) { - private val binding by viewBindings(FragmentListBinding::bind) + private val binding by viewBindings(FragmentGifticonListBinding::bind) } From bfa4fff15c44fd8c2e3144493c42a7bd77b3cb7f Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Fri, 11 Nov 2022 00:56:28 +0900 Subject: [PATCH 017/929] =?UTF-8?q?Issues=20#23=20chore:=20=EB=9D=BC?= =?UTF-8?q?=EB=B2=A8=20=EC=9E=90=EB=8F=99=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/labeler.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 000000000..447a0a2ec --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,22 @@ +test: + - app/src/test/**/* + - app/src/androidTest/**/* + - library/src/test/**/* + - library/src/androidTest/**/* + +chore: + - app/*.gradle + - build.gradle + - buildSrc/**/* + +style: + - presentation/src/main/res/**/* + +feat: + - app/**/* + - data/src/**/* + - domain/src/**/* + - presentation/src/main/java/**/* + +docs: + - README.md \ No newline at end of file From fde9674010cfa6e59fa89795da659936724103b7 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Fri, 11 Nov 2022 02:33:14 +0900 Subject: [PATCH 018/929] =?UTF-8?q?Issues=20#24=20chore:=20app=20=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20hilt,=20retrofit,=20okHttp3,=20room?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 6 ++++++ buildSrc/src/main/kotlin/Dependencies.kt | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a73fc9677..06ae7620a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -3,6 +3,8 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties plugins { id("com.android.application") id("org.jetbrains.kotlin.android") + kotlin("kapt") + id("dagger.hilt.android.plugin") } android { @@ -47,6 +49,10 @@ dependencies { implementation(project(":domain")) implementation(project(":presentation")) implementation(project(":data")) + + kapt(Kapt.APP_LIBRARIES) + implementation(Libraries.APP_LIBRARIES) + annotationProcessor(AnnotationProcessors.APP_LIBRARIES) } fun getApiKey(propertyKey: String): String { diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 0c04969a9..c3459b1c4 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -124,6 +124,13 @@ object Libraries { PAGING_COMMON_KTX, ROOM_COMMON ) + val APP_LIBRARIES = arrayListOf( + HILT, + RETROFIT, + MOSHI_KOTLIN, + MOSHI_ADAPTERS, + CONVERTER_MOSHI + ) } object TestImpl { @@ -176,6 +183,12 @@ object Kapt { ROOM_COMPILER, MOSHI_KOTLIN_CODEGEN ) + + val APP_LIBRARIES = arrayListOf( + HILT, + ROOM_COMPILER, + MOSHI_KOTLIN_CODEGEN + ) } fun DependencyHandler.kapt(list: List) { From 7db6421fc1bbd98c8946599af7a819eb23363c63 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Fri, 11 Nov 2022 02:36:42 +0900 Subject: [PATCH 019/929] =?UTF-8?q?Issues=20#24=20chore:=20application,=20?= =?UTF-8?q?activity=EB=A5=BC=20manifest=EC=97=90=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 3 ++- app/src/main/java/com/lighthouse/BeepApplication.kt | 11 +++++++++++ presentation/src/main/AndroidManifest.xml | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/lighthouse/BeepApplication.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 738dc6dab..e60b7fabc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ + android:value="${naver_map_api_id}" /> \ No newline at end of file diff --git a/app/src/main/java/com/lighthouse/BeepApplication.kt b/app/src/main/java/com/lighthouse/BeepApplication.kt new file mode 100644 index 000000000..7d3104956 --- /dev/null +++ b/app/src/main/java/com/lighthouse/BeepApplication.kt @@ -0,0 +1,11 @@ +package com.lighthouse + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp + +@HiltAndroidApp +class BeepApplication : Application() { + override fun onCreate() { + super.onCreate() + } +} diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 63d27f9df..2628aace8 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -22,5 +22,9 @@ + + \ No newline at end of file From f832d5eb488021234ee2ba83ea17716d38408c48 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Fri, 11 Nov 2022 02:37:05 +0900 Subject: [PATCH 020/929] =?UTF-8?q?Issues=20#24=20chore:=20app=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=EC=97=90=20=EB=A3=B8=20?= =?UTF-8?q?=EC=BB=B4=ED=8C=8C=EC=9D=BC=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/Dependencies.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index c3459b1c4..15251f7a9 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -167,6 +167,10 @@ object AnnotationProcessors { val DATA_LIBRARIES = arrayListOf( ROOM_COMPILER ) + + val APP_LIBRARIES = arrayListOf( + ROOM_COMPILER + ) } object Kapt { From c6e2a058d15f9b4ab5eaf7a8e81349028752afb9 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Fri, 11 Nov 2022 02:39:43 +0900 Subject: [PATCH 021/929] =?UTF-8?q?Issues=20#24=20feat:=20=EB=A0=88?= =?UTF-8?q?=ED=8A=B8=EB=A1=9C=ED=95=8F=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20api=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - moshi, okhttp, retrofit - 카카오 서치 브랜드 기준 검색 결과를 받기 위한 model 정의 --- .../lighthouse/di/HTTPRequestInterceptor.kt | 17 +++++++ .../java/com/lighthouse/di/NetworkModule.kt | 48 +++++++++++++++++++ .../model/BrandPlaceInfoDataContainer.kt | 41 ++++++++++++++++ .../lighthouse/network/NetworkApiService.kt | 17 +++++++ 4 files changed, 123 insertions(+) create mode 100644 app/src/main/java/com/lighthouse/di/HTTPRequestInterceptor.kt create mode 100644 app/src/main/java/com/lighthouse/di/NetworkModule.kt create mode 100644 data/src/main/java/com/lighthouse/model/BrandPlaceInfoDataContainer.kt create mode 100644 data/src/main/java/com/lighthouse/network/NetworkApiService.kt diff --git a/app/src/main/java/com/lighthouse/di/HTTPRequestInterceptor.kt b/app/src/main/java/com/lighthouse/di/HTTPRequestInterceptor.kt new file mode 100644 index 000000000..ec61f3480 --- /dev/null +++ b/app/src/main/java/com/lighthouse/di/HTTPRequestInterceptor.kt @@ -0,0 +1,17 @@ +package com.lighthouse.di + +import com.lighthouse.beep.BuildConfig +import okhttp3.Interceptor +import okhttp3.Response + +class HTTPRequestInterceptor : Interceptor { + + override fun intercept(chain: Interceptor.Chain): Response { + val origin = chain.request() + val request = origin.newBuilder() + .addHeader("Content-Type", "application/json") + .addHeader("Authorization", "KakaoAK ${BuildConfig.kakaoSearchId}") + .build() + return chain.proceed(request) + } +} diff --git a/app/src/main/java/com/lighthouse/di/NetworkModule.kt b/app/src/main/java/com/lighthouse/di/NetworkModule.kt new file mode 100644 index 000000000..9496f60ae --- /dev/null +++ b/app/src/main/java/com/lighthouse/di/NetworkModule.kt @@ -0,0 +1,48 @@ +package com.lighthouse.di + +import com.lighthouse.network.NetworkApiService +import com.squareup.moshi.Moshi +import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import okhttp3.OkHttpClient +import retrofit2.Retrofit +import retrofit2.converter.moshi.MoshiConverterFactory +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object NetworkModule { + + private const val KAKAO_URL = "https://dapi.kakao.com/" + + private val moshi = Moshi.Builder() + .addLast(KotlinJsonAdapterFactory()) + .build() + + @Provides + @Singleton + fun provideOkHttpClient(): OkHttpClient { + return OkHttpClient.Builder() + .addInterceptor(HTTPRequestInterceptor()) + .build() + } + + @Provides + @Singleton + fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit { + return Retrofit.Builder() + .client(okHttpClient) + .baseUrl(KAKAO_URL) + .addConverterFactory(MoshiConverterFactory.create(moshi)) + .build() + } + + @Provides + @Singleton + fun provideApiService(retrofit: Retrofit): NetworkApiService { + return retrofit.create(NetworkApiService::class.java) + } +} diff --git a/data/src/main/java/com/lighthouse/model/BrandPlaceInfoDataContainer.kt b/data/src/main/java/com/lighthouse/model/BrandPlaceInfoDataContainer.kt new file mode 100644 index 000000000..b08db0f26 --- /dev/null +++ b/data/src/main/java/com/lighthouse/model/BrandPlaceInfoDataContainer.kt @@ -0,0 +1,41 @@ +package com.lighthouse.model + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class BrandPlaceInfoDataContainer( + val documents: List, + val meta: Meta +) { + @JsonClass(generateAdapter = true) + data class BrandPlaceInfoData( + @field:Json(name = "address_name") val addressName: String, + @field:Json(name = "category_group_code") val categoryGroupCode: String, + @field:Json(name = "category_group_name") val categoryGroupName: String, + @field:Json(name = "category_name") val categoryName: String, + @field:Json(name = "distance") val distance: String, + @field:Json(name = "id") val id: String, + @field:Json(name = "phone") val phone: String, + @field:Json(name = "place_name") val placeName: String, + @field:Json(name = "place_url") val placeUrl: String, + @field:Json(name = "road_address_name") val roadAddressName: String, + @field:Json(name = "x") val x: String, + @field:Json(name = "y") val y: String + ) + + @JsonClass(generateAdapter = true) + data class Meta( + @field:Json(name = "is_end") val isEnd: Boolean, + @field:Json(name = "pageable_count") val pageableCount: Int, + @field:Json(name = "same_name") val sameName: SameName, + @field:Json(name = "total_count") val totalCount: Int + ) + + @JsonClass(generateAdapter = true) + data class SameName( + @field:Json(name = "keyword") val keyword: String, + @field:Json(name = "region") val region: List, + @field:Json(name = "selected_region") val selectedRegion: String + ) +} diff --git a/data/src/main/java/com/lighthouse/network/NetworkApiService.kt b/data/src/main/java/com/lighthouse/network/NetworkApiService.kt new file mode 100644 index 000000000..f3032cd35 --- /dev/null +++ b/data/src/main/java/com/lighthouse/network/NetworkApiService.kt @@ -0,0 +1,17 @@ +package com.lighthouse.network + +import com.lighthouse.model.BrandPlaceInfoDataContainer +import retrofit2.http.GET +import retrofit2.http.Query + +interface NetworkApiService { + + @GET("v2/local/search/keyword.json") + suspend fun getAllBrandPlaceInfo( + @Query("query") query: String, + @Query("x") x: String, + @Query("y") y: String, + @Query("rect") rect: String, + @Query("radius") radius: Int + ): BrandPlaceInfoDataContainer +} From 07855bcd1da0f87dc29d26fa3b82522b0ffafb21 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Fri, 11 Nov 2022 02:54:23 +0900 Subject: [PATCH 022/929] =?UTF-8?q?Issues=20#24=20feat:=20=EC=B9=B4?= =?UTF-8?q?=EC=B9=B4=EC=98=A4=20=EC=84=9C=EC=B9=98=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=ED=8B=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 보내는 로직 viewModel(키워드 등등) -> UseCase -> Repository -> DataSource -> NetworkApiService - 응답 로직 NetworkApiService -> DataSource -> Repository -> UseCase -> viewModel - Binds와 Provide를 활용해서 Di 주입 --- .../main/java/com/lighthouse/di/DataModule.kt | 28 +++++++++++++++ .../datasource/BrandRemoteSource.kt | 7 ++++ .../datasource/BrandRemoteSourceImpl.kt | 28 +++++++++++++++ .../BrandPlaceInfoDataContainerMapper.kt | 18 ++++++++++ .../java/com/lighthouse/mapper/ErrorMapper.kt | 8 +++++ .../com/lighthouse/model/CustomErrorData.kt | 9 +++++ .../repository/BrandRepositoryImpl.kt | 30 ++++++++++++++++ .../lighthouse/domain/model/CustomError.kt | 9 +++++ .../domain/repository/BrandRepository.kt | 7 ++++ .../usecase/GetBrandPlaceInfosUseCase.kt | 16 +++++++-- .../mapper/BrandPlaceInfoUiModelMapper.kt | 13 +++++++ .../model/BrandPlaceInfoUiModel.kt | 10 ++++++ .../presentation/ui/map/MapActivity.kt | 3 ++ .../presentation/ui/map/MapViewModel.kt | 34 ++++++++++++++++++- 14 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/lighthouse/di/DataModule.kt create mode 100644 data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt create mode 100644 data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt create mode 100644 data/src/main/java/com/lighthouse/mapper/BrandPlaceInfoDataContainerMapper.kt create mode 100644 data/src/main/java/com/lighthouse/mapper/ErrorMapper.kt create mode 100644 data/src/main/java/com/lighthouse/model/CustomErrorData.kt create mode 100644 data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/model/CustomError.kt create mode 100644 domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/mapper/BrandPlaceInfoUiModelMapper.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/model/BrandPlaceInfoUiModel.kt diff --git a/app/src/main/java/com/lighthouse/di/DataModule.kt b/app/src/main/java/com/lighthouse/di/DataModule.kt new file mode 100644 index 000000000..6df896b76 --- /dev/null +++ b/app/src/main/java/com/lighthouse/di/DataModule.kt @@ -0,0 +1,28 @@ +package com.lighthouse.di + +import com.lighthouse.datasource.BrandRemoteSource +import com.lighthouse.datasource.BrandRemoteSourceImpl +import com.lighthouse.domain.repository.BrandRepository +import com.lighthouse.repository.BrandRepositoryImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class DataModule { + + @Binds + @Singleton + abstract fun bindBrandRemoteDataSource( + source: BrandRemoteSourceImpl + ): BrandRemoteSource + + @Binds + @Singleton + abstract fun bindBrandRepository( + repository: BrandRepositoryImpl + ): BrandRepository +} diff --git a/data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt new file mode 100644 index 000000000..f33229c57 --- /dev/null +++ b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt @@ -0,0 +1,7 @@ +package com.lighthouse.datasource + +import com.lighthouse.model.BrandPlaceInfoDataContainer + +interface BrandRemoteSource { + suspend fun getBrandPlaceInfo(brandName: String, x: String, y: String, rect: String, size: Int): Result +} diff --git a/data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt new file mode 100644 index 000000000..476face71 --- /dev/null +++ b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt @@ -0,0 +1,28 @@ +package com.lighthouse.datasource + +import com.lighthouse.model.BrandPlaceInfoDataContainer +import com.lighthouse.model.CustomErrorData +import com.lighthouse.network.NetworkApiService +import java.net.UnknownHostException +import javax.inject.Inject + +class BrandRemoteSourceImpl @Inject constructor( + private val networkApiService: NetworkApiService +) : BrandRemoteSource { + + override suspend fun getBrandPlaceInfo( + brandName: String, + x: String, + y: String, + rect: String, + size: Int + ): Result { + val result = runCatching { networkApiService.getAllBrandPlaceInfo(brandName, x, y, rect, size) } + + return when (val exception = result.exceptionOrNull()) { + null -> result + is UnknownHostException -> Result.failure(CustomErrorData.NetworkFailure) + else -> Result.failure(exception) + } + } +} diff --git a/data/src/main/java/com/lighthouse/mapper/BrandPlaceInfoDataContainerMapper.kt b/data/src/main/java/com/lighthouse/mapper/BrandPlaceInfoDataContainerMapper.kt new file mode 100644 index 000000000..64d86cdd7 --- /dev/null +++ b/data/src/main/java/com/lighthouse/mapper/BrandPlaceInfoDataContainerMapper.kt @@ -0,0 +1,18 @@ +package com.lighthouse.mapper + +import com.lighthouse.domain.model.BrandPlaceInfo +import com.lighthouse.model.BrandPlaceInfoDataContainer + +fun BrandPlaceInfoDataContainer.toDomain(): List { + val brandName = this.meta.sameName.keyword + return this.documents.map { + BrandPlaceInfo( + addressName = it.addressName, + placeName = it.placeName, + placeUrl = it.placeUrl, + brand = brandName, + x = it.x, + y = it.y + ) + } +} diff --git a/data/src/main/java/com/lighthouse/mapper/ErrorMapper.kt b/data/src/main/java/com/lighthouse/mapper/ErrorMapper.kt new file mode 100644 index 000000000..52287b3ab --- /dev/null +++ b/data/src/main/java/com/lighthouse/mapper/ErrorMapper.kt @@ -0,0 +1,8 @@ +package com.lighthouse.mapper + +import com.lighthouse.domain.model.CustomError +import com.lighthouse.model.CustomErrorData + +internal fun CustomErrorData.toDomain(): CustomError = when (this) { + is CustomErrorData.NetworkFailure -> CustomError.NetworkFailure +} diff --git a/data/src/main/java/com/lighthouse/model/CustomErrorData.kt b/data/src/main/java/com/lighthouse/model/CustomErrorData.kt new file mode 100644 index 000000000..9a731395c --- /dev/null +++ b/data/src/main/java/com/lighthouse/model/CustomErrorData.kt @@ -0,0 +1,9 @@ +package com.lighthouse.model + +sealed class CustomErrorData( + override val message: String? = null, + override val cause: Throwable? = null +) : Exception(message, cause) { + + object NetworkFailure : CustomErrorData() +} diff --git a/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt b/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt new file mode 100644 index 000000000..4072f7534 --- /dev/null +++ b/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt @@ -0,0 +1,30 @@ +package com.lighthouse.repository + +import com.lighthouse.datasource.BrandRemoteSource +import com.lighthouse.domain.model.BrandPlaceInfo +import com.lighthouse.domain.repository.BrandRepository +import com.lighthouse.mapper.toDomain +import com.lighthouse.model.CustomErrorData +import javax.inject.Inject + +class BrandRepositoryImpl @Inject constructor( + private val remoteBrandSource: BrandRemoteSource +) : BrandRepository { + + override suspend fun getBrandPlaceInfo( + brandName: String, + x: String, + y: String, + rect: String, + size: Int + ): Result> { + val result = remoteBrandSource.getBrandPlaceInfo(brandName, x, y, rect, size).mapCatching { it.toDomain() } + val exception = result.exceptionOrNull() + + return if (exception is CustomErrorData) { + Result.failure(exception.toDomain()) + } else { + result + } + } +} diff --git a/domain/src/main/java/com/lighthouse/domain/model/CustomError.kt b/domain/src/main/java/com/lighthouse/domain/model/CustomError.kt new file mode 100644 index 000000000..2244ba4e2 --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/model/CustomError.kt @@ -0,0 +1,9 @@ +package com.lighthouse.domain.model + +sealed class CustomError( + override val message: String? = null, + override val cause: Throwable? = null +) : Exception(message, cause) { + + object NetworkFailure : CustomError() +} diff --git a/domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt b/domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt new file mode 100644 index 000000000..7745b31be --- /dev/null +++ b/domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt @@ -0,0 +1,7 @@ +package com.lighthouse.domain.repository + +import com.lighthouse.domain.model.BrandPlaceInfo + +interface BrandRepository { + suspend fun getBrandPlaceInfo(brandName: String, x: String, y: String, rect: String, size: Int): Result> +} diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt index d69ba33ac..d6b24e674 100644 --- a/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt @@ -1,10 +1,20 @@ package com.lighthouse.domain.usecase import com.lighthouse.domain.model.BrandPlaceInfo +import com.lighthouse.domain.repository.BrandRepository +import javax.inject.Inject -class GetBrandPlaceInfosUseCase { +class GetBrandPlaceInfosUseCase @Inject constructor( + private val brandRepository: BrandRepository +) { - operator fun invoke(brandName: String, x: Int, y: Int, rect: Int, size: Int): List { - return emptyList() + suspend operator fun invoke( + brandName: String, + x: String, + y: String, + rect: String, + size: Int + ): Result> { + return brandRepository.getBrandPlaceInfo(brandName, x, y, rect, size) } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/mapper/BrandPlaceInfoUiModelMapper.kt b/presentation/src/main/java/com/lighthouse/presentation/mapper/BrandPlaceInfoUiModelMapper.kt new file mode 100644 index 000000000..50cdee9b7 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/mapper/BrandPlaceInfoUiModelMapper.kt @@ -0,0 +1,13 @@ +package com.lighthouse.presentation.mapper + +import com.lighthouse.domain.model.BrandPlaceInfo +import com.lighthouse.presentation.model.BrandPlaceInfoUiModel + +fun BrandPlaceInfo.toPresentation(): BrandPlaceInfoUiModel = BrandPlaceInfoUiModel( + addressName = this.addressName, + placeName = this.placeName, + placeUrl = this.placeUrl, + brand = this.brand, + x = this.x, + y = this.y +) diff --git a/presentation/src/main/java/com/lighthouse/presentation/model/BrandPlaceInfoUiModel.kt b/presentation/src/main/java/com/lighthouse/presentation/model/BrandPlaceInfoUiModel.kt new file mode 100644 index 000000000..65c30f3dd --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/model/BrandPlaceInfoUiModel.kt @@ -0,0 +1,10 @@ +package com.lighthouse.presentation.model + +data class BrandPlaceInfoUiModel( + val addressName: String, + val placeName: String, + val placeUrl: String, + val brand: String, + val x: String, + val y: String +) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt index a76b94053..c020f15e0 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt @@ -6,7 +6,9 @@ import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ActivityMapBinding +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class MapActivity : AppCompatActivity() { private lateinit var binding: ActivityMapBinding @@ -15,5 +17,6 @@ class MapActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_map) + viewModel // by ViewModels는 lazy라서 실행 확인을 위한 코드 } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt index 54d1e009a..eb1cb7b42 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt @@ -1,5 +1,37 @@ package com.lighthouse.presentation.ui.map +import android.util.Log import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.lighthouse.domain.usecase.GetBrandPlaceInfosUseCase +import com.lighthouse.presentation.mapper.toPresentation +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.launch +import javax.inject.Inject -class MapViewModel : ViewModel() +@HiltViewModel +class MapViewModel @Inject constructor( + private val getBrandPlaceInfosUseCase: GetBrandPlaceInfosUseCase +) : ViewModel() { + + // TODO 임시 데이터 변경 필요 + private val brandList = arrayListOf().apply { + add("스타벅스") + add("베스킨라빈스") + add("BHC") + add("BBQ") + } + + init { + viewModelScope.launch { + for (query in brandList) { + getBrandPlaceInfosUseCase(query, "37.2840", "127.1071", "500", 5) + .onSuccess { brandPlaceInfos -> + val brandPlaceInfoUiModels = brandPlaceInfos.map { it.toPresentation() } + Log.d("TAG", "브랜드 리스트 갖고 오기 성공 -> $brandPlaceInfoUiModels") + } + .onFailure { Log.d("TAG", " 브랜드 리스트 갖고 오기 실패 -> $it") } + } + } + } +} From 5218f6e5cb0a71c801819d6a8b747506751a38d1 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Fri, 11 Nov 2022 02:54:34 +0900 Subject: [PATCH 023/929] =?UTF-8?q?Issues=20#17=20style:=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=95=A1=ED=8B=B0=EB=B9=84=ED=8B=B0,=20Fr?= =?UTF-8?q?agment=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/AndroidManifest.xml | 12 ++++++---- .../presentation/ui/signin/SignInActivity.kt | 24 +++++++++++++++++++ .../presentation/ui/signin/SignInFragment.kt | 23 ++++++++++++++++++ .../presentation/ui/signin/SignInViewModel.kt | 5 ++++ .../src/main/res/layout/activity_sign_in.xml | 23 ++++++++++++++++++ .../src/main/res/layout/fragment_sign_in.xml | 24 +++++++++++++++++++ 6 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt create mode 100644 presentation/src/main/res/layout/activity_sign_in.xml create mode 100644 presentation/src/main/res/layout/fragment_sign_in.xml diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 63d27f9df..dff2340bb 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -2,10 +2,16 @@ + + + - @@ -16,11 +22,9 @@ android:name="android.app.lib_name" android:value="" /> - - - + \ No newline at end of file diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt new file mode 100644 index 000000000..16600fb81 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt @@ -0,0 +1,24 @@ +package com.lighthouse.presentation.ui.signin + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil +import androidx.fragment.app.commit +import androidx.fragment.app.replace +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.ActivitySignInBinding + +class SignInActivity : AppCompatActivity() { + + private lateinit var binding: ActivitySignInBinding + + private val signInFragment by lazy { SignInFragment() } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DataBindingUtil.setContentView(this, R.layout.activity_sign_in) + supportFragmentManager.commit { + add(R.id.fl_signin, signInFragment) + } + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt new file mode 100644 index 000000000..fd29f2f29 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt @@ -0,0 +1,23 @@ +package com.lighthouse.presentation.ui.signin + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.fragment.app.viewModels +import com.google.android.gms.auth.api.signin.GoogleSignInOptions +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.FragmentSignInBinding +import com.lighthouse.presentation.ui.common.viewBindings + +class SignInFragment : Fragment() { + + private val binding by viewBindings(FragmentSignInBinding::bind) + private val viewModel: SignInViewModel by viewModels() + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.fragment_sign_in, container, false) + } + +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt new file mode 100644 index 000000000..86f32c513 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt @@ -0,0 +1,5 @@ +package com.lighthouse.presentation.ui.signin + +import androidx.lifecycle.ViewModel + +class SignInViewModel : ViewModel() diff --git a/presentation/src/main/res/layout/activity_sign_in.xml b/presentation/src/main/res/layout/activity_sign_in.xml new file mode 100644 index 000000000..d08f4c735 --- /dev/null +++ b/presentation/src/main/res/layout/activity_sign_in.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_sign_in.xml b/presentation/src/main/res/layout/fragment_sign_in.xml new file mode 100644 index 000000000..10c02fa05 --- /dev/null +++ b/presentation/src/main/res/layout/fragment_sign_in.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + \ No newline at end of file From f598255067b46b81f4014c77871d7abe99f825ef Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Fri, 11 Nov 2022 03:38:15 +0900 Subject: [PATCH 024/929] =?UTF-8?q?Issues=20#23=20chore:=20=EB=9D=BC?= =?UTF-8?q?=EB=B2=A8=20=EC=9E=90=EB=8F=99=ED=99=94=20=EB=A7=88=EC=A7=80?= =?UTF-8?q?=EB=A7=89=20=EC=9E=8E=EC=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflow/labeler.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflow/labeler.yml diff --git a/.github/workflow/labeler.yml b/.github/workflow/labeler.yml new file mode 100644 index 000000000..e203258a3 --- /dev/null +++ b/.github/workflow/labeler.yml @@ -0,0 +1,14 @@ +name: "Pull Request Labeler" +on: + pull_request_target: + branches: + - develop + +jobs: + label: + runs-on: ubuntu-latest + + steps: + - uses: actions/labeler@v2 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file From 4796ca55af7f775f3c19ea78dd3db903b7e849a2 Mon Sep 17 00:00:00 2001 From: ezhoon <53300830+lee-ji-hoon@users.noreply.github.com> Date: Fri, 11 Nov 2022 11:27:49 +0900 Subject: [PATCH 025/929] =?UTF-8?q?Issues=20#26=20chore:=20CI=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android.yml | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 000000000..aacee217d --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,60 @@ +name: Android CI +on: + pull_request: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup JDK 11 + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: 11 + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Decrypt secrets.tar.gpg + run: gpg --quiet --batch --yes --always-trust --decrypt --passphrase="$SECRET_GPG_PASSWORD" --output secrets.tar secrets.tar.gpg + env: + SECRET_GPG_PASSWORD: ${{ secrets.SECRET_GPG_PASSWORD }} + + - name: Unzip secrets.tar + run: tar xvf secrets.tar + + - name: Run ktlint + run: ./gradlew ktlintCheck + + - name: Run detekt + run: ./gradlew detekt + + - name: Run unit tests + run: ./gradlew testDebugUnitTest + + - name: Build assemble release apk + run: ./gradlew assembleRelease + + - name: Create android test report + uses: asadmansr/android-test-report-action@v1.2.0 + if: ${{ always() }} + + - name: Build assemble release apk + run: ./gradlew assembleRelease From e7c0436457e28c5e13c0d8a4444feab53cd58fca Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Sat, 12 Nov 2022 13:37:52 +0900 Subject: [PATCH 026/929] =?UTF-8?q?Issues=20#17=20chore:=20google-service?= =?UTF-8?q?=20gitignore,=20gradle=20classpath=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/.gitignore | 2 +- build.gradle.kts | 6 ++++++ presentation/.gitignore | 3 ++- presentation/build.gradle.kts | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/.gitignore b/app/.gitignore index da214ccbe..a0645b811 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -74,7 +74,7 @@ captures/ .cxx/ # Google Services (e.g. APIs or Firebase) -google-services.json +../google-services.json # Version control vcs.xml diff --git a/build.gradle.kts b/build.gradle.kts index fac9122e2..179e3e9cd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,12 @@ plugins { id("com.google.dagger.hilt.android") version "2.44" apply false } +buildscript { + dependencies { + classpath("com.google.gms:google-services:4.3.14") + } +} + tasks.register("clean", Delete::class) { delete(rootProject.buildDir) } diff --git a/presentation/.gitignore b/presentation/.gitignore index 42afabfd2..2abde4aab 100644 --- a/presentation/.gitignore +++ b/presentation/.gitignore @@ -1 +1,2 @@ -/build \ No newline at end of file +/build +/google-services.json diff --git a/presentation/build.gradle.kts b/presentation/build.gradle.kts index 2aa89fb43..8b0da3696 100644 --- a/presentation/build.gradle.kts +++ b/presentation/build.gradle.kts @@ -3,6 +3,7 @@ plugins { id("org.jetbrains.kotlin.android") kotlin("kapt") id("dagger.hilt.android.plugin") + id("com.google.gms.google-services") } android { From 518cb712dab8cdea3cefcc43bf00afc98c49b012 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Sat, 12 Nov 2022 15:29:36 +0900 Subject: [PATCH 027/929] =?UTF-8?q?Issues=20#17=20feat:=20google=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/AndroidManifest.xml | 2 +- .../presentation/ui/signin/SignInFragment.kt | 45 +++++++++++++++++++ .../src/main/res/layout/fragment_sign_in.xml | 5 --- presentation/src/main/res/values/strings.xml | 5 +++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index dff2340bb..4596b477e 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ - + + if (result.resultCode == Activity.RESULT_OK) { + val task = GoogleSignIn.getSignedInAccountFromIntent(result.data) + + try { + val account = task.getResult(ApiException::class.java) + account.idToken?.let { signInWithGoogle(it) } + } catch (e: ApiException) { + Snackbar.make(requireView(), getString(R.string.signin_google_fail), Snackbar.LENGTH_SHORT).show() + } + } else { + Snackbar.make(requireView(), getString(R.string.signin_google_connect_fail), Snackbar.LENGTH_SHORT) + .show() + } + } + + activityLauncher.launch(googleSignInClient.signInIntent) + } + + private fun signInWithGoogle(idToken: String) { + val credential = GoogleAuthProvider.getCredential(idToken, null) + Firebase.auth.signInWithCredential(credential).addOnCompleteListener { task -> + if (task.isSuccessful) { + Snackbar.make(requireView(), getString(R.string.signin_success), Snackbar.LENGTH_SHORT).show() + } else { + Snackbar.make(requireView(), getString(R.string.signin_fail), Snackbar.LENGTH_SHORT).show() + } + } + } } diff --git a/presentation/src/main/res/layout/fragment_sign_in.xml b/presentation/src/main/res/layout/fragment_sign_in.xml index 10c02fa05..8038ffe1e 100644 --- a/presentation/src/main/res/layout/fragment_sign_in.xml +++ b/presentation/src/main/res/layout/fragment_sign_in.xml @@ -14,11 +14,6 @@ tools:context=".ui.signin.SignInFragment" > - - \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 541195e7a..2dc4b8078 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -13,4 +13,9 @@ 전체 기프티콘 추가하기 버튼 + + 구글 로그인 실패 + 구글 연결 실패 + 로그인 성공 + 로그인 실패 \ No newline at end of file From bc2aa5d6c1f6a926daf235f25514f40a141ffec0 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Sat, 12 Nov 2022 15:47:46 +0900 Subject: [PATCH 028/929] =?UTF-8?q?Issues=20#17=20chore:=20presentation=20?= =?UTF-8?q?manifest=20=EC=97=90=EC=84=9C=20=EC=9D=B8=ED=84=B0=EB=84=B7=20?= =?UTF-8?q?=ED=8D=BC=EB=AF=B8=EC=85=98=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/AndroidManifest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 4596b477e..e19cc7f88 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - - \ No newline at end of file From 70a9d099a584c7ca400ff4d7b5592e88ac39eb46 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Sat, 12 Nov 2022 15:48:24 +0900 Subject: [PATCH 029/929] =?UTF-8?q?Issues=20#17=20style:=20fragment=5Fsign?= =?UTF-8?q?=5Fin.xml=20=EC=A0=95=EB=A0=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/res/layout/fragment_sign_in.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/res/layout/fragment_sign_in.xml b/presentation/src/main/res/layout/fragment_sign_in.xml index 8038ffe1e..d9da11c73 100644 --- a/presentation/src/main/res/layout/fragment_sign_in.xml +++ b/presentation/src/main/res/layout/fragment_sign_in.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools"> + @@ -11,9 +12,7 @@ - + tools:context=".ui.signin.SignInFragment"> \ No newline at end of file From 6db370be1abe634f080e4e92f223805d42097673 Mon Sep 17 00:00:00 2001 From: ezhoon <53300830+lee-ji-hoon@users.noreply.github.com> Date: Sat, 12 Nov 2022 15:55:17 +0900 Subject: [PATCH 030/929] =?UTF-8?q?=20Issues=20#26=20chore:=20=EB=9D=BC?= =?UTF-8?q?=EB=B2=A8=20=EC=9E=90=EB=8F=99=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/labeler.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/labeler.yml diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 000000000..4c92f5bdf --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,14 @@ +name: "Pull Request Labeler" +on: + pull_request_target: + branches: + - develop + +jobs: + label: + runs-on: ubuntu-latest + + steps: + - uses: actions/labeler@v2 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From a8c47ef6d9041c9831ea73ff3e1220814bf67ee9 Mon Sep 17 00:00:00 2001 From: ezhoon <53300830+lee-ji-hoon@users.noreply.github.com> Date: Sat, 12 Nov 2022 15:55:48 +0900 Subject: [PATCH 031/929] =?UTF-8?q?=20Issues=20#26=20remove:=20label=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=ED=99=94=20directory=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflow/labeler.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .github/workflow/labeler.yml diff --git a/.github/workflow/labeler.yml b/.github/workflow/labeler.yml deleted file mode 100644 index e203258a3..000000000 --- a/.github/workflow/labeler.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: "Pull Request Labeler" -on: - pull_request_target: - branches: - - develop - -jobs: - label: - runs-on: ubuntu-latest - - steps: - - uses: actions/labeler@v2 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file From e446ee74f2b42da31e209df25af886e9ca59c8df Mon Sep 17 00:00:00 2001 From: ezhoon <53300830+lee-ji-hoon@users.noreply.github.com> Date: Sat, 12 Nov 2022 16:01:21 +0900 Subject: [PATCH 032/929] =?UTF-8?q?=20Issues=20#26=20chore:=20CI=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=ED=99=94=20=EA=B5=AC=EC=84=B1=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index aacee217d..bb66277a0 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -32,11 +32,6 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Decrypt secrets.tar.gpg - run: gpg --quiet --batch --yes --always-trust --decrypt --passphrase="$SECRET_GPG_PASSWORD" --output secrets.tar secrets.tar.gpg - env: - SECRET_GPG_PASSWORD: ${{ secrets.SECRET_GPG_PASSWORD }} - - name: Unzip secrets.tar run: tar xvf secrets.tar From 90d4dbe876d1123b6ffd4b6ac93f00d6f6317820 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Sat, 12 Nov 2022 16:15:27 +0900 Subject: [PATCH 033/929] =?UTF-8?q?Issues=20#17=20chore:=20gitignore,=20ma?= =?UTF-8?q?nifest=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/.gitignore | 3 --- presentation/src/main/AndroidManifest.xml | 3 --- 2 files changed, 6 deletions(-) diff --git a/app/.gitignore b/app/.gitignore index a0645b811..6c1a5a3af 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -73,9 +73,6 @@ captures/ .externalNativeBuild .cxx/ -# Google Services (e.g. APIs or Firebase) -../google-services.json - # Version control vcs.xml diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index e19cc7f88..31dc65b4d 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -4,9 +4,6 @@ - Date: Sat, 12 Nov 2022 16:16:45 +0900 Subject: [PATCH 034/929] Issues #17 style: FrameLayout -> FragmentContainerView --- .../com/lighthouse/presentation/ui/signin/SignInActivity.kt | 3 +-- presentation/src/main/res/layout/activity_sign_in.xml | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt index 16600fb81..c5a643840 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.fragment.app.commit -import androidx.fragment.app.replace import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ActivitySignInBinding @@ -18,7 +17,7 @@ class SignInActivity : AppCompatActivity() { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_sign_in) supportFragmentManager.commit { - add(R.id.fl_signin, signInFragment) + add(R.id.fcv_signin, signInFragment) } } } diff --git a/presentation/src/main/res/layout/activity_sign_in.xml b/presentation/src/main/res/layout/activity_sign_in.xml index d08f4c735..45cca4785 100644 --- a/presentation/src/main/res/layout/activity_sign_in.xml +++ b/presentation/src/main/res/layout/activity_sign_in.xml @@ -12,10 +12,8 @@ android:layout_height="match_parent" tools:context=".ui.signin.SignInActivity"> - - - From 76797b1036a35834c0c02aba67b0a254ee99ae93 Mon Sep 17 00:00:00 2001 From: ezhoon <53300830+lee-ji-hoon@users.noreply.github.com> Date: Sat, 12 Nov 2022 16:19:04 +0900 Subject: [PATCH 035/929] =?UTF-8?q?=20Issues=20#26=20chore:=20CI=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=ED=99=94=20unzip=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index bb66277a0..b960327d1 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -32,9 +32,6 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Unzip secrets.tar - run: tar xvf secrets.tar - - name: Run ktlint run: ./gradlew ktlintCheck From 38b3914873fc09615130bc745faa2403838caf38 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Sat, 12 Nov 2022 17:49:25 +0900 Subject: [PATCH 036/929] =?UTF-8?q?Issues=20#18=20style:=20SignInFragment?= =?UTF-8?q?=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/signin/SignInFragment.kt | 39 ++++++++++++------- .../src/main/res/layout/fragment_sign_in.xml | 13 +++++++ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt index 5be5df96d..f715e75b5 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt @@ -1,14 +1,17 @@ package com.lighthouse.presentation.ui.signin import android.app.Activity +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.google.android.gms.auth.api.signin.GoogleSignIn +import com.google.android.gms.auth.api.signin.GoogleSignInClient import com.google.android.gms.auth.api.signin.GoogleSignInOptions import com.google.android.gms.common.api.ApiException import com.google.android.material.snackbar.Snackbar @@ -24,19 +27,9 @@ class SignInFragment : Fragment() { private val binding by viewBindings(FragmentSignInBinding::bind) private val viewModel: SignInViewModel by viewModels() - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return inflater.inflate(R.layout.fragment_sign_in, container, false) - } - - private fun initGoogleLogin() { - val googleSignInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) - .requestEmail() - .requestIdToken(getString(R.string.default_web_client_id)) - .build() - - val googleSignInClient = GoogleSignIn.getClient(requireContext(), googleSignInOptions) - - val activityLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> + private lateinit var googleSignInClient: GoogleSignInClient + private val activityLauncher: ActivityResultLauncher = + registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == Activity.RESULT_OK) { val task = GoogleSignIn.getSignedInAccountFromIntent(result.data) @@ -52,7 +45,25 @@ class SignInFragment : Fragment() { } } - activityLauncher.launch(googleSignInClient.signInIntent) + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.fragment_sign_in, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + initGoogleLogin() + } + + private fun initGoogleLogin() { + val googleSignInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) + .requestEmail() + .requestIdToken(getString(R.string.default_web_client_id)) + .build() + + googleSignInClient = GoogleSignIn.getClient(requireContext(), googleSignInOptions) + + binding.btnGoogleLogin.setOnClickListener { + activityLauncher.launch(googleSignInClient.signInIntent) + } } private fun signInWithGoogle(idToken: String) { diff --git a/presentation/src/main/res/layout/fragment_sign_in.xml b/presentation/src/main/res/layout/fragment_sign_in.xml index d9da11c73..390495301 100644 --- a/presentation/src/main/res/layout/fragment_sign_in.xml +++ b/presentation/src/main/res/layout/fragment_sign_in.xml @@ -1,5 +1,6 @@ @@ -12,7 +13,19 @@ + + \ No newline at end of file From 5358492e5636c4c5d63b34aa384042ca371af5b4 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Sat, 12 Nov 2022 17:51:54 +0900 Subject: [PATCH 037/929] =?UTF-8?q?Issues=20#18=20chore:=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20SignInViewMo?= =?UTF-8?q?del=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lighthouse/presentation/ui/signin/SignInFragment.kt | 2 -- .../com/lighthouse/presentation/ui/signin/SignInViewModel.kt | 5 ----- presentation/src/main/res/layout/fragment_sign_in.xml | 3 --- 3 files changed, 10 deletions(-) delete mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt index f715e75b5..036ce752f 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt @@ -9,7 +9,6 @@ import android.view.ViewGroup import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.fragment.app.Fragment -import androidx.fragment.app.viewModels import com.google.android.gms.auth.api.signin.GoogleSignIn import com.google.android.gms.auth.api.signin.GoogleSignInClient import com.google.android.gms.auth.api.signin.GoogleSignInOptions @@ -25,7 +24,6 @@ import com.lighthouse.presentation.ui.common.viewBindings class SignInFragment : Fragment() { private val binding by viewBindings(FragmentSignInBinding::bind) - private val viewModel: SignInViewModel by viewModels() private lateinit var googleSignInClient: GoogleSignInClient private val activityLauncher: ActivityResultLauncher = diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt deleted file mode 100644 index 86f32c513..000000000 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInViewModel.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.lighthouse.presentation.ui.signin - -import androidx.lifecycle.ViewModel - -class SignInViewModel : ViewModel() diff --git a/presentation/src/main/res/layout/fragment_sign_in.xml b/presentation/src/main/res/layout/fragment_sign_in.xml index 390495301..87b790ceb 100644 --- a/presentation/src/main/res/layout/fragment_sign_in.xml +++ b/presentation/src/main/res/layout/fragment_sign_in.xml @@ -5,9 +5,6 @@ - Date: Sat, 12 Nov 2022 18:03:18 +0900 Subject: [PATCH 038/929] =?UTF-8?q?Issues=20#18=20feat:=20=EA=B5=AC?= =?UTF-8?q?=EA=B8=80=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=84=B1=EA=B3=B5=20?= =?UTF-8?q?=EC=8B=9C=20MainActivity=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/signin/SignInFragment.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt index 036ce752f..1c3127fda 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt @@ -14,18 +14,21 @@ import com.google.android.gms.auth.api.signin.GoogleSignInClient import com.google.android.gms.auth.api.signin.GoogleSignInOptions import com.google.android.gms.common.api.ApiException import com.google.android.material.snackbar.Snackbar +import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.GoogleAuthProvider import com.google.firebase.auth.ktx.auth import com.google.firebase.ktx.Firebase import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.FragmentSignInBinding import com.lighthouse.presentation.ui.common.viewBindings +import com.lighthouse.presentation.ui.main.MainActivity class SignInFragment : Fragment() { private val binding by viewBindings(FragmentSignInBinding::bind) private lateinit var googleSignInClient: GoogleSignInClient + private val auth: FirebaseAuth = Firebase.auth private val activityLauncher: ActivityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == Activity.RESULT_OK) { @@ -48,7 +51,7 @@ class SignInFragment : Fragment() { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - initGoogleLogin() + auth.currentUser?.let { gotoMain() } ?: initGoogleLogin() } private fun initGoogleLogin() { @@ -66,12 +69,18 @@ class SignInFragment : Fragment() { private fun signInWithGoogle(idToken: String) { val credential = GoogleAuthProvider.getCredential(idToken, null) - Firebase.auth.signInWithCredential(credential).addOnCompleteListener { task -> + auth.signInWithCredential(credential).addOnCompleteListener { task -> if (task.isSuccessful) { Snackbar.make(requireView(), getString(R.string.signin_success), Snackbar.LENGTH_SHORT).show() + gotoMain() } else { Snackbar.make(requireView(), getString(R.string.signin_fail), Snackbar.LENGTH_SHORT).show() } } } + + private fun gotoMain() { + val intent = Intent(requireContext(), MainActivity::class.java) + startActivity(intent) + } } From f6746adba8d3803b0544dafa71cd5a70a7ef1227 Mon Sep 17 00:00:00 2001 From: ezhoon <53300830+lee-ji-hoon@users.noreply.github.com> Date: Sat, 12 Nov 2022 18:28:19 +0900 Subject: [PATCH 039/929] =?UTF-8?q?=20Issues=20#26=20chore:=20CI=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=ED=99=94=20lint=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b960327d1..8bc4c4748 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -32,21 +32,9 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Run ktlint - run: ./gradlew ktlintCheck - - - name: Run detekt - run: ./gradlew detekt - - name: Run unit tests run: ./gradlew testDebugUnitTest - - name: Build assemble release apk - run: ./gradlew assembleRelease - - name: Create android test report uses: asadmansr/android-test-report-action@v1.2.0 if: ${{ always() }} - - - name: Build assemble release apk - run: ./gradlew assembleRelease From 9f2713566b248d142bcb75d5b12d7cb9c8a3e74a Mon Sep 17 00:00:00 2001 From: ezhoon <53300830+lee-ji-hoon@users.noreply.github.com> Date: Sat, 12 Nov 2022 18:31:34 +0900 Subject: [PATCH 040/929] =?UTF-8?q?Issues=20#26=20chore:=20pull=20request?= =?UTF-8?q?=20ktlint=20=EC=9E=90=EB=8F=99=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/reviewKtlint.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/reviewKtlint.yml diff --git a/.github/workflows/reviewKtlint.yml b/.github/workflows/reviewKtlint.yml new file mode 100644 index 000000000..170cdc24d --- /dev/null +++ b/.github/workflows/reviewKtlint.yml @@ -0,0 +1,22 @@ +name: reviewKtlint +on: [pull_request] + +jobs: + ktlint: + name: Check Code Quality + runs-on: ubuntu-latest + + steps: + - name: Clone repo + uses: actions/checkout@main + with: + fetch-depth: 1 + + - name: ktlint + uses: ScaCap/action-ktlint@master + with: + github_token: $ + reporter: github-pr-review + android: true + fail_on_error: true + level: warning From c0a94c2004a9d1e7dd541caf983c05ffc8dde0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Sat, 12 Nov 2022 21:33:29 +0900 Subject: [PATCH 041/929] =?UTF-8?q?Issues=20#22=20style:=20Gallery,=20Add?= =?UTF-8?q?=20Gifticon,=20Crop=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=A0=20Resource=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20Materia?= =?UTF-8?q?l2=20=EB=A7=88=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/res/color/black_a12.xml | 5 +++ .../main/res/drawable/bg_gallery_selected.xml | 9 +++++ .../res/drawable/bg_gallery_unselected.xml | 11 ++++++ .../res/drawable/btn_main_floating_add.xml | 10 ++++++ .../res/drawable/ic_add_default_gifticon.xml | 11 ++++++ .../res/drawable/ic_add_delete_gifticon.xml | 10 ++++++ .../main/res/drawable/ic_add_goto_gallery.xml | 13 +++++++ .../res/drawable/ic_add_warning_badge.xml | 9 +++++ .../src/main/res/drawable/ic_back.xml | 11 ++++++ .../res/drawable/ic_main_floating_add.xml | 5 --- .../src/main/res/layout/activity_main.xml | 2 +- presentation/src/main/res/values/colors.xml | 4 +++ presentation/src/main/res/values/strings.xml | 36 +++++++++++++++++-- presentation/src/main/res/values/themes.xml | 9 +++-- 14 files changed, 132 insertions(+), 13 deletions(-) create mode 100644 presentation/src/main/res/color/black_a12.xml create mode 100644 presentation/src/main/res/drawable/bg_gallery_selected.xml create mode 100644 presentation/src/main/res/drawable/bg_gallery_unselected.xml create mode 100644 presentation/src/main/res/drawable/btn_main_floating_add.xml create mode 100644 presentation/src/main/res/drawable/ic_add_default_gifticon.xml create mode 100644 presentation/src/main/res/drawable/ic_add_delete_gifticon.xml create mode 100644 presentation/src/main/res/drawable/ic_add_goto_gallery.xml create mode 100644 presentation/src/main/res/drawable/ic_add_warning_badge.xml create mode 100644 presentation/src/main/res/drawable/ic_back.xml delete mode 100644 presentation/src/main/res/drawable/ic_main_floating_add.xml diff --git a/presentation/src/main/res/color/black_a12.xml b/presentation/src/main/res/color/black_a12.xml new file mode 100644 index 000000000..1c7b24883 --- /dev/null +++ b/presentation/src/main/res/color/black_a12.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/bg_gallery_selected.xml b/presentation/src/main/res/drawable/bg_gallery_selected.xml new file mode 100644 index 000000000..fb2abf0bf --- /dev/null +++ b/presentation/src/main/res/drawable/bg_gallery_selected.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/bg_gallery_unselected.xml b/presentation/src/main/res/drawable/bg_gallery_unselected.xml new file mode 100644 index 000000000..6f42d6082 --- /dev/null +++ b/presentation/src/main/res/drawable/bg_gallery_unselected.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/btn_main_floating_add.xml b/presentation/src/main/res/drawable/btn_main_floating_add.xml new file mode 100644 index 000000000..a9503fd36 --- /dev/null +++ b/presentation/src/main/res/drawable/btn_main_floating_add.xml @@ -0,0 +1,10 @@ + + + diff --git a/presentation/src/main/res/drawable/ic_add_default_gifticon.xml b/presentation/src/main/res/drawable/ic_add_default_gifticon.xml new file mode 100644 index 000000000..86dba8582 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_add_default_gifticon.xml @@ -0,0 +1,11 @@ + + + + diff --git a/presentation/src/main/res/drawable/ic_add_delete_gifticon.xml b/presentation/src/main/res/drawable/ic_add_delete_gifticon.xml new file mode 100644 index 000000000..35b13485e --- /dev/null +++ b/presentation/src/main/res/drawable/ic_add_delete_gifticon.xml @@ -0,0 +1,10 @@ + + + diff --git a/presentation/src/main/res/drawable/ic_add_goto_gallery.xml b/presentation/src/main/res/drawable/ic_add_goto_gallery.xml new file mode 100644 index 000000000..5306e15e2 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_add_goto_gallery.xml @@ -0,0 +1,13 @@ + + + + diff --git a/presentation/src/main/res/drawable/ic_add_warning_badge.xml b/presentation/src/main/res/drawable/ic_add_warning_badge.xml new file mode 100644 index 000000000..0c3a31266 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_add_warning_badge.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/ic_back.xml b/presentation/src/main/res/drawable/ic_back.xml new file mode 100644 index 000000000..1686755f3 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_back.xml @@ -0,0 +1,11 @@ + + + diff --git a/presentation/src/main/res/drawable/ic_main_floating_add.xml b/presentation/src/main/res/drawable/ic_main_floating_add.xml deleted file mode 100644 index 89633bb12..000000000 --- a/presentation/src/main/res/drawable/ic_main_floating_add.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/presentation/src/main/res/layout/activity_main.xml b/presentation/src/main/res/layout/activity_main.xml index 9a2ef2396..c2aa63330 100644 --- a/presentation/src/main/res/layout/activity_main.xml +++ b/presentation/src/main/res/layout/activity_main.xml @@ -29,7 +29,7 @@ android:layout_marginBottom="16dp" android:contentDescription="@string/main_add_gifticon_description" android:onClickListener="@{() -> vm.gotoAddGifticon()}" - android:src="@drawable/ic_main_floating_add" + android:src="@drawable/btn_main_floating_add" app:layout_constraintBottom_toTopOf="@id/bnv" app:layout_constraintEnd_toEndOf="parent" /> diff --git a/presentation/src/main/res/values/colors.xml b/presentation/src/main/res/values/colors.xml index c8524cd96..fd6c2210b 100644 --- a/presentation/src/main/res/values/colors.xml +++ b/presentation/src/main/res/values/colors.xml @@ -2,4 +2,8 @@ #FF000000 #FFFFFFFF + #8C8C8C + + #E93B14 + #F5F5F5 \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 541195e7a..6a6b4bb9e 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -7,10 +7,42 @@ 목록 설정 - 최신순 디데이순 전체 - 기프티콘 추가하기 버튼 + + 기프티콘 추가에서 뒤로가기 버튼 + 기프티콘 추가 + 없음 + 개 등록됨 + 갤러리 이동하기 버튼 + 등록된 이미지 삭제 버튼 + 기프티콘 후보 버튼 + 선택된 기프티콘 이미지 + 편집하기 + 원본이미지 확인 + 금액권 + 삭제하기 + 편집하기 + 기프티콘 브랜드 이미지 + 이름 + 쿠폰 이름을 입력하세요. + 브랜드 + 브랜드명을 입력하세요. + 유효기간 + 유효기간을 선택하세요. + 잔액 + 잔액을 입력하세요. + 메모 + 메모를 남겨주세요. + 취소 + 등록하기 + + 뒤로가기 버튼 + 갤러리 이미지 + 이미지 선택 + 완료 + + 완료 \ No newline at end of file diff --git a/presentation/src/main/res/values/themes.xml b/presentation/src/main/res/values/themes.xml index 7a255a938..497b315a0 100644 --- a/presentation/src/main/res/values/themes.xml +++ b/presentation/src/main/res/values/themes.xml @@ -1,8 +1,7 @@ - - - \ No newline at end of file From 8479870241e4db0d0813a6fb2ce26fae56556f70 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Mon, 14 Nov 2022 18:17:44 +0900 Subject: [PATCH 075/929] =?UTF-8?q?Issues=20#15=20refactor:=20state?= =?UTF-8?q?=EC=99=80=20=EA=B2=80=EC=83=89=20=EA=B2=B0=EA=B3=BC=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=20=EA=B5=AC=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - radius -> size : 잘못된 쿼리 값 변경 --- .../main/java/com/lighthouse/network/NetworkApiService.kt | 2 +- .../java/com/lighthouse/presentation/ui/map/MapState.kt | 4 +--- .../com/lighthouse/presentation/ui/map/MapViewModel.kt | 8 ++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/data/src/main/java/com/lighthouse/network/NetworkApiService.kt b/data/src/main/java/com/lighthouse/network/NetworkApiService.kt index f3032cd35..3062cc399 100644 --- a/data/src/main/java/com/lighthouse/network/NetworkApiService.kt +++ b/data/src/main/java/com/lighthouse/network/NetworkApiService.kt @@ -12,6 +12,6 @@ interface NetworkApiService { @Query("x") x: String, @Query("y") y: String, @Query("rect") rect: String, - @Query("radius") radius: Int + @Query("size") size: Int ): BrandPlaceInfoDataContainer } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapState.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapState.kt index abe140eb1..1b462eaf7 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapState.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapState.kt @@ -1,9 +1,7 @@ package com.lighthouse.presentation.ui.map -import com.lighthouse.presentation.model.BrandPlaceInfoUiModel - sealed class MapState { - data class Success(val brandPlaceInfoUiModel: List) : MapState() + object Success : MapState() object Loading : MapState() object NotFoundSearchResults : MapState() object NetworkFailure : MapState() diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt index a69305bbe..7e56e503c 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope import com.lighthouse.domain.model.CustomError import com.lighthouse.domain.usecase.GetBrandPlaceInfosUseCase import com.lighthouse.presentation.mapper.toPresentation +import com.lighthouse.presentation.model.BrandPlaceInfoUiModel import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch @@ -19,6 +20,8 @@ class MapViewModel @Inject constructor( var state: MutableStateFlow = MutableStateFlow(MapState.Loading) private set + var brandPlaceSearchResults = listOf() + private set init { getBrandPlaceInfos(brandList) @@ -26,10 +29,11 @@ class MapViewModel @Inject constructor( fun getBrandPlaceInfos(brandList: List) { viewModelScope.launch { - getBrandPlaceInfosUseCase(brandList, "37.2840", "127.1071", "500", 5) + getBrandPlaceInfosUseCase(brandList, "127.110515", "37.282778", "1000", 5) .mapCatching { it.toPresentation() } .onSuccess { brandPlaceInfos -> - state.value = MapState.Success(brandPlaceInfos) + brandPlaceSearchResults = brandPlaceInfos + state.value = MapState.Success } .onFailure { throwable -> when (throwable) { From d0fa733df8e18c89293fe1f1cc10dcb3da862660 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Mon, 14 Nov 2022 18:31:51 +0900 Subject: [PATCH 076/929] =?UTF-8?q?Issues=20#37=20style:=20primary=20color?= =?UTF-8?q?=20=ED=86=A4=20=EC=A1=B0=EC=A0=95,=20gray=20=EB=AA=85=EB=8F=84?= =?UTF-8?q?=EB=B3=84=20=EC=BD=94=EB=93=9C=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/res/layout/fragment_sign_in.xml | 2 +- presentation/src/main/res/values/colors.xml | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/res/layout/fragment_sign_in.xml b/presentation/src/main/res/layout/fragment_sign_in.xml index 87b790ceb..5ca9a0a85 100644 --- a/presentation/src/main/res/layout/fragment_sign_in.xml +++ b/presentation/src/main/res/layout/fragment_sign_in.xml @@ -10,7 +10,7 @@ #E93B14 #F5F5F5 - #FF2869 + #EF2C67 + + #EAEAEA + #B8B8B8 + #8C8C8C + \ No newline at end of file From 4a3fb91b83d33c1e57f4ee26486510bc21439aa8 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Mon, 14 Nov 2022 20:46:24 +0900 Subject: [PATCH 077/929] =?UTF-8?q?Issues=20#37=20fix:=20Splash=20->=20Mai?= =?UTF-8?q?nActivity=20=EC=9D=B4=EB=8F=99=20=EC=8B=9C=20=EA=B0=95=EC=A0=9C?= =?UTF-8?q?=EC=A2=85=EB=A3=8C=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 +- presentation/src/main/AndroidManifest.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e7fda0a21..e60b7fabc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.BEEP.Splash" + android:theme="@style/Theme.BEEP" tools:targetApi="31"> From 871f2b62b678876f17997efa49c6abf76ed96ebe Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Mon, 14 Nov 2022 21:35:21 +0900 Subject: [PATCH 078/929] =?UTF-8?q?Issues=20#37=20refactor:=20=EA=B0=80?= =?UTF-8?q?=EB=8F=85=EC=84=B1=20=EA=B4=80=EB=A0=A8=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lighthouse/presentation/ui/signin/SignInFragment.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt index 1c3127fda..3231c5799 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt @@ -51,7 +51,11 @@ class SignInFragment : Fragment() { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - auth.currentUser?.let { gotoMain() } ?: initGoogleLogin() + if (auth.currentUser == null) { + initGoogleLogin() + } else { + gotoMain() + } } private fun initGoogleLogin() { From f40c5c5417451588b65901094a56d93838a3a095 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Mon, 14 Nov 2022 21:35:48 +0900 Subject: [PATCH 079/929] =?UTF-8?q?Issues=20#37=20chore:=20SignInActivity?= =?UTF-8?q?=EA=B0=80=20=EC=8A=A4=ED=83=9D=EC=97=90=20=EB=82=A8=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index b38b5ef5e..13a1f6f3a 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ From bf5c6a13ac7a907d2c8b2b0b6f3a916b62758725 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Mon, 14 Nov 2022 21:48:55 +0900 Subject: [PATCH 080/929] Issues #15 refactor: rect -> radius MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - api 요청할때 rect아닌 radius로 해야지 원하는 결과값 도출 가능 --- .../main/java/com/lighthouse/datasource/BrandRemoteSource.kt | 2 +- .../java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt | 4 ++-- .../src/main/java/com/lighthouse/network/NetworkApiService.kt | 2 +- .../java/com/lighthouse/repository/BrandRepositoryImpl.kt | 4 ++-- .../java/com/lighthouse/domain/repository/BrandRepository.kt | 2 +- .../lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt index f33229c57..594c42510 100644 --- a/data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt +++ b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSource.kt @@ -3,5 +3,5 @@ package com.lighthouse.datasource import com.lighthouse.model.BrandPlaceInfoDataContainer interface BrandRemoteSource { - suspend fun getBrandPlaceInfo(brandName: String, x: String, y: String, rect: String, size: Int): Result + suspend fun getBrandPlaceInfo(brandName: String, x: String, y: String, radius: String, size: Int): Result } diff --git a/data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt index 476face71..8bb996001 100644 --- a/data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt +++ b/data/src/main/java/com/lighthouse/datasource/BrandRemoteSourceImpl.kt @@ -14,10 +14,10 @@ class BrandRemoteSourceImpl @Inject constructor( brandName: String, x: String, y: String, - rect: String, + radius: String, size: Int ): Result { - val result = runCatching { networkApiService.getAllBrandPlaceInfo(brandName, x, y, rect, size) } + val result = runCatching { networkApiService.getAllBrandPlaceInfo(brandName, x, y, radius, size) } return when (val exception = result.exceptionOrNull()) { null -> result diff --git a/data/src/main/java/com/lighthouse/network/NetworkApiService.kt b/data/src/main/java/com/lighthouse/network/NetworkApiService.kt index 3062cc399..e6009a9e5 100644 --- a/data/src/main/java/com/lighthouse/network/NetworkApiService.kt +++ b/data/src/main/java/com/lighthouse/network/NetworkApiService.kt @@ -11,7 +11,7 @@ interface NetworkApiService { @Query("query") query: String, @Query("x") x: String, @Query("y") y: String, - @Query("rect") rect: String, + @Query("radius") radius: String, @Query("size") size: Int ): BrandPlaceInfoDataContainer } diff --git a/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt b/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt index 4072f7534..16b990215 100644 --- a/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt +++ b/data/src/main/java/com/lighthouse/repository/BrandRepositoryImpl.kt @@ -15,10 +15,10 @@ class BrandRepositoryImpl @Inject constructor( brandName: String, x: String, y: String, - rect: String, + radius: String, size: Int ): Result> { - val result = remoteBrandSource.getBrandPlaceInfo(brandName, x, y, rect, size).mapCatching { it.toDomain() } + val result = remoteBrandSource.getBrandPlaceInfo(brandName, x, y, radius, size).mapCatching { it.toDomain() } val exception = result.exceptionOrNull() return if (exception is CustomErrorData) { diff --git a/domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt b/domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt index 7745b31be..4346abf97 100644 --- a/domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt +++ b/domain/src/main/java/com/lighthouse/domain/repository/BrandRepository.kt @@ -3,5 +3,5 @@ package com.lighthouse.domain.repository import com.lighthouse.domain.model.BrandPlaceInfo interface BrandRepository { - suspend fun getBrandPlaceInfo(brandName: String, x: String, y: String, rect: String, size: Int): Result> + suspend fun getBrandPlaceInfo(brandName: String, x: String, y: String, radius: String, size: Int): Result> } diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt index f0e793776..1e9c60999 100644 --- a/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetBrandPlaceInfosUseCase.kt @@ -13,13 +13,13 @@ class GetBrandPlaceInfosUseCase @Inject constructor( brandNames: List, x: String, y: String, - rect: String, + radius: String, size: Int ): Result> { val brandPlaceInfos = mutableListOf() for (brandName in brandNames) { - val brandSearchResults = brandRepository.getBrandPlaceInfo(brandName, x, y, rect, size).getOrThrow() + val brandSearchResults = brandRepository.getBrandPlaceInfo(brandName, x, y, radius, size).getOrThrow() if (brandSearchResults.isNotEmpty()) brandPlaceInfos.addAll(brandSearchResults) } From 179857ac6756cf9d20728db7f3fdba03c3bd0a90 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Mon, 14 Nov 2022 21:50:16 +0900 Subject: [PATCH 081/929] =?UTF-8?q?Issues=20#15=20feat:=20=ED=98=84?= =?UTF-8?q?=EC=9E=AC=20(=EC=9C=84=EB=8F=84,=EA=B2=BD=EB=8F=84)=20=EA=B0=96?= =?UTF-8?q?=EA=B3=A0=20=EC=98=A4=EA=B8=B0=20/=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/map/FusedLocationProvider.kt | 112 ++++++++++++++++++ .../presentation/ui/map/MapActivity.kt | 106 ++++++++++++++++- .../presentation/ui/map/MapViewModel.kt | 10 +- .../ui/map/OnLocationUpdateListener.kt | 7 ++ 4 files changed, 225 insertions(+), 10 deletions(-) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/map/FusedLocationProvider.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/map/OnLocationUpdateListener.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/FusedLocationProvider.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/FusedLocationProvider.kt new file mode 100644 index 000000000..d5cb81f99 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/FusedLocationProvider.kt @@ -0,0 +1,112 @@ +package com.lighthouse.presentation.ui.map + +import android.Manifest +import android.annotation.SuppressLint +import android.content.Context +import android.content.pm.PackageManager +import android.os.Looper +import androidx.core.app.ActivityCompat +import com.google.android.gms.location.FusedLocationProviderClient +import com.google.android.gms.location.LocationCallback +import com.google.android.gms.location.LocationRequest +import com.google.android.gms.location.LocationResult +import com.google.android.gms.location.LocationServices +import com.google.android.gms.location.LocationSettingsRequest +import com.google.android.gms.location.Priority + +@SuppressLint("MissingPermission") +class FusedLocationProvider( + private val context: Context, + private val listener: OnLocationUpdateListener +) { + + private lateinit var fusedLocationProviderClient: FusedLocationProviderClient + private lateinit var locationCallback: LocationCallback + + init { + setLocationClient() + setLocationCallback() + } + + private fun setLocationClient() { + fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context) + + val locationRequest = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, LOCATION_INTERVAL) + .setWaitForAccurateLocation(false) + .setMinUpdateIntervalMillis(LOCATION_INTERVAL) + .setMaxUpdateDelayMillis(LOCATION_INTERVAL) + .build() + + val builder = LocationSettingsRequest.Builder() + .addLocationRequest(locationRequest) + + val client = LocationServices.getSettingsClient(context) + client.checkLocationSettings(builder.build()) + } + + private fun setLocationCallback() { + locationCallback = object : LocationCallback() { + override fun onLocationResult(locationResult: LocationResult) { + for (location in locationResult.locations) { + listener.onLocationUpdated(location) + break + } + } + } + } + + // location 특정 시간(LOCATION_INTERVAL) 마다 계속 수신 받을 때를 위해서 미리 만들어놓은 함수 + // 나중에 위젯에 사용 + fun startLocationUpdates() { + if (ActivityCompat.checkSelfPermission( + context, + Manifest.permission.ACCESS_FINE_LOCATION + ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( + context, + Manifest.permission.ACCESS_COARSE_LOCATION + ) != PackageManager.PERMISSION_GRANTED + ) { + return + } + + val locationRequest = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, LOCATION_INTERVAL) + .setWaitForAccurateLocation(false) + .setMinUpdateIntervalMillis(LOCATION_INTERVAL) + .setMaxUpdateDelayMillis(LOCATION_INTERVAL) + .build() + + fusedLocationProviderClient.requestLocationUpdates( + locationRequest, + locationCallback, + Looper.getMainLooper() + ) + } + + // 최근 위치를 갖고 온다. + fun requestLastLocation() { + if (ActivityCompat.checkSelfPermission( + context, + Manifest.permission.ACCESS_FINE_LOCATION + ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( + context, + Manifest.permission.ACCESS_COARSE_LOCATION + ) != PackageManager.PERMISSION_GRANTED + ) { + return + } + + fusedLocationProviderClient.lastLocation + .addOnSuccessListener { location -> + listener.onLocationUpdated(location) + } + } + + // location 추적 종료 + fun stopLocationUpdates() { + fusedLocationProviderClient.removeLocationUpdates(locationCallback) + } + + companion object { + private const val LOCATION_INTERVAL = 1000L + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt index 125a43d2c..ce6f8369e 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt @@ -1,38 +1,58 @@ package com.lighthouse.presentation.ui.map +import android.location.Location import android.os.Bundle +import android.util.Log import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import com.google.android.material.snackbar.Snackbar import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ActivityMapBinding +import com.lighthouse.presentation.model.BrandPlaceInfoUiModel +import com.naver.maps.geometry.LatLng +import com.naver.maps.map.CameraUpdate +import com.naver.maps.map.MapView +import com.naver.maps.map.NaverMap +import com.naver.maps.map.OnMapReadyCallback +import com.naver.maps.map.overlay.Marker +import com.naver.maps.map.overlay.Overlay +import com.naver.maps.map.util.FusedLocationSource import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch @AndroidEntryPoint -class MapActivity : AppCompatActivity() { +class MapActivity : AppCompatActivity(), OnMapReadyCallback, Overlay.OnClickListener, OnLocationUpdateListener { private lateinit var binding: ActivityMapBinding + private lateinit var naverMap: NaverMap + private lateinit var mapView: MapView + private lateinit var fusedLocationProviderClient: FusedLocationProvider + private lateinit var locationSource: FusedLocationSource private val viewModel: MapViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_map) + mapView = binding.mapView.apply { + onCreate(savedInstanceState) + getMapAsync(this@MapActivity) + } setObserveSearchData() + setFusedLocationProvider() } private fun setObserveSearchData() { lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.state.collectLatest { state -> - // TODO 지도에 그려줄 때 처리할 로직들 when (state) { - is MapState.Success -> {} + is MapState.Success -> updateBrandMarker(viewModel.brandPlaceSearchResults) is MapState.Failure -> {} is MapState.NetworkFailure -> {} is MapState.NotFoundSearchResults -> {} @@ -42,4 +62,84 @@ class MapActivity : AppCompatActivity() { } } } + + private fun updateBrandMarker(brandPlaceSearchResults: List) { + brandPlaceSearchResults.forEach { brandPlaceSearchResult -> + val marker = Marker() + + val latLng = LatLng(brandPlaceSearchResult.y.toDouble(), brandPlaceSearchResult.x.toDouble()) + with(marker) { + position = latLng + onClickListener = this@MapActivity + map = naverMap + width = Marker.SIZE_AUTO + height = Marker.SIZE_AUTO + tag = brandPlaceSearchResult.brand + captionText = brandPlaceSearchResult.brand + } + } + } + + private fun setFusedLocationProvider() { + fusedLocationProviderClient = FusedLocationProvider(this, this).apply { + requestLastLocation() + } + } + + override fun onMapReady(map: NaverMap) { + naverMap = map + locationSource = FusedLocationSource(this, 1000) + naverMap.locationSource = locationSource + setNaverMapZoom() + moveMapCamera(naverMap) + } + + private fun setNaverMapZoom() { + naverMap.maxZoom = 18.0 + naverMap.minZoom = 10.0 + } + + private fun moveMapCamera(naverMap: NaverMap) { + val cameraUpdate = CameraUpdate.scrollTo(LatLng(37.2840, 127.1071)) + naverMap.moveCamera(cameraUpdate) + } + + override fun onClick(overlay: Overlay): Boolean { + return true + } + + override fun onLocationUpdated(location: Location) { + viewModel.getBrandPlaceInfos(location.longitude, location.latitude) + } + + override fun onResume() { + mapView.onResume() + super.onResume() + } + + override fun onPause() { + super.onPause() + mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + mapView.onSaveInstanceState(outState) + } + + override fun onStop() { + super.onStop() + mapView.onStop() + } + + override fun onDestroy() { + super.onDestroy() + mapView.onDestroy() + fusedLocationProviderClient.stopLocationUpdates() + } + + override fun onLowMemory() { + super.onLowMemory() + mapView.onLowMemory() + } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt index 7e56e503c..889943645 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapViewModel.kt @@ -16,20 +16,16 @@ class MapViewModel @Inject constructor( private val getBrandPlaceInfosUseCase: GetBrandPlaceInfosUseCase ) : ViewModel() { - private val brandList = arrayListOf("스타벅스", "베스킨라빈스", "BHC", "BBQ") + private val brandList = listOf("스타벅스", "베스킨라빈스", "BHC", "BBQ") var state: MutableStateFlow = MutableStateFlow(MapState.Loading) private set var brandPlaceSearchResults = listOf() private set - init { - getBrandPlaceInfos(brandList) - } - - fun getBrandPlaceInfos(brandList: List) { + fun getBrandPlaceInfos(x: Double, y: Double) { viewModelScope.launch { - getBrandPlaceInfosUseCase(brandList, "127.110515", "37.282778", "1000", 5) + getBrandPlaceInfosUseCase(brandList, x.toString(), y.toString(), "1000", 5) .mapCatching { it.toPresentation() } .onSuccess { brandPlaceInfos -> brandPlaceSearchResults = brandPlaceInfos diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/OnLocationUpdateListener.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/OnLocationUpdateListener.kt new file mode 100644 index 000000000..625d2b59b --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/OnLocationUpdateListener.kt @@ -0,0 +1,7 @@ +package com.lighthouse.presentation.ui.map + +import android.location.Location + +interface OnLocationUpdateListener { + fun onLocationUpdated(location: Location) +} From 744279970969eae7fccff3908aec312a182073d6 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Mon, 14 Nov 2022 22:05:18 +0900 Subject: [PATCH 082/929] =?UTF-8?q?Issues=20#15=20refactor:=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B2=84=20=EB=A7=B5=20=EC=B9=B4=EB=A9=94=EB=9D=BC=20?= =?UTF-8?q?=EC=A4=8C=20=EC=9C=84=EC=B9=98=20=EB=8F=99=EC=A0=81=EC=9C=BC?= =?UTF-8?q?=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 --- .../lighthouse/presentation/ui/map/MapActivity.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt index ce6f8369e..4bebd171d 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt @@ -2,14 +2,12 @@ package com.lighthouse.presentation.ui.map import android.location.Location import android.os.Bundle -import android.util.Log import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle -import com.google.android.material.snackbar.Snackbar import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ActivityMapBinding import com.lighthouse.presentation.model.BrandPlaceInfoUiModel @@ -91,7 +89,6 @@ class MapActivity : AppCompatActivity(), OnMapReadyCallback, Overlay.OnClickList locationSource = FusedLocationSource(this, 1000) naverMap.locationSource = locationSource setNaverMapZoom() - moveMapCamera(naverMap) } private fun setNaverMapZoom() { @@ -99,17 +96,18 @@ class MapActivity : AppCompatActivity(), OnMapReadyCallback, Overlay.OnClickList naverMap.minZoom = 10.0 } - private fun moveMapCamera(naverMap: NaverMap) { - val cameraUpdate = CameraUpdate.scrollTo(LatLng(37.2840, 127.1071)) - naverMap.moveCamera(cameraUpdate) - } - override fun onClick(overlay: Overlay): Boolean { return true } override fun onLocationUpdated(location: Location) { viewModel.getBrandPlaceInfos(location.longitude, location.latitude) + moveMapCamera(location.longitude, location.latitude) + } + + private fun moveMapCamera(longitude: Double, latitude: Double) { + val cameraUpdate = CameraUpdate.scrollTo(LatLng(latitude, longitude)) + naverMap.moveCamera(cameraUpdate) } override fun onResume() { From aa3f0daf4c317244a8ac5529c8b074998a3f327a Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Mon, 14 Nov 2022 23:10:15 +0900 Subject: [PATCH 083/929] =?UTF-8?q?Issues=20#39=20style:=20=EB=B3=B4?= =?UTF-8?q?=EC=95=88=20Activity,=20Fragment=EB=93=A4=20=EC=B6=94=EA=B0=80(?= =?UTF-8?q?=EC=A7=80=EB=AC=B8,=20PIN)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/AndroidManifest.xml | 15 +++++++++---- .../ui/security/FingerprintFragment.kt | 19 +++++++++++++++++ .../presentation/ui/security/PinFragment.kt | 20 ++++++++++++++++++ .../ui/security/SecurityActivity.kt | 20 ++++++++++++++++++ .../src/main/res/layout/activity_security.xml | 21 +++++++++++++++++++ .../main/res/layout/fragment_fingerprint.xml | 16 ++++++++++++++ .../src/main/res/layout/fragment_pin.xml | 16 ++++++++++++++ 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/security/FingerprintFragment.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/security/PinFragment.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt create mode 100644 presentation/src/main/res/layout/activity_security.xml create mode 100644 presentation/src/main/res/layout/fragment_fingerprint.xml create mode 100644 presentation/src/main/res/layout/fragment_pin.xml diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 13a1f6f3a..d9f3d3c4f 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -1,11 +1,19 @@ + + + + + android:theme="@style/Theme.BEEP.Splash"> @@ -15,7 +23,6 @@ - @@ -23,9 +30,9 @@ - + \ No newline at end of file diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/security/FingerprintFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/security/FingerprintFragment.kt new file mode 100644 index 000000000..e7ff27323 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/security/FingerprintFragment.kt @@ -0,0 +1,19 @@ +package com.lighthouse.presentation.ui.security + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.lighthouse.presentation.R + +class FingerprintFragment : Fragment() { + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.fragment_fingerprint, container, false) + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/security/PinFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/security/PinFragment.kt new file mode 100644 index 000000000..a61dddba7 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/security/PinFragment.kt @@ -0,0 +1,20 @@ +package com.lighthouse.presentation.ui.security + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.lighthouse.presentation.R + +class PinFragment : Fragment() { + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_pin, container, false) + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt new file mode 100644 index 000000000..45ce59fd8 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt @@ -0,0 +1,20 @@ +package com.lighthouse.presentation.ui.security + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.commit +import com.lighthouse.presentation.R + +class SecurityActivity : AppCompatActivity() { + + private val fingerprintFragment by lazy { FingerprintFragment() } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_security) + + supportFragmentManager.commit { + add(R.id.fcv_security, fingerprintFragment) + } + } +} diff --git a/presentation/src/main/res/layout/activity_security.xml b/presentation/src/main/res/layout/activity_security.xml new file mode 100644 index 000000000..8ba74b09d --- /dev/null +++ b/presentation/src/main/res/layout/activity_security.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_fingerprint.xml b/presentation/src/main/res/layout/fragment_fingerprint.xml new file mode 100644 index 000000000..048268856 --- /dev/null +++ b/presentation/src/main/res/layout/fragment_fingerprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_pin.xml b/presentation/src/main/res/layout/fragment_pin.xml new file mode 100644 index 000000000..409b4f75b --- /dev/null +++ b/presentation/src/main/res/layout/fragment_pin.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file From 55316f1c950209fcb1c4e9b83516b7c8a6256193 Mon Sep 17 00:00:00 2001 From: yangsooplus <69582122+yangsooplus@users.noreply.github.com> Date: Tue, 15 Nov 2022 00:45:26 +0900 Subject: [PATCH 084/929] =?UTF-8?q?Issues=20#39=20feat:=20=EB=B3=B4?= =?UTF-8?q?=EC=95=88=20=EC=95=A1=ED=8B=B0=EB=B9=84=ED=8B=B0=EC=97=90?= =?UTF-8?q?=EC=84=9C=20Fragment=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/security/SecurityActivity.kt | 22 ++++++++++++++++++- .../ui/security/event/SecurityDirections.kt | 6 +++++ .../presentation/ui/signin/SignInFragment.kt | 9 +++++++- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/security/event/SecurityDirections.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt index 45ce59fd8..60b2cb646 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/security/SecurityActivity.kt @@ -3,18 +3,38 @@ package com.lighthouse.presentation.ui.security import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.commit +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle import com.lighthouse.presentation.R +import com.lighthouse.presentation.ui.security.event.SecurityDirections +import kotlinx.coroutines.launch class SecurityActivity : AppCompatActivity() { private val fingerprintFragment by lazy { FingerprintFragment() } + private val pinFragment by lazy { PinFragment() } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_security) + moveScreen(SecurityDirections.FINGERPRINT) + } + + private fun moveScreen(directions: SecurityDirections) { + val fragment = when (directions) { + SecurityDirections.FINGERPRINT -> fingerprintFragment + SecurityDirections.PIN -> pinFragment + } supportFragmentManager.commit { - add(R.id.fcv_security, fingerprintFragment) + if (fragment != fingerprintFragment && fingerprintFragment.isAdded) hide(fingerprintFragment) + if (fragment != pinFragment && pinFragment.isAdded) hide(pinFragment) + if (fragment.isAdded) { + show(fragment) + } else { + add(R.id.fcv_security, fragment) + } } } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/security/event/SecurityDirections.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/security/event/SecurityDirections.kt new file mode 100644 index 000000000..c5ae3b235 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/security/event/SecurityDirections.kt @@ -0,0 +1,6 @@ +package com.lighthouse.presentation.ui.security.event + +enum class SecurityDirections { + PIN, + FINGERPRINT +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt index 3231c5799..934064d34 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/signin/SignInFragment.kt @@ -22,6 +22,7 @@ import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.FragmentSignInBinding import com.lighthouse.presentation.ui.common.viewBindings import com.lighthouse.presentation.ui.main.MainActivity +import com.lighthouse.presentation.ui.security.SecurityActivity class SignInFragment : Fragment() { @@ -54,7 +55,8 @@ class SignInFragment : Fragment() { if (auth.currentUser == null) { initGoogleLogin() } else { - gotoMain() + // gotoMain() + gotoSecurity() // TODO: fingerprint test } } @@ -87,4 +89,9 @@ class SignInFragment : Fragment() { val intent = Intent(requireContext(), MainActivity::class.java) startActivity(intent) } + + private fun gotoSecurity() { + val intent = Intent(requireContext(), SecurityActivity::class.java) + startActivity(intent) + } } From e34b2659c9aaa1337515a6e60f8baca09808fcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Tue, 15 Nov 2022 01:22:45 +0900 Subject: [PATCH 085/929] =?UTF-8?q?Issues=20#36=20feat:=20ItemDecoration?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/recycler/GridSpaceItemDecoration.kt | 63 +++++++++++++++ .../utils/recycler/ListSpaceItemDecoration.kt | 76 ++++++++++++++++++ .../utils/recycler/SectionSpaceGridDivider.kt | 78 +++++++++++++++++++ 3 files changed, 217 insertions(+) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/utils/recycler/GridSpaceItemDecoration.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/utils/recycler/ListSpaceItemDecoration.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/utils/recycler/SectionSpaceGridDivider.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/GridSpaceItemDecoration.kt b/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/GridSpaceItemDecoration.kt new file mode 100644 index 000000000..d726663ed --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/GridSpaceItemDecoration.kt @@ -0,0 +1,63 @@ +package com.lighthouse.presentation.utils.recycler + +import android.graphics.Rect +import android.view.View +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.RecyclerView + +class GridSpaceItemDecoration( + private val vSpace: Int, + private val hSpace: Int, + private val start: Int = 0, + private val top: Int = 0, + private val end: Int = 0, + private val bottom: Int = 0 +) : RecyclerView.ItemDecoration() { + constructor( + vSpace: Float, + hSpace: Float, + start: Float = 0f, + top: Float = 0f, + end: Float = 0f, + bottom: Float = 0f + ) : this(vSpace.toInt(), hSpace.toInt(), start.toInt(), top.toInt(), end.toInt(), bottom.toInt()) + + override fun getItemOffsets( + outRect: Rect, + view: View, + parent: RecyclerView, + state: RecyclerView.State + ) { + super.getItemOffsets(outRect, view, parent, state) + + val manager = parent.layoutManager as? GridLayoutManager ?: return + + val position = parent.getChildAdapterPosition(view) + val spanCount = manager.spanCount + + outRect.left = if (isFirstCol(position, spanCount)) start else hSpace / 2 + outRect.top = if (isFirstRow(position, spanCount)) top else vSpace / 2 + outRect.right = if (isLastCol(position, spanCount)) end else hSpace / 2 + outRect.bottom = if (isLastRow(position, spanCount, getItemCount(parent))) bottom else vSpace / 2 + } + + private fun isFirstRow(position: Int, spanCount: Int): Boolean { + return position < spanCount + } + + private fun isFirstCol(position: Int, spanCount: Int): Boolean { + return position % spanCount == 0 + } + + private fun isLastRow(position: Int, spanCount: Int, itemCount: Int): Boolean { + return position >= itemCount - itemCount % spanCount + } + + private fun isLastCol(position: Int, spanCount: Int): Boolean { + return isFirstCol(position + 1, spanCount) + } + + private fun getItemCount(parent: RecyclerView): Int { + return parent.adapter?.itemCount ?: 0 + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/ListSpaceItemDecoration.kt b/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/ListSpaceItemDecoration.kt new file mode 100644 index 000000000..8740c6226 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/ListSpaceItemDecoration.kt @@ -0,0 +1,76 @@ +package com.lighthouse.presentation.utils.recycler + +import android.graphics.Rect +import android.view.View +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView + +class ListSpaceItemDecoration( + private val space: Int, + private val start: Int = 0, + private val top: Int = 0, + private val end: Int = 0, + private val bottom: Int = 0 +) : RecyclerView.ItemDecoration() { + + constructor( + space: Float, + start: Float = 0f, + top: Float = 0f, + end: Float = 0f, + bottom: Float = 0f + ) : this(space.toInt(), start.toInt(), top.toInt(), end.toInt(), bottom.toInt()) + + override fun getItemOffsets( + outRect: Rect, + view: View, + parent: RecyclerView, + state: RecyclerView.State + ) { + super.getItemOffsets(outRect, view, parent, state) + val manager = parent.layoutManager as? LinearLayoutManager ?: return + val itemCount = parent.adapter?.itemCount ?: 0 + val position = when (parent.getChildAdapterPosition(view)) { + 0 -> Position.Start + itemCount - 1 -> Position.End + else -> Position.Mid + } + + val isVertical = manager.orientation == LinearLayoutManager.VERTICAL + if (isVertical) { + calculateVerticalOffsets(outRect, position) + } else { + calculateHorizontalOffsets(outRect, position) + } + } + + private fun calculateVerticalOffsets(outRect: Rect, pos: Position) { + outRect.left = start + outRect.top = when (pos) { + Position.Start -> top + else -> space / 2 + } + outRect.right = end + outRect.bottom = when (pos) { + Position.End -> bottom + else -> space / 2 + } + } + + private fun calculateHorizontalOffsets(outRect: Rect, pos: Position) { + outRect.left = when (pos) { + Position.Start -> start + else -> space / 2 + } + outRect.top = top + outRect.right = when (pos) { + Position.End -> end + else -> space / 2 + } + outRect.bottom = bottom + } + + private enum class Position { + Start, End, Mid + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/SectionSpaceGridDivider.kt b/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/SectionSpaceGridDivider.kt new file mode 100644 index 000000000..39379970e --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/utils/recycler/SectionSpaceGridDivider.kt @@ -0,0 +1,78 @@ +package com.lighthouse.presentation.utils.recycler + +import android.graphics.Rect +import android.view.View +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.RecyclerView + +class SectionSpaceGridDivider( + private val sectionDivider: Int, + private val itemSpace: Int, + private val start: Int = 0, + private val top: Int = 0, + private val end: Int = 0, + private val bottom: Int = 0 +) : RecyclerView.ItemDecoration() { + + constructor( + sectionDivider: Float, + itemSpace: Float, + start: Float = 0f, + top: Float = 0f, + end: Float = 0f, + bottom: Float = 0f + ) : this(sectionDivider.toInt(), itemSpace.toInt(), start.toInt(), top.toInt(), end.toInt(), bottom.toInt()) + + override fun getItemOffsets( + outRect: Rect, + view: View, + parent: RecyclerView, + state: RecyclerView.State + ) { + super.getItemOffsets(outRect, view, parent, state) + + val manager = parent.layoutManager as? GridLayoutManager ?: return + val params = view.layoutParams as? GridLayoutManager.LayoutParams ?: return + + val position = parent.getChildAdapterPosition(view) + + outRect.top = if (isSection(manager, params)) { + if (isFirstRow(position)) top else sectionDivider - itemSpace / 2 + } else itemSpace / 2 + + outRect.bottom = if (isLastRow(position, manager, parent)) bottom + else itemSpace / 2 + + outRect.left = if (isFirstCol(params)) start + else itemSpace / 2 + + outRect.right = if (isLastCol(manager, params)) end + else itemSpace / 2 + } + + private fun isSection(manager: GridLayoutManager, params: GridLayoutManager.LayoutParams): Boolean { + return manager.spanCount == params.spanSize + } + + private fun isFirstRow(position: Int): Boolean { + return position == 0 + } + + private fun isLastRow(position: Int, manager: GridLayoutManager, recyclerView: RecyclerView): Boolean { + val itemCount = recyclerView.adapter?.itemCount ?: 0 + + return getGroupIndex(position, manager) == getGroupIndex(itemCount - 1, manager) + } + + private fun getGroupIndex(position: Int, manager: GridLayoutManager): Int { + return manager.spanSizeLookup.getSpanGroupIndex(position, manager.spanCount) + } + + private fun isFirstCol(params: GridLayoutManager.LayoutParams): Boolean { + return params.spanIndex == 0 + } + + private fun isLastCol(manager: GridLayoutManager, params: GridLayoutManager.LayoutParams): Boolean { + return params.spanIndex + params.spanSize == manager.spanCount + } +} From 50fa93880906586cf88d96029662efa61e654faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Tue, 15 Nov 2022 01:23:28 +0900 Subject: [PATCH 086/929] =?UTF-8?q?Issues=20#36=20feat:=20extention=20?= =?UTF-8?q?=EB=B0=8F=20bindingAdapter=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/binding/ImageView.kt | 18 ++++++++++++++++++ .../ui/bindingadapter/ImageView.kt | 10 ---------- .../utils/extention/KotlinExtention.kt | 9 +++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/binding/ImageView.kt delete mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/bindingadapter/ImageView.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/utils/extention/KotlinExtention.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/binding/ImageView.kt b/presentation/src/main/java/com/lighthouse/presentation/binding/ImageView.kt new file mode 100644 index 000000000..b53d9706b --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/binding/ImageView.kt @@ -0,0 +1,18 @@ +package com.lighthouse.presentation.binding + +import android.net.Uri +import android.widget.ImageView +import androidx.databinding.BindingAdapter +import com.bumptech.glide.Glide + +@BindingAdapter("loadUri") +fun loadUri(view: ImageView, uri: Uri?) { + if (uri != null) { + Glide.with(view) + .load(uri) + .centerCrop() + .into(view) + } else { + view.setImageBitmap(null) + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/bindingadapter/ImageView.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/bindingadapter/ImageView.kt deleted file mode 100644 index 653d11911..000000000 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/bindingadapter/ImageView.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.lighthouse.presentation.ui.bindingadapter - -import android.net.Uri -import android.widget.ImageView - -fun load(view: ImageView, uri: Uri?) { - if (uri == null) { - } else { - } -} diff --git a/presentation/src/main/java/com/lighthouse/presentation/utils/extention/KotlinExtention.kt b/presentation/src/main/java/com/lighthouse/presentation/utils/extention/KotlinExtention.kt new file mode 100644 index 000000000..51cfbdedb --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/utils/extention/KotlinExtention.kt @@ -0,0 +1,9 @@ +package com.lighthouse.presentation.utils.extention + +import android.content.res.Resources +import android.util.TypedValue + +val Int.dp + get() = Resources.getSystem().displayMetrics?.let { dm -> + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this.toFloat(), dm) + } ?: 0f From 4274216f4cfcb437fa27ec3615db6a557c482b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Tue, 15 Nov 2022 01:25:05 +0900 Subject: [PATCH 087/929] =?UTF-8?q?Issues=20#36=20feat:=20Gallery=ED=99=94?= =?UTF-8?q?=EB=A9=B4=EC=97=90=20Paging=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/GalleryImageLocalSource.kt | 2 +- .../datasource/GalleryImageLocalSourceImpl.kt | 41 ++++++++++++++----- .../datasource/GalleryImagePagingSource.kt | 28 +++++++++++++ .../repository/GalleryImageRepositoryImpl.kt | 14 ++++++- .../repository/GalleryImageRepository.kt | 4 +- .../domain/usecase/GetGalleryImagesUseCase.kt | 4 +- presentation/src/main/AndroidManifest.xml | 3 +- .../presentation/model/GalleryUIModel.kt | 2 +- .../adapter/AddCandidateGifticonViewHolder.kt | 1 + .../ui/gallery/GalleryActivity.kt | 21 ++++++++-- .../ui/gallery/GalleryViewModel.kt | 35 +++++++++++++--- .../ui/gallery/adapter/GalleryAdapter.kt | 17 ++++---- .../ui/gallery/adapter/GalleryDisplayModel.kt | 13 ++++++ .../adapter/GalleryHeaderViewHolder.kt | 3 +- .../gallery/adapter/GalleryItemViewHolder.kt | 6 +-- .../src/main/res/layout/activity_gallery.xml | 2 +- .../src/main/res/layout/activity_main.xml | 2 +- .../layout/item_add_candidate_gifticon.xml | 16 ++++++-- .../src/main/res/layout/item_gallery.xml | 12 +++++- .../main/res/layout/item_gallery_header.xml | 8 ++++ 20 files changed, 188 insertions(+), 46 deletions(-) create mode 100644 data/src/main/java/com/lighthouse/datasource/GalleryImagePagingSource.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryDisplayModel.kt diff --git a/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSource.kt b/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSource.kt index e5272c762..b58e470ed 100644 --- a/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSource.kt +++ b/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSource.kt @@ -3,5 +3,5 @@ package com.lighthouse.datasource import com.lighthouse.domain.model.GalleryImage interface GalleryImageLocalSource { - suspend fun getImages(): List + suspend fun getImages(page: Int, limit: Int): List } diff --git a/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSourceImpl.kt b/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSourceImpl.kt index 297fdd4e8..259b2d560 100644 --- a/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSourceImpl.kt +++ b/data/src/main/java/com/lighthouse/datasource/GalleryImageLocalSourceImpl.kt @@ -2,6 +2,8 @@ package com.lighthouse.datasource import android.content.ContentResolver import android.content.ContentUris +import android.os.Build +import android.os.Bundle import android.provider.MediaStore import android.webkit.MimeTypeMap import com.lighthouse.domain.model.GalleryImage @@ -12,7 +14,7 @@ class GalleryImageLocalSourceImpl @Inject constructor( private val contentResolver: ContentResolver ) : GalleryImageLocalSource { - override suspend fun getImages(): List { + override suspend fun getImages(page: Int, limit: Int): List { val projection = arrayOf( MediaStore.Images.Media._ID, MediaStore.Images.Media.DATE_ADDED @@ -23,15 +25,32 @@ class GalleryImageLocalSourceImpl @Inject constructor( mimeTypeMap.getMimeTypeFromExtension("png"), mimeTypeMap.getMimeTypeFromExtension("jpg") ) - val sortOrder = "${MediaStore.Images.Media.DATE_ADDED} DESC" - - val cursor = contentResolver.query( - MediaStore.Images.Media.EXTERNAL_CONTENT_URI, - projection, - selection, - selectionArg, - sortOrder - ) + val offset = page * limit + val cursor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + val queryArgs = Bundle().apply { + putString(ContentResolver.QUERY_ARG_SQL_SELECTION, selection) + putStringArray(ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS, selectionArg) + putStringArray(ContentResolver.QUERY_ARG_SORT_COLUMNS, arrayOf(MediaStore.Images.Media.DATE_ADDED)) + putInt(ContentResolver.QUERY_ARG_SORT_DIRECTION, ContentResolver.QUERY_SORT_DIRECTION_DESCENDING) + putInt(ContentResolver.QUERY_ARG_OFFSET, offset) + putInt(ContentResolver.QUERY_ARG_LIMIT, limit) + } + contentResolver.query( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + projection, + queryArgs, + null + ) + } else { + val sortOrder = "${MediaStore.Images.Media.DATE_ADDED} DESC OFFSET $offset LIMIT $limit " + contentResolver.query( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + projection, + selection, + selectionArg, + sortOrder + ) + } val list = ArrayList() cursor?.use { @@ -42,7 +61,7 @@ class GalleryImageLocalSourceImpl @Inject constructor( val id = it.getLong(idColumn) val contentUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id) val dateAdded = it.getLong(dateAddedColumn) - val date = Date(dateAdded) + val date = Date(dateAdded * 1000) list.add(GalleryImage(id, contentUri.toString(), date)) } } diff --git a/data/src/main/java/com/lighthouse/datasource/GalleryImagePagingSource.kt b/data/src/main/java/com/lighthouse/datasource/GalleryImagePagingSource.kt new file mode 100644 index 000000000..8b364c4d4 --- /dev/null +++ b/data/src/main/java/com/lighthouse/datasource/GalleryImagePagingSource.kt @@ -0,0 +1,28 @@ +package com.lighthouse.datasource + +import androidx.paging.PagingSource +import androidx.paging.PagingState +import com.lighthouse.domain.model.GalleryImage + +class GalleryImagePagingSource( + private val localSource: GalleryImageLocalSource, + private val page: Int, + private val limit: Int +) : PagingSource() { + + override fun getRefreshKey(state: PagingState): Int? = state.anchorPosition + + override suspend fun load(params: LoadParams): LoadResult { + val current = params.key ?: page + val results = localSource.getImages(current, limit) + return try { + LoadResult.Page( + data = results, + prevKey = null, + nextKey = if (results.size < params.loadSize) null else current + 1 + ) + } catch (e: Exception) { + LoadResult.Error(e) + } + } +} diff --git a/data/src/main/java/com/lighthouse/repository/GalleryImageRepositoryImpl.kt b/data/src/main/java/com/lighthouse/repository/GalleryImageRepositoryImpl.kt index 71270fb8d..8b5535649 100644 --- a/data/src/main/java/com/lighthouse/repository/GalleryImageRepositoryImpl.kt +++ b/data/src/main/java/com/lighthouse/repository/GalleryImageRepositoryImpl.kt @@ -1,15 +1,25 @@ package com.lighthouse.repository +import androidx.paging.Pager +import androidx.paging.PagingConfig +import androidx.paging.PagingData import com.lighthouse.datasource.GalleryImageLocalSource +import com.lighthouse.datasource.GalleryImagePagingSource import com.lighthouse.domain.model.GalleryImage import com.lighthouse.domain.repository.GalleryImageRepository +import kotlinx.coroutines.flow.Flow import javax.inject.Inject class GalleryImageRepositoryImpl @Inject constructor( private val localSource: GalleryImageLocalSource ) : GalleryImageRepository { - override suspend fun getImages(): List { - return localSource.getImages() + override fun getImages(): Flow> { + return Pager( + config = PagingConfig(pageSize = 10, initialLoadSize = 10, enablePlaceholders = false), + pagingSourceFactory = { + GalleryImagePagingSource(localSource, 0, 10) + } + ).flow } } diff --git a/domain/src/main/java/com/lighthouse/domain/repository/GalleryImageRepository.kt b/domain/src/main/java/com/lighthouse/domain/repository/GalleryImageRepository.kt index 7d36e72ee..ee1d78f01 100644 --- a/domain/src/main/java/com/lighthouse/domain/repository/GalleryImageRepository.kt +++ b/domain/src/main/java/com/lighthouse/domain/repository/GalleryImageRepository.kt @@ -1,7 +1,9 @@ package com.lighthouse.domain.repository +import androidx.paging.PagingData import com.lighthouse.domain.model.GalleryImage +import kotlinx.coroutines.flow.Flow interface GalleryImageRepository { - suspend fun getImages(): List + fun getImages(): Flow> } diff --git a/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt b/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt index ffecd3787..dd92330a6 100644 --- a/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt +++ b/domain/src/main/java/com/lighthouse/domain/usecase/GetGalleryImagesUseCase.kt @@ -1,14 +1,16 @@ package com.lighthouse.domain.usecase +import androidx.paging.PagingData import com.lighthouse.domain.model.GalleryImage import com.lighthouse.domain.repository.GalleryImageRepository +import kotlinx.coroutines.flow.Flow import javax.inject.Inject class GetGalleryImagesUseCase @Inject constructor( private val galleryImageRepository: GalleryImageRepository ) { - suspend operator fun invoke(): List { + operator fun invoke(): Flow> { return galleryImageRepository.getImages() } } diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 048a4a53f..81b44320b 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ - + diff --git a/presentation/src/main/java/com/lighthouse/presentation/model/GalleryUIModel.kt b/presentation/src/main/java/com/lighthouse/presentation/model/GalleryUIModel.kt index ec42fd99d..2af0eb689 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/model/GalleryUIModel.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/model/GalleryUIModel.kt @@ -4,7 +4,7 @@ import android.net.Uri import java.util.Date sealed class GalleryUIModel { - data class Header(val date: Date) : GalleryUIModel() + data class Header(val date: String) : GalleryUIModel() data class Gallery( val id: Long, val uri: Uri, diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/adapter/AddCandidateGifticonViewHolder.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/adapter/AddCandidateGifticonViewHolder.kt index 12f5baf91..291410eed 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/adapter/AddCandidateGifticonViewHolder.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/addgifticon/adapter/AddCandidateGifticonViewHolder.kt @@ -17,5 +17,6 @@ class AddCandidateGifticonViewHolder( ) : RecyclerView.ViewHolder(binding.root) { fun bind(item: AddGifticonUIModel.Gifticon) { + binding.dm = AddCandidateGifticonDisplayModel(item, onClick, onDelete) } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt index 6510e4f64..b0e3716dc 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryActivity.kt @@ -4,11 +4,13 @@ import android.os.Bundle import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil +import androidx.recyclerview.widget.GridLayoutManager import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ActivityGalleryBinding import com.lighthouse.presentation.ui.gallery.adapter.GalleryAdapter +import com.lighthouse.presentation.utils.extention.dp +import com.lighthouse.presentation.utils.recycler.SectionSpaceGridDivider import dagger.hilt.android.AndroidEntryPoint -import java.util.* @AndroidEntryPoint class GalleryActivity : AppCompatActivity() { @@ -17,7 +19,9 @@ class GalleryActivity : AppCompatActivity() { private val viewModel: GalleryViewModel by viewModels() - private val galleryAdapter = GalleryAdapter() + private val galleryAdapter = GalleryAdapter( + onClickGallery = {} + ) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -28,6 +32,17 @@ class GalleryActivity : AppCompatActivity() { vm = viewModel } - binding.rvList.adapter = galleryAdapter + val spanCount = 3 + binding.rvList.apply { + adapter = galleryAdapter + layoutManager = GridLayoutManager(context, spanCount).apply { + spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() { + override fun getSpanSize(position: Int): Int { + return if (galleryAdapter.getItemViewType(position) == GalleryAdapter.TYPE_HEADER) spanCount else 1 + } + } + } + addItemDecoration(SectionSpaceGridDivider(20.dp, 4.dp, 4.dp, 12.dp, 4.dp, 12.dp)) + } } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt index fca1610bd..8665d1160 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/GalleryViewModel.kt @@ -2,23 +2,46 @@ package com.lighthouse.presentation.ui.gallery import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import androidx.paging.PagingData +import androidx.paging.cachedIn +import androidx.paging.insertSeparators +import androidx.paging.map import com.lighthouse.domain.usecase.GetGalleryImagesUseCase import com.lighthouse.presentation.mapper.toPresentation +import com.lighthouse.presentation.model.GalleryUIModel import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn +import java.text.SimpleDateFormat +import java.util.Locale import javax.inject.Inject @HiltViewModel class GalleryViewModel @Inject constructor( - private val getGalleryImagesUseCase: GetGalleryImagesUseCase + getGalleryImagesUseCase: GetGalleryImagesUseCase ) : ViewModel() { - val list = flow { - val images = getGalleryImagesUseCase().map { + private val format = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) + + val list = getGalleryImagesUseCase().map { pagingData -> + pagingData.map { it.toPresentation() + }.insertSeparators { before: GalleryUIModel.Gallery?, after: GalleryUIModel.Gallery? -> + if (before == null && after != null) { + GalleryUIModel.Header(format.format(after.date)) + } else if (before != null && after != null) { + val beforeDate = format.format(before.date) + val afterDate = format.format(after.date) + if (beforeDate != afterDate) { + GalleryUIModel.Header(afterDate) + } else { + null + } + } else { + null + } } - emit(images) - }.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) + }.cachedIn(viewModelScope) + .stateIn(viewModelScope, SharingStarted.Eagerly, PagingData.empty()) } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryAdapter.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryAdapter.kt index b6fab9e96..d47c3b996 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryAdapter.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryAdapter.kt @@ -3,21 +3,23 @@ package com.lighthouse.presentation.ui.gallery.adapter import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView -import com.lighthouse.presentation.adapter.BindableListAdapter +import com.lighthouse.presentation.adapter.BindablePagingAdapter import com.lighthouse.presentation.model.GalleryUIModel -class GalleryAdapter() : BindableListAdapter(Diff) { +class GalleryAdapter( + private val onClickGallery: (GalleryUIModel.Gallery) -> Unit +) : BindablePagingAdapter(Diff) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { TYPE_HEADER -> GalleryHeaderViewHolder(parent) - TYPE_GALLERY -> GalleryItemViewHolder(parent) + TYPE_GALLERY -> GalleryItemViewHolder(parent, onClickGallery) else -> throw IllegalArgumentException("잘못된 viewType 입니다.") } } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { - val item = currentList[position] + val item = getItem(position) when { holder is GalleryHeaderViewHolder && item is GalleryUIModel.Header -> { holder.bind(item) @@ -29,9 +31,10 @@ class GalleryAdapter() : BindableListAdapter TYPE_HEADER is GalleryUIModel.Gallery -> TYPE_GALLERY + else -> throw IllegalArgumentException("잘못된 viewType 입니다.") } } @@ -54,7 +57,7 @@ class GalleryAdapter() : BindableListAdapter Unit +) { + + fun onClickItem() { + onClick(item) + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryHeaderViewHolder.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryHeaderViewHolder.kt index 70d8d7e71..6cd49841b 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryHeaderViewHolder.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryHeaderViewHolder.kt @@ -14,6 +14,7 @@ class GalleryHeaderViewHolder( ) ) : RecyclerView.ViewHolder(binding.root) { - fun bind(header: GalleryUIModel.Header) { + fun bind(item: GalleryUIModel.Header) { + binding.item = item } } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryItemViewHolder.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryItemViewHolder.kt index e0b53ce29..9f78cf3ca 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryItemViewHolder.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/gallery/adapter/GalleryItemViewHolder.kt @@ -3,21 +3,19 @@ package com.lighthouse.presentation.ui.gallery.adapter import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ItemGalleryBinding import com.lighthouse.presentation.model.GalleryUIModel class GalleryItemViewHolder( parent: ViewGroup, + private val onClick: (GalleryUIModel.Gallery) -> Unit, private val binding: ItemGalleryBinding = ItemGalleryBinding.bind( LayoutInflater.from(parent.context).inflate(R.layout.item_gallery, parent, false) ) ) : RecyclerView.ViewHolder(binding.root) { fun bind(item: GalleryUIModel.Gallery) { - Glide.with(binding.ivThumbnail.context) - .load(item.uri) - .into(binding.ivThumbnail) + binding.dm = GalleryDisplayModel(item, onClick) } } diff --git a/presentation/src/main/res/layout/activity_gallery.xml b/presentation/src/main/res/layout/activity_gallery.xml index 818c3619e..5647ec82d 100644 --- a/presentation/src/main/res/layout/activity_gallery.xml +++ b/presentation/src/main/res/layout/activity_gallery.xml @@ -47,7 +47,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/iv_back" - app:spanCount="4" + app:spanCount="3" app:setItems="@{vm.list}" tools:listitem="@layout/item_gallery"/> diff --git a/presentation/src/main/res/layout/activity_main.xml b/presentation/src/main/res/layout/activity_main.xml index ea8ac82e8..e2c9bde18 100644 --- a/presentation/src/main/res/layout/activity_main.xml +++ b/presentation/src/main/res/layout/activity_main.xml @@ -33,7 +33,7 @@ android:onClickListener="@{() -> vm.gotoAddGifticon()}" android:src="@drawable/btn_main_floating_add" app:layout_constraintBottom_toTopOf="@id/bnv" - app:layout_constraintEnd_toEndOf="parent" /> + app:layout_constraintEnd_toEndOf="parent"/> + + + + + @@ -16,7 +23,8 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + android:onClickListener="@{() -> dm.onClickItem()}"/> + app:layout_constraintTop_toTopOf="parent" + app:visibility="@{dm.closeVisibility}"/> + app:layout_constraintTop_toTopOf="parent" + app:visibility="@{dm.badgeVisibility}"/> \ No newline at end of file diff --git a/presentation/src/main/res/layout/item_gallery.xml b/presentation/src/main/res/layout/item_gallery.xml index 8ffa8e459..3b070fbfb 100644 --- a/presentation/src/main/res/layout/item_gallery.xml +++ b/presentation/src/main/res/layout/item_gallery.xml @@ -3,6 +3,12 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> + + + + @@ -12,11 +18,13 @@ android:layout_width="0dp" android:layout_height="0dp" android:contentDescription="@string/gallery_image_description" + android:onClickListener="@{() -> dm.onClickItem()}" android:scaleType="centerCrop" app:layout_constraintDimensionRatio="1" - app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:loadUri="@{dm.item.uri}" /> + + + + From 2041453415e448733e41312a613003adbceb6826 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Tue, 15 Nov 2022 01:42:59 +0900 Subject: [PATCH 088/929] =?UTF-8?q?Issues=20#15=20chore:=20activity=20?= =?UTF-8?q?=ED=9A=8C=EC=A0=84=20=EC=95=88=EB=90=98=EA=B2=8C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/AndroidManifest.xml | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 048a4a53f..0981d1c50 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -3,27 +3,31 @@ - + android:exported="true" + android:screenOrientation="portrait" /> + android:exported="true" + android:screenOrientation="portrait"> - - - - - + + + + android:exported="true" + android:screenOrientation="portrait" /> \ No newline at end of file From 7f19e06d80f00eeed3e2c719a997aa6fa6877b35 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Tue, 15 Nov 2022 01:43:14 +0900 Subject: [PATCH 089/929] =?UTF-8?q?Issues=20#15=20chore:=20viewPager=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/Dependencies.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index b8d0f48d8..929960a1f 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -33,6 +33,7 @@ object Versions { const val PLAY_SERVICES_LOCATION = "21.0.1" const val GLIDE = "4.14.2" + const val VIEW_PAGER2 = "2:1.0.0" const val JUNIT = "4.13.2" const val ANDROID_JUNIT = "1.1.3" @@ -90,6 +91,8 @@ object Libraries { private const val GLIDE = "com.github.bumptech.glide:glide:${Versions.GLIDE}" + private const val VIEW_PAGER2 = "androidx.viewpager2:viewpager${Versions.VIEW_PAGER2}" + val VIEW_LIBRARIES = arrayListOf( CORE, APP_COMPAT, @@ -107,7 +110,8 @@ object Libraries { BIOMETRIC, NAVER_MAP, PLAY_SERVICES_LOCATION, - GLIDE + GLIDE, + VIEW_PAGER2 ) val DATA_LIBRARIES = arrayListOf( ROOM_RUNTIME, From 060a489222d18de46e2f657ceb874daff5f61378 Mon Sep 17 00:00:00 2001 From: lee-ji-hoon Date: Tue, 15 Nov 2022 01:47:10 +0900 Subject: [PATCH 090/929] =?UTF-8?q?Issues=20#15=20feat:=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B2=84=20=EB=A7=B5=20=ED=95=98=EB=8B=A8=20viewPager?= =?UTF-8?q?2=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 아이템 바인딩 (test data) - d-day 날짜에 따른 String Resource 분기 --- .../binding/TextBindingAdapter.kt | 31 +++++++++++++++++++ .../presentation/ui/map/MapActivity.kt | 23 ++++++++++++++ .../ui/map/adapter/MapGifticonAdapter.kt | 29 +++++++++++++++++ .../map/adapter/MapGifticonItemViewHolder.kt | 20 ++++++++++++ .../presentation/ui/utils/TimeCalculator.kt | 18 +++++++++++ .../src/main/res/layout/activity_map.xml | 17 +++++----- .../res/layout/item_gifticon_horizontal.xml | 22 ++++++++----- presentation/src/main/res/values/strings.xml | 2 ++ 8 files changed, 145 insertions(+), 17 deletions(-) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/binding/TextBindingAdapter.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonAdapter.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonItemViewHolder.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/utils/TimeCalculator.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/binding/TextBindingAdapter.kt b/presentation/src/main/java/com/lighthouse/presentation/binding/TextBindingAdapter.kt new file mode 100644 index 000000000..fcd123d1d --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/binding/TextBindingAdapter.kt @@ -0,0 +1,31 @@ +package com.lighthouse.presentation.binding + +import android.widget.TextView +import androidx.databinding.BindingAdapter +import com.lighthouse.presentation.R +import com.lighthouse.presentation.ui.utils.TimeCalculator +import com.lighthouse.presentation.ui.utils.TimeCalculator.MAX_DAY +import com.lighthouse.presentation.ui.utils.TimeCalculator.MIN_DAY +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale + +@BindingAdapter("setExportedDate") +fun setExportedDate(view: TextView, date: Date) { + view.text = date.toString("~ yyyy-MM-dd") +} + +@BindingAdapter("setDday") +fun setDday(view: TextView, date: Date) { + val dDay = TimeCalculator.formatDdayToInt(date.time) + view.text = when { + dDay in MIN_DAY until MAX_DAY -> String.format(view.context.getString(R.string.all_d_day), dDay) + dDay < MIN_DAY -> view.context.getString(R.string.all_d_day_expired) + else -> view.context.getString(R.string.all_d_day_more_than_year) + } +} + +private fun Date.toString(format: String): String { + val dateFormatter = SimpleDateFormat(format, Locale.getDefault()) + return dateFormatter.format(this) +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt index 4bebd171d..2e88a1706 100644 --- a/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/MapActivity.kt @@ -8,9 +8,11 @@ import androidx.databinding.DataBindingUtil import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import com.lighthouse.domain.model.Gifticon import com.lighthouse.presentation.R import com.lighthouse.presentation.databinding.ActivityMapBinding import com.lighthouse.presentation.model.BrandPlaceInfoUiModel +import com.lighthouse.presentation.ui.map.adapter.MapGifticonAdapter import com.naver.maps.geometry.LatLng import com.naver.maps.map.CameraUpdate import com.naver.maps.map.MapView @@ -22,6 +24,8 @@ import com.naver.maps.map.util.FusedLocationSource import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch +import java.util.Date +import java.util.UUID @AndroidEntryPoint class MapActivity : AppCompatActivity(), OnMapReadyCallback, Overlay.OnClickListener, OnLocationUpdateListener { @@ -32,6 +36,7 @@ class MapActivity : AppCompatActivity(), OnMapReadyCallback, Overlay.OnClickList private lateinit var fusedLocationProviderClient: FusedLocationProvider private lateinit var locationSource: FusedLocationSource private val viewModel: MapViewModel by viewModels() + private val adapter = MapGifticonAdapter() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -41,10 +46,16 @@ class MapActivity : AppCompatActivity(), OnMapReadyCallback, Overlay.OnClickList getMapAsync(this@MapActivity) } + setGifticonAdapter() setObserveSearchData() setFusedLocationProvider() } + override fun onStart() { + super.onStart() + mapView.onStart() + } + private fun setObserveSearchData() { lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { @@ -96,6 +107,18 @@ class MapActivity : AppCompatActivity(), OnMapReadyCallback, Overlay.OnClickList naverMap.minZoom = 10.0 } + private fun setGifticonAdapter() { + val gifticonTestData = listOf( + Gifticon(UUID.randomUUID().toString(), "이름", "bbq", "bbq", Date(120, 20, 20), "bar", true, 1, "memo", true), + Gifticon(UUID.randomUUID().toString(), "이름", "bbq", "bbq", Date(122, 11, 15), "bar", true, 1, "memo", true), + Gifticon(UUID.randomUUID().toString(), "이름", "bbq", "bbq", Date(122, 5, 10), "bar", true, 1, "memo", true), + Gifticon(UUID.randomUUID().toString(), "이름", "bbq", "bbq", Date(150, 10, 20), "bar", true, 1, "memo", true), + Gifticon(UUID.randomUUID().toString(), "이름", "bbq", "bbq", Date(160, 10, 20), "bar", true, 1, "memo", true) + ) + adapter.submitList(gifticonTestData) + binding.viewPagerGifticon.adapter = adapter + } + override fun onClick(overlay: Overlay): Boolean { return true } diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonAdapter.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonAdapter.kt new file mode 100644 index 000000000..e53ffc6a8 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonAdapter.kt @@ -0,0 +1,29 @@ +package com.lighthouse.presentation.ui.map.adapter + +import android.view.ViewGroup +import androidx.recyclerview.widget.DiffUtil +import com.lighthouse.domain.model.Gifticon +import com.lighthouse.presentation.adapter.BindableListAdapter + +class MapGifticonAdapter : BindableListAdapter(Diff) { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MapGifticonItemViewHolder { + return MapGifticonItemViewHolder(parent) + } + + override fun onBindViewHolder(holder: MapGifticonItemViewHolder, position: Int) { + holder.bind(currentList[position]) + } + + companion object { + private val Diff = object : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: Gifticon, newItem: Gifticon): Boolean { + return oldItem.id == newItem.id + } + + override fun areContentsTheSame(oldItem: Gifticon, newItem: Gifticon): Boolean { + return oldItem == newItem + } + } + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonItemViewHolder.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonItemViewHolder.kt new file mode 100644 index 000000000..82c0acc5f --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/map/adapter/MapGifticonItemViewHolder.kt @@ -0,0 +1,20 @@ +package com.lighthouse.presentation.ui.map.adapter + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.lighthouse.domain.model.Gifticon +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.ItemGifticonHorizontalBinding + +class MapGifticonItemViewHolder( + parent: ViewGroup, + private val binding: ItemGifticonHorizontalBinding = ItemGifticonHorizontalBinding.bind( + LayoutInflater.from(parent.context).inflate(R.layout.item_gifticon_horizontal, parent, false) + ) +) : RecyclerView.ViewHolder(binding.root) { + + fun bind(gifticon: Gifticon) { + binding.gifticon = gifticon + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/utils/TimeCalculator.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/utils/TimeCalculator.kt new file mode 100644 index 000000000..dd467c8a3 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/utils/TimeCalculator.kt @@ -0,0 +1,18 @@ +package com.lighthouse.presentation.ui.utils + +object TimeCalculator { + + const val MAX_DAY = 365 + const val MIN_DAY = 0 + + fun formatDdayToInt(endTime: Long): Int { + val today = System.currentTimeMillis() + val diffDate = (endTime - today) / (24 * 60 * 60 * 1000) + + return if (diffDate < MAX_DAY || diffDate > MIN_DAY) { + diffDate.toInt() + } else { + MAX_DAY + } + } +} diff --git a/presentation/src/main/res/layout/activity_map.xml b/presentation/src/main/res/layout/activity_map.xml index 6cac997fd..ce6ef6880 100644 --- a/presentation/src/main/res/layout/activity_map.xml +++ b/presentation/src/main/res/layout/activity_map.xml @@ -21,20 +21,17 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="12dp" - app:layout_constraintBottom_toTopOf="@id/rv_gifticon" + app:layout_constraintBottom_toTopOf="@id/view_pager_gifticon" app:layout_constraintStart_toStartOf="parent" /> - + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/item_gifticon_horizontal.xml b/presentation/src/main/res/layout/item_gifticon_horizontal.xml index f4c983b7c..a429ab7ff 100644 --- a/presentation/src/main/res/layout/item_gifticon_horizontal.xml +++ b/presentation/src/main/res/layout/item_gifticon_horizontal.xml @@ -5,13 +5,15 @@ + @@ -22,11 +24,13 @@ @@ -41,6 +45,7 @@ android:textSize="12sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" + app:setDday="@{gifticon.expireAt}" tools:text="D-31" /> diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index ca6c07f6a..1e2317cf5 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -3,6 +3,8 @@ D-%1$d + D-365+ + 만료 목록 From 86371660ed98e19e2e21c24aab50735396fff65a Mon Sep 17 00:00:00 2001 From: mangbaam Date: Tue, 15 Nov 2022 03:19:21 +0900 Subject: [PATCH 091/929] =?UTF-8?q?Issues=20#19=20style:=20=EA=B8=B0?= =?UTF-8?q?=ED=94=84=ED=8B=B0=EC=BD=98=20=EC=83=81=EC=84=B8=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EA=B0=80=EC=9E=A5=20=EB=B0=91=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EB=B2=84=ED=8A=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/AndroidManifest.xml | 2 + .../presentation/bindingadapter/View.kt | 2 +- .../presentation/extension/LifecycleOwner.kt | 16 + .../presentation/extension/ScrollView.kt | 10 + .../lighthouse/presentation/extension/View.kt | 12 + .../presentation/ui/detailgifticon/Event.kt | 8 + .../detailgifticon/GifticonDetailActivity.kt | 51 ++ .../detailgifticon/GifticonDetailViewModel.kt | 54 ++ .../com/lighthouse/presentation/util/UUID.kt | 7 + .../res/drawable/ic_double_arrow_down.xml | 6 + .../res/layout/activity_gifticon_detail.xml | 661 +++++++++--------- presentation/src/main/res/values/strings.xml | 1 + 12 files changed, 511 insertions(+), 319 deletions(-) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/extension/LifecycleOwner.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/extension/ScrollView.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/extension/View.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/Event.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailActivity.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailViewModel.kt create mode 100644 presentation/src/main/java/com/lighthouse/presentation/util/UUID.kt create mode 100644 presentation/src/main/res/drawable/ic_double_arrow_down.xml diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 048a4a53f..894175e24 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ + + Unit) { + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + block(this) + } + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/extension/ScrollView.kt b/presentation/src/main/java/com/lighthouse/presentation/extension/ScrollView.kt new file mode 100644 index 000000000..b87f8919e --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/extension/ScrollView.kt @@ -0,0 +1,10 @@ +package com.lighthouse.presentation.extension + +import android.view.View +import android.widget.ScrollView + +fun ScrollView.scrollToBottom() { + this.post { + this.fullScroll(View.FOCUS_DOWN) + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/extension/View.kt b/presentation/src/main/java/com/lighthouse/presentation/extension/View.kt new file mode 100644 index 000000000..04d34b810 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/extension/View.kt @@ -0,0 +1,12 @@ +package com.lighthouse.presentation.extension + +import android.view.View + +fun View.isOnScreen(): Boolean { + val viewLocation = IntArray(2) + getLocationOnScreen(viewLocation) + val screenHeight = resources.displayMetrics.heightPixels + val screenWidth = resources.displayMetrics.widthPixels + + return viewLocation[0] in 0..screenWidth && viewLocation[1] in 0..screenHeight +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/Event.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/Event.kt new file mode 100644 index 000000000..ccadf09fb --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/Event.kt @@ -0,0 +1,8 @@ +package com.lighthouse.presentation.ui.detailgifticon + +sealed class Event { + object ScrollDownForUseButtonClicked : Event() + object ShareButtonClicked : Event() + object EditButtonClicked : Event() + object ShowAllUsedInfoButtonClicked : Event() +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailActivity.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailActivity.kt new file mode 100644 index 000000000..b8b7297cf --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailActivity.kt @@ -0,0 +1,51 @@ +package com.lighthouse.presentation.ui.detailgifticon + +import android.os.Bundle +import androidx.activity.viewModels +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.isVisible +import androidx.databinding.DataBindingUtil +import com.lighthouse.presentation.R +import com.lighthouse.presentation.databinding.ActivityGifticonDetailBinding +import com.lighthouse.presentation.extension.isOnScreen +import com.lighthouse.presentation.extension.repeatOnStarted +import com.lighthouse.presentation.extension.scrollToBottom + +class GifticonDetailActivity : AppCompatActivity() { + + private lateinit var binding: ActivityGifticonDetailBinding + private val viewModel: GifticonDetailViewModel by viewModels() + + private val btnUseGifticon by lazy { binding.btnUseGifticon } + private val chip by lazy { binding.chipScrollDownForUseButton } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + binding = DataBindingUtil.setContentView(this, R.layout.activity_gifticon_detail) + binding.lifecycleOwner = this + binding.vm = viewModel + + binding.btnUseGifticon.viewTreeObserver.addOnDrawListener { + chip.post { + chip.isVisible = btnUseGifticon.isOnScreen().not() + chip.invalidate() + } + } + repeatOnStarted { + viewModel.event.collect { event -> + handleEvent(event) + } + } + } + + private fun handleEvent(event: Event) { + when (event) { + is Event.ScrollDownForUseButtonClicked -> { + binding.svGifticonDetail.scrollToBottom() + } + else -> { // TODO(이벤트 처리) + } + } + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailViewModel.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailViewModel.kt new file mode 100644 index 000000000..c25623424 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/detailgifticon/GifticonDetailViewModel.kt @@ -0,0 +1,54 @@ +package com.lighthouse.presentation.ui.detailgifticon + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.lighthouse.domain.model.Gifticon +import com.lighthouse.presentation.util.UUID +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import java.util.Date + +class GifticonDetailViewModel : ViewModel() { + private val _gifticon = MutableStateFlow( + Gifticon( + id = UUID.generate(), + userId = "temp_id", + name = "딸기마카롱설빙", + brand = "설빙", + expireAt = Date(System.currentTimeMillis()), + barcode = "123456781234", + isCashCard = false, + balance = 100, + memo = "", + isUsed = false + ) + ) + val gifticon = _gifticon.asStateFlow() + private val _event = MutableSharedFlow() + val event = _event.asSharedFlow() + + fun scrollDownForUseButtonClicked() { + event(Event.ScrollDownForUseButtonClicked) + } + + fun shareButtonClicked() { + event(Event.ShareButtonClicked) + } + + fun editButtonClicked() { + event(Event.EditButtonClicked) + } + + fun showAllUsedInfoButtonClicked() { + event(Event.ShowAllUsedInfoButtonClicked) + } + + private fun event(event: Event) { + viewModelScope.launch { + _event.emit(event) + } + } +} diff --git a/presentation/src/main/java/com/lighthouse/presentation/util/UUID.kt b/presentation/src/main/java/com/lighthouse/presentation/util/UUID.kt new file mode 100644 index 000000000..ff63240bc --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/util/UUID.kt @@ -0,0 +1,7 @@ +package com.lighthouse.presentation.util + +import java.util.UUID + +object UUID { + fun generate() = UUID.randomUUID().toString() +} diff --git a/presentation/src/main/res/drawable/ic_double_arrow_down.xml b/presentation/src/main/res/drawable/ic_double_arrow_down.xml new file mode 100644 index 000000000..699c5befa --- /dev/null +++ b/presentation/src/main/res/drawable/ic_double_arrow_down.xml @@ -0,0 +1,6 @@ + + + + diff --git a/presentation/src/main/res/layout/activity_gifticon_detail.xml b/presentation/src/main/res/layout/activity_gifticon_detail.xml index fd46c8a41..62d4e4bc4 100644 --- a/presentation/src/main/res/layout/activity_gifticon_detail.xml +++ b/presentation/src/main/res/layout/activity_gifticon_detail.xml @@ -10,326 +10,351 @@ type="com.lighthouse.presentation.ui.detailgifticon.GifticonDetailViewModel" /> - + android:layout_height="match_parent"> - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +