mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-29 03:03:05 -04:00
refactor: move askToRate() to GeeksvilleApplication
This commit is contained in:
@@ -6,11 +6,13 @@ import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.edit
|
||||
import com.geeksville.mesh.analytics.AnalyticsProvider
|
||||
import com.geeksville.mesh.util.exceptionReporter
|
||||
import com.google.android.gms.common.ConnectionResult
|
||||
import com.google.android.gms.common.GoogleApiAvailabilityLight
|
||||
|
||||
import com.suddenh4x.ratingdialog.AppRating
|
||||
|
||||
fun isGooglePlayAvailable(context: Context): Boolean {
|
||||
val a = GoogleApiAvailabilityLight.getInstance()
|
||||
@@ -82,6 +84,19 @@ open class GeeksvilleApplication : Application(), Logging {
|
||||
analytics.setEnabled(value && !isInTestLab) // Never do analytics in the test lab
|
||||
}
|
||||
|
||||
/** Ask user to rate in play store */
|
||||
fun askToRate(activity: AppCompatActivity) {
|
||||
if (!isGooglePlayAvailable(this)) return
|
||||
exceptionReporter { // we don't want to crash our app because of bugs in this optional feature
|
||||
AppRating.Builder(activity)
|
||||
.setMinimumLaunchTimes(10) // default is 5, 3 means app is launched 3 or more times
|
||||
.setMinimumDays(10) // default is 5, 0 means install day, 10 means app is launched 10 or more days later than installation
|
||||
.setMinimumLaunchTimesToShowAgain(5) // default is 5, 1 means app is launched 1 or more times after neutral button clicked
|
||||
.setMinimumDaysToShowAgain(14) // default is 14, 1 means app is launched 1 or more days after neutral button clicked
|
||||
.showIfMeetsConditions()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user