package com.tsi.navi.vo;

import android.content.Context;

import com.tsi.navi.preferences.PrefDefaultValue;
import com.tsi.navi.preferences.PrefManager;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class MapConfig {

    private String type;
    private int trackingZoom;
    private boolean nightMode;

    private int runTilt;
    private int runTrackingDistance;
    private int runDriveDistance;

    public void loadConfig(final Context context) {
        this.type = PrefManager.getMapType(context);
        this.trackingZoom = PrefManager.getMapTrackingZoom(context);
        this.nightMode = PrefManager.getMapNightMode(context);

        this.runTilt = PrefManager.getInt(context, PrefManager.MAP_RUN_TILT, PrefDefaultValue.MAP_RUN_TILT);
        this.runTrackingDistance = PrefManager.getInt(context, PrefManager.MAP_RUN_TRACKING_DISTANCE, PrefDefaultValue.MAP_RUN_TRACKING_DISTANCE);
        this.runDriveDistance = PrefManager.getInt(context, PrefManager.MAP_RUN_DRIVE_DISTANCE, PrefDefaultValue.MAP_RUN_DRIVE_DISTANCE);
    }

    public void saveConfig(final Context context) {
        PrefManager.setMapType(context, this.type);
        PrefManager.setMapTrackingZoom(context, this.trackingZoom);
        PrefManager.setMapNightMode(context, this.nightMode);

        PrefManager.putInt(context, PrefManager.MAP_RUN_TILT, this.runTilt);
        PrefManager.putInt(context, PrefManager.MAP_RUN_TRACKING_DISTANCE, this.runTrackingDistance);
        PrefManager.putInt(context, PrefManager.MAP_RUN_DRIVE_DISTANCE, this.runDriveDistance);
    }
}
