Removed more code and string about unused location tracking
authorDavid A. Velasco <dvelasco@solidgear.es>
Wed, 23 Oct 2013 09:09:59 +0000 (11:09 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Wed, 23 Oct 2013 09:09:59 +0000 (11:09 +0200)
src/com/owncloud/android/location/LocationServiceLauncherReciever.java [deleted file]
src/com/owncloud/android/location/LocationUpdateService.java [deleted file]

diff --git a/src/com/owncloud/android/location/LocationServiceLauncherReciever.java b/src/com/owncloud/android/location/LocationServiceLauncherReciever.java
deleted file mode 100644 (file)
index a974c56..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ownCloud Android client application
- *   Copyright (C) 2011  Bartek Przybylski
- *   Copyright (C) 2012-2013 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package com.owncloud.android.location;
-
-import com.owncloud.android.Log_OC;
-
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningServiceInfo;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-
-public class LocationServiceLauncherReciever extends BroadcastReceiver {
-
-    private final String TAG = getClass().getSimpleName();
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        Intent deviceTrackingIntent = new Intent();
-        deviceTrackingIntent
-                .setAction("com.owncloud.android.location.LocationUpdateService");
-        SharedPreferences preferences = PreferenceManager
-                .getDefaultSharedPreferences(context);
-        boolean trackDevice = preferences.getBoolean("enable_devicetracking",
-                true);
-
-        // Used in Preferences activity so that tracking is disabled or
-        // reenabled
-        if (intent.hasExtra("TRACKING_SETTING")) {
-            trackDevice = intent.getBooleanExtra("TRACKING_SETTING", true);
-        }
-
-        startOrStopDeviceTracking(context, trackDevice);
-    }
-
-    /**
-     * Used internally. Starts or stops the device tracking service
-     * 
-     * @param trackDevice true to start the service, false to stop it
-     */
-    private void startOrStopDeviceTracking(Context context, boolean trackDevice) {
-        Intent deviceTrackingIntent = new Intent();
-        deviceTrackingIntent
-                .setAction("com.owncloud.android.location.LocationUpdateService");
-        if (!isDeviceTrackingServiceRunning(context) && trackDevice) {
-            Log_OC.d(TAG, "Starting device tracker service");
-            context.startService(deviceTrackingIntent);
-        } else if (isDeviceTrackingServiceRunning(context) && !trackDevice) {
-            Log_OC.d(TAG, "Stopping device tracker service");
-            context.stopService(deviceTrackingIntent);
-        }
-    }
-
-    /**
-     * Checks to see whether or not the LocationUpdateService is running
-     * 
-     * @return true, if it is. Otherwise false
-     */
-    private boolean isDeviceTrackingServiceRunning(Context context) {
-        ActivityManager manager = (ActivityManager) context
-                .getSystemService(Context.ACTIVITY_SERVICE);
-        for (RunningServiceInfo service : manager
-                .getRunningServices(Integer.MAX_VALUE)) {
-            if (getClass().getName().equals(service.service.getClassName())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-}
diff --git a/src/com/owncloud/android/location/LocationUpdateService.java b/src/com/owncloud/android/location/LocationUpdateService.java
deleted file mode 100644 (file)
index 7fe2ee9..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ownCloud Android client application
- *   Copyright (C) 2011  Bartek Przybylski
- *   Copyright (C) 2012-2013 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package com.owncloud.android.location;
-
-import android.app.IntentService;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.location.Criteria;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.location.LocationProvider;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.widget.Toast;
-
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.R;
-
-public class LocationUpdateService extends IntentService implements
-        LocationListener {
-
-    public static final String TAG = "LocationUpdateService";
-
-    private LocationManager mLocationManager;
-    private LocationProvider mLocationProvider;
-    private SharedPreferences mPreferences;
-
-    public LocationUpdateService() {
-        super(TAG);
-    }
-
-    @Override
-    protected void onHandleIntent(Intent intent) {
-        mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
-        // Determine, how we can track the device
-        Criteria criteria = new Criteria();
-        criteria.setAccuracy(Criteria.ACCURACY_FINE);
-        criteria.setPowerRequirement(Criteria.POWER_LOW);
-        mLocationProvider = mLocationManager.getProvider(mLocationManager
-                .getBestProvider(criteria, true));
-
-        // Notify user if there is no way to track the device
-        if (mLocationProvider == null) {
-            String message = String.format(getString(R.string.location_no_provider), getString(R.string.app_name));
-            Toast.makeText(this,
-                    message,
-                    Toast.LENGTH_LONG).show();
-            stopSelf();
-            return;
-        }
-
-        // Get preferences for device tracking
-        mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-        boolean trackDevice = mPreferences.getBoolean("enable_devicetracking",
-                true);
-        int updateIntervall = Integer.parseInt(mPreferences.getString(
-                "devicetracking_update_intervall", "30")) * 60 * 1000;
-        int distanceBetweenLocationChecks = 50;
-
-        // If we do shall track the device -> Stop
-        if (!trackDevice) {
-            Log_OC.d(TAG, "Devicetracking is disabled");
-            stopSelf();
-            return;
-        }
-
-        mLocationManager.requestLocationUpdates(mLocationProvider.getName(),
-                updateIntervall, distanceBetweenLocationChecks, this);
-    }
-
-    @Override
-    public void onLocationChanged(Location location) {
-        Log_OC.d(TAG, "Location changed: " + location);
-
-    }
-
-    @Override
-    public void onProviderDisabled(String arg0) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void onProviderEnabled(String arg0) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
-        // TODO Auto-generated method stub
-
-    }
-
-}