mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
review-manager feedback updates
This commit is contained in:
parent
d8ecc40834
commit
6b950ee4a9
8 changed files with 44 additions and 16 deletions
|
|
@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.helpers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.edit
|
||||||
import com.google.android.play.core.review.ReviewManagerFactory
|
import com.google.android.play.core.review.ReviewManagerFactory
|
||||||
|
|
||||||
class ReviewManager(private val context: Context) {
|
class ReviewManager(private val context: Context) {
|
||||||
|
|
@ -24,13 +25,17 @@ class ReviewManager(private val context: Context) {
|
||||||
if (!shouldQueueReview) {
|
if (!shouldQueueReview) {
|
||||||
// First review request has been made, wait for following request (if any)
|
// First review request has been made, wait for following request (if any)
|
||||||
// to request again in the spirit of asking during a logical break.
|
// to request again in the spirit of asking during a logical break.
|
||||||
sharedPref.edit().putBoolean(SHOULD_QUEUE_REVIEW, true).apply()
|
sharedPref.edit {
|
||||||
return false
|
putBoolean(SHOULD_QUEUE_REVIEW, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialCheckins == -1) {
|
if (initialCheckins == -1) {
|
||||||
// Store the current checkins as the initial value
|
// Store the current checkins as the initial value
|
||||||
sharedPref.edit().putInt(INITIAL_CHECKINS_KEY, currentCheckins).apply()
|
|
||||||
|
sharedPref.edit {
|
||||||
|
putInt(INITIAL_CHECKINS_KEY, currentCheckins)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,12 +75,16 @@ class ReviewManager(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the current checkins after a successful review request
|
// Save the current checkins after a successful review request
|
||||||
sharedPref.edit().putInt(LAST_REVIEW_CHECKIN_KEY, currentCheckins).apply()
|
sharedPref.edit {
|
||||||
|
putInt(LAST_REVIEW_CHECKIN_KEY, currentCheckins)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun incrementReviewRequestCount() {
|
private fun incrementReviewRequestCount() {
|
||||||
val currentCount = sharedPref.getInt(REVIEW_REQUEST_COUNT_KEY, 0)
|
val currentCount = sharedPref.getInt(REVIEW_REQUEST_COUNT_KEY, 0)
|
||||||
sharedPref.edit().putInt(REVIEW_REQUEST_COUNT_KEY, currentCount + 1).apply()
|
sharedPref.edit {
|
||||||
|
putInt(REVIEW_REQUEST_COUNT_KEY, currentCount + 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.habitrpg.android.habitica.BuildConfig
|
||||||
import com.habitrpg.android.habitica.data.ApiClient
|
import com.habitrpg.android.habitica.data.ApiClient
|
||||||
import com.habitrpg.android.habitica.data.ContentRepository
|
import com.habitrpg.android.habitica.data.ContentRepository
|
||||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||||
|
import com.habitrpg.android.habitica.helpers.ReviewManager
|
||||||
import com.habitrpg.android.habitica.helpers.SoundFileLoader
|
import com.habitrpg.android.habitica.helpers.SoundFileLoader
|
||||||
import com.habitrpg.android.habitica.helpers.notifications.PushNotificationManager
|
import com.habitrpg.android.habitica.helpers.notifications.PushNotificationManager
|
||||||
import com.habitrpg.common.habitica.helpers.KeyHelper
|
import com.habitrpg.common.habitica.helpers.KeyHelper
|
||||||
|
|
@ -100,4 +101,9 @@ class AppModule {
|
||||||
fun providesRemoteConfigManager(contentRepository: ContentRepository?): AppConfigManager {
|
fun providesRemoteConfigManager(contentRepository: ContentRepository?): AppConfigManager {
|
||||||
return AppConfigManager(contentRepository)
|
return AppConfigManager(contentRepository)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
fun providesReviewManager(@ApplicationContext context: Context): ReviewManager {
|
||||||
|
return ReviewManager(context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ class ArmoireActivity : BaseActivity() {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var userViewModel: MainUserViewModel
|
lateinit var userViewModel: MainUserViewModel
|
||||||
private lateinit var reviewManager: ReviewManager
|
|
||||||
|
@Inject
|
||||||
|
lateinit var reviewManager: ReviewManager
|
||||||
|
|
||||||
override fun getLayoutResId(): Int = R.layout.activity_armoire
|
override fun getLayoutResId(): Int = R.layout.activity_armoire
|
||||||
|
|
||||||
|
|
@ -153,9 +155,8 @@ class ArmoireActivity : BaseActivity() {
|
||||||
|
|
||||||
if (args.type == "gear") {
|
if (args.type == "gear") {
|
||||||
userViewModel.user.observeOnce(this) { user ->
|
userViewModel.user.observeOnce(this) { user ->
|
||||||
val totalCheckIns = user?.loginIncentives
|
user?.loginIncentives?.let { totalCheckins ->
|
||||||
if (totalCheckIns != null) {
|
reviewManager.requestReview(this@ArmoireActivity, totalCheckins)
|
||||||
reviewManager.requestReview(this@ArmoireActivity, totalCheckIns)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ class ClassSelectionActivity : BaseActivity() {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var userViewModel: MainUserViewModel
|
lateinit var userViewModel: MainUserViewModel
|
||||||
private lateinit var reviewManager: ReviewManager
|
|
||||||
|
@Inject
|
||||||
|
lateinit var reviewManager: ReviewManager
|
||||||
|
|
||||||
private lateinit var binding: ActivityClassSelectionBinding
|
private lateinit var binding: ActivityClassSelectionBinding
|
||||||
private var currentClass: String? = null
|
private var currentClass: String? = null
|
||||||
|
|
@ -303,8 +305,9 @@ class ClassSelectionActivity : BaseActivity() {
|
||||||
|
|
||||||
private fun checkForReviewPromptAfterClassSelection() {
|
private fun checkForReviewPromptAfterClassSelection() {
|
||||||
userViewModel.user.observeOnce(this) { user ->
|
userViewModel.user.observeOnce(this) { user ->
|
||||||
val totalCheckIns = user?.loginIncentives ?: return@observeOnce
|
user?.loginIncentives?.let { totalCheckins ->
|
||||||
reviewManager.requestReview(this, totalCheckIns)
|
reviewManager.requestReview(this, totalCheckins)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,9 @@ class FullProfileActivity : BaseActivity() {
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var sharedPrefs: SharedPreferences
|
lateinit var sharedPrefs: SharedPreferences
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var reviewManager: ReviewManager
|
||||||
|
|
||||||
private var userID = ""
|
private var userID = ""
|
||||||
private var username: String? = null
|
private var username: String? = null
|
||||||
private var userDisplayName: String? = null
|
private var userDisplayName: String? = null
|
||||||
|
|
@ -90,7 +93,7 @@ class FullProfileActivity : BaseActivity() {
|
||||||
private val attributeRows = ArrayList<TableRow>()
|
private val attributeRows = ArrayList<TableRow>()
|
||||||
private val dateFormatter = SimpleDateFormat.getDateInstance()
|
private val dateFormatter = SimpleDateFormat.getDateInstance()
|
||||||
private lateinit var binding: ActivityFullProfileBinding
|
private lateinit var binding: ActivityFullProfileBinding
|
||||||
private lateinit var reviewManager: ReviewManager
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,9 @@ open class MainActivity : BaseActivity(), SnackbarActivity {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
internal lateinit var appConfigManager: AppConfigManager
|
internal lateinit var appConfigManager: AppConfigManager
|
||||||
private lateinit var reviewManager: ReviewManager
|
|
||||||
|
@Inject
|
||||||
|
lateinit var reviewManager: ReviewManager
|
||||||
|
|
||||||
lateinit var binding: ActivityMainBinding
|
lateinit var binding: ActivityMainBinding
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ class EquipmentDetailFragment :
|
||||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var userViewModel: MainUserViewModel
|
lateinit var userViewModel: MainUserViewModel
|
||||||
private lateinit var reviewManager: ReviewManager
|
|
||||||
|
@Inject
|
||||||
|
lateinit var reviewManager: ReviewManager
|
||||||
|
|
||||||
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRefreshRecyclerviewBinding {
|
||||||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,9 @@ class PetDetailRecyclerFragment :
|
||||||
private var animalGroup: String? = null
|
private var animalGroup: String? = null
|
||||||
private var animalColor: String? = null
|
private var animalColor: String? = null
|
||||||
internal var layoutManager: androidx.recyclerview.widget.GridLayoutManager? = null
|
internal var layoutManager: androidx.recyclerview.widget.GridLayoutManager? = null
|
||||||
private lateinit var reviewManager: ReviewManager
|
|
||||||
|
@Inject
|
||||||
|
lateinit var reviewManager: ReviewManager
|
||||||
|
|
||||||
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
override var binding: FragmentRefreshRecyclerviewBinding? = null
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue