@@ -0,0 +1,2801 @@
+package com.revo.display.sensors;%0A%0Aimport android.content.Context;%0Aimport android.location.Location;%0Aimport android.location.LocationListener;%0Aimport android.location.LocationManager;%0Aimport android.os.Bundle;%0A%0Aimport com.revo.display.network.ValueCallback;%0A%0Aimport java.util.ArrayList;%0A%0A%0A/**%0A * Created by isaac on 1/31/15.%0A */%0Apublic class GPSSensor implements LocationListener %7B%0A    private static final long TIME_LIMIT = 5;%0A    // TODO: I have no idea if this value is reasonable%0A    private static final long ACCURACY_LIMIT = 100;%0A%0A    private Context context;%0A    private LocationManager locationManager;%0A    private Location currentLocation;%0A    private ArrayList%3CValueCallback%3E listeners;%0A%0A    public GPSSensor(Context context) %7B%0A        this.context = context;%0A        locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);%0A        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);%0A        listeners = new ArrayList%3CValueCallback%3E();%0A    %7D%0A%0A    /**%0A     * Returns the more accurate location based on time and accuracy%0A     * @param newLoc the newer Location%0A     * @param oldLoc the older Location%0A     * @return the %22better%22 location%0A     */%0A    private Location betterLocation(Location oldLoc, Location newLoc) %7B%0A        // Check for null Locations%0A        if (newLoc == null && oldLoc == null) return null;%0A        if (newLoc == null) return oldLoc;%0A        if (oldLoc == null) return newLoc;%0A%0A        long timeDiff = newLoc.getTime() - oldLoc.getTime();%0A        boolean muchNewer = timeDiff %3E TIME_LIMIT;%0A        boolean newer = timeDiff %3E= 0;%0A%0A        float accuracyDiff = newLoc.getAccuracy() - oldLoc.getAccuracy();%0A        boolean muchLessAccurate = accuracyDiff %3C -ACCURACY_LIMIT;%0A        boolean moreAccurate = accuracyDiff %3E= 0;%0A%0A        if (muchNewer && moreAccurate) return newLoc;%0A        else if (newer && moreAccurate) return newLoc;%0A        else if (muchNewer && !muchLessAccurate) return newLoc;%0A        else return oldLoc;%0A    %7D%0A%0A    public void registerListener(ValueCallback callback) %7B%0A        listeners.add(callback);%0A    %7D%0A%0A    public void deregisterListener(ValueCallback callback) %7B%0A        listeners.remove(callback);%0A    %7D%0A%0A    private void notifyListeners(Location loc) %7B%0A        for (ValueCallback callback : listeners) %7B%0A            callback.handleValue(loc);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onLocationChanged(Location newLocation) %7B%0A        currentLocation = betterLocation(currentLocation, newLocation);%0A        notifyListeners(currentLocation);%0A    %7D%0A%0A    @Override%0A    public void onStatusChanged(String s, int i, Bundle bundle) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void onProviderEnabled(String s) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void onProviderDisabled(String s) %7B%0A%0A    %7D%0A%7D%0A

add gps sensor