Skip to content

Commit

Permalink
Disable Google Play functions, as in our case it conflicts with the o…
Browse files Browse the repository at this point in the history
…ther library.
  • Loading branch information
tomekit committed Jan 22, 2023
1 parent 406722a commit 0c5f425
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
disable 'InvalidPackage'
}
dependencies {
implementation 'com.google.android.play:core:1.8.0'
// implementation 'com.google.android.play:core:1.8.0'
}
}

Expand Down
86 changes: 43 additions & 43 deletions android/src/main/kotlin/fr/skyost/rate_my_app/RateMyAppPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import androidx.annotation.NonNull
import com.google.android.play.core.review.ReviewInfo
import com.google.android.play.core.review.ReviewManager
import com.google.android.play.core.review.ReviewManagerFactory
//import com.google.android.play.core.review.ReviewInfo
//import com.google.android.play.core.review.ReviewManager
//import com.google.android.play.core.review.ReviewManagerFactory
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
Expand All @@ -27,7 +27,7 @@ public class RateMyAppPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
private var context: Context? = null
private lateinit var channel: MethodChannel

private var reviewInfo: ReviewInfo? = null
// private var reviewInfo: ReviewInfo? = null

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "rate_my_app")
Expand All @@ -42,7 +42,7 @@ public class RateMyAppPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || !isPlayStoreInstalled()) {
result.success(false)
} else {
cacheReviewInfo(result)
// cacheReviewInfo(result)
}
}
"launchStore" -> result.success(goToPlayStore(call.argument<String>("appId")))
Expand Down Expand Up @@ -77,22 +77,22 @@ public class RateMyAppPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
* @param result The method channel result object.
*/

private fun cacheReviewInfo(result: Result) {
if (context == null) {
result.error("context_is_null", "Android context not available.", null)
return
}
val manager = ReviewManagerFactory.create(context!!)
val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
reviewInfo = task.result
result.success(true)
} else {
result.success(false)
}
}
}
// private fun cacheReviewInfo(result: Result) {
// if (context == null) {
// result.error("context_is_null", "Android context not available.", null)
// return
// }
// val manager = ReviewManagerFactory.create(context!!)
// val request = manager.requestReviewFlow()
// request.addOnCompleteListener { task ->
// if (task.isSuccessful) {
// reviewInfo = task.result
// result.success(true)
// } else {
// result.success(false)
// }
// }
// }

/**
* Requests a review.
Expand All @@ -108,19 +108,19 @@ public class RateMyAppPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
if (activity == null) {
result.error("activity_is_null", "Android activity not available.", null)
}
val manager = ReviewManagerFactory.create(context!!)
if (reviewInfo != null) {
launchReviewFlow(result, manager, reviewInfo!!)
return
}
val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
when {
task.isSuccessful -> launchReviewFlow(result, manager, task.result)
task.exception != null -> result.error(task.exception!!.javaClass.name, task.exception!!.localizedMessage, null)
else -> result.success(false)
}
}
// val manager = ReviewManagerFactory.create(context!!)
// if (reviewInfo != null) {
// launchReviewFlow(result, manager, reviewInfo!!)
// return
// }
// val request = manager.requestReviewFlow()
// request.addOnCompleteListener { task ->
// when {
// task.isSuccessful -> launchReviewFlow(result, manager, task.result)
// task.exception != null -> result.error(task.exception!!.javaClass.name, task.exception!!.localizedMessage, null)
// else -> result.success(false)
// }
// }
}

/**
Expand All @@ -131,15 +131,15 @@ public class RateMyAppPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
* @param reviewInfo The review info object.
*/

private fun launchReviewFlow(result: Result, manager: ReviewManager, reviewInfo: ReviewInfo) {
val flow = manager.launchReviewFlow(activity!!, reviewInfo)
flow.addOnCompleteListener { task ->
run {
this.reviewInfo = null
result.success(task.isSuccessful)
}
}
}
// private fun launchReviewFlow(result: Result, manager: ReviewManager, reviewInfo: ReviewInfo) {
// val flow = manager.launchReviewFlow(activity!!, reviewInfo)
// flow.addOnCompleteListener { task ->
// run {
// this.reviewInfo = null
// result.success(task.isSuccessful)
// }
// }
// }

/**
* Returns whether the Play Store is installed on the current device.
Expand Down

0 comments on commit 0c5f425

Please sign in to comment.