Commit bc7186e2 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Only ask for a rating if the app hasn't crashed in the last 12 hours

parent 6fda5a62
......@@ -95,6 +95,7 @@ fun Context.log(
fun Context.log(e: Throwable, extras: Map<String, String>? = null) {
logErrorSentry(e, extras)
getPreferences().lastCrashTimeStamp = System.currentTimeMillis()
if (Logger.isEnabled(this)) {
Logger.getInstance(this).log(e)
} else {
......
......@@ -134,7 +134,9 @@ class MainActivity : NavigationDrawerActivity() {
dialog.dismiss()
}, null)
} else if(getPreferences().totalAppLaunches > 6 && !getPreferences().hasAskedRateApp
&& Random.nextInt(0, 100) <= 15 && isPackageInstalled(this, "com.android.vending")) {
&& Random.nextInt(0, 100) <= 15 && isPackageInstalled(this, "com.android.vending")
&& getPreferences().lastCrashTimeStamp?.let { System.currentTimeMillis() - it >= 12*60*60*1000 } != false
) {
showInfoTextDialog(this, getString(R.string.dialog_raterequest_title),
getString(R.string.dialog_raterequest_message),
getString(R.string.dialog_join_group_positive) to { dialog, _ ->
......
......@@ -158,6 +158,8 @@ class AppSettingsSharedPreferences(context: Context) : AppSettings, SimpleTypedP
}
})
var lastCrashTimeStamp:Long? by longPref("last_crash_timestamp")
override var hasRatedApp: Boolean by booleanPref("has_rated_app", false)
var hasAskedRateApp:Boolean by booleanPref("asked_rate_app", false)
override var previousInstalledVersion:Int by nonOptionalOf(intPref("previous_version"),true, BuildConfig.VERSION_CODE)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment