diff --git a/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt b/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt index 8b12c41e..ded848d2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt @@ -33,7 +33,7 @@ object AppRater { private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches @JvmStatic - fun appLaunched(context: Context) { + fun appLaunched(context: Activity) { val prefs = context.getSharedPreferences(APP_RATING, 0) if (prefs.getBoolean(DO_NOT_SHOW_AGAIN, false)) { return @@ -56,21 +56,24 @@ object AppRater { if (launchCount >= LAUNCHES_UNTIL_PROMPT) { if (System.currentTimeMillis() >= dateFirstLaunch + DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000) { //showRateDialog(context, editor) - showPlayStoreReviewDialog(context) + showPlayStoreReviewDialog(context, editor) } } editor.commit() } - private fun showPlayStoreReviewDialog(context: Context) { + private fun showPlayStoreReviewDialog(context: Activity, editor: SharedPreferences.Editor) { val manager = ReviewManagerFactory.create(context) - manager.requestReviewFlow().addOnCompleteListener { request -> + val flow = manager.requestReviewFlow() + flow.addOnCompleteListener { request -> if (request.isSuccessful) { val reviewInfo = request.result - manager.launchReviewFlow(context as Activity, reviewInfo).addOnCompleteListener { + val flowManager = manager.launchReviewFlow(context, reviewInfo) + flowManager.addOnCompleteListener { if (it.isSuccessful) { - //Toast.makeText(context, "Thanks for the feedback", Toast.LENGTH_SHORT).show() + editor.putBoolean(DO_NOT_SHOW_AGAIN, true) + editor.commit() } } }