Android Open Source - RateMyApp Rate My App

From Project

Back to project page RateMyApp.


The source code is released under:

MIT License

If you think the Android project RateMyApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mariosangiorgio.ratemyapp;
/* w  ww  .j  a v  a  2  s  . c  o  m*/
import android.util.Log;

import com.mariosangiorgio.ratemyapp.actions.Action;

public class RateMyApp {
    private final PreferencesManager preferencesManager;
    private final OptionalValue<Integer> daysUntilPrompt;
    private final OptionalValue<Integer> launchesUntilPrompt;
    private final Action action;

            PreferencesManager preferencesManager,
            OptionalValue<Integer> daysUntilPrompt,
            OptionalValue<Integer> launchesUntilPrompt,
            Action action
        if(( daysUntilPrompt.hasValue() && daysUntilPrompt.value() < 0 )  || (launchesUntilPrompt.hasValue() && launchesUntilPrompt.value() < 0))
            throw new IllegalArgumentException("Expected non-negative values");
        this.daysUntilPrompt = daysUntilPrompt;
        this.launchesUntilPrompt = launchesUntilPrompt;
        if(preferencesManager == null){
            throw new IllegalArgumentException("preferences manager should not be null");
        this.preferencesManager = preferencesManager;
        if(action == null){
            throw new IllegalArgumentException("action should not be null");
        this.action = action;

    public void appLaunched(Activity activity){
        Log.i("RateMyApp", "Application launch registered");
        FragmentManager fragmentManager = activity.getFragmentManager();
        if(preferencesManager.alertEnabled() && canShowDialog() && fragmentManager != null){
            action.execute(activity, fragmentManager);

    private boolean launchCounterConditionsMet(){
            return preferencesManager.launchCounter() >= launchesUntilPrompt.value();
            return true;

    private boolean daysElapsedConditionsMet(){
            return preferencesManager.daysFromFirstLaunch() >= daysUntilPrompt.value();
            return true;

    private boolean canShowDialog() {
        return launchCounterConditionsMet() && daysElapsedConditionsMet();

Java Source Code List