File tree Expand file tree Collapse file tree 17 files changed +145
-7
lines changed
src/main/java/com/sopt/clody Expand file tree Collapse file tree 17 files changed +145
-7
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,9 @@ dependencies {
123123 // Mavericks
124124 implementation(libs.bundles.mavericks)
125125
126+ // Play Store
127+ implementation(libs.bundles.plays)
128+
126129 // ETC
127130 implementation(libs.timber)
128131 implementation(libs.lottie.compose)
Original file line number Diff line number Diff line change 1+ package com.sopt.clody.core.review
2+
3+ import android.app.Activity
4+ import com.google.android.play.core.review.ReviewManagerFactory
5+ import com.sopt.clody.presentation.utils.appupdate.AppUpdateUtils
6+ import timber.log.Timber
7+
8+ object InAppReviewManager {
9+ fun showPopup (activity : Activity ) {
10+ if (activity.isFinishing || activity.isDestroyed) return
11+
12+ val reviewManager = ReviewManagerFactory .create(activity)
13+ val request = reviewManager.requestReviewFlow()
14+
15+ request.addOnCompleteListener { task ->
16+ if (task.isSuccessful) {
17+ val reviewInfo = task.result
18+ reviewManager.launchReviewFlow(activity, reviewInfo)
19+ } else {
20+ try {
21+ AppUpdateUtils .navigateToMarket(activity)
22+ } catch (e: Exception ) {
23+ e.printStackTrace()
24+ Timber .e(e, " Failed to open store for app review" )
25+ }
26+ }
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ package com.sopt.clody.data.local.datasource
2+
3+ interface AppReviewLocalDataSource {
4+ var shouldShowPopup: Boolean
5+ }
Original file line number Diff line number Diff line change 1+ package com.sopt.clody.data.local.datasourceimpl
2+
3+ import android.content.SharedPreferences
4+ import androidx.core.content.edit
5+ import com.sopt.clody.data.local.datasource.AppReviewLocalDataSource
6+ import com.sopt.clody.di.qualifier.ReviewPrefs
7+ import javax.inject.Inject
8+
9+ class AppReviewLocalDataSourceImpl @Inject constructor(
10+ @ReviewPrefs private val sharedPreferences : SharedPreferences ,
11+ ) : AppReviewLocalDataSource {
12+
13+ override var shouldShowPopup: Boolean
14+ get() = sharedPreferences.getBoolean(SHOULD_SHOW_POPUP , true )
15+ set(value) = sharedPreferences.edit { putBoolean(SHOULD_SHOW_POPUP , value) }
16+
17+ companion object {
18+ private const val SHOULD_SHOW_POPUP = " shouldShowPopup"
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ package com.sopt.clody.data.repositoryimpl
2+
3+ import com.sopt.clody.data.local.datasource.AppReviewLocalDataSource
4+ import com.sopt.clody.domain.repository.ReviewRepository
5+ import javax.inject.Inject
6+
7+ class ReviewRepositoryImpl @Inject constructor(
8+ private val appReviewLocalDataSource : AppReviewLocalDataSource ,
9+ ) : ReviewRepository {
10+ override fun getShouldShowPopup (): Boolean = appReviewLocalDataSource.shouldShowPopup
11+
12+ override fun setShouldShowPopup (state : Boolean ) {
13+ appReviewLocalDataSource.shouldShowPopup = state
14+ }
15+ }
Original file line number Diff line number Diff line change @@ -3,9 +3,12 @@ package com.sopt.clody.di
33import android.content.SharedPreferences
44import com.sopt.clody.data.datastore.TokenDataStore
55import com.sopt.clody.data.datastore.TokenDataStoreImpl
6+ import com.sopt.clody.data.local.datasource.AppReviewLocalDataSource
67import com.sopt.clody.data.local.datasource.FirstDraftLocalDataSource
8+ import com.sopt.clody.data.local.datasourceimpl.AppReviewLocalDataSourceImpl
79import com.sopt.clody.data.local.datasourceimpl.FirstDraftLocalDataSourceImpl
810import com.sopt.clody.di.qualifier.FirstDraftPrefs
11+ import com.sopt.clody.di.qualifier.ReviewPrefs
912import com.sopt.clody.di.qualifier.TokenPrefs
1013import dagger.Module
1114import dagger.Provides
@@ -26,4 +29,9 @@ object LocalDataSourceModule {
2629 @Singleton
2730 fun provideFirstDraftLocalDataSource (@FirstDraftPrefs sharedPreferences : SharedPreferences ): FirstDraftLocalDataSource =
2831 FirstDraftLocalDataSourceImpl (sharedPreferences)
32+
33+ @Provides
34+ @Singleton
35+ fun provideAppReviewLocalDataSource (@ReviewPrefs sharedPreferences : SharedPreferences ): AppReviewLocalDataSource =
36+ AppReviewLocalDataSourceImpl (sharedPreferences)
2937}
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import com.sopt.clody.data.repositoryimpl.AuthRepositoryImpl
66import com.sopt.clody.data.repositoryimpl.DiaryRepositoryImpl
77import com.sopt.clody.data.repositoryimpl.DraftRepositoryImpl
88import com.sopt.clody.data.repositoryimpl.NotificationRepositoryImpl
9+ import com.sopt.clody.data.repositoryimpl.ReviewRepositoryImpl
910import com.sopt.clody.data.repositoryimpl.TokenReissueRepositoryImpl
1011import com.sopt.clody.data.repositoryimpl.TokenRepositoryImpl
1112import com.sopt.clody.domain.repository.AccountManagementRepository
@@ -14,6 +15,7 @@ import com.sopt.clody.domain.repository.AuthRepository
1415import com.sopt.clody.domain.repository.DiaryRepository
1516import com.sopt.clody.domain.repository.DraftRepository
1617import com.sopt.clody.domain.repository.NotificationRepository
18+ import com.sopt.clody.domain.repository.ReviewRepository
1719import com.sopt.clody.domain.repository.TokenReissueRepository
1820import com.sopt.clody.domain.repository.TokenRepository
1921import dagger.Binds
@@ -72,4 +74,10 @@ abstract class RepositoryModule {
7274 abstract fun bindDraftRepository (
7375 draftRepositoryImpl : DraftRepositoryImpl ,
7476 ): DraftRepository
77+
78+ @Binds
79+ @Singleton
80+ abstract fun bindReviewRepository (
81+ reviewRepositoryImpl : ReviewRepositoryImpl ,
82+ ): ReviewRepository
7583}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.sopt.clody.di
33import android.content.Context
44import android.content.SharedPreferences
55import com.sopt.clody.di.qualifier.FirstDraftPrefs
6+ import com.sopt.clody.di.qualifier.ReviewPrefs
67import com.sopt.clody.di.qualifier.TokenPrefs
78import dagger.Module
89import dagger.Provides
@@ -15,17 +16,24 @@ import javax.inject.Singleton
1516@InstallIn(SingletonComponent ::class )
1617object SharedPreferencesModule {
1718
18- @TokenPrefs
1919 @Provides
2020 @Singleton
21+ @TokenPrefs
2122 fun provideTokenSharedPreferences (@ApplicationContext context : Context ): SharedPreferences {
2223 return context.getSharedPreferences(" token_prefs" , Context .MODE_PRIVATE )
2324 }
2425
25- @FirstDraftPrefs
2626 @Provides
2727 @Singleton
28+ @FirstDraftPrefs
2829 fun provideFirstDraftSharedPreferences (@ApplicationContext context : Context ): SharedPreferences {
2930 return context.getSharedPreferences(" first_draft_prefs" , Context .MODE_PRIVATE )
3031 }
32+
33+ @Provides
34+ @Singleton
35+ @ReviewPrefs
36+ fun provideReviewSharedPreferences (@ApplicationContext context : Context ): SharedPreferences {
37+ return context.getSharedPreferences(" review_prefs" , Context .MODE_PRIVATE )
38+ }
3139}
Original file line number Diff line number Diff line change @@ -9,3 +9,7 @@ annotation class TokenPrefs
99@Qualifier
1010@Retention(AnnotationRetention .BINARY )
1111annotation class FirstDraftPrefs
12+
13+ @Qualifier
14+ @Retention(AnnotationRetention .BINARY )
15+ annotation class ReviewPrefs
Original file line number Diff line number Diff line change 1+ package com.sopt.clody.domain.repository
2+
3+ interface ReviewRepository {
4+ fun getShouldShowPopup (): Boolean
5+ fun setShouldShowPopup (state : Boolean )
6+ }
You can’t perform that action at this time.
0 commit comments