mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 05:38:55 +00:00
make review prompt remote configurable
This commit is contained in:
parent
51e58f0183
commit
ded2e1db86
8 changed files with 12 additions and 9 deletions
|
|
@ -129,6 +129,10 @@
|
|||
<key>hideGuilds</key>
|
||||
<value>false</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>enableReviewPrompti </key>
|
||||
<value>false</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>hideChallenges</key>
|
||||
<value>false</value>
|
||||
|
|
|
|||
|
|
@ -167,6 +167,10 @@ class AppConfigManager(contentRepository: ContentRepository?) : com.habitrpg.com
|
|||
return remoteConfig.getBoolean("hideChallenges")
|
||||
}
|
||||
|
||||
fun enableReviewPrompt(): Boolean {
|
||||
return remoteConfig.getBoolean("enableReviewPrompt")
|
||||
}
|
||||
|
||||
fun getBirthdayEvent(): WorldStateEvent? {
|
||||
val events = ((worldState?.events as? List<WorldStateEvent>) ?: listOf(worldState?.currentEvent))
|
||||
return events.firstOrNull { it?.eventKey == "birthday10" && it.end?.after(Date()) == true }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.core.content.edit
|
||||
import com.google.android.play.core.review.ReviewManagerFactory
|
||||
|
||||
class ReviewManager(private val context: Context) {
|
||||
class ReviewManager(context: Context, private val configManager: AppConfigManager) {
|
||||
|
||||
private val reviewManager = ReviewManagerFactory.create(context)
|
||||
private val sharedPref = context.getSharedPreferences("ReviewPrefs", Context.MODE_PRIVATE)
|
||||
|
|
@ -18,6 +18,7 @@ class ReviewManager(private val context: Context) {
|
|||
}
|
||||
|
||||
private fun canRequestReview(currentCheckins: Int): Boolean {
|
||||
if (!configManager.enableReviewPrompt()) return false
|
||||
val initialCheckins = sharedPref.getInt(INITIAL_CHECKINS_KEY, -1)
|
||||
val shouldQueueReview = sharedPref.getBoolean(SHOULD_QUEUE_REVIEW, false)
|
||||
val lastReviewCheckin = sharedPref.getInt(LAST_REVIEW_CHECKIN_KEY, -1)
|
||||
|
|
@ -32,7 +33,6 @@ class ReviewManager(private val context: Context) {
|
|||
|
||||
if (initialCheckins == -1) {
|
||||
// Store the current checkins as the initial value
|
||||
|
||||
sharedPref.edit {
|
||||
putInt(INITIAL_CHECKINS_KEY, currentCheckins)
|
||||
}
|
||||
|
|
@ -87,4 +87,3 @@ class ReviewManager(private val context: Context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class AppModule {
|
|||
}
|
||||
|
||||
@Provides
|
||||
fun providesReviewManager(@ApplicationContext context: Context): ReviewManager {
|
||||
return ReviewManager(context)
|
||||
fun providesReviewManager(@ApplicationContext context: Context, configManager: AppConfigManager): ReviewManager {
|
||||
return ReviewManager(context, configManager)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ class ArmoireActivity : BaseActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
reviewManager = ReviewManager(this)
|
||||
|
||||
binding.goldView.currency = "gold"
|
||||
binding.goldView.animationDuration = 1000
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ class ClassSelectionActivity : BaseActivity() {
|
|||
setSupportActionBar(binding.toolbar)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
reviewManager = ReviewManager(this)
|
||||
|
||||
val args = navArgs<ClassSelectionActivityArgs>().value
|
||||
isClassSelected = args.isClassSelected
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ class FullProfileActivity : BaseActivity() {
|
|||
if (userID.isEmpty()) {
|
||||
userID = intent?.data?.path?.removePrefix("/profile/") ?: ""
|
||||
}
|
||||
reviewManager = ReviewManager(this)
|
||||
|
||||
setTitle(R.string.profile_loading_data)
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,6 @@ open class MainActivity : BaseActivity(), SnackbarActivity {
|
|||
launchTrace?.start()
|
||||
super.onCreate(savedInstanceState)
|
||||
DataBindingUtils.configManager = appConfigManager
|
||||
reviewManager = ReviewManager(this)
|
||||
|
||||
if (!viewModel.isAuthenticated) {
|
||||
val intent = Intent(this, IntroActivity::class.java)
|
||||
|
|
|
|||
Loading…
Reference in a new issue