forked from upstream-mirrors/OpenTracks
Merge to head
This commit is contained in:
@@ -77,8 +77,8 @@ public class ChartActivity extends Activity implements TrackDataListener {
|
||||
private double trackMaxSpeed;
|
||||
|
||||
// Modes of operation
|
||||
private boolean metricUnits;
|
||||
private boolean reportSpeed;
|
||||
private boolean metricUnits = true;
|
||||
private boolean reportSpeed = true;
|
||||
|
||||
/*
|
||||
* UI elements:
|
||||
@@ -240,6 +240,7 @@ public class ChartActivity extends Activity implements TrackDataListener {
|
||||
|
||||
private void prepareSettingsDialog(ChartSettingsDialog settingsDialog) {
|
||||
settingsDialog.setMode(chartView.getMode());
|
||||
settingsDialog.setDisplaySpeed(reportSpeed);
|
||||
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
||||
settingsDialog.setSeriesEnabled(i, chartView.isChartValueSeriesEnabled(i));
|
||||
}
|
||||
@@ -452,26 +453,33 @@ public class ChartActivity extends Activity implements TrackDataListener {
|
||||
|
||||
@Override
|
||||
public boolean onUnitsChanged(boolean metric) {
|
||||
boolean changed = metric != this.metricUnits;
|
||||
if (!changed) return false;
|
||||
|
||||
this.metricUnits = metric;
|
||||
|
||||
chartView.setMetricUnits(metric);
|
||||
|
||||
return true; // Reload data
|
||||
if (metricUnits == metric) {
|
||||
return false;
|
||||
}
|
||||
metricUnits = metric;
|
||||
chartView.setMetricUnits(metricUnits);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chartView.requestLayout();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
@Override
|
||||
public boolean onReportSpeedChanged(boolean reportSpeed) {
|
||||
boolean changed = reportSpeed != this.reportSpeed;
|
||||
if (!changed) return false;
|
||||
|
||||
this.reportSpeed = reportSpeed;
|
||||
|
||||
chartView.setReportSpeed(reportSpeed, this);
|
||||
|
||||
return true; // Reload data
|
||||
public boolean onReportSpeedChanged(boolean speed) {
|
||||
if (reportSpeed == speed) {
|
||||
return false;
|
||||
}
|
||||
reportSpeed = speed;
|
||||
chartView.setReportSpeed(speed, this);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chartView.requestLayout();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,15 @@ public class ChartSettingsDialog extends Dialog {
|
||||
? R.id.chart_settings_by_distance
|
||||
: R.id.chart_settings_by_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to display speed or pace.
|
||||
*
|
||||
* @param displaySpeed true to display speed
|
||||
*/
|
||||
public void setDisplaySpeed(boolean displaySpeed) {
|
||||
series[ChartView.SPEED_SERIES].setText(displaySpeed ? R.string.stat_speed : R.string.stat_pace);
|
||||
}
|
||||
|
||||
public void setSeriesEnabled(int seriesIdx, boolean enabled) {
|
||||
series[seriesIdx].setChecked(enabled);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ChartView extends View {
|
||||
*/
|
||||
private int bottomBorder;
|
||||
|
||||
private static final int RIGHT_BORDER = 17;
|
||||
private static final int RIGHT_BORDER = 40;
|
||||
|
||||
/** Space to leave for drawing the unit labels */
|
||||
private static final int UNIT_BORDER = 15;
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ImportAllTracks {
|
||||
Log.i(Constants.TAG, "ImportAllTracks: Releasing wake lock.");
|
||||
}
|
||||
|
||||
activity.runOnUiThread(new Thread() {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showDoneDialog();
|
||||
@@ -219,7 +219,7 @@ public class ImportAllTracks {
|
||||
* Attempts to import a GPX file. Returns true on success, issues error
|
||||
* notifications and returns false on failure.
|
||||
*/
|
||||
private boolean importFile(File gpxFile, MyTracksProviderUtils providerUtils) {
|
||||
private boolean importFile(final File gpxFile, MyTracksProviderUtils providerUtils) {
|
||||
Log.i(Constants.TAG, "ImportAllTracks: importing: " + gpxFile.getName());
|
||||
try {
|
||||
importedTrackIds = GpxImporter.importGPXFile(new FileInputStream(gpxFile), providerUtils);
|
||||
@@ -234,8 +234,13 @@ public class ImportAllTracks {
|
||||
} catch (IOException e) {
|
||||
Log.w(Constants.TAG, "Error reading file: " + gpxFile.getAbsolutePath(), e);
|
||||
}
|
||||
Toast.makeText(activity, activity.getString(R.string.import_error, gpxFile.getName()),
|
||||
Toast.LENGTH_LONG).show();
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(activity, activity.getString(R.string.import_error, gpxFile.getName()),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -420,9 +420,8 @@ public class MapActivity extends com.google.android.maps.MapActivity
|
||||
Constants.getActionFromMenuId(item.getItemId()));
|
||||
return true;
|
||||
case Constants.MENU_EDIT: {
|
||||
Intent intent = new Intent(this, TrackDetails.class);
|
||||
// TODO: Pass in a content URI
|
||||
intent.putExtra("trackid", dataHub.getSelectedTrackId());
|
||||
Intent intent = new Intent(this, TrackDetail.class);
|
||||
intent.putExtra(TrackDetail.TRACK_ID, dataHub.getSelectedTrackId());
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
||||
case DIALOG_EULA_ID:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.eula_title);
|
||||
builder.setMessage(R.string.eula_message);
|
||||
builder.setMessage(EulaUtil.getEulaMessage(this));
|
||||
builder.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@@ -477,9 +477,9 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
||||
serviceConnection.stop();
|
||||
|
||||
if (currentTrackId > 0) {
|
||||
Intent intent = new Intent(MyTracks.this, TrackDetails.class);
|
||||
intent.putExtra("trackid", currentTrackId);
|
||||
intent.putExtra("hasCancelButton", false);
|
||||
Intent intent = new Intent(MyTracks.this, TrackDetail.class);
|
||||
intent.putExtra(TrackDetail.TRACK_ID, currentTrackId);
|
||||
intent.putExtra(TrackDetail.SHOW_CANCEL, false);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class SensorStateActivity extends Activity {
|
||||
/**
|
||||
* A temporary sensor manager, when none is available.
|
||||
*/
|
||||
SensorManager tempSensorManager = null;
|
||||
private SensorManager tempSensorManager = null;
|
||||
|
||||
/**
|
||||
* A state flag set to true when the activity is active/visible,
|
||||
@@ -91,7 +91,7 @@ public class SensorStateActivity extends Activity {
|
||||
* it could cause the {@link #tempSensorManager} to be recreated, after it
|
||||
* is destroyed at the pause event.
|
||||
*/
|
||||
boolean isVisible = false;
|
||||
private boolean isVisible = false;
|
||||
|
||||
public SensorStateActivity() {
|
||||
utils = new StatsUtilities(this);
|
||||
@@ -139,7 +139,7 @@ public class SensorStateActivity extends Activity {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
protected void updateState() {
|
||||
private void updateState() {
|
||||
Log.d(TAG, "Updating SensorStateActivity");
|
||||
|
||||
ITrackRecordingService service = serviceConnection.getServiceIfBound();
|
||||
@@ -162,8 +162,7 @@ public class SensorStateActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFromTempSensorManager()
|
||||
{
|
||||
private void updateFromTempSensorManager() {
|
||||
// Use variables to hold the sensor state and data set.
|
||||
Sensor.SensorState currentState = null;
|
||||
Sensor.SensorDataSet currentDataSet = null;
|
||||
@@ -186,8 +185,7 @@ public class SensorStateActivity extends Activity {
|
||||
updateSensorStateAndData(currentState, currentDataSet);
|
||||
}
|
||||
|
||||
private void updateFromSysSensorManager()
|
||||
{
|
||||
private void updateFromSysSensorManager() {
|
||||
// Use variables to hold the sensor state and data set.
|
||||
Sensor.SensorState currentState = null;
|
||||
Sensor.SensorDataSet currentDataSet = null;
|
||||
@@ -228,91 +226,115 @@ public class SensorStateActivity extends Activity {
|
||||
/**
|
||||
* Stops the temporary sensor manager, if one exists.
|
||||
*/
|
||||
private void stopTempSensorManager()
|
||||
{
|
||||
private void stopTempSensorManager() {
|
||||
if (tempSensorManager != null) {
|
||||
tempSensorManager.shutdown();
|
||||
tempSensorManager = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSensorStateAndData(Sensor.SensorState state, Sensor.SensorDataSet dataSet)
|
||||
{
|
||||
private void updateSensorStateAndData(Sensor.SensorState state, Sensor.SensorDataSet dataSet) {
|
||||
updateSensorState(state == null ? Sensor.SensorState.NONE : state);
|
||||
updateSensorData(dataSet);
|
||||
}
|
||||
|
||||
private void updateSensorState(Sensor.SensorState state) {
|
||||
TextView sensorTime =
|
||||
((TextView) findViewById(R.id.sensor_state_register));
|
||||
sensorTime.setText(SensorUtils.getStateAsString(state, this));
|
||||
((TextView) findViewById(R.id.sensor_state)).setText(SensorUtils.getStateAsString(state, this));
|
||||
}
|
||||
|
||||
protected void updateSensorData(Sensor.SensorDataSet sds) {
|
||||
private void updateSensorData(Sensor.SensorDataSet sds) {
|
||||
if (sds == null) {
|
||||
utils.setUnknown(R.id.sensor_data_time_register);
|
||||
utils.setUnknown(R.id.cadence_state_register);
|
||||
utils.setUnknown(R.id.power_state_register);
|
||||
utils.setUnknown(R.id.heart_rate_register);
|
||||
utils.setUnknown(R.id.battery_level_register);
|
||||
return;
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
TextView sensorTime =
|
||||
((TextView) findViewById(R.id.sensor_data_time_register));
|
||||
sensorTime.setText(
|
||||
TIMESTAMP_FORMAT.format(new Date(sds.getCreationTime())));
|
||||
/**
|
||||
* Gets the last sensor time.
|
||||
*
|
||||
* @param sds sensor data set
|
||||
*/
|
||||
private String getLastSensorTime(Sensor.SensorDataSet sds) {
|
||||
return TIMESTAMP_FORMAT.format(new Date(sds.getCreationTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power.
|
||||
*
|
||||
* @param sds sensor data set
|
||||
*/
|
||||
private String getPower(Sensor.SensorDataSet sds) {
|
||||
String value;
|
||||
if (sds.hasPower() && sds.getPower().hasValue()
|
||||
&& sds.getPower().getState() == Sensor.SensorState.SENDING) {
|
||||
utils.setText(R.id.power_state_register,
|
||||
Integer.toString(sds.getPower().getValue()));
|
||||
String format = getString(R.string.sensor_state_power_value);
|
||||
value = String.format(format, sds.getPower().getValue());
|
||||
} else {
|
||||
utils.setText(R.id.power_state_register,
|
||||
SensorUtils.getStateAsString(
|
||||
sds.hasPower()
|
||||
? sds.getPower().getState()
|
||||
: Sensor.SensorState.NONE,
|
||||
this));
|
||||
value = SensorUtils.getStateAsString(
|
||||
sds.hasPower() ? sds.getPower().getState() : Sensor.SensorState.NONE, this);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cadence.
|
||||
*
|
||||
* @param sds sensor data set
|
||||
*/
|
||||
private String getCadence(Sensor.SensorDataSet sds) {
|
||||
String value;
|
||||
if (sds.hasCadence() && sds.getCadence().hasValue()
|
||||
&& sds.getCadence().getState() == Sensor.SensorState.SENDING) {
|
||||
utils.setText(R.id.cadence_state_register,
|
||||
Integer.toString(sds.getCadence().getValue()));
|
||||
String format = getString(R.string.sensor_state_cadence_value);
|
||||
value = String.format(format, sds.getCadence().getValue());
|
||||
} else {
|
||||
utils.setText(R.id.cadence_state_register,
|
||||
SensorUtils.getStateAsString(
|
||||
sds.hasCadence()
|
||||
? sds.getCadence().getState()
|
||||
: Sensor.SensorState.NONE,
|
||||
this));
|
||||
value = SensorUtils.getStateAsString(
|
||||
sds.hasCadence() ? sds.getCadence().getState() : Sensor.SensorState.NONE, this);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the heart rate.
|
||||
*
|
||||
* @param sds sensor data set
|
||||
*/
|
||||
private String getHeartRate(Sensor.SensorDataSet sds) {
|
||||
String value;
|
||||
if (sds.hasHeartRate() && sds.getHeartRate().hasValue()
|
||||
&& sds.getHeartRate().getState() == Sensor.SensorState.SENDING) {
|
||||
utils.setText(R.id.heart_rate_register,
|
||||
Integer.toString(sds.getHeartRate().getValue()));
|
||||
String format = getString(R.string.sensor_state_heart_rate_value);
|
||||
value = String.format(format, sds.getHeartRate().getValue());
|
||||
} else {
|
||||
utils.setText(R.id.heart_rate_register,
|
||||
SensorUtils.getStateAsString(
|
||||
sds.hasHeartRate()
|
||||
? sds.getHeartRate().getState()
|
||||
: Sensor.SensorState.NONE,
|
||||
this));
|
||||
value = SensorUtils.getStateAsString(
|
||||
sds.hasHeartRate() ? sds.getHeartRate().getState() : Sensor.SensorState.NONE, this);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the battery.
|
||||
*
|
||||
* @param sds sensor data set
|
||||
*/
|
||||
private String getBattery(Sensor.SensorDataSet sds) {
|
||||
String value;
|
||||
if (sds.hasBatteryLevel() && sds.getBatteryLevel().hasValue()
|
||||
&& sds.getBatteryLevel().getState() == Sensor.SensorState.SENDING) {
|
||||
utils.setText(R.id.battery_level_register,
|
||||
Integer.toString(sds.getBatteryLevel().getValue()));
|
||||
String format = getString(R.string.sensor_state_battery_value);
|
||||
value = String.format(format, sds.getBatteryLevel().getValue());
|
||||
} else {
|
||||
utils.setText(R.id.battery_level_register,
|
||||
SensorUtils.getStateAsString(
|
||||
sds.hasBatteryLevel()
|
||||
? sds.getBatteryLevel().getState()
|
||||
: Sensor.SensorState.NONE,
|
||||
this));
|
||||
value = SensorUtils.getStateAsString(
|
||||
sds.hasBatteryLevel() ? sds.getBatteryLevel().getState() : Sensor.SensorState.NONE, this);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,8 @@ public class StatsActivity extends Activity implements TrackDataListener {
|
||||
sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET);
|
||||
|
||||
showUnknownLocation();
|
||||
|
||||
updateLabels();
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
if (metrics.heightPixels > 600) {
|
||||
@@ -153,24 +154,22 @@ public class StatsActivity extends Activity implements TrackDataListener {
|
||||
|
||||
@Override
|
||||
public boolean onUnitsChanged(boolean metric) {
|
||||
// Ignore if unchanged.
|
||||
if (metric == utils.isMetricUnits()) return false;
|
||||
|
||||
if (utils.isMetricUnits() == metric) {
|
||||
return false;
|
||||
}
|
||||
utils.setMetricUnits(metric);
|
||||
updateLabels();
|
||||
|
||||
return true; // Reload data
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onReportSpeedChanged(boolean displaySpeed) {
|
||||
// Ignore if unchanged.
|
||||
if (displaySpeed == utils.isReportSpeed()) return false;
|
||||
|
||||
utils.setReportSpeed(displaySpeed);
|
||||
public boolean onReportSpeedChanged(boolean speed) {
|
||||
if (utils.isReportSpeed() == speed) {
|
||||
return false;
|
||||
}
|
||||
utils.setReportSpeed(speed);
|
||||
updateLabels();
|
||||
|
||||
return true; // Reload data
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateLabels() {
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
* 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 com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* An activity that let's the user see and edit the user editable track meta
|
||||
* data such as track name, activity type, and track description.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public class TrackDetail extends Activity implements OnClickListener {
|
||||
|
||||
public static final String TRACK_ID = "trackId";
|
||||
public static final String SHOW_CANCEL = "showCancel";
|
||||
|
||||
private static final String TAG = TrackDetail.class.getSimpleName();
|
||||
|
||||
private Long trackId;
|
||||
private MyTracksProviderUtils myTracksProviderUtils;
|
||||
private Track track;
|
||||
|
||||
private EditText trackName;
|
||||
private AutoCompleteTextView activityType;
|
||||
private EditText trackDescription;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.track_detail);
|
||||
|
||||
trackId = getIntent().getLongExtra(TRACK_ID, -1);
|
||||
if (trackId < 0) {
|
||||
Log.e(TAG, "invalid trackId.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
|
||||
track = myTracksProviderUtils.getTrack(trackId);
|
||||
if (track == null) {
|
||||
Log.e(TAG, "no track.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
trackName = (EditText) findViewById(R.id.track_detail_track_name);
|
||||
trackName.setText(track.getName());
|
||||
|
||||
activityType = (AutoCompleteTextView) findViewById(R.id.track_detail_activity_type);
|
||||
activityType.setText(track.getCategory());
|
||||
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
|
||||
activityType.setAdapter(adapter);
|
||||
trackDescription = (EditText) findViewById(R.id.track_detail_track_description);
|
||||
trackDescription.setText(track.getDescription());
|
||||
|
||||
Button save = (Button) findViewById(R.id.track_detail_save);
|
||||
save.setOnClickListener(this);
|
||||
|
||||
Button cancel = (Button) findViewById(R.id.track_detail_cancel);
|
||||
if (getIntent().getBooleanExtra(SHOW_CANCEL, true)) {
|
||||
cancel.setOnClickListener(this);
|
||||
cancel.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cancel.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.track_detail_save:
|
||||
save();
|
||||
finish();
|
||||
break;
|
||||
case R.id.track_detail_cancel:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
track.setName(trackName.getText().toString());
|
||||
track.setCategory(activityType.getText().toString());
|
||||
track.setDescription(trackDescription.getText().toString());
|
||||
myTracksProviderUtils.updateTrack(track);
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
* 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 com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* An activity that let's the user see and edit the user editable track meta
|
||||
* data such as name, activity type and description.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public class TrackDetails extends Activity implements OnClickListener {
|
||||
|
||||
/**
|
||||
* The id of the track being edited (taken from bundle, "trackid")
|
||||
*/
|
||||
private Long trackId;
|
||||
|
||||
private EditText name;
|
||||
private EditText description;
|
||||
private AutoCompleteTextView category;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.mytracks_detail);
|
||||
|
||||
// Required extra when launching this intent:
|
||||
trackId = getIntent().getLongExtra("trackid", -1);
|
||||
if (trackId < 0) {
|
||||
Log.d(Constants.TAG,
|
||||
"MyTracksDetails intent was launched w/o track id.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
// Optional extra that can be used to suppress the cancel button:
|
||||
boolean hasCancelButton =
|
||||
getIntent().getBooleanExtra("hasCancelButton", true);
|
||||
|
||||
name = (EditText) findViewById(R.id.trackdetails_name);
|
||||
description = (EditText) findViewById(R.id.trackdetails_description);
|
||||
category = (AutoCompleteTextView) findViewById(R.id.trackdetails_category);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
|
||||
this,
|
||||
R.array.activity_types,
|
||||
android.R.layout.simple_dropdown_item_1line);
|
||||
category.setAdapter(adapter);
|
||||
|
||||
Button cancel = (Button) findViewById(R.id.trackdetails_cancel);
|
||||
if (hasCancelButton) {
|
||||
cancel.setOnClickListener(this);
|
||||
cancel.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cancel.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
Button save = (Button) findViewById(R.id.trackdetails_save);
|
||||
save.setOnClickListener(this);
|
||||
|
||||
fillDialog();
|
||||
}
|
||||
|
||||
private void fillDialog() {
|
||||
Track track = MyTracksProviderUtils.Factory.get(this).getTrack(trackId);
|
||||
if (track != null) {
|
||||
name.setText(track.getName());
|
||||
description.setText(track.getDescription());
|
||||
category.setText(track.getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
private void saveDialog() {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(TracksColumns.NAME, name.getText().toString());
|
||||
values.put(TracksColumns.DESCRIPTION, description.getText().toString());
|
||||
values.put(TracksColumns.CATEGORY, category.getText().toString());
|
||||
getContentResolver().update(
|
||||
TracksColumns.CONTENT_URI,
|
||||
values,
|
||||
"_id = " + trackId,
|
||||
null/*selectionArgs*/);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.trackdetails_cancel:
|
||||
finish();
|
||||
break;
|
||||
case R.id.trackdetails_save:
|
||||
saveDialog();
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,8 +167,8 @@ public class TrackList extends ListActivity
|
||||
return true;
|
||||
}
|
||||
case Constants.MENU_EDIT: {
|
||||
Intent intent = new Intent(this, TrackDetails.class);
|
||||
intent.putExtra("trackid", trackId);
|
||||
Intent intent = new Intent(this, TrackDetail.class);
|
||||
intent.putExtra(TrackDetail.TRACK_ID, trackId);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ public class TrackList extends ListActivity
|
||||
TextView textView = (TextView) view;
|
||||
if (columnIndex == startTimeIdx) {
|
||||
long time = cursor.getLong(startTimeIdx);
|
||||
textView.setText(String.format("%tc", time));
|
||||
textView.setText(StringUtils.formatDateTime(time));
|
||||
} else if (columnIndex == totalDistanceIdx) {
|
||||
double length = cursor.getDouble(totalDistanceIdx);
|
||||
String lengthUnit = null;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class WaypointsList extends ListActivity
|
||||
R.string.marker_list_edit_marker);
|
||||
menu.add(0, Constants.MENU_DELETE, 0,
|
||||
R.string.marker_list_delete_marker).setEnabled(
|
||||
recordingTrackId < 0 || type == Waypoint.TYPE_WAYPOINT ||
|
||||
recordingTrackId < 0 || type == Waypoint.TYPE_WAYPOINT || type == Waypoint.TYPE_STATISTICS ||
|
||||
info.id != providerUtils.getLastWaypointId(recordingTrackId));
|
||||
}
|
||||
}
|
||||
@@ -265,9 +265,13 @@ public class WaypointsList extends ListActivity
|
||||
if (columnIndex == timeIdx) {
|
||||
long time = cursor.getLong(timeIdx);
|
||||
TextView textView = (TextView) view;
|
||||
textView.setText(String.format("%tc", time));
|
||||
textView.setVisibility(
|
||||
textView.getText().length() < 1 ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (time == 0) {
|
||||
textView.setVisibility(View.GONE);
|
||||
} else {
|
||||
textView.setText(StringUtils.formatDateTime(time));
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (columnIndex == typeIdx) {
|
||||
int type = cursor.getInt(typeIdx);
|
||||
ImageView imageView = (ImageView) view;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.util.EulaUtil;
|
||||
import com.google.android.apps.mytracks.util.SystemUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
@@ -77,7 +78,7 @@ public class WelcomeActivity extends Activity {
|
||||
case DIALOG_EULA_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.eula_title);
|
||||
builder.setMessage(R.string.eula_message);
|
||||
builder.setMessage(EulaUtil.getEulaMessage(this));
|
||||
builder.setPositiveButton(R.string.generic_ok, null);
|
||||
builder.setCancelable(true);
|
||||
return builder.create();
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks.io.backup;
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.MyTracks;
|
||||
import com.google.android.apps.mytracks.util.FileUtils;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -32,7 +33,6 @@ import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -46,10 +46,6 @@ import java.util.Date;
|
||||
*/
|
||||
public class BackupActivityHelper {
|
||||
|
||||
// Since the user sees this format, we use the local timezone
|
||||
private static final DateFormat DISPLAY_BACKUP_FORMAT = DateFormat.getDateTimeInstance(
|
||||
DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
||||
private static final Comparator<Date> REVERSE_DATE_ORDER =
|
||||
new Comparator<Date>() {
|
||||
@Override
|
||||
@@ -160,7 +156,7 @@ public class BackupActivityHelper {
|
||||
// Make a user-visible version of the backup filenames
|
||||
final String backupDateStrs[] = new String[backupDates.length];
|
||||
for (int i = 0; i < backupDates.length; i++) {
|
||||
backupDateStrs[i] = DISPLAY_BACKUP_FORMAT.format(backupDates[i]);
|
||||
backupDateStrs[i] = StringUtils.formatDateTime(backupDates[i].getTime());
|
||||
}
|
||||
|
||||
// Show a dialog for the user to pick which backup to restore
|
||||
|
||||
@@ -44,8 +44,6 @@ import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
@@ -290,7 +288,7 @@ public class DocsHelper {
|
||||
DocsTagBuilder tagBuilder = new DocsTagBuilder(metricUnits)
|
||||
.append("name", track.getName())
|
||||
.append("description", track.getDescription())
|
||||
.append("date", getDisplayDate(stats.getStartTime()))
|
||||
.append("date", StringUtils.formatDateTime(stats.getStartTime()))
|
||||
.append("totaltime", StringUtils.formatTimeAlwaysShowingHours(
|
||||
stats.getTotalTime()))
|
||||
.append("movingtime", StringUtils.formatTimeAlwaysShowingHours(
|
||||
@@ -330,19 +328,6 @@ public class DocsHelper {
|
||||
Log.i(Constants.TAG, "Post finished.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display string for a time.
|
||||
*
|
||||
* @param time the time
|
||||
* @return the display string of the time
|
||||
*/
|
||||
private String getDisplayDate(long time) {
|
||||
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
Date startTime = new Date(time);
|
||||
String dateString = format.format(startTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes spreadsheet row data to the indicated worksheet.
|
||||
*
|
||||
|
||||
@@ -212,9 +212,21 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
||||
return createProgressDialog();
|
||||
case DONE_DIALOG:
|
||||
return createDoneDialog();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialog(int id, Dialog dialog) {
|
||||
switch (id) {
|
||||
case SEND_DIALOG:
|
||||
SendDialog sendDialog = (SendDialog) dialog;
|
||||
sendDialog.setDocsEnabled(!shareRequested);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Dialog createSendDialog() {
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TableRow;
|
||||
|
||||
/**
|
||||
* A dialog where the user can choose where to send the tracks to, i.e.
|
||||
@@ -46,6 +47,9 @@ public class SendDialog extends Dialog {
|
||||
private CheckBox myMapsCheckBox;
|
||||
private CheckBox fusionTablesCheckBox;
|
||||
private CheckBox docsCheckBox;
|
||||
private TableRow docsTableRow;
|
||||
private boolean docsEnabled;
|
||||
|
||||
private OnClickListener clickListener;
|
||||
|
||||
public SendDialog(Context context) {
|
||||
@@ -67,7 +71,9 @@ public class SendDialog extends Dialog {
|
||||
myMapsCheckBox = (CheckBox) findViewById(R.id.send_google_my_maps);
|
||||
fusionTablesCheckBox = (CheckBox) findViewById(R.id.send_google_fusion_tables);
|
||||
docsCheckBox = (CheckBox) findViewById(R.id.send_google_docs);
|
||||
|
||||
|
||||
docsTableRow = (TableRow) findViewById(R.id.send_google_docs_table_row);
|
||||
|
||||
Button cancel = (Button) findViewById(R.id.send_google_cancel);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
@@ -90,9 +96,8 @@ public class SendDialog extends Dialog {
|
||||
|
||||
OnCheckedChangeListener checkBoxListener = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton button, boolean checked) {
|
||||
sendButton.setEnabled(myMapsCheckBox.isChecked() || fusionTablesCheckBox.isChecked()
|
||||
|| docsCheckBox.isChecked());
|
||||
myMapsGroup.setVisibility(myMapsCheckBox.isChecked() ? View.VISIBLE : View.GONE);
|
||||
sendButton.setEnabled(getSendToMyMaps() || getSendToFusionTables() || getSendToDocs());
|
||||
myMapsGroup.setVisibility(getSendToMyMaps() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,19 +131,29 @@ public class SendDialog extends Dialog {
|
||||
if (prefs != null) {
|
||||
Editor editor = prefs.edit();
|
||||
if (editor != null) {
|
||||
editor.putBoolean(getContext().getString(R.string.pick_existing_map_key),
|
||||
existingMapRadioButton.isChecked());
|
||||
editor.putBoolean(getContext().getString(R.string.send_to_my_maps_key),
|
||||
myMapsCheckBox.isChecked());
|
||||
editor.putBoolean(getContext().getString(R.string.send_to_fusion_tables_key),
|
||||
fusionTablesCheckBox.isChecked());
|
||||
editor.putBoolean(getContext().getString(R.string.send_to_docs_key),
|
||||
docsCheckBox.isChecked());
|
||||
editor.putBoolean(
|
||||
getContext().getString(R.string.pick_existing_map_key), !getCreateNewMap());
|
||||
editor.putBoolean(getContext().getString(R.string.send_to_my_maps_key), getSendToMyMaps());
|
||||
editor.putBoolean(
|
||||
getContext().getString(R.string.send_to_fusion_tables_key), getSendToFusionTables());
|
||||
if (docsEnabled) {
|
||||
editor.putBoolean(getContext().getString(R.string.send_to_docs_key), getSendToDocs());
|
||||
}
|
||||
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To enable the Google Docs option.
|
||||
*
|
||||
* @param docsEnabled true to enable the Google Docs option
|
||||
*/
|
||||
public void setDocsEnabled(boolean docsEnabled) {
|
||||
this.docsEnabled = docsEnabled;
|
||||
docsTableRow.setVisibility(docsEnabled ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public void setOnClickListener(OnClickListener clickListener) {
|
||||
this.clickListener = clickListener;
|
||||
}
|
||||
@@ -156,6 +171,6 @@ public class SendDialog extends Dialog {
|
||||
}
|
||||
|
||||
public boolean getSendToDocs() {
|
||||
return docsCheckBox.isChecked();
|
||||
return docsEnabled && docsCheckBox.isChecked();
|
||||
}
|
||||
}
|
||||
+21
-11
@@ -36,27 +36,40 @@ import android.util.Log;
|
||||
*/
|
||||
public class DynamicSpeedTrackPathDescriptor
|
||||
implements TrackPathDescriptor, OnSharedPreferenceChangeListener {
|
||||
|
||||
private int slowSpeed;
|
||||
private int normalSpeed;
|
||||
private int speedMargin;
|
||||
private final int speedMarginDefault;
|
||||
private double averageMovingSpeed;
|
||||
private final Context context;
|
||||
|
||||
public DynamicSpeedTrackPathDescriptor(Context context){
|
||||
this.context = context;
|
||||
speedMarginDefault = Integer.parseInt(
|
||||
context.getString(R.string.color_mode_dynamic_percentage_default));
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
if (prefs == null) {
|
||||
speedMargin = 25;
|
||||
speedMargin = speedMarginDefault;
|
||||
return;
|
||||
}
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
speedMargin = Integer.parseInt(prefs.getString(
|
||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key), "25"));
|
||||
speedMargin = getSpeedMargin(prefs);
|
||||
}
|
||||
|
||||
|
||||
private int getSpeedMargin(SharedPreferences sharedPreferences) {
|
||||
try {
|
||||
return Integer.parseInt(sharedPreferences.getString(
|
||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key),
|
||||
Integer.toString(speedMarginDefault)));
|
||||
} catch (NumberFormatException e) {
|
||||
return speedMarginDefault;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the slow speed calculated based on the % below the average speed.
|
||||
* @return The speed limit considered as slow.
|
||||
@@ -88,15 +101,12 @@ public class DynamicSpeedTrackPathDescriptor
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
if (prefs == null) {
|
||||
speedMargin = 25;
|
||||
speedMargin = speedMarginDefault;
|
||||
return;
|
||||
}
|
||||
|
||||
speedMargin =
|
||||
Integer.parseInt(
|
||||
prefs.getString(
|
||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key), "25"));
|
||||
}
|
||||
|
||||
speedMargin = getSpeedMargin(prefs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsRedraw() {
|
||||
|
||||
+17
-12
@@ -34,32 +34,37 @@ import android.util.Log;
|
||||
public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSharedPreferenceChangeListener {
|
||||
private int slowSpeed;
|
||||
private int normalSpeed;
|
||||
private final int slowDefault;
|
||||
private final int normalDefault;
|
||||
private final Context context;
|
||||
|
||||
public FixedSpeedTrackPathDescriptor(Context context) {
|
||||
|
||||
this.context = context;
|
||||
slowDefault = Integer.parseInt(context.getString(R.string.color_mode_fixed_slow_default));
|
||||
normalDefault = Integer.parseInt(context.getString(R.string.color_mode_fixed_medium_default));
|
||||
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
if (prefs == null) {
|
||||
slowSpeed = 9;
|
||||
normalSpeed = 17;
|
||||
slowSpeed = slowDefault;
|
||||
normalSpeed = normalDefault;
|
||||
return;
|
||||
}
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
try {
|
||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_slow_key), "9"));
|
||||
R.string.track_color_mode_fixed_speed_slow_key), Integer.toString(slowDefault)));
|
||||
} catch (NumberFormatException e) {
|
||||
slowSpeed = 9;
|
||||
slowSpeed = slowDefault;
|
||||
}
|
||||
|
||||
try {
|
||||
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_medium_key), "17"));
|
||||
R.string.track_color_mode_fixed_speed_medium_key), Integer.toString(normalDefault)));
|
||||
} catch (NumberFormatException e) {
|
||||
normalSpeed = 17;
|
||||
normalSpeed = normalDefault;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,22 +95,22 @@ public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSha
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
if (prefs == null) {
|
||||
slowSpeed = 9;
|
||||
normalSpeed = 17;
|
||||
slowSpeed = slowDefault;
|
||||
normalSpeed = normalDefault;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_slow_key), "9"));
|
||||
R.string.track_color_mode_fixed_speed_slow_key), Integer.toString(slowDefault)));
|
||||
} catch (NumberFormatException e) {
|
||||
slowSpeed = 9;
|
||||
slowSpeed = slowDefault;
|
||||
}
|
||||
try {
|
||||
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
||||
R.string.track_color_mode_fixed_speed_medium_key), "17"));
|
||||
R.string.track_color_mode_fixed_speed_medium_key), Integer.toString(normalDefault)));
|
||||
} catch (NumberFormatException e) {
|
||||
normalSpeed = 17;
|
||||
normalSpeed = normalDefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
package com.google.android.apps.mytracks.services;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Creates a default track name based on the current default track name policy.
|
||||
*
|
||||
@@ -46,8 +44,7 @@ class DefaultTrackNameFactory {
|
||||
*/
|
||||
String newTrackName(long trackId, long startTime) {
|
||||
if (useTimestampTrackName()) {
|
||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
return formatter.format(new Date(startTime));
|
||||
return StringUtils.formatDateTime(startTime);
|
||||
} else {
|
||||
return String.format(context.getString(R.string.track_name_format), trackId);
|
||||
}
|
||||
|
||||
+2
-2
@@ -130,8 +130,8 @@ public class BluetoothSensorManager extends SensorManager {
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
String address =
|
||||
prefs.getString(context.getString(R.string.bluetooth_sensor_key), null);
|
||||
if (address == null) {
|
||||
prefs.getString(context.getString(R.string.bluetooth_sensor_key), "");
|
||||
if (address == null || address.equals("")) {
|
||||
return;
|
||||
}
|
||||
Log.w(Constants.TAG, "Connecting to bluetooth sensor: " + address);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SensorUtils {
|
||||
public static String getStateAsString(Sensor.SensorState state, Context c) {
|
||||
switch (state) {
|
||||
case NONE:
|
||||
return c.getString(R.string.sensor_type_value_none);
|
||||
return c.getString(R.string.settings_sensor_type_none);
|
||||
case CONNECTING:
|
||||
return c.getString(R.string.sensor_state_connecting);
|
||||
case CONNECTED:
|
||||
|
||||
@@ -15,16 +15,22 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.util;
|
||||
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
|
||||
/**
|
||||
* Utilities for the EULA preference value.
|
||||
* Utilities for EULA.
|
||||
*/
|
||||
public class EulaUtil {
|
||||
private static final String EULA_PREFERENCE_FILE = "eula";
|
||||
private static final String EULA_PREFERENCE_KEY = "eula.accepted";
|
||||
|
||||
// Accepting Google mobile terms of service
|
||||
private static final String EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
|
||||
|
||||
private static final String HOST_NAME = "m.google.com";
|
||||
|
||||
private EulaUtil() {}
|
||||
|
||||
@@ -41,4 +47,29 @@ public class EulaUtil {
|
||||
editor.putBoolean(EULA_PREFERENCE_KEY, true);
|
||||
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||
}
|
||||
|
||||
public static String getEulaMessage(Context context) {
|
||||
String item1 = String.format(context.getString(R.string.eula_message_item1), HOST_NAME,
|
||||
HOST_NAME, HOST_NAME, HOST_NAME, HOST_NAME);
|
||||
String item3 = String.format(context.getString(R.string.eula_message_item3), HOST_NAME);
|
||||
String footer = String.format(context.getString(R.string.eula_message_footer), HOST_NAME);
|
||||
|
||||
return context.getString(R.string.eula_message_date)
|
||||
+ "\n\n"
|
||||
+ context.getString(R.string.eula_message_header)
|
||||
+ "\n\n"
|
||||
+ context.getString(R.string.eula_message_body)
|
||||
+ "\n\n"
|
||||
+ "1. " + item1
|
||||
+ "\n\n"
|
||||
+ "2. " + context.getString(R.string.eula_message_item2)
|
||||
+ "\n\n"
|
||||
+ "3. " + item3
|
||||
+ "\n\n"
|
||||
+ "4. " + context.getString(R.string.eula_message_item4)
|
||||
+ "\n\n"
|
||||
+ footer
|
||||
+ "\n\n"
|
||||
+ context.getString(R.string.eula_message_copyright);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.google.android.maps.mytracks.R;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParsePosition;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -44,6 +45,16 @@ public class StringUtils implements DescriptionGenerator {
|
||||
|
||||
private final Context context;
|
||||
|
||||
/**
|
||||
* Formats the time based on user locale.
|
||||
*
|
||||
* @param time time
|
||||
*/
|
||||
public static String formatDateTime(long time) {
|
||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
return formatter.format(new Date(time));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a number of milliseconds as a string.
|
||||
*
|
||||
@@ -303,7 +314,7 @@ public class StringUtils implements DescriptionGenerator {
|
||||
+ "%s: %d %s (%d %s)<br>"
|
||||
+ "%s: %d %%<br>"
|
||||
+ "%s: %d %%<br>"
|
||||
+ "%s: %tc<br>"
|
||||
+ "%s: %s<br>"
|
||||
+ "%s: %s<br>"
|
||||
+ "<img border=\"0\" src=\"%s\"/>",
|
||||
|
||||
@@ -349,7 +360,7 @@ public class StringUtils implements DescriptionGenerator {
|
||||
|
||||
// Line 11
|
||||
context.getString(R.string.send_google_recorded),
|
||||
new Date(trackStats.getStartTime()),
|
||||
StringUtils.formatDateTime(trackStats.getStartTime()),
|
||||
|
||||
// Line 12
|
||||
context.getString(R.string.track_detail_activity_type_hint), category,
|
||||
|
||||
Reference in New Issue
Block a user