forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -27,7 +27,6 @@ import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
@@ -41,12 +40,10 @@ import java.util.TimerTask;
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class SensorStateActivity extends Activity {
|
||||
public class SensorStateActivity extends AbstractMyTracksActivity {
|
||||
|
||||
private static final long REFRESH_PERIOD_MS = 250;
|
||||
|
||||
private final StatsUtilities utils;
|
||||
|
||||
/**
|
||||
* This timer periodically invokes the refresh timer task.
|
||||
*/
|
||||
@@ -91,11 +88,6 @@ public class SensorStateActivity extends Activity {
|
||||
*/
|
||||
private boolean isVisible = false;
|
||||
|
||||
public SensorStateActivity() {
|
||||
utils = new StatsUtilities(this);
|
||||
Log.w(TAG, "SensorStateActivity()");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -239,18 +231,18 @@ public class SensorStateActivity extends Activity {
|
||||
}
|
||||
|
||||
private void updateSensorData(Sensor.SensorDataSet sds) {
|
||||
if (sds == null) {
|
||||
utils.setUnknown(R.id.sensor_state_last_sensor_time);
|
||||
utils.setUnknown(R.id.sensor_state_power);
|
||||
utils.setUnknown(R.id.sensor_state_cadence);
|
||||
utils.setUnknown(R.id.sensor_state_battery);
|
||||
} else {
|
||||
((TextView) findViewById(R.id.sensor_state_last_sensor_time)).setText(getLastSensorTime(sds));
|
||||
((TextView) findViewById(R.id.sensor_state_power)).setText(getPower(sds));
|
||||
((TextView) findViewById(R.id.sensor_state_cadence)).setText(getCadence(sds));
|
||||
((TextView) findViewById(R.id.sensor_state_heart_rate)).setText(getHeartRate(sds));
|
||||
((TextView) findViewById(R.id.sensor_state_battery)).setText(getBattery(sds));
|
||||
}
|
||||
String lastSensorTime = sds == null ? getString(R.string.value_unknown)
|
||||
: getLastSensorTime(sds);
|
||||
String power = sds == null ? getString(R.string.value_unknown) : getPower(sds);
|
||||
String cadence = sds == null ? getString(R.string.value_unknown) : getCadence(sds);
|
||||
String heartRate = sds == null ? getString(R.string.value_unknown) : getHeartRate(sds);
|
||||
String battery = sds == null ? getString(R.string.value_unknown) : getBattery(sds);
|
||||
|
||||
((TextView) findViewById(R.id.sensor_state_last_sensor_time)).setText(lastSensorTime);
|
||||
((TextView) findViewById(R.id.sensor_state_power)).setText(power);
|
||||
((TextView) findViewById(R.id.sensor_state_cadence)).setText(cadence);
|
||||
((TextView) findViewById(R.id.sensor_state_heart_rate)).setText(heartRate);
|
||||
((TextView) findViewById(R.id.sensor_state_battery)).setText(battery);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,8 +317,7 @@ public class SensorStateActivity extends Activity {
|
||||
String value;
|
||||
if (sds.hasBatteryLevel() && sds.getBatteryLevel().hasValue()
|
||||
&& sds.getBatteryLevel().getState() == Sensor.SensorState.SENDING) {
|
||||
String format = getString(R.string.value_integer_percent);
|
||||
value = String.format(format, sds.getBatteryLevel().getValue());
|
||||
value = getString(R.string.value_integer_percent, sds.getBatteryLevel().getValue());
|
||||
} else {
|
||||
value = SensorUtils.getStateAsString(
|
||||
sds.hasBatteryLevel() ? sds.getBatteryLevel().getState() : Sensor.SensorState.NONE, this);
|
||||
|
||||
Reference in New Issue
Block a user