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
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.ChartValueSeries.ZoomSettings;
import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.stats.ExtremityMonitor;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R;
@@ -75,7 +76,7 @@ public class ChartView extends View {
/**
* Unscaled top border of the chart.
*/
private static final int TOP_BORDER = 15;
private static final int TOP_BORDER = 16;
/**
* Device scaled top border of the chart.
@@ -85,7 +86,7 @@ public class ChartView extends View {
/**
* Unscaled bottom border of the chart.
*/
private static final float BOTTOM_BORDER = 40;
private static final float BOTTOM_BORDER = 8;
/**
* Device scaled bottom border of the chart.
@@ -190,7 +191,7 @@ public class ChartView extends View {
pointer.setBounds(0, 0,
pointer.getIntrinsicWidth(), pointer.getIntrinsicHeight());
statsMarker = getResources().getDrawable(R.drawable.ylw_pushpin);
statsMarker = getResources().getDrawable(R.drawable.yellow_pushpin);
markerWidth = statsMarker.getIntrinsicWidth();
markerHeight = statsMarker.getIntrinsicHeight();
statsMarker.setBounds(0, 0, markerWidth, markerHeight);
@@ -214,7 +215,7 @@ public class ChartView extends View {
R.color.elevation_border,
new ZoomSettings(MAX_INTERVALS,
new int[] {5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000}),
R.string.stat_elevation);
R.string.stats_elevation);
series[SPEED_SERIES] =
new ChartValueSeries(context,
@@ -222,7 +223,7 @@ public class ChartView extends View {
R.color.speed_border,
new ZoomSettings(MAX_INTERVALS, 0, Integer.MIN_VALUE,
new int[] {1, 5, 10, 20, 50}),
R.string.stat_speed);
R.string.stats_speed);
series[POWER_SERIES] =
new ChartValueSeries(context,
R.color.power_fill,
@@ -269,8 +270,8 @@ public class ChartView extends View {
public void setReportSpeed(boolean reportSpeed, Context c) {
series[SPEED_SERIES].setTitle(c.getString(reportSpeed
? R.string.stat_speed
: R.string.stat_pace));
? R.string.stats_speed
: R.string.stats_pace));
}
private void addDataPointInternal(double[] theData) {
@@ -485,8 +486,7 @@ public class ChartView extends View {
}
}
if (nearestWaypoint != null && dmin < 100) {
Intent intent = new Intent(getContext(), MarkerDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
Intent intent = IntentUtils.newIntent(getContext(), MarkerDetailActivity.class)
.putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, nearestWaypoint.getId());
getContext().startActivity(intent);
return true;
@@ -509,10 +509,16 @@ public class ChartView extends View {
return true;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
updateEffectiveDimensionsIfChanged(
View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(heightMeasureSpec));
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onDraw(Canvas c) {
synchronized (data) {
updateEffectiveDimensionsIfChanged(c);
// Keep original state.
c.save();
@@ -742,13 +748,16 @@ public class ChartView extends View {
/**
* Updates the effective dimensions where the graph will be drawn, only if the
* dimensions of the given canvas have changed since the last call.
* dimensions have changed since the last call.
*
* @param newWidth the new width
* @param newHeight the new height
*/
private void updateEffectiveDimensionsIfChanged(Canvas c) {
if (w != c.getWidth() || h != c.getHeight()) {
private void updateEffectiveDimensionsIfChanged(int newWidth, int newHeight) {
if (w != newWidth || h != newHeight) {
// Dimensions have changed (for example due to orientation change).
w = c.getWidth();
h = c.getHeight();
w = newWidth;
h = newHeight;
updateEffectiveDimensions();
setUpPath();
}