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