package com.androidsx.rateme;

public class CustomShowDialog {
    
private static final String TAG = CustomShowDialog.class.getSimpleName();
    
    private static final String PREF_NAME = "RateThisApp";
    private static final String KEY_INSTALL_DATE = "rta_install_date";
    private static final String KEY_LAUNCH_TIMES = "rta_launch_times";
    private static final String KEY_OPT_OUT = "rta_opt_out";
    
    private static Date mInstallDate = new Date();
    private static int mLaunchTimes = 0;
    private static boolean mOptOut = false;
    
    /**
     * Days after installation until showing rate dialog
     */
    public static final int INSTALL_DAYS = 7;
    /**
     * App launching times until showing rate dialog
     */
    public static final int LAUNCH_TIMES = 5;
    
    /**
     * If true, print LogCat
     */
    public static final boolean DEBUG = false;

}

@@ -24,16 +24,189 @@
 ateme;%0A%0A
+import java.util.Date;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0Aimport android.content.SharedPreferences.Editor;%0Aimport android.util.Log;%0A%0A
 public c
@@ -1051,12 +1051,1152 @@
 = false;
+%0A    %0A    /**%0A     * Call this API when the launcher activity is launched.%3Cbr%3E%0A     * It is better to call this API in onStart() of the launcher activity.%0A     */%0A    public static void onStart(Context context) %7B%0A        %0A        SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);%0A        Editor editor = pref.edit();%0A        // If it is the first launch, save the date in shared preference.%0A        if (pref.getLong(KEY_INSTALL_DATE, 0) == 0L) %7B%0A            Date now = new Date();%0A            editor.putLong(KEY_INSTALL_DATE, now.getTime());%0A            Log.d(TAG, %22First install: %22 + now.toString());%0A        %7D%0A        // Increment launch times%0A        int launchTimes = pref.getInt(KEY_LAUNCH_TIMES, 0);%0A        launchTimes++;%0A        editor.putInt(KEY_LAUNCH_TIMES, launchTimes);%0A        Log.d(TAG, %22Launch times; %22 + launchTimes);%0A        %0A        editor.commit();%0A        %0A        mInstallDate = new Date(pref.getLong(KEY_INSTALL_DATE, 0));%0A        mLaunchTimes = pref.getInt(KEY_LAUNCH_TIMES, 0);%0A        mOptOut = pref.getBoolean(KEY_OPT_OUT, false);%0A        %0A        printStatus(context);%0A    %7D
 %0A%0A%7D%0A

add method onStart