forked from upstream-mirrors/OpenTracks
Move Stats settings to StatsSettingsActivity.
This commit is contained in:
+5
-4
@@ -47,8 +47,8 @@ public class CheckUnitsDialogFragment extends DialogFragment {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key, defaultMetric);
|
||||
final String metric = getString(R.string.preferred_units_metric);
|
||||
final String imperial = getString(R.string.preferred_units_imperial);
|
||||
final String metric = getString(R.string.settings_stats_units_metric);
|
||||
final String imperial = getString(R.string.settings_stats_units_imperial);
|
||||
final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
|
||||
: new CharSequence[] { imperial, metric };
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
@@ -56,12 +56,13 @@ public class CheckUnitsDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key, items[position].equals(metric));
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.metric_units_key, items[position].equals(metric));
|
||||
onDone();
|
||||
}
|
||||
})
|
||||
.setSingleChoiceItems(items, 0, null)
|
||||
.setTitle(R.string.preferred_units_title).create();
|
||||
.setTitle(R.string.settings_stats_units_title).create();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -270,8 +270,11 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
||||
private synchronized boolean isRecording() {
|
||||
return trackDataHub != null && trackDataHub.isRecordingSelected();
|
||||
}
|
||||
|
||||
public void updateUi() {
|
||||
|
||||
/**
|
||||
* Updates the UI.
|
||||
*/
|
||||
private void updateUi() {
|
||||
StatsUtils.setTripStatisticsValues(getActivity(), lastTripStatistics);
|
||||
StatsUtils.setLocationValues(getActivity(), lastLocation, true);
|
||||
}
|
||||
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 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.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
/**
|
||||
* A DialogFragment to show stats settings.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class StatsSettingsDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String STATS_SETTINGS_DIALOG_TAG = "statsSettingsDialog";
|
||||
|
||||
public interface OnStatsSettingsChangedListener {
|
||||
public void onStatsSettingsChanged();
|
||||
}
|
||||
|
||||
private OnStatsSettingsChangedListener listener;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
try {
|
||||
listener = (OnStatsSettingsChangedListener) activity;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(activity.toString()
|
||||
+ " must implement OnArticleSelectedListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.stats_settings, null);
|
||||
final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.stats_settings_time);
|
||||
boolean totalTime = PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.stats_show_total_time_key, true);
|
||||
radioGroup.check(totalTime ? R.id.stats_settings_total_time : R.id.stats_settings_moving_time);
|
||||
|
||||
final CheckBox elevation = (CheckBox) view.findViewById(R.id.stats_settings_elevation);
|
||||
final CheckBox grade = (CheckBox) view.findViewById(R.id.stats_settings_grade);
|
||||
final CheckBox coordinate = (CheckBox) view.findViewById(R.id.stats_settings_coordinate);
|
||||
|
||||
elevation.setChecked(
|
||||
PreferencesUtils.getBoolean(getActivity(), R.string.stats_show_elevation_key, false));
|
||||
grade.setChecked(
|
||||
PreferencesUtils.getBoolean(getActivity(), R.string.stats_show_grade_key, false));
|
||||
coordinate.setChecked(
|
||||
PreferencesUtils.getBoolean(getActivity(), R.string.stats_show_coordinate_key, false));
|
||||
|
||||
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.stats_show_total_time_key,
|
||||
radioGroup.getCheckedRadioButtonId() == R.id.stats_settings_total_time);
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.stats_show_elevation_key, elevation.isChecked());
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.stats_show_grade_key, grade.isChecked());
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.stats_show_coordinate_key, coordinate.isChecked());
|
||||
listener.onStatsSettingsChanged();
|
||||
}
|
||||
})
|
||||
.setTitle(R.string.menu_stats_settings)
|
||||
.setView(view)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user