Use fused location provider
Этот коммит содержится в:
@@ -2,12 +2,12 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 26
|
compileSdkVersion 26
|
||||||
buildToolsVersion '26.0.1'
|
buildToolsVersion '26.0.2'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.traccar.client"
|
applicationId "org.traccar.client"
|
||||||
buildConfigField "boolean", "HIDDEN_APP", "false"
|
buildConfigField "boolean", "HIDDEN_APP", "false"
|
||||||
minSdkVersion 14
|
minSdkVersion 15
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 42
|
versionCode 42
|
||||||
versionName '5.5'
|
versionName '5.5'
|
||||||
@@ -35,11 +35,12 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:design:26.0.1'
|
compile 'com.android.support:design:26.1.0'
|
||||||
|
compile 'com.mapzen.android:lost:3.0.2'
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
testCompile 'org.robolectric:robolectric:3.4.2'
|
testCompile 'org.robolectric:robolectric:3.4.2'
|
||||||
googleCompile 'com.google.firebase:firebase-core:11.2.0'
|
googleCompile 'com.google.firebase:firebase-core:11.6.0'
|
||||||
googleCompile 'com.google.firebase:firebase-crash:11.2.0'
|
googleCompile 'com.google.firebase:firebase-crash:11.6.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Google")) {
|
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Google")) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
public static final String KEY_INTERVAL = "interval";
|
public static final String KEY_INTERVAL = "interval";
|
||||||
public static final String KEY_DISTANCE = "distance";
|
public static final String KEY_DISTANCE = "distance";
|
||||||
public static final String KEY_ANGLE = "angle";
|
public static final String KEY_ANGLE = "angle";
|
||||||
public static final String KEY_PROVIDER = "provider";
|
public static final String KEY_ACCURACY = "accuracy";
|
||||||
public static final String KEY_STATUS = "status";
|
public static final String KEY_STATUS = "status";
|
||||||
|
|
||||||
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
||||||
@@ -175,7 +175,7 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
findPreference(KEY_INTERVAL).setEnabled(enabled);
|
findPreference(KEY_INTERVAL).setEnabled(enabled);
|
||||||
findPreference(KEY_DISTANCE).setEnabled(enabled);
|
findPreference(KEY_DISTANCE).setEnabled(enabled);
|
||||||
findPreference(KEY_ANGLE).setEnabled(enabled);
|
findPreference(KEY_ANGLE).setEnabled(enabled);
|
||||||
findPreference(KEY_PROVIDER).setEnabled(enabled);
|
findPreference(KEY_ACCURACY).setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -247,13 +247,8 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
ALARM_MANAGER_INTERVAL, ALARM_MANAGER_INTERVAL, alarmIntent);
|
ALARM_MANAGER_INTERVAL, ALARM_MANAGER_INTERVAL, alarmIntent);
|
||||||
} else {
|
} else {
|
||||||
sharedPreferences.edit().putBoolean(KEY_STATUS, false).apply();
|
sharedPreferences.edit().putBoolean(KEY_STATUS, false).apply();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
|
||||||
TwoStatePreference preference = (TwoStatePreference) findPreference(KEY_STATUS);
|
TwoStatePreference preference = (TwoStatePreference) findPreference(KEY_STATUS);
|
||||||
preference.setChecked(false);
|
preference.setChecked(false);
|
||||||
} else {
|
|
||||||
CheckBoxPreference preference = (CheckBoxPreference) findPreference(KEY_STATUS);
|
|
||||||
preference.setChecked(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 - 2017 Anton Tananaev (anton.tananaev@gmail.com)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.traccar.client;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.location.GpsStatus;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
@SuppressWarnings("MissingPermission")
|
|
||||||
public class MixedPositionProvider extends PositionProvider implements LocationListener, GpsStatus.Listener {
|
|
||||||
|
|
||||||
private static final int FIX_TIMEOUT = 30 * 1000;
|
|
||||||
|
|
||||||
private LocationListener backupListener;
|
|
||||||
private long lastFixTime;
|
|
||||||
|
|
||||||
public MixedPositionProvider(Context context, PositionListener listener) {
|
|
||||||
super(context, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startUpdates() {
|
|
||||||
lastFixTime = System.currentTimeMillis();
|
|
||||||
locationManager.addGpsStatusListener(this);
|
|
||||||
try {
|
|
||||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, requestInterval, 0, this);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopUpdates() {
|
|
||||||
locationManager.removeUpdates(this);
|
|
||||||
locationManager.removeGpsStatusListener(this);
|
|
||||||
stopBackupProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startBackupProvider() {
|
|
||||||
Log.i(TAG, "backup provider start");
|
|
||||||
if (backupListener == null) {
|
|
||||||
|
|
||||||
backupListener = new LocationListener() {
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
Log.i(TAG, "backup provider location");
|
|
||||||
updateLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String s, int i, Bundle bundle) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String s) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
locationManager.requestLocationUpdates(
|
|
||||||
LocationManager.NETWORK_PROVIDER, requestInterval, 0, backupListener);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopBackupProvider() {
|
|
||||||
Log.i(TAG, "backup provider stop");
|
|
||||||
if (backupListener != null) {
|
|
||||||
locationManager.removeUpdates(backupListener);
|
|
||||||
backupListener = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
Log.i(TAG, "provider location");
|
|
||||||
stopBackupProvider();
|
|
||||||
lastFixTime = System.currentTimeMillis();
|
|
||||||
updateLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String provider) {
|
|
||||||
Log.i(TAG, "provider enabled");
|
|
||||||
stopBackupProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String provider) {
|
|
||||||
Log.i(TAG, "provider disabled");
|
|
||||||
startBackupProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsStatusChanged(int event) {
|
|
||||||
if (backupListener == null && System.currentTimeMillis() - lastFixTime - requestInterval > FIX_TIMEOUT) {
|
|
||||||
startBackupProvider();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,19 +15,24 @@
|
|||||||
*/
|
*/
|
||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public abstract class PositionProvider {
|
import com.mapzen.android.lost.api.LocationListener;
|
||||||
|
import com.mapzen.android.lost.api.LocationRequest;
|
||||||
|
import com.mapzen.android.lost.api.LocationServices;
|
||||||
|
import com.mapzen.android.lost.api.LostApiClient;
|
||||||
|
|
||||||
protected static final String TAG = PositionProvider.class.getSimpleName();
|
public class PositionProvider implements LostApiClient.ConnectionCallbacks, LocationListener {
|
||||||
|
|
||||||
|
private static final String TAG = PositionProvider.class.getSimpleName();
|
||||||
|
|
||||||
private static final int MINIMUM_INTERVAL = 1000;
|
private static final int MINIMUM_INTERVAL = 1000;
|
||||||
|
|
||||||
@@ -38,14 +43,13 @@ public abstract class PositionProvider {
|
|||||||
private final PositionListener listener;
|
private final PositionListener listener;
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
protected final LocationManager locationManager;
|
private SharedPreferences preferences;
|
||||||
|
private LostApiClient apiClient;
|
||||||
|
|
||||||
private String deviceId;
|
private String deviceId;
|
||||||
protected String type;
|
private long interval;
|
||||||
protected long requestInterval;
|
private double distance;
|
||||||
protected long interval;
|
private double angle;
|
||||||
protected double distance;
|
|
||||||
protected double angle;
|
|
||||||
|
|
||||||
private Location lastLocation;
|
private Location lastLocation;
|
||||||
|
|
||||||
@@ -53,28 +57,42 @@ public abstract class PositionProvider {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
|
||||||
|
|
||||||
deviceId = preferences.getString(MainFragment.KEY_DEVICE, "undefined");
|
deviceId = preferences.getString(MainFragment.KEY_DEVICE, "undefined");
|
||||||
interval = Long.parseLong(preferences.getString(MainFragment.KEY_INTERVAL, "600")) * 1000;
|
interval = Long.parseLong(preferences.getString(MainFragment.KEY_INTERVAL, "600")) * 1000;
|
||||||
distance = Integer.parseInt(preferences.getString(MainFragment.KEY_DISTANCE, "0"));
|
distance = Integer.parseInt(preferences.getString(MainFragment.KEY_DISTANCE, "0"));
|
||||||
angle = Integer.parseInt(preferences.getString(MainFragment.KEY_ANGLE, "0"));
|
angle = Integer.parseInt(preferences.getString(MainFragment.KEY_ANGLE, "0"));
|
||||||
|
|
||||||
if (distance > 0 || angle > 0) {
|
|
||||||
requestInterval = MINIMUM_INTERVAL;
|
|
||||||
} else {
|
|
||||||
requestInterval = interval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type = preferences.getString(MainFragment.KEY_PROVIDER, "gps");
|
public void startUpdates() {
|
||||||
|
apiClient = new LostApiClient.Builder(context).addConnectionCallbacks(this).build();
|
||||||
|
apiClient.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void startUpdates();
|
private int getPriority(String accuracy) {
|
||||||
|
switch (accuracy) {
|
||||||
|
case "high":
|
||||||
|
return LocationRequest.PRIORITY_HIGH_ACCURACY;
|
||||||
|
case "low":
|
||||||
|
return LocationRequest.PRIORITY_LOW_POWER;
|
||||||
|
default:
|
||||||
|
return LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void stopUpdates();
|
@SuppressLint("MissingPermission")
|
||||||
|
@Override
|
||||||
|
public void onConnected() {
|
||||||
|
LocationRequest request = LocationRequest.create()
|
||||||
|
.setPriority(getPriority(preferences.getString(MainFragment.KEY_ACCURACY, "medium")))
|
||||||
|
.setInterval(distance > 0 || angle > 0 ? MINIMUM_INTERVAL : interval);
|
||||||
|
|
||||||
protected void updateLocation(Location location) {
|
LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, request, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged(Location location) {
|
||||||
if (location != null && (lastLocation == null
|
if (location != null && (lastLocation == null
|
||||||
|| location.getTime() - lastLocation.getTime() >= interval
|
|| location.getTime() - lastLocation.getTime() >= interval
|
||||||
|| distance > 0 && DistanceCalculator.distance(location.getLatitude(), location.getLongitude(), lastLocation.getLatitude(), lastLocation.getLongitude()) >= distance
|
|| distance > 0 && DistanceCalculator.distance(location.getLatitude(), location.getLongitude(), lastLocation.getLatitude(), lastLocation.getLongitude()) >= distance
|
||||||
@@ -87,6 +105,15 @@ public abstract class PositionProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectionSuspended() {
|
||||||
|
Log.i(TAG, "lost client suspended");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopUpdates() {
|
||||||
|
apiClient.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
public static double getBatteryLevel(Context context) {
|
public static double getBatteryLevel(Context context) {
|
||||||
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||||
if (batteryIntent != null) {
|
if (batteryIntent != null) {
|
||||||
|
|||||||
@@ -15,11 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
@@ -34,7 +32,10 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class ShortcutActivity extends AppCompatActivity {
|
import com.mapzen.android.lost.api.LocationServices;
|
||||||
|
import com.mapzen.android.lost.api.LostApiClient;
|
||||||
|
|
||||||
|
public class ShortcutActivity extends AppCompatActivity implements LostApiClient.ConnectionCallbacks {
|
||||||
|
|
||||||
public static final String EXTRA_ACTION = "action";
|
public static final String EXTRA_ACTION = "action";
|
||||||
public static final String ACTION_START = "start";
|
public static final String ACTION_START = "start";
|
||||||
@@ -43,6 +44,8 @@ public class ShortcutActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private static final String ALARM_SOS = "sos";
|
private static final String ALARM_SOS = "sos";
|
||||||
|
|
||||||
|
private LostApiClient apiClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -99,16 +102,16 @@ public class ShortcutActivity extends AppCompatActivity {
|
|||||||
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
|
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("MissingPermission")
|
|
||||||
private void sendAlarm() {
|
private void sendAlarm() {
|
||||||
|
apiClient = new LostApiClient.Builder(this).addConnectionCallbacks(this).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("MissingPermission")
|
||||||
|
@Override
|
||||||
|
public void onConnected() {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
Location location = LocationServices.FusedLocationApi.getLastLocation(apiClient);
|
||||||
|
|
||||||
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
|
||||||
if (location == null) {
|
|
||||||
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
||||||
@@ -133,6 +136,12 @@ public class ShortcutActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.status_send_fail, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.status_send_fail, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiClient.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectionSuspended() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean executeAction(Intent intent) {
|
private boolean executeAction(Intent intent) {
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.traccar.client;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
@SuppressWarnings("MissingPermission")
|
|
||||||
public class SimplePositionProvider extends PositionProvider implements LocationListener {
|
|
||||||
|
|
||||||
public SimplePositionProvider(Context context, PositionListener listener) {
|
|
||||||
super(context, listener);
|
|
||||||
if (!type.equals(LocationManager.NETWORK_PROVIDER)) {
|
|
||||||
type = LocationManager.GPS_PROVIDER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startUpdates() {
|
|
||||||
try {
|
|
||||||
locationManager.requestLocationUpdates(type, requestInterval, 0, this);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopUpdates() {
|
|
||||||
locationManager.removeUpdates(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
updateLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String provider) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String provider) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -57,11 +57,7 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (preferences.getString(MainFragment.KEY_PROVIDER, "gps").equals("mixed")) {
|
positionProvider = new PositionProvider(context, this);
|
||||||
positionProvider = new MixedPositionProvider(context, this);
|
|
||||||
} else {
|
|
||||||
positionProvider = new SimplePositionProvider(context, this);
|
|
||||||
}
|
|
||||||
databaseHelper = new DatabaseHelper(context);
|
databaseHelper = new DatabaseHelper(context);
|
||||||
networkManager = new NetworkManager(context, this);
|
networkManager = new NetworkManager(context, this);
|
||||||
isOnline = networkManager.isOnline();
|
isOnline = networkManager.isOnline();
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
<string name="settings_status_on">Stop</string>
|
<string name="settings_status_on">Stop</string>
|
||||||
<string name="settings_status_off_summary">Service stopped</string>
|
<string name="settings_status_off_summary">Service stopped</string>
|
||||||
<string name="settings_status_on_summary">Service running</string>
|
<string name="settings_status_on_summary">Service running</string>
|
||||||
<string name="settings_provider_title">Location provider</string>
|
<string name="settings_accuracy_title">Location accuracy</string>
|
||||||
<string name="settings_provider_summary">Source of location data</string>
|
<string name="settings_accuracy_summary">Desired location accuracy</string>
|
||||||
<string name="settings_provider_gps">GPS provider</string>
|
<string name="settings_accuracy_high">High</string>
|
||||||
<string name="settings_provider_network">Network provider</string>
|
<string name="settings_accuracy_medium">Medium</string>
|
||||||
<string name="settings_provider_mixed">Mixed provider</string>
|
<string name="settings_accuracy_low">Low</string>
|
||||||
<string name="settings_foreground_title">Foreground service</string>
|
<string name="settings_foreground_title">Foreground service</string>
|
||||||
<string name="settings_foreground_summary">Increase service priority</string>
|
<string name="settings_foreground_summary">Increase service priority</string>
|
||||||
<string name="menu_status">Status</string>
|
<string name="menu_status">Status</string>
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
|
|
||||||
<string name="settings_url_default_value" translatable="false">http://demo.traccar.org:5055</string>
|
<string name="settings_url_default_value" translatable="false">http://demo.traccar.org:5055</string>
|
||||||
|
|
||||||
<string-array name="settings_provider_values" translatable="false">
|
<string-array name="settings_accuracy_values" translatable="false">
|
||||||
<item>gps</item>
|
<item>high</item>
|
||||||
<item>network</item>
|
<item>medium</item>
|
||||||
<item>mixed</item>
|
<item>low</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="settings_provider_names">
|
<string-array name="settings_accuracy_names">
|
||||||
<item>@string/settings_provider_gps</item>
|
<item>@string/settings_accuracy_high</item>
|
||||||
<item>@string/settings_provider_network</item>
|
<item>@string/settings_accuracy_medium</item>
|
||||||
<item>@string/settings_provider_mixed</item>
|
<item>@string/settings_accuracy_low</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -20,6 +20,14 @@
|
|||||||
android:summary="@string/settings_url_summary"
|
android:summary="@string/settings_url_summary"
|
||||||
android:title="@string/settings_url_title" />
|
android:title="@string/settings_url_title" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="medium"
|
||||||
|
android:entries="@array/settings_accuracy_names"
|
||||||
|
android:entryValues="@array/settings_accuracy_values"
|
||||||
|
android:key="accuracy"
|
||||||
|
android:summary="@string/settings_accuracy_summary"
|
||||||
|
android:title="@string/settings_accuracy_title" />
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="300"
|
android:defaultValue="300"
|
||||||
android:key="interval"
|
android:key="interval"
|
||||||
@@ -41,12 +49,4 @@
|
|||||||
android:summary="@string/settings_angle_summary"
|
android:summary="@string/settings_angle_summary"
|
||||||
android:title="@string/settings_angle_title" />
|
android:title="@string/settings_angle_title" />
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:defaultValue="gps"
|
|
||||||
android:entries="@array/settings_provider_names"
|
|
||||||
android:entryValues="@array/settings_provider_values"
|
|
||||||
android:key="provider"
|
|
||||||
android:summary="@string/settings_provider_summary"
|
|
||||||
android:title="@string/settings_provider_title" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user