// Path: app/src/main/java/org/parallelzero/hancel/Config.java
// public class Config {
// 
// 	public static final boolean DEBUG=true;    // ==> R E V I S A R  P A R A  T I E N D A S //
// 	public static final boolean DEBUG_SERVICE = true;
// 	public static final boolean DEBUG_LOCATION = false;
// 	public static final boolean DEBUG_TASKS = true;
// 	public static final boolean DEBUG_MAP = true;
// 
// 	//Alert Button
// 	public static final int RESTART_HARDWARE_BUTTON_TIME = 5000;
// 
//     // location
//  	public static final int     TIME_AFTER_START   = 15;  // Start on x seconds after init Scheduler
// 	public static final long    DEFAULT_INTERVAL   = 1000 * 15 * 1;  // Default interval for background service: 3 minutes
// 	public static final long 	DEFAULT_INTERVAL_FASTER = 1000 * 10 * 1;
// 	public static final float   ACCURACY 	= 200;
// 	public static final long    LOCATION_ROUTE_INTERVAL = 1000 * 60;
// 	public static final long    LOCATION_MAP_INTERVAL = 1000 * 120;
// 
// 	public static final int		VIBRATION_TIME_SMS = 500;
// 
// 	public static final String FIREBASE_MAIN = "https://hancel.firebaseio.com";
// 	public static final String FIREBASE_TRANSACTIONS = "tracks";
// 	public static float map_zoom_init = 14;
// }
// 
// Path: app/src/main/java/org/parallelzero/hancel/services/TrackLocationService.java
// public class TrackLocationService extends Service implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener{
// 
//     public static final String TAG = TrackLocationService.class.getSimpleName();
//     private static final boolean DEBUG = Config.DEBUG;
//     public static final String TRACK_SERVICE_CONNECT = "brodcast_onfirebase_connected";
//     public static final String KEY_TRACKID = "key_trackId";
// 
// 
//     private GoogleApiClient mGoogleApiClient;
//     private Location location;
//     private LocationRequest locationRequest;
//     private String trackId;
// 
//     @Override
//     public void onCreate(){
//         startLocationService();
//     }
// 
//     @Override
//     public int onStartCommand(Intent intent,  int flags, int startId){
//         if(DEBUG) Log.i(TAG, "=== OnStartCommand ");
//         this.trackId = Storage.getTrackId(this);
//         sendBroadcast(new Intent(TRACK_SERVICE_CONNECT));
//         return Service.START_STICKY;
//     }
// 
//     @Nullable
//     @Override
//     public IBinder onBind(Intent intent) {
//         return null;
// 
//     }
// 
//     public void onDestroy(){
//         stopLocationService();
//         if(DEBUG)Log.i(TAG, "=== onDestroy");
//     }
// 
// 
//     public void stopLocationService() {
//         if(DEBUG)Log.i(TAG, "=== stopLocationService");
//         if (mGoogleApiClient!=null&&mGoogleApiClient.isConnected()) {
//             mGoogleApiClient.disconnect();
//         }
//     }
// 
//     private void sendDataFrame(Location location) {
//         if(DEBUG)Log.i(TAG, "=== Sending Tracking to server");
//         Track track = new Track();
//         track.lat=location.getLatitude();
//         track.lon=location.getLongitude();
//         track.acu=location.getAccuracy();
//         track.upd=location.getTime();
// 
//         track.alias=Storage.getCurrentAlias(this);
//         track.color=Storage.getCurrentColor(this);
//     }
// 
//     private void setupLocationForMap() {
//         long fastUpdate = Config.DEFAULT_INTERVAL_FASTER;
//         locationRequest = LocationRequest.create();
//         locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
//         locationRequest.setInterval(Config.DEFAULT_INTERVAL);
//         locationRequest.setFastestInterval(fastUpdate);
//     }
// 
//     private synchronized void startLocationService() {
//         if( mGoogleApiClient == null || !mGoogleApiClient.isConnected()) {
//             if(DEBUG)Log.i(TAG, "=== Starting LocationServices: NON CONECTED -> CONECTED");
//             mGoogleApiClient = new GoogleApiClient.Builder(this)
//                     .addApi(LocationServices.API)
//                     .addConnectionCallbacks(this)
//                     .addOnConnectionFailedListener(this)
//                     .build();
//             mGoogleApiClient.connect();
//         }
//         else
//             if(DEBUG)Log.i(TAG, "=== GPS service started: CONECTED");
//     }
// 
//     @Override
//     public void onConnected(Bundle bundle) {
// 
//         setupLocationForMap();
// 
//         if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
//             startLocationUpdates();
//         }
// 
//     }
// 
//     protected void startLocationUpdates() {
//         LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
//     }
// 
//     @Override
//     public void onConnectionSuspended(int i) {
//         if(DEBUG)Log.i(TAG, "=== Connection suspended");
//     }
// 
//     @Override
//     public void onLocationChanged(Location location) {
//         this.location = location;
//         if(DEBUG)Log.i(TAG, "=== onLocationChanged: Latitude: " + this.location.getLatitude() + " Longitude: " + this.location.getLongitude());
//         sendDataFrame(location);
//     }
// 
// 
//     @Override
//     public void onConnectionFailed(ConnectionResult connectionResult) {
//         if(DEBUG)Log.i(TAG, "=== Connection Fail");
//     }
// 
// 
// }


