Improve chartview layout.

This commit is contained in:
Jimmy Shih
2012-05-25 17:28:50 -07:00
parent e6abe73404
commit 81805f00d8
5 changed files with 686 additions and 577 deletions
+4 -4
View File
@@ -497,10 +497,6 @@ limitations under the License.
translation_description="Label for location speed in meters per second."> translation_description="Label for location speed in meters per second.">
Speed (m/s) Speed (m/s)
</string> </string>
<string name="description_location_time"
translation_description="Label for location time.">
Time
</string>
<string name="description_max_elevation" <string name="description_max_elevation"
translation_description="Max elevation description. translation_description="Max elevation description.
@@ -578,6 +574,10 @@ limitations under the License.
translation_description="Speed in metric units, kilometers per hour."> translation_description="Speed in metric units, kilometers per hour.">
Speed (km/hr) Speed (km/hr)
</string> </string>
<string name="description_time"
translation_description="Label for time.">
Time
</string>
<string name="description_track_point" <string name="description_track_point"
translation_description="Label for a track point"> translation_description="Label for a track point">
Point Point
@@ -85,13 +85,15 @@ public class ChartValueSeries {
strokePaint.setColor(context.getResources().getColor(strokeColor)); strokePaint.setColor(context.getResources().getColor(strokeColor));
strokePaint.setAntiAlias(true); strokePaint.setAntiAlias(true);
float scale = context.getResources().getDisplayMetrics().density;
// Make copies of the stroke paint with the default thickness // Make copies of the stroke paint with the default thickness
titlePaint = new Paint(strokePaint); titlePaint = new Paint(strokePaint);
titlePaint.setTextSize(ChartView.LARGE_TEXT_SIZE); titlePaint.setTextSize(ChartView.MEDIUM_TEXT_SIZE * scale);
titlePaint.setTextAlign(Align.CENTER); titlePaint.setTextAlign(Align.CENTER);
markerPaint = new Paint(strokePaint); markerPaint = new Paint(strokePaint);
markerPaint.setTextSize(ChartView.MEDIUM_TEXT_SIZE); markerPaint.setTextSize(ChartView.SMALL_TEXT_SIZE * scale);
markerPaint.setTextAlign(Align.RIGHT); markerPaint.setTextAlign(Align.RIGHT);
// Set stroke paint thickness // Set stroke paint thickness
File diff suppressed because it is too large Load Diff
@@ -280,8 +280,10 @@ public class ChartFragment extends Fragment implements TrackDataListener {
return false; return false;
} }
reportSpeed = speed; reportSpeed = speed;
setSeriesEnabled(ChartView.SPEED_SERIES, reportSpeed); boolean chartShowSpeed = PreferencesUtils.getBoolean(
setSeriesEnabled(ChartView.PACE_SERIES, !reportSpeed); getActivity(), R.string.chart_show_speed_key, PreferencesUtils.CHART_SHOW_SPEED_DEFAULT);
setSeriesEnabled(ChartView.SPEED_SERIES, chartShowSpeed && reportSpeed);
setSeriesEnabled(ChartView.PACE_SERIES, chartShowSpeed && !reportSpeed);
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -307,12 +309,13 @@ public class ChartFragment extends Fragment implements TrackDataListener {
R.string.chart_show_elevation_key, PreferencesUtils.CHART_SHOW_ELEVATION_DEFAULT))) { R.string.chart_show_elevation_key, PreferencesUtils.CHART_SHOW_ELEVATION_DEFAULT))) {
needUpdate = true; needUpdate = true;
} }
if (setSeriesEnabled(ChartView.SPEED_SERIES, PreferencesUtils.getBoolean(
getActivity(), R.string.chart_show_speed_key, PreferencesUtils.CHART_SHOW_SPEED_DEFAULT))) { boolean chartShowSpeed = PreferencesUtils.getBoolean(
getActivity(), R.string.chart_show_speed_key, PreferencesUtils.CHART_SHOW_SPEED_DEFAULT);
if (setSeriesEnabled(ChartView.SPEED_SERIES, chartShowSpeed && reportSpeed)) {
needUpdate = true; needUpdate = true;
} }
if (setSeriesEnabled(ChartView.PACE_SERIES, !PreferencesUtils.getBoolean( if (setSeriesEnabled(ChartView.PACE_SERIES, chartShowSpeed && !reportSpeed)) {
getActivity(), R.string.chart_show_speed_key, PreferencesUtils.CHART_SHOW_SPEED_DEFAULT))) {
needUpdate = true; needUpdate = true;
} }
if (setSeriesEnabled(ChartView.POWER_SERIES, PreferencesUtils.getBoolean( if (setSeriesEnabled(ChartView.POWER_SERIES, PreferencesUtils.getBoolean(
@@ -110,7 +110,7 @@ public class CsvTrackWriter implements TrackFormatWriter {
context.getString(R.string.description_location_bearing), context.getString(R.string.description_location_bearing),
context.getString(R.string.description_location_accuracy), context.getString(R.string.description_location_accuracy),
context.getString(R.string.description_location_speed), context.getString(R.string.description_location_speed),
context.getString(R.string.description_location_time)); context.getString(R.string.description_time));
} }
@Override @Override
@@ -143,7 +143,7 @@ public class CsvTrackWriter implements TrackFormatWriter {
context.getString(R.string.description_location_bearing), context.getString(R.string.description_location_bearing),
context.getString(R.string.description_location_accuracy), context.getString(R.string.description_location_accuracy),
context.getString(R.string.description_location_speed), context.getString(R.string.description_location_speed),
context.getString(R.string.description_location_time), context.getString(R.string.description_time),
context.getString(R.string.description_sensor_power), context.getString(R.string.description_sensor_power),
context.getString(R.string.description_sensor_cadence), context.getString(R.string.description_sensor_cadence),
context.getString(R.string.description_sensor_heart_rate), context.getString(R.string.description_sensor_heart_rate),