/** * Show the rate dialog if the criteria is satisfied. * @param context Context * @return true if shown, false otherwise. */ public static boolean showRateDialogIfNeeded(final Context context) { if (shouldShowRateDialog()) { showRateDialog(context); return true; } else { return false; } }
/** * Show the rate dialog if the criteria is satisfied. * @param context Context * @param themeId Theme ID * @return true if shown, false otherwise. */ public static boolean showRateDialogIfNeeded(final Context context, int themeId) { if (shouldShowRateDialog()) { showRateDialog(context, themeId); return true; } else { return false; } }
@Test public void shouldRateDialogIfNeeded_LaunchTimeIsCorrect() { Context context = RuntimeEnvironment.application.getApplicationContext(); RateThisApp.init(new RateThisApp.Config(1, 3)); RateThisApp.onStart(context); Assert.assertFalse(RateThisApp.shouldShowRateDialog()); RateThisApp.onStart(context); Assert.assertFalse(RateThisApp.shouldShowRateDialog()); RateThisApp.onStart(context); Assert.assertTrue(RateThisApp.shouldShowRateDialog()); RateThisApp.onStart(context); Assert.assertTrue(RateThisApp.shouldShowRateDialog()); }