// Path: Webkiosk/src/main/java/com/blackMonster/webkiosk/controller/RefreshStatus.java
// public enum RefreshStatus {
//     STOPPED,
//     LOGGING_IN,
//     REFRESHING_O,       //refresh avg attendance.
//     REFRESHING_D,       //refreshing detailed attendance.
//     REFRESHING_DATESHEET,
//     CREATING_DB;
// 
//     public static RefreshStatus getEnumFromString(String name) {
//         return RefreshStatus.valueOf(name);
//     }
// 
//     public String getString() {
//         return name();
//     }
// 
//     /**
//      * Returns messages that can be shown in UI for each phase of refresh.
//      * @param context
//      * @return
//      */
//     public static String getStatusMessage(Context context) {
//         switch (RefreshDBPrefs.getStatus(context)) {
// 
//             case REFRESHING_D:
//                 return context.getString(R.string.refreshing_detailed_atnd);
//             case REFRESHING_DATESHEET:
//                 return context.getString(R.string.refreshing_datesheet);
//             default:
//                 return context.getString(R.string.refresh_in_progress);
//         }
//     }
// 
// }


import android.content.Context;
import android.content.SharedPreferences;
import com.blackMonster.webkiosk.controller.RefreshStatus;
package com.blackMonster.webkiosk.SharedPrefs;



/**
 * Current status of database refresher and refresh related other details is stored here.
 */
public class RefreshDBPrefs {

    public static final String REFRESH_SERVICE_STATUS = "refSStatus";


    //Name value is out of sync, would be great if someone could fix it.
    public static final String DETAILED_ATND_TIMESTAMP = "lastUpdate";
    public static final String REFRESH_START_TIMESTAMP = "refreshStartTime";
    public static final String PASSWORD_UPTO_DATE = "passUptoDate";
    public static final String WIFI_ZONE_END_RANDOMIZE_TIME = "wifiZoneEndRandomizeTime";
    private static final String AVG_ATND_TIMESTAMP = "ATND_OVERVIEW_TIMESTAMP";
    public static final String SHOW_RECENTLY_UPDATED_TAG = "showRecentlyUpdatedTag";
    private static final String IS_FIRST_REFRESH = "isFirstRefresh";
    private static final String REFRESH_END_TIMESTAMP = "refreshEndTime";

    public static final int DEFAULT_TIMESTAMP = 0;

    static SharedPreferences prefs = null;

    //Singleton init preference.
    private static void initPrefInstance(Context context) {
        if (prefs == null)
            prefs = context.getApplicationContext().getSharedPreferences(MainPrefs.PREFS_NAME, 0);
    }

    /**
     * Refresher has to use setStatus(..) before doing anything so that other part of app has info what refresher is currently doing.
     * @param status    Current status of refresh
     * @param context   Context
     */
    public static void setStatus(RefreshStatus status, Context context) {
        initPrefInstance(context);
        prefs.edit().putString(REFRESH_SERVICE_STATUS, status.getString()).commit();
    }

    /**
     * Return current status of Refresher.
     * @param context
     * @return RefreshStatus
     */
// Path: Webkiosk/src/main/java/com/blackMonster/webkiosk/controller/RefreshStatus.java
// public enum RefreshStatus {
//     STOPPED,
//     LOGGING_IN,
//     REFRESHING_O,       //refresh avg attendance.
//     REFRESHING_D,       //refreshing detailed attendance.
//     REFRESHING_DATESHEET,
//     CREATING_DB;
// 
//     public static RefreshStatus getEnumFromString(String name) {
//         return RefreshStatus.valueOf(name);
//     }
// 
//     public String getString() {
//         return name();
//     }
// 
//     /**
//      * Returns messages that can be shown in UI for each phase of refresh.
//      * @param context
//      * @return
//      */
//     public static String getStatusMessage(Context context) {
//         switch (RefreshDBPrefs.getStatus(context)) {
// 
//             case REFRESHING_D:
//                 return context.getString(R.string.refreshing_detailed_atnd);
//             case REFRESHING_DATESHEET:
//                 return context.getString(R.string.refreshing_datesheet);
//             default:
//                 return context.getString(R.string.refresh_in_progress);
//         }
//     }
// 
// }


// Path: Webkiosk/src/main/java/com/blackMonster/webkiosk/SharedPrefs/RefreshDBPrefs.java
import android.content.Context;
import android.content.SharedPreferences;
import com.blackMonster.webkiosk.controller.RefreshStatus;

package com.blackMonster.webkiosk.SharedPrefs;



/**
 * Current status of database refresher and refresh related other details is stored here.
 */
public class RefreshDBPrefs {

    public static final String REFRESH_SERVICE_STATUS = "refSStatus";


    //Name value is out of sync, would be great if someone could fix it.
    public static final String DETAILED_ATND_TIMESTAMP = "lastUpdate";
    public static final String REFRESH_START_TIMESTAMP = "refreshStartTime";
    public static final String PASSWORD_UPTO_DATE = "passUptoDate";
    public static final String WIFI_ZONE_END_RANDOMIZE_TIME = "wifiZoneEndRandomizeTime";
    private static final String AVG_ATND_TIMESTAMP = "ATND_OVERVIEW_TIMESTAMP";
    public static final String SHOW_RECENTLY_UPDATED_TAG = "showRecentlyUpdatedTag";
    private static final String IS_FIRST_REFRESH = "isFirstRefresh";
    private static final String REFRESH_END_TIMESTAMP = "refreshEndTime";

    public static final int DEFAULT_TIMESTAMP = 0;

    static SharedPreferences prefs = null;

    //Singleton init preference.
    private static void initPrefInstance(Context context) {
        if (prefs == null)
            prefs = context.getApplicationContext().getSharedPreferences(MainPrefs.PREFS_NAME, 0);
    }

    /**
     * Refresher has to use setStatus(..) before doing anything so that other part of app has info what refresher is currently doing.
     * @param status    Current status of refresh
     * @param context   Context
     */
    public static void setStatus(RefreshStatus status, Context context) {
        initPrefInstance(context);
        prefs.edit().putString(REFRESH_SERVICE_STATUS, status.getString()).commit();
    }

    /**
     * Return current status of Refresher.
     * @param context
     * @return RefreshStatus
     */
    public static RefreshStatus getStatus(Context context) {