From b922b925908167701b319222771b624f03b6c0e6 Mon Sep 17 00:00:00 2001 From: Adam Fisher Date: Tue, 17 Oct 2017 16:44:20 -0400 Subject: [PATCH] Added setRemindLaunchTimes to allow prompting at launch intervals. --- .../src/main/java/hotchemi/android/rate/AppRate.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/src/main/java/hotchemi/android/rate/AppRate.java b/library/src/main/java/hotchemi/android/rate/AppRate.java index b9a4907..d1c6b5b 100644 --- a/library/src/main/java/hotchemi/android/rate/AppRate.java +++ b/library/src/main/java/hotchemi/android/rate/AppRate.java @@ -28,6 +28,8 @@ public final class AppRate { private int remindInterval = 1; + private int remindLaunchTimes = 0; + private boolean isDebug = false; private AppRate(Context context) { @@ -72,6 +74,11 @@ public AppRate setRemindInterval(int remindInterval) { return this; } + public AppRate setRemindLaunchTimes(int remindLaunchTimes) { + this.remindLaunchTimes = remindLaunchTimes; + return this; + } + public AppRate setShowLaterButton(boolean isShowNeutralButton) { options.setShowNeutralButton(isShowNeutralButton); return this; @@ -189,6 +196,7 @@ public void showRateDialog(Activity activity) { public boolean shouldShowRateDialog() { return getIsAgreeShowDialog(context) && isOverLaunchTimes() && + isOverRemindLaunchTimes() && isOverInstallDate() && isOverRemindDate(); } @@ -197,6 +205,8 @@ private boolean isOverLaunchTimes() { return getLaunchTimes(context) >= launchTimes; } + private boolean isOverRemindLaunchTimes() { return remindLaunchTimes != 0 && getLaunchTimes(context) % remindLaunchTimes == 0; } + private boolean isOverInstallDate() { return isOverDate(getInstallDate(context), installDate); }