Rename id to device id
Этот коммит содержится в:
@@ -35,7 +35,7 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
|
||||
public static final String LOG_TAG = "traccar";
|
||||
|
||||
public static final String KEY_ID = "id";
|
||||
public static final String KEY_DEVICE = "id";
|
||||
public static final String KEY_ADDRESS = "address";
|
||||
public static final String KEY_PORT = "port";
|
||||
public static final String KEY_INTERVAL = "interval";
|
||||
@@ -71,7 +71,7 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
|
||||
private void setPreferencesEnabled(boolean enabled) {
|
||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
preferenceScreen.findPreference(KEY_ID).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_DEVICE).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_ADDRESS).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_PORT).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_INTERVAL).setEnabled(enabled);
|
||||
@@ -88,8 +88,8 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
stopService(new Intent(this, TrackingService.class));
|
||||
setPreferencesEnabled(true);
|
||||
}
|
||||
} else if (key.equals(KEY_ID)) {
|
||||
findPreference(KEY_ID).setSummary(sharedPreferences.getString(KEY_ID, null));
|
||||
} else if (key.equals(KEY_DEVICE)) {
|
||||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,10 +119,10 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
|
||||
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
||||
|
||||
if (!sharedPreferences.contains(KEY_ID)) {
|
||||
sharedPreferences.edit().putString(KEY_ID, id).commit();
|
||||
if (!sharedPreferences.contains(KEY_DEVICE)) {
|
||||
sharedPreferences.edit().putString(KEY_DEVICE, id).commit();
|
||||
}
|
||||
findPreference(KEY_ID).setSummary(sharedPreferences.getString(KEY_ID, id));
|
||||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, id));
|
||||
}
|
||||
|
||||
// TEMPORARY PORT CHANGE DIALOG (DELME)
|
||||
|
||||
@@ -23,10 +23,10 @@ public class Position {
|
||||
|
||||
public Location location; // DELME
|
||||
|
||||
public Position(String id, Location location, double battery) {
|
||||
public Position(String deviceId, Location location, double battery) {
|
||||
this.location = location; // DELME
|
||||
|
||||
this.id = id;
|
||||
this.deviceId = deviceId;
|
||||
time = new Date(location.getTime());
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
@@ -36,9 +36,9 @@ public class Position {
|
||||
this.battery = battery;
|
||||
}
|
||||
|
||||
private String id;
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
private String deviceId;
|
||||
public String getDeviceId() { return deviceId; }
|
||||
public void setDeviceId(String deviceId) { this.deviceId = deviceId; }
|
||||
|
||||
private Date time;
|
||||
public Date getTime() { return time; }
|
||||
|
||||
@@ -42,18 +42,18 @@ public class PositionProvider {
|
||||
private final long period;
|
||||
private final PositionListener listener;
|
||||
private final Context context;
|
||||
private String id;
|
||||
private String deviceId;
|
||||
|
||||
private boolean useFine;
|
||||
private boolean useCoarse;
|
||||
|
||||
public PositionProvider(Context context, PositionListener listener, String id, String type, long period) {
|
||||
public PositionProvider(Context context, PositionListener listener, String deviceId, String type, long period) {
|
||||
handler = new Handler(context.getMainLooper());
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
this.period = period;
|
||||
this.listener = listener;
|
||||
this.context = context;
|
||||
this.id = id;
|
||||
this.deviceId = deviceId;
|
||||
|
||||
// Determine providers
|
||||
if (type.equals(PROVIDER_MIXED)) {
|
||||
@@ -105,7 +105,7 @@ public class PositionProvider {
|
||||
|
||||
if (location != null && location.getTime() != lastTime) {
|
||||
lastTime = location.getTime();
|
||||
listener.onPositionUpdate(new Position(id, location, getBatteryLevel()));
|
||||
listener.onPositionUpdate(new Position(deviceId, location, getBatteryLevel()));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ProtocolFormatter {
|
||||
|
||||
Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme("http").encodedAuthority(address + ':' + port)
|
||||
.appendQueryParameter("id", position.getId())
|
||||
.appendQueryParameter("id", position.getDeviceId())
|
||||
.appendQueryParameter("timestamp", String.valueOf(position.getTime().getTime() / 1000))
|
||||
.appendQueryParameter("lat", String.valueOf(position.getLatitude()))
|
||||
.appendQueryParameter("lon", String.valueOf(position.getLongitude()))
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TrackingController implements PositionProvider.PositionListener {
|
||||
this.context = context;
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
positionProvider = new PositionProvider(context, this,
|
||||
preferences.getString(MainActivity.KEY_ID, null),
|
||||
preferences.getString(MainActivity.KEY_DEVICE, null),
|
||||
preferences.getString(MainActivity.KEY_PROVIDER, null),
|
||||
Integer.parseInt(preferences.getString(MainActivity.KEY_INTERVAL, null)) * 1000);
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user