Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fixed In-App Review API problem & update user disease, allergen problem #16

Merged
merged 2 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions app/src/main/java/com/dna/beyoureyes/ui/assign/AssignViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AssignViewModel : ViewModel() {
}

fun clearAllergenSet() {
_allergenSet = null
_allergenSet?.clear()
}

fun addToDiseaseSet(disease: Disease) {
Expand All @@ -77,7 +77,7 @@ class AssignViewModel : ViewModel() {
}

fun clearDiseaseSet() {
_diseaseSet = null
_diseaseSet?.clear()
}

fun setBirth(year: Int, month:Int, day:Int) {
Expand Down Expand Up @@ -136,12 +136,18 @@ class AssignViewModel : ViewModel() {
if (diseaseSet.isNotEmpty()) { // 질환 정보 전달 - enum명으로 DB 저장
AppUser.info?.disease = diseaseSet
updatedInfo["userDisease"] = diseaseSet.map{ it.name }
}else{
AppUser.info?.disease = null
updatedInfo["userDisease"] = null
}
}
_allergenSet?.let { allergenSet ->
if (allergenSet.isNotEmpty()) { // 알레르기 정보 전달 - enum명으로 DB 저장
AppUser.info?.allergens = allergenSet
updatedInfo["userAllergens"] = allergenSet.map{ it.name }
}else{
AppUser.info?.allergens = null
updatedInfo["userAllergens"] = null
}
}
AppUser.id?.let { uid ->
Expand All @@ -164,8 +170,8 @@ class AssignViewModel : ViewModel() {
"userGender" to _gender,
"userBirth" to birthTimeStamp,
"userProfile" to null,
"userDisease" to diseaseSet?.map{ it.name }, // 질환 정보 전달 - enum명으로 DB 저장
"userAllergens" to allergenSet?.map {it.name }, // 알레르기 정보 전달 - enum명으로 DB 저장
"userDisease" to diseaseSet?.map{ it.name }?.ifEmpty { null }, // 질환 정보 전달 - enum명으로 DB 저장
"userAllergens" to allergenSet?.map {it.name }?.ifEmpty { null }, // 알레르기 정보 전달 - enum명으로 DB 저장
"lastActivationDate" to FieldValue.serverTimestamp()
)

Expand Down
37 changes: 14 additions & 23 deletions app/src/main/java/com/dna/beyoureyes/ui/myInfo/MyInfoFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dna.beyoureyes.ui.myInfo

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
Expand Down Expand Up @@ -101,7 +102,7 @@ class MyInfoFragment : Fragment() {
}
// 앱 스토어 리뷰 남기기
binding.reviewBtn.setOnClickListener {
requestReviewInfo()
openPlayStoreReviewPage()

}
// 고객센터 문의하기
Expand Down Expand Up @@ -199,28 +200,18 @@ class MyInfoFragment : Fragment() {
}
}

private fun requestReviewInfo() {
//Testing
//val reviewManager: ReviewManager = FakeReviewManager(requireContext())
val reviewManager: ReviewManager = ReviewManagerFactory.create(requireContext())
val request: Task<ReviewInfo> = reviewManager.requestReviewFlow()

request.addOnCompleteListener { task ->
if (task.isSuccessful) {
val reviewInfo = task.result
reviewManager.launchReviewFlow(requireActivity(), reviewInfo)
.addOnCompleteListener { launchTask ->
if (launchTask.isSuccessful) {
Log.d("ReviewFlow", "Review flow launched successfully.")
} else {
Log.e("ReviewFlowError", "Error launching review flow", launchTask.exception)
}
}

} else {
Log.e("ReviewError", "Error requesting review flow", task.exception)
Toast.makeText(requireContext(), "오류가 발생했습니다. 잠시 후 다시 시도해주세요.", Toast.LENGTH_SHORT).show()
}
private fun openPlayStoreReviewPage() {
val packageName = requireContext().packageName // 앱의 패키지 이름 가져오기
try {
// Google Play Store 앱의 리뷰 페이지 URL 생성 (market:// 방식)
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=$packageName"))
startActivity(intent)
} catch (e: ActivityNotFoundException) {
// Google Play Store 앱이 설치되어 있지 않은 경우, 웹 브라우저로 연결 (https:// 방식)
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=$packageName"))
startActivity(intent)
}
}

Expand Down
Loading