@@ -0,0 +1,2448 @@
+package com.stefanhoth.ropasclisp.achievements;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0A%0Aimport java.text.DateFormat;%0Aimport java.util.Date;%0Aimport java.util.Locale;%0A%0Aimport static android.content.Context.MODE_PRIVATE;%0A%0Apublic final class DAILY_STATE %7B%0A%0A    private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);%0A    public static final int NO_STARTS = 0;%0A%0A    public static DAILY_STATE with(Context context) %7B%0A        return new DAILY_STATE(context);%0A    %7D%0A%0A    private static String PREFERENCE_NAME = %22DAILY_STATE%22;%0A    private static String KEY_TODAYS_DATE = DAILY_STATE.class.getName() + %22.TODAYS_DATE%22;%0A    private static String KEY_TODAYS_STARTS = DAILY_STATE.class.getName() + %22.TODAYS_STARTS%22;%0A%0A    private final Context context;%0A%0A    private DAILY_STATE(Context context) %7B%0A        this.context = context;%0A    %7D%0A%0A    public boolean isTodaysFirstStart() %7B%0A%0A        if(! hasPreviousEntriesFromToday())%7B%0A            return false;%0A        %7D%0A%0A        return NO_STARTS == getTodaysStarts();%0A    %7D%0A%0A    int getTodaysStarts() %7B%0A        return getSharedPreferences().getInt(KEY_TODAYS_STARTS, NO_STARTS);%0A    %7D%0A%0A    public void countAppStart() %7B%0A        SharedPreferences preferences = getSharedPreferences();%0A        int starts = getTodaysStarts();%0A%0A        preferences.edit()%0A                .putInt(KEY_TODAYS_STARTS, starts + 1)%0A                .apply();%0A    %7D%0A%0A    private synchronized SharedPreferences getSharedPreferences() %7B%0A%0A        return context.getSharedPreferences(PREFERENCE_NAME, MODE_PRIVATE);%0A    %7D%0A%0A    private boolean hasPreviousEntriesFromToday() %7B%0A%0A        String currentDate = getCurrentDateString();%0A        SharedPreferences preferences = getSharedPreferences();%0A%0A        if(currentDate.equals(preferences.getString(KEY_TODAYS_DATE, %22NEVER_MATCH%22)))%7B%0A            return true;%0A        %7D%0A%0A        cleanupOldData(preferences);%0A        createNewDayEntry(preferences);%0A        return false;%0A    %7D%0A%0A    private void createNewDayEntry(SharedPreferences preferences) %7B%0A        preferences.edit()%0A                .putString(KEY_TODAYS_DATE, getCurrentDateString())%0A                .apply();%0A    %7D%0A%0A    private String getCurrentDateString() %7B%0A%0A        return DATE_FORMAT.format(new Date());%0A    %7D%0A%0A    private void cleanupOldData(SharedPreferences preferences) %7B%0A%0A        preferences.edit()%0A                .clear()%0A                .apply();%0A    %7D%0A%0A%7D%0A

Add class for encapsulating state for daily session data