// Path: src/main/java/com/github/randoapp/db/model/Statistics.java
// public class Statistics implements Serializable {
//     private int likes;
//     private int dislikes;
// 
//     public static Statistics of(int likes, int dislikes) {
//         Statistics statistics = new Statistics();
//         statistics.likes = likes;
//         statistics.dislikes = dislikes;
//         return statistics;
//     }
// 
//     public static Statistics from(JSONObject obj) {
//         Statistics statistics = new Statistics();
//         try {
//             statistics.likes = obj.has(Constants.USER_STATISTICS_LIKES) ? obj.getInt(Constants.USER_STATISTICS_LIKES) : 0;
//             statistics.dislikes = obj.has(Constants.USER_STATISTICS_DISLIKES) ? obj.getInt(Constants.USER_STATISTICS_DISLIKES) : 0;
//         } catch (JSONException e) {
//             e.printStackTrace();
//         }
//         return statistics;
//     }
// 
//     public int getLikes() {
//         return likes;
//     }
// 
//     public void setLikes(int likes) {
//         this.likes = likes;
//     }
// 
//     public int getDislikes() {
//         return dislikes;
//     }
// 
//     public void setDislikes(int dislikes) {
//         this.dislikes = dislikes;
//     }
// }
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String ACCOUNT = "account";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String AUTH_TOKEN = "auth.token";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String BAN_RESET_AT = "main.ban.reset.at";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_FACING_STRING = "camera.facing.string";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_FLASH_MODE = "camera.flash.mode";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_GRID_STRING = "camera.grid.string";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String FIREBASE_INSTANCE_ID = "firebase.instance.id";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String LATITUDE_PARAM = "latitude";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String LOCATION = "location";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String LONGITUDE_PARAM = "longitude";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String PREFERENCES_FILE_NAME = "rando.prefs";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String TRAINING_FRAGMENT_SHOWN = "training.fragment.shown";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String USER_STATISTICS_DISLIKES = "dislikes";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String USER_STATISTICS_LIKES = "likes";


