Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.kobakei.ratethisapp;

public enum RateConditionsEnum { AND, OR }
32 changes: 21 additions & 11 deletions ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package com.kobakei.ratethisapp;

import java.lang.ref.WeakReference;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
Expand All @@ -36,6 +32,10 @@
import android.util.Log;
import android.view.KeyEvent;

import java.lang.ref.WeakReference;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
* RateThisApp<br>
* A library to show the app rate dialog
Expand Down Expand Up @@ -161,15 +161,20 @@ public static boolean shouldShowRateDialog() {
if (mOptOut) {
return false;
} else {
if (mLaunchTimes >= sConfig.mCriteriaLaunchTimes) {
return true;
}
boolean launchTimesFulfilled = mLaunchTimes >= sConfig.mCriteriaLaunchTimes;

long threshold = TimeUnit.DAYS.toMillis(sConfig.mCriteriaInstallDays); // msec
if (new Date().getTime() - mInstallDate.getTime() >= threshold &&
new Date().getTime() - mAskLaterDate.getTime() >= threshold) {
return true;
boolean installThresholdFulfilled =
new Date().getTime() - mInstallDate.getTime() >= threshold &&
new Date().getTime() - mAskLaterDate.getTime() >= threshold;

boolean answer = false;
switch (sConfig.mCondition) {
case AND: answer = launchTimesFulfilled && installThresholdFulfilled; break;
case OR: answer = launchTimesFulfilled || installThresholdFulfilled; break;
}
return false;

return answer;
}
}

Expand Down Expand Up @@ -400,6 +405,7 @@ public static class Config {
private int mNoButtonId = 0;
private int mCancelButton = 0;
private int mCancelMode = CANCEL_MODE_BACK_KEY_OR_TOUCH_OUTSIDE;
private RateConditionsEnum mCondition = RateConditionsEnum.OR;

/**
* Constructor with default criteria.
Expand Down Expand Up @@ -474,6 +480,10 @@ public void setUrl(String url) {
public void setCancelMode(int cancelMode) {
this.mCancelMode = cancelMode;
}

public void setOrCondition() { this.mCondition = RateConditionsEnum.OR; }

public void setAndCondition(){ this.mCondition = RateConditionsEnum.AND; }
}

/**
Expand Down