Skip to content

Commit c585b27

Browse files
Merge pull request codechimp-org#33 from ForestTree/set_cancelable_option
Added setCancelable option to set rating dialog not cancelable (will not...
2 parents a42cd13 + 00497dc commit c585b27

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

AppRater/src/main/java/org/codechimp/apprater/AppRater.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class AppRater {
3232
private static boolean hideNoButton;
3333
private static boolean isVersionNameCheckEnabled;
3434
private static boolean isVersionCodeCheckEnabled;
35+
private static boolean isCancelable = true;
3536

3637
private static Market market = new GoogleMarket();
3738

@@ -83,6 +84,15 @@ public static void setDontRemindButtonVisible(boolean isNoButtonVisible) {
8384
AppRater.hideNoButton = isNoButtonVisible;
8485
}
8586

87+
/**
88+
* sets whether the rating dialog is cancelable or not, default is true.
89+
*
90+
* @param cancelable
91+
*/
92+
public static void setCancelable(boolean cancelable) {
93+
isCancelable = cancelable;
94+
}
95+
8696
/**
8797
* Call this method at the end of your OnCreate method to determine whether
8898
* to show the rate prompt using the specified or default day, launch count
@@ -242,6 +252,8 @@ private static void showRateAlertDialog(final Context context, final SharedPrefe
242252

243253
builder.setMessage(context.getString(R.string.rate_message));
244254

255+
builder.setCancelable(isCancelable);
256+
245257
builder.setPositiveButton(context.getString(R.string.rate),
246258
new DialogInterface.OnClickListener() {
247259
public void onClick(DialogInterface dialog, int id) {
@@ -306,4 +318,4 @@ public static void resetData(Context context) {
306318
editor.putLong(PREF_FIRST_LAUNCHED, date_firstLaunch);
307319
commitOrApply(editor);
308320
}
309-
}
321+
}

0 commit comments

Comments
 (0)