import android.content.Context;
import android.content.SharedPreferences;
import android.location.Location;
import com.github.randoapp.db.model.Statistics;
import com.otaliastudios.cameraview.Facing;
import com.otaliastudios.cameraview.Flash;
import com.otaliastudios.cameraview.Grid;
import static com.github.randoapp.Constants.ACCOUNT;
import static com.github.randoapp.Constants.AUTH_TOKEN;
import static com.github.randoapp.Constants.BAN_RESET_AT;
import static com.github.randoapp.Constants.CAMERA_FACING_STRING;
import static com.github.randoapp.Constants.CAMERA_FLASH_MODE;
import static com.github.randoapp.Constants.CAMERA_GRID_STRING;
import static com.github.randoapp.Constants.FIREBASE_INSTANCE_ID;
import static com.github.randoapp.Constants.LATITUDE_PARAM;
import static com.github.randoapp.Constants.LOCATION;
import static com.github.randoapp.Constants.LONGITUDE_PARAM;
import static com.github.randoapp.Constants.PREFERENCES_FILE_NAME;
import static com.github.randoapp.Constants.TRAINING_FRAGMENT_SHOWN;
import static com.github.randoapp.Constants.USER_STATISTICS_DISLIKES;
import static com.github.randoapp.Constants.USER_STATISTICS_LIKES;

    public static void setAccount(Context context, String token) {
        if (token != null) {
            synchronized (monitor) {
                getSharedPreferences(context).edit().putString(ACCOUNT, token).apply();
            }
        }
    }

    public static void removeAccount(Context context) {
        synchronized (monitor) {
            getSharedPreferences(context).edit().remove(ACCOUNT).apply();
        }
    }

    public static Location getLocation(Context context) {
        Location location = new Location(LOCATION);
        synchronized (monitor) {
            double lat = Double.valueOf(getSharedPreferences(context).getString(LATITUDE_PARAM, "0"));
            double lon = Double.valueOf(getSharedPreferences(context).getString(LONGITUDE_PARAM, "0"));
            location.setLatitude(lat);
            location.setLongitude(lon);
        }
        return location;
    }

    public static void setLocation(Context context, Location location) {
        if (location != null) {
            synchronized (monitor) {
                getSharedPreferences(context).edit().putString(LONGITUDE_PARAM, String.valueOf(location.getLongitude())).apply();
// Path: src/main/java/com/github/randoapp/db/model/Statistics.java
// public class Statistics implements Serializable {
//     private int likes;
//     private int dislikes;
// 
//     public static Statistics of(int likes, int dislikes) {
//         Statistics statistics = new Statistics();
//         statistics.likes = likes;
//         statistics.dislikes = dislikes;
//         return statistics;
//     }
// 
//     public static Statistics from(JSONObject obj) {
//         Statistics statistics = new Statistics();
//         try {
//             statistics.likes = obj.has(Constants.USER_STATISTICS_LIKES) ? obj.getInt(Constants.USER_STATISTICS_LIKES) : 0;
//             statistics.dislikes = obj.has(Constants.USER_STATISTICS_DISLIKES) ? obj.getInt(Constants.USER_STATISTICS_DISLIKES) : 0;
//         } catch (JSONException e) {
//             e.printStackTrace();
//         }
//         return statistics;
//     }
// 
//     public int getLikes() {
//         return likes;
//     }
// 
//     public void setLikes(int likes) {
//         this.likes = likes;
//     }
// 
//     public int getDislikes() {
//         return dislikes;
//     }
// 
//     public void setDislikes(int dislikes) {
//         this.dislikes = dislikes;
//     }
// }
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String ACCOUNT = "account";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String AUTH_TOKEN = "auth.token";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String BAN_RESET_AT = "main.ban.reset.at";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_FACING_STRING = "camera.facing.string";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_FLASH_MODE = "camera.flash.mode";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_GRID_STRING = "camera.grid.string";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String FIREBASE_INSTANCE_ID = "firebase.instance.id";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String LATITUDE_PARAM = "latitude";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String LOCATION = "location";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String LONGITUDE_PARAM = "longitude";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String PREFERENCES_FILE_NAME = "rando.prefs";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String TRAINING_FRAGMENT_SHOWN = "training.fragment.shown";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String USER_STATISTICS_DISLIKES = "dislikes";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String USER_STATISTICS_LIKES = "likes";


// Path: src/main/java/com/github/randoapp/preferences/Preferences.java
import android.content.Context;
import android.content.SharedPreferences;
import android.location.Location;
import com.github.randoapp.db.model.Statistics;
import com.otaliastudios.cameraview.Facing;
import com.otaliastudios.cameraview.Flash;
import com.otaliastudios.cameraview.Grid;
import static com.github.randoapp.Constants.ACCOUNT;
import static com.github.randoapp.Constants.AUTH_TOKEN;
import static com.github.randoapp.Constants.BAN_RESET_AT;
import static com.github.randoapp.Constants.CAMERA_FACING_STRING;
import static com.github.randoapp.Constants.CAMERA_FLASH_MODE;
import static com.github.randoapp.Constants.CAMERA_GRID_STRING;
import static com.github.randoapp.Constants.FIREBASE_INSTANCE_ID;
import static com.github.randoapp.Constants.LATITUDE_PARAM;
import static com.github.randoapp.Constants.LOCATION;
import static com.github.randoapp.Constants.LONGITUDE_PARAM;
import static com.github.randoapp.Constants.PREFERENCES_FILE_NAME;
import static com.github.randoapp.Constants.TRAINING_FRAGMENT_SHOWN;
import static com.github.randoapp.Constants.USER_STATISTICS_DISLIKES;
import static com.github.randoapp.Constants.USER_STATISTICS_LIKES;


    public static void setAccount(Context context, String token) {
        if (token != null) {
            synchronized (monitor) {
                getSharedPreferences(context).edit().putString(ACCOUNT, token).apply();
            }
        }
    }

    public static void removeAccount(Context context) {
        synchronized (monitor) {
            getSharedPreferences(context).edit().remove(ACCOUNT).apply();
        }
    }

    public static Location getLocation(Context context) {
        Location location = new Location(LOCATION);
        synchronized (monitor) {
            double lat = Double.valueOf(getSharedPreferences(context).getString(LATITUDE_PARAM, "0"));
            double lon = Double.valueOf(getSharedPreferences(context).getString(LONGITUDE_PARAM, "0"));
            location.setLatitude(lat);
            location.setLongitude(lon);
        }
        return location;
    }

    public static void setLocation(Context context, Location location) {
        if (location != null) {
            synchronized (monitor) {
                getSharedPreferences(context).edit().putString(LONGITUDE_PARAM, String.valueOf(location.getLongitude())).apply();
                getSharedPreferences(context).edit().putString(LATITUDE_PARAM, String.valueOf(location.getLatitude())).apply();