show the Rate Us prompt after 1003 launches, never again
This commit is contained in:
parent
4f320de1e0
commit
7ee7fa3e22
7 changed files with 37 additions and 3 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
|||
propMinSdkVersion = 21
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '5.11.0'
|
||||
propVersionName = '5.11.2'
|
||||
kotlin_version = '1.3.21'
|
||||
}
|
||||
|
||||
|
|
|
@ -185,6 +185,4 @@ class AboutActivity : BaseSimpleActivity() {
|
|||
val year = Calendar.getInstance().get(Calendar.YEAR)
|
||||
about_copyright.text = String.format(getString(R.string.copyright), versionName, year)
|
||||
}
|
||||
|
||||
private fun getStoreUrl() = "https://play.google.com/store/apps/details?id=${packageName.removeSuffix(".debug")}"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.simplemobiletools.commons.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.extensions.getStoreUrl
|
||||
import com.simplemobiletools.commons.extensions.launchViewIntent
|
||||
|
||||
class RateUsDialog(val activity: Activity) {
|
||||
|
||||
init {
|
||||
ConfirmationDialog(activity, "", R.string.rate_us_prompt, R.string.rate, R.string.cancel) {
|
||||
launchGooglePlay()
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchGooglePlay() {
|
||||
try {
|
||||
activity.launchViewIntent("market://details?id=${activity.packageName.removeSuffix(".debug")}")
|
||||
} catch (ignored: ActivityNotFoundException) {
|
||||
activity.launchViewIntent(activity.getStoreUrl())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -69,6 +69,11 @@ fun Activity.appLaunched(appId: String) {
|
|||
if (baseConfig.appRunCount % 50 == 0 && !isAProApp()) {
|
||||
showDonateOrUpgradeDialog()
|
||||
}
|
||||
|
||||
if (baseConfig.appRunCount > 1003 && !baseConfig.wasRateUsPromptShown) {
|
||||
baseConfig.wasRateUsPromptShown = true
|
||||
RateUsDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.showDonateOrUpgradeDialog() {
|
||||
|
|
|
@ -604,6 +604,8 @@ fun Context.getCanAppBeUpgraded() = proPackages.contains(baseConfig.appId.remove
|
|||
|
||||
fun Context.getProUrl() = "https://play.google.com/store/apps/details?id=${baseConfig.appId.removeSuffix(".debug")}.pro"
|
||||
|
||||
fun Context.getStoreUrl() = "https://play.google.com/store/apps/details?id=${packageName.removeSuffix(".debug")}"
|
||||
|
||||
fun Context.getTimeFormat() = if (baseConfig.use24HourFormat) TIME_FORMAT_24 else TIME_FORMAT_12
|
||||
|
||||
fun Context.getResolution(path: String): Point? {
|
||||
|
|
|
@ -310,4 +310,8 @@ open class BaseConfig(val context: Context) {
|
|||
var wasUpgradedFromFreeShown: Boolean
|
||||
get() = prefs.getBoolean(WAS_UPGRADED_FROM_FREE_SHOWN, false)
|
||||
set(wasUpgradedFromFreeShown) = prefs.edit().putBoolean(WAS_UPGRADED_FROM_FREE_SHOWN, wasUpgradedFromFreeShown).apply()
|
||||
|
||||
var wasRateUsPromptShown: Boolean
|
||||
get() = prefs.getBoolean(WAS_RATE_US_PROMPT_SHOWN, false)
|
||||
set(wasRateUsPromptShown) = prefs.edit().putBoolean(WAS_RATE_US_PROMPT_SHOWN, wasRateUsPromptShown).apply()
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ const val APP_SIDELOADING_STATUS = "app_sideloading_status"
|
|||
const val DATE_FORMAT = "date_format"
|
||||
const val WAS_OTG_HANDLED = "was_otg_handled_2"
|
||||
const val WAS_UPGRADED_FROM_FREE_SHOWN = "was_upgraded_from_free_shown"
|
||||
const val WAS_RATE_US_PROMPT_SHOWN = "was_rate_us_prompt_shown"
|
||||
|
||||
// licenses
|
||||
internal const val LICENSE_KOTLIN = 1
|
||||
|
|
Loading…
Reference in a new issue