// Path: app/src/main/java/org/secuso/privacyfriendlyactivitytracker/models/StepCount.java
// public class StepCount {
// 
//     // from https://github.com/bagilevi/android-pedometer/blob/master/src/name/bagi/levente/pedometer/CaloriesNotifier.java
//     private static double METRIC_RUNNING_FACTOR = 1.02784823;
//     private static double METRIC_WALKING_FACTOR = 0.708;
//     private static double METRIC_AVG_FACTOR = (METRIC_RUNNING_FACTOR + METRIC_WALKING_FACTOR) / 2;
// 
// 
//     private int stepCount;
//     private long startTime;
//     private long endTime;
//     private WalkingMode walkingMode;
// 
//     public int getStepCount() {
//         return stepCount;
//     }
// 
//     public void setStepCount(int stepCount) {
//         this.stepCount = stepCount;
//     }
// 
//     public long getStartTime() {
//         return startTime;
//     }
// 
//     public void setStartTime(long startTime) {
//         this.startTime = startTime;
//     }
// 
//     public long getEndTime() {
//         return endTime;
//     }
// 
//     public void setEndTime(long endTime) {
//         this.endTime = endTime;
//     }
// 
//     public WalkingMode getWalkingMode() {
//         return walkingMode;
//     }
// 
//     public void setWalkingMode(WalkingMode walkingMode) {
//         this.walkingMode = walkingMode;
//     }
// 
//     /**
//      * Gets the distance walked in this interval.
//      *
//      * @return The distance in meters
//      */
//     public double getDistance(){
//         if(getWalkingMode() != null) {
//             return getStepCount() * getWalkingMode().getStepLength();
//         }else{
//             return 0;
//         }
//     }
// 
//     /**
//      * Gets the calories
//      * @return the calories in cal
//      */
//     public double getCalories(Context context){
//         // inspired by https://github.com/bagilevi/android-pedometer/blob/master/src/name/bagi/levente/pedometer/CaloriesNotifier.java
//         SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
//         float bodyWeight = Float.parseFloat(sharedPref.getString(context.getString(R.string.pref_weight),context.getString(R.string.pref_default_weight)));
//         return bodyWeight * METRIC_AVG_FACTOR * UnitHelper.metersToKilometers(getDistance());
//     }
//     @Override
//     public String toString() {
//         SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyy HH:mm:ss");
//         return "StepCount{" + format.format(new Date(startTime)) +
//                 " - " + format.format(new Date(endTime)) +
//                 ": " + stepCount + " @ " + ((walkingMode == null) ? -1 : walkingMode.getId())+
//                 '}';
//     }
// }


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import org.secuso.privacyfriendlyactivitytracker.models.StepCount;
import java.util.ArrayList;
import java.util.List;
     */
    private static SQLiteDatabase getDatabase(StepCountDbHelper instance){
        if(db == null){
            db = instance.getWritableDatabase();
        }
        return db;
    }

    public static void invalidateReference(){
        db = null;
    }

    public StepCountDbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        this.context = context;
    }
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SQL_CREATE_ENTRIES);
    }
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // Fill when upgrading DB
    }
    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        onUpgrade(db, oldVersion, newVersion);
    }

    /**
     * Stores the given StepCount in database. EndTime will be used for KEY_TIMESTAMP.
     * @param stepCount the StepCount to save.
     */
// Path: app/src/main/java/org/secuso/privacyfriendlyactivitytracker/models/StepCount.java
// public class StepCount {
// 
//     // from https://github.com/bagilevi/android-pedometer/blob/master/src/name/bagi/levente/pedometer/CaloriesNotifier.java
//     private static double METRIC_RUNNING_FACTOR = 1.02784823;
//     private static double METRIC_WALKING_FACTOR = 0.708;
//     private static double METRIC_AVG_FACTOR = (METRIC_RUNNING_FACTOR + METRIC_WALKING_FACTOR) / 2;
// 
// 
//     private int stepCount;
//     private long startTime;
//     private long endTime;
//     private WalkingMode walkingMode;
// 
//     public int getStepCount() {
//         return stepCount;
//     }
// 
//     public void setStepCount(int stepCount) {
//         this.stepCount = stepCount;
//     }
// 
//     public long getStartTime() {
//         return startTime;
//     }
// 
//     public void setStartTime(long startTime) {
//         this.startTime = startTime;
//     }
// 
//     public long getEndTime() {
//         return endTime;
//     }
// 
//     public void setEndTime(long endTime) {
//         this.endTime = endTime;
//     }
// 
//     public WalkingMode getWalkingMode() {
//         return walkingMode;
//     }
// 
//     public void setWalkingMode(WalkingMode walkingMode) {
//         this.walkingMode = walkingMode;
//     }
// 
//     /**
//      * Gets the distance walked in this interval.
//      *
//      * @return The distance in meters
//      */
//     public double getDistance(){
//         if(getWalkingMode() != null) {
//             return getStepCount() * getWalkingMode().getStepLength();
//         }else{
//             return 0;
//         }
//     }
// 
//     /**
//      * Gets the calories
//      * @return the calories in cal
//      */
//     public double getCalories(Context context){
//         // inspired by https://github.com/bagilevi/android-pedometer/blob/master/src/name/bagi/levente/pedometer/CaloriesNotifier.java
//         SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
//         float bodyWeight = Float.parseFloat(sharedPref.getString(context.getString(R.string.pref_weight),context.getString(R.string.pref_default_weight)));
//         return bodyWeight * METRIC_AVG_FACTOR * UnitHelper.metersToKilometers(getDistance());
//     }
//     @Override
//     public String toString() {
//         SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyy HH:mm:ss");
//         return "StepCount{" + format.format(new Date(startTime)) +
//                 " - " + format.format(new Date(endTime)) +
//                 ": " + stepCount + " @ " + ((walkingMode == null) ? -1 : walkingMode.getId())+
//                 '}';
//     }
// }


// Path: app/src/main/java/org/secuso/privacyfriendlyactivitytracker/persistence/StepCountDbHelper.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import org.secuso.privacyfriendlyactivitytracker.models.StepCount;
import java.util.ArrayList;
import java.util.List;

     */
    private static SQLiteDatabase getDatabase(StepCountDbHelper instance){
        if(db == null){
            db = instance.getWritableDatabase();
        }
        return db;
    }

    public static void invalidateReference(){
        db = null;
    }

    public StepCountDbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        this.context = context;
    }
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SQL_CREATE_ENTRIES);
    }
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // Fill when upgrading DB
    }
    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        onUpgrade(db, oldVersion, newVersion);
    }

    /**
     * Stores the given StepCount in database. EndTime will be used for KEY_TIMESTAMP.
     * @param stepCount the StepCount to save.
     */
    public void addStepCount(StepCount stepCount){