Merge heads

This commit is contained in:
youtaol
2012-05-04 17:04:45 +08:00
parent a12f4bcbe8
commit fd90dcffa6
189 changed files with 3288 additions and 3323 deletions
@@ -20,11 +20,13 @@ import static com.google.android.apps.mytracks.Constants.SETTINGS_NAME;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.TrackDetailActivity;
import com.google.android.apps.mytracks.TrackListActivity;
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.apps.mytracks.services.ControlRecordingService;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
@@ -69,7 +71,7 @@ public class TrackWidgetProvider
private Context context;
private String unknown;
private TrackObserver trackObserver;
private boolean isMetric;
private boolean metricUnits;
private boolean reportSpeed;
private long selectedTrackId;
private SharedPreferences sharedPreferences;
@@ -146,10 +148,12 @@ public class TrackWidgetProvider
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.track_widget);
// Make all of the stats open the mytracks activity.
Intent intent = new Intent(context, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
Intent intent;
if (track != null) {
intent.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, track.getId());
intent = IntentUtils.newIntent(context, TrackDetailActivity.class)
.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, track.getId());
} else {
intent = IntentUtils.newIntent(context, TrackListActivity.class);
}
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
views.setOnClickPendingIntent(R.id.appwidget_track_statistics, pendingIntent);
@@ -174,11 +178,11 @@ public class TrackWidgetProvider
if (TRACK_STARTED_ACTION.equals(action)) {
// If a new track is started by this appwidget or elsewhere,
// toggle the button to active and have it disable the track if pressed.
setButtonIntent(views, R.string.track_action_end, R.drawable.appwidget_button_enabled);
setButtonIntent(views, R.string.track_action_end, R.drawable.app_widget_button_enabled);
} else {
// If a track is stopped by this appwidget or elsewhere,
// toggle the button to inactive and have it start a new track if pressed.
setButtonIntent(views, R.string.track_action_start, R.drawable.appwidget_button_disabled);
setButtonIntent(views, R.string.track_action_start, R.drawable.app_widget_button_disabled);
}
}
@@ -190,8 +194,8 @@ public class TrackWidgetProvider
* @param icon The resource id of the icon to show for the button
*/
private void setButtonIntent(RemoteViews views, int action, int icon) {
Intent intent = new Intent(context, ControlRecordingService.class);
intent.setAction(context.getString(action));
Intent intent = new Intent(context, ControlRecordingService.class)
.setAction(context.getString(action));
PendingIntent pendingIntent = PendingIntent.getService(context, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.appwidget_button, pendingIntent);
@@ -214,10 +218,10 @@ public class TrackWidgetProvider
}
TripStatistics stats = track.getStatistics();
String distance = StringUtils.formatDistance(context, stats.getTotalDistance(), isMetric);
String distance = StringUtils.formatDistance(context, stats.getTotalDistance(), metricUnits);
String time = StringUtils.formatElapsedTime(stats.getMovingTime());
String speed = StringUtils.formatSpeed(
context, stats.getAverageMovingSpeed(), isMetric, reportSpeed);
context, stats.getAverageMovingSpeed(), metricUnits, reportSpeed);
views.setTextViewText(R.id.appwidget_distance_text, distance);
views.setTextViewText(R.id.appwidget_time_text, time);
@@ -226,14 +230,12 @@ public class TrackWidgetProvider
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
String metricUnitsKey = context.getString(R.string.metric_units_key);
if (key == null || key.equals(metricUnitsKey)) {
isMetric = prefs.getBoolean(metricUnitsKey, true);
if (key == null || key.equals(PreferencesUtils.getMetricUnitsKey(context))) {
metricUnits = PreferencesUtils.isMetricUnits(context);
}
String reportSpeedKey = context.getString(R.string.report_speed_key);
if (key == null || key.equals(reportSpeedKey)) {
reportSpeed = prefs.getBoolean(reportSpeedKey, true);
if (key == null || key.equals(PreferencesUtils.getReportSpeedKey(context))) {
reportSpeed = PreferencesUtils.isReportSpeed(context);
}
if (key == null || key.equals(PreferencesUtils.getSelectedTrackIdKey(context))) {