import android.util.Log;
import org.parallelzero.hancel.Config;
import org.parallelzero.hancel.services.TrackLocationService;
package org.parallelzero.hancel.Firebase;


/**
 * Created by Antonio Vanegas @hpsaturn on 11/2/15.
 */
public class FirebaseHandler {

    public static final String TAG = TrackLocationService.class.getSimpleName();
// Path: app/src/main/java/org/parallelzero/hancel/Config.java
// public class Config {
// 
// 	public static final boolean DEBUG=true;    // ==> R E V I S A R  P A R A  T I E N D A S //
// 	public static final boolean DEBUG_SERVICE = true;
// 	public static final boolean DEBUG_LOCATION = false;
// 	public static final boolean DEBUG_TASKS = true;
// 	public static final boolean DEBUG_MAP = true;
// 
// 	//Alert Button
// 	public static final int RESTART_HARDWARE_BUTTON_TIME = 5000;
// 
//     // location
//  	public static final int     TIME_AFTER_START   = 15;  // Start on x seconds after init Scheduler
// 	public static final long    DEFAULT_INTERVAL   = 1000 * 15 * 1;  // Default interval for background service: 3 minutes
// 	public static final long 	DEFAULT_INTERVAL_FASTER = 1000 * 10 * 1;
// 	public static final float   ACCURACY 	= 200;
// 	public static final long    LOCATION_ROUTE_INTERVAL = 1000 * 60;
// 	public static final long    LOCATION_MAP_INTERVAL = 1000 * 120;
// 
// 	public static final int		VIBRATION_TIME_SMS = 500;
// 
// 	public static final String FIREBASE_MAIN = "https://hancel.firebaseio.com";
// 	public static final String FIREBASE_TRANSACTIONS = "tracks";
// 	public static float map_zoom_init = 14;
// }
// 
// Path: app/src/main/java/org/parallelzero/hancel/services/TrackLocationService.java
// public class TrackLocationService extends Service implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener{
// 
//     public static final String TAG = TrackLocationService.class.getSimpleName();
//     private static final boolean DEBUG = Config.DEBUG;
//     public static final String TRACK_SERVICE_CONNECT = "brodcast_onfirebase_connected";
//     public static final String KEY_TRACKID = "key_trackId";
// 
// 
//     private GoogleApiClient mGoogleApiClient;
//     private Location location;
//     private LocationRequest locationRequest;
//     private String trackId;
// 
//     @Override
//     public void onCreate(){
//         startLocationService();
//     }
// 
//     @Override
//     public int onStartCommand(Intent intent,  int flags, int startId){
//         if(DEBUG) Log.i(TAG, "=== OnStartCommand ");
//         this.trackId = Storage.getTrackId(this);
//         sendBroadcast(new Intent(TRACK_SERVICE_CONNECT));
//         return Service.START_STICKY;
//     }
// 
//     @Nullable
//     @Override
//     public IBinder onBind(Intent intent) {
//         return null;
// 
//     }
// 
//     public void onDestroy(){
//         stopLocationService();
//         if(DEBUG)Log.i(TAG, "=== onDestroy");
//     }
// 
// 
//     public void stopLocationService() {
//         if(DEBUG)Log.i(TAG, "=== stopLocationService");
//         if (mGoogleApiClient!=null&&mGoogleApiClient.isConnected()) {
//             mGoogleApiClient.disconnect();
//         }
//     }
// 
//     private void sendDataFrame(Location location) {
//         if(DEBUG)Log.i(TAG, "=== Sending Tracking to server");
//         Track track = new Track();
//         track.lat=location.getLatitude();
//         track.lon=location.getLongitude();
//         track.acu=location.getAccuracy();
//         track.upd=location.getTime();
// 
//         track.alias=Storage.getCurrentAlias(this);
//         track.color=Storage.getCurrentColor(this);
//     }
// 
//     private void setupLocationForMap() {
//         long fastUpdate = Config.DEFAULT_INTERVAL_FASTER;
//         locationRequest = LocationRequest.create();
//         locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
//         locationRequest.setInterval(Config.DEFAULT_INTERVAL);
//         locationRequest.setFastestInterval(fastUpdate);
//     }
// 
//     private synchronized void startLocationService() {
//         if( mGoogleApiClient == null || !mGoogleApiClient.isConnected()) {
//             if(DEBUG)Log.i(TAG, "=== Starting LocationServices: NON CONECTED -> CONECTED");
//             mGoogleApiClient = new GoogleApiClient.Builder(this)
//                     .addApi(LocationServices.API)
//                     .addConnectionCallbacks(this)
//                     .addOnConnectionFailedListener(this)
//                     .build();
//             mGoogleApiClient.connect();
//         }
//         else
//             if(DEBUG)Log.i(TAG, "=== GPS service started: CONECTED");
//     }
// 
//     @Override
//     public void onConnected(Bundle bundle) {
// 
//         setupLocationForMap();
// 
//         if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
//             startLocationUpdates();
//         }
// 
//     }
// 
//     protected void startLocationUpdates() {
//         LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
//     }
// 
//     @Override
//     public void onConnectionSuspended(int i) {
//         if(DEBUG)Log.i(TAG, "=== Connection suspended");
//     }
// 
//     @Override
//     public void onLocationChanged(Location location) {
//         this.location = location;
//         if(DEBUG)Log.i(TAG, "=== onLocationChanged: Latitude: " + this.location.getLatitude() + " Longitude: " + this.location.getLongitude());
//         sendDataFrame(location);
//     }
// 
// 
//     @Override
//     public void onConnectionFailed(ConnectionResult connectionResult) {
//         if(DEBUG)Log.i(TAG, "=== Connection Fail");
//     }
// 
// 
// }


// Path: app/src/main/java/org/parallelzero/hancel/Firebase/FirebaseHandler.java
import android.util.Log;
import org.parallelzero.hancel.Config;
import org.parallelzero.hancel.services.TrackLocationService;

package org.parallelzero.hancel.Firebase;


/**
 * Created by Antonio Vanegas @hpsaturn on 11/2/15.
 */
public class FirebaseHandler {

    public static final String TAG = TrackLocationService.class.getSimpleName();
    private static final boolean DEBUG = Config.DEBUG;