mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-03 09:53:06 +02:00
Update the chart settings dialog based on ICS style guide.
This commit is contained in:
@@ -35,9 +35,9 @@ import com.google.android.maps.mytracks.R;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
@@ -45,7 +45,9 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.ZoomControls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -59,7 +61,7 @@ import java.util.EnumSet;
|
||||
*/
|
||||
public class ChartActivity extends Activity implements TrackDataListener {
|
||||
|
||||
public static final int CHART_SETTINGS_DIALOG = 1;
|
||||
private static final int DIALOG_CHART_SETTINGS_ID = 0;
|
||||
|
||||
private final DoubleBuffer elevationBuffer =
|
||||
new DoubleBuffer(Constants.ELEVATION_SMOOTHING_FACTOR);
|
||||
@@ -185,43 +187,60 @@ public class ChartActivity extends Activity implements TrackDataListener {
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
if (id == CHART_SETTINGS_DIALOG) {
|
||||
final ChartSettingsDialog settingsDialog = new ChartSettingsDialog(this);
|
||||
settingsDialog.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface arg0, int which) {
|
||||
if (which != DialogInterface.BUTTON_POSITIVE) {
|
||||
return;
|
||||
}
|
||||
switch (id) {
|
||||
case DIALOG_CHART_SETTINGS_ID:
|
||||
View view = getLayoutInflater().inflate(R.layout.chart_settings, null);
|
||||
final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.chart_settings_x);
|
||||
radioGroup.check(chartView.getMode() == Mode.BY_DISTANCE
|
||||
? R.id.chart_settings_by_distance : R.id.chart_settings_by_time);
|
||||
|
||||
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
||||
chartView.setChartValueSeriesEnabled(i, settingsDialog.isSeriesEnabled(i));
|
||||
}
|
||||
setMode(settingsDialog.getMode());
|
||||
chartView.postInvalidate();
|
||||
final CheckBox[] checkBoxes = new CheckBox[ChartView.NUM_SERIES];
|
||||
checkBoxes[ChartView.ELEVATION_SERIES] = (CheckBox) view.findViewById(
|
||||
R.id.chart_settings_elevation);
|
||||
checkBoxes[ChartView.SPEED_SERIES] = (CheckBox) view.findViewById(
|
||||
R.id.chart_settings_speed);
|
||||
checkBoxes[ChartView.POWER_SERIES] = (CheckBox) view.findViewById(
|
||||
R.id.chart_settings_power);
|
||||
checkBoxes[ChartView.CADENCE_SERIES] = (CheckBox) view.findViewById(
|
||||
R.id.chart_settings_cadence);
|
||||
checkBoxes[ChartView.HEART_RATE_SERIES] = (CheckBox) view.findViewById(
|
||||
R.id.chart_settings_heart_rate);
|
||||
|
||||
// set checkboxes values
|
||||
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
||||
checkBoxes[i].setChecked(chartView.isChartValueSeriesEnabled(i));
|
||||
}
|
||||
});
|
||||
return settingsDialog;
|
||||
}
|
||||
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialog(int id, Dialog dialog) {
|
||||
super.onPrepareDialog(id, dialog);
|
||||
|
||||
if (id == CHART_SETTINGS_DIALOG) {
|
||||
prepareSettingsDialog((ChartSettingsDialog) dialog);
|
||||
checkBoxes[ChartView.SPEED_SERIES]
|
||||
.setText(reportSpeed ? R.string.stat_speed : R.string.stat_pace);
|
||||
|
||||
return new AlertDialog.Builder(this)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(R.string.generic_cancel, null)
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
setMode(radioGroup.getCheckedRadioButtonId() == R.id.chart_settings_by_distance
|
||||
? Mode.BY_DISTANCE
|
||||
: Mode.BY_TIME);
|
||||
for (int i = 0; i < ChartView.NUM_SERIES; i++) {
|
||||
chartView.setChartValueSeriesEnabled(i, checkBoxes[i].isChecked());
|
||||
}
|
||||
chartView.postInvalidate();
|
||||
}
|
||||
})
|
||||
.setTitle(R.string.menu_chart_view_chart_settings)
|
||||
.setView(view)
|
||||
.create();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
/**
|
||||
* Shows the chart settings dialog
|
||||
*/
|
||||
public void showChartSettingsDialog() {
|
||||
showDialog(DIALOG_CHART_SETTINGS_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user