-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/#273] 인앱 리뷰 유도 기능을 구현합니다. #274
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
Changes from 10 commits
236f58c
402cde0
d0e33d4
0cc06d0
8908804
7eb6053
da8f6c4
02cffb4
0fa677f
79a4ba9
1da7261
25d06c6
4e97a13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.sopt.clody.core.review | ||
|
|
||
| import android.app.Activity | ||
| import android.content.Context | ||
| import com.google.android.play.core.review.ReviewManagerFactory | ||
| import com.sopt.clody.presentation.utils.appupdate.AppUpdateUtils | ||
| import timber.log.Timber | ||
|
|
||
| object InAppReviewManager { | ||
| fun showPopup(activity: Activity, context: Context) { | ||
| if (activity.isFinishing || activity.isDestroyed) return | ||
|
|
||
| val reviewManager = ReviewManagerFactory.create(activity) | ||
| val request = reviewManager.requestReviewFlow() | ||
|
|
||
| request.addOnCompleteListener { task -> | ||
| if (task.isSuccessful) { | ||
| val reviewInfo = task.result | ||
| reviewManager.launchReviewFlow(activity, reviewInfo) | ||
| } else { | ||
| try { | ||
| AppUpdateUtils.navigateToMarket(context) | ||
| } catch (e: Exception) { | ||
| e.printStackTrace() | ||
| Timber.e(e, "Failed to open store for app review") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
SYAAINN marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+8
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P4 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.sopt.clody.data.local.datasource | ||
|
|
||
| interface AppReviewLocalDataSource { | ||
| var shouldShowPopup: Boolean | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.sopt.clody.data.local.datasourceimpl | ||
|
|
||
| import android.content.SharedPreferences | ||
| import androidx.core.content.edit | ||
| import com.sopt.clody.data.local.datasource.AppReviewLocalDataSource | ||
| import com.sopt.clody.di.qualifier.ReviewPrefs | ||
| import javax.inject.Inject | ||
|
|
||
| class AppReviewLocalDataSourceImpl @Inject constructor( | ||
| @ReviewPrefs private val sharedPreferences: SharedPreferences, | ||
| ) : AppReviewLocalDataSource { | ||
|
|
||
| override var shouldShowPopup: Boolean | ||
| get() = sharedPreferences.getBoolean(SHOULD_SHOW_POPUP, true) | ||
| set(value) = sharedPreferences.edit { putBoolean(SHOULD_SHOW_POPUP, value) } | ||
|
Comment on lines
+13
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P5 |
||
|
|
||
| companion object { | ||
| private const val SHOULD_SHOW_POPUP = "shouldShowPopup" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.sopt.clody.data.repositoryimpl | ||
|
|
||
| import com.sopt.clody.data.local.datasource.AppReviewLocalDataSource | ||
| import com.sopt.clody.domain.repository.ReviewRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class ReviewRepositoryImpl @Inject constructor( | ||
| private val appReviewLocalDataSource: AppReviewLocalDataSource, | ||
| ) : ReviewRepository { | ||
| override fun getShouldShowPopup(): Boolean = appReviewLocalDataSource.shouldShowPopup | ||
|
|
||
| override fun setShouldShowPopup(state: Boolean) { | ||
| appReviewLocalDataSource.shouldShowPopup = state | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.sopt.clody.di.qualifier | ||
|
|
||
| import javax.inject.Qualifier | ||
|
|
||
| @Qualifier | ||
| @Retention(AnnotationRetention.BINARY) | ||
| annotation class TokenPrefs | ||
|
|
||
| @Qualifier | ||
| @Retention(AnnotationRetention.BINARY) | ||
| annotation class ReviewPrefs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.sopt.clody.domain.repository | ||
|
|
||
| interface ReviewRepository { | ||
| fun getShouldShowPopup(): Boolean | ||
| fun setShouldShowPopup(state: Boolean) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add null check for reviewInfo before launching review flow.
While the task success check is good, you should also validate that
reviewInfois not null before launching the review flow to prevent potential crashes.request.addOnCompleteListener { task -> if (task.isSuccessful) { val reviewInfo = task.result - reviewManager.launchReviewFlow(activity, reviewInfo) + if (reviewInfo != null) { + reviewManager.launchReviewFlow(activity, reviewInfo) + } } else {📝 Committable suggestion
🤖 Prompt for AI Agents