Fixed showing app rate
This commit is contained in:
parent
fdfedf274f
commit
f56b158e78
1 changed files with 9 additions and 6 deletions
|
@ -33,7 +33,7 @@ object AppRater {
|
||||||
private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches
|
private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun appLaunched(context: Context) {
|
fun appLaunched(context: Activity) {
|
||||||
val prefs = context.getSharedPreferences(APP_RATING, 0)
|
val prefs = context.getSharedPreferences(APP_RATING, 0)
|
||||||
if (prefs.getBoolean(DO_NOT_SHOW_AGAIN, false)) {
|
if (prefs.getBoolean(DO_NOT_SHOW_AGAIN, false)) {
|
||||||
return
|
return
|
||||||
|
@ -56,21 +56,24 @@ object AppRater {
|
||||||
if (launchCount >= LAUNCHES_UNTIL_PROMPT) {
|
if (launchCount >= LAUNCHES_UNTIL_PROMPT) {
|
||||||
if (System.currentTimeMillis() >= dateFirstLaunch + DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000) {
|
if (System.currentTimeMillis() >= dateFirstLaunch + DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000) {
|
||||||
//showRateDialog(context, editor)
|
//showRateDialog(context, editor)
|
||||||
showPlayStoreReviewDialog(context)
|
showPlayStoreReviewDialog(context, editor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.commit()
|
editor.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showPlayStoreReviewDialog(context: Context) {
|
private fun showPlayStoreReviewDialog(context: Activity, editor: SharedPreferences.Editor) {
|
||||||
val manager = ReviewManagerFactory.create(context)
|
val manager = ReviewManagerFactory.create(context)
|
||||||
manager.requestReviewFlow().addOnCompleteListener { request ->
|
val flow = manager.requestReviewFlow()
|
||||||
|
flow.addOnCompleteListener { request ->
|
||||||
if (request.isSuccessful) {
|
if (request.isSuccessful) {
|
||||||
val reviewInfo = request.result
|
val reviewInfo = request.result
|
||||||
manager.launchReviewFlow(context as Activity, reviewInfo).addOnCompleteListener {
|
val flowManager = manager.launchReviewFlow(context, reviewInfo)
|
||||||
|
flowManager.addOnCompleteListener {
|
||||||
if (it.isSuccessful) {
|
if (it.isSuccessful) {
|
||||||
//Toast.makeText(context, "Thanks for the feedback", Toast.LENGTH_SHORT).show()
|
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||||
|
editor.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue