mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Use list preference for chart x axis settings
This commit is contained in:
@@ -92,6 +92,14 @@ limitations under the License.
|
||||
<item>15</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
<string-array name="chart_x_axis_options">
|
||||
<item>@string/settings_chart_by_distance</item>
|
||||
<item>@string/settings_chart_by_time</item>
|
||||
</string-array>
|
||||
<string-array name="chart_x_axis_values">
|
||||
<item>@string/chart_x_axis_distance</item>
|
||||
<item>@string/chart_x_axis_time</item>
|
||||
</string-array>
|
||||
<string-array name="frequency_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
|
||||
@@ -16,6 +16,8 @@ limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<!-- DO NOT TRANSLATE ANY STRINGS IN THIS FILE. -->
|
||||
<string name="chart_x_axis_distance">DISTANCE</string>
|
||||
<string name="chart_x_axis_time">TIME</string>
|
||||
<string name="eula_korean">위치정보서비스 및 위치기반서비스 이용약관\n
|
||||
\n
|
||||
다음은 구글코리아 유한회사(이하 “Google”)가 Google의 제품에 대하여 제공하고 있는 위치기반서비스에 적용되는 이용조건입니다. 아래 이용조건은 이동통신사업자의 가입신청서에 포함된 위치정보 수집동의 및 모바일 단말기 이용조건과 함께 적용됩니다.\n
|
||||
|
||||
@@ -18,12 +18,12 @@ limitations under the License.
|
||||
<!-- Keys for persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
|
||||
<string name="allow_access_key">allowAccess</string>
|
||||
<string name="auto_resume_track_timeout_key">autoResumeTrackTimeout</string>
|
||||
<string name="chart_by_distance_key">chartByDistance</string>
|
||||
<string name="chart_show_cadence_key">chartShowCadence</string>
|
||||
<string name="chart_show_elevation_key">chartShowElevation</string>
|
||||
<string name="chart_show_heart_rate_key">chartShowHeartRate</string>
|
||||
<string name="chart_show_power_key">chartShowPower</string>
|
||||
<string name="chart_show_speed_key">chartShowSpeed</string>
|
||||
<string name="chart_x_axis_key">chartXAxis</string>
|
||||
<string name="default_activity_key">defaultActivity</string>
|
||||
<string name="export_external_storage_format_key">exportExternalStorageFormat</string>
|
||||
<string name="export_google_fusion_tables_public_key">exportGoogleFusionTablesPublic</string>
|
||||
|
||||
@@ -16,11 +16,9 @@ limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/track_detail_chart_tab" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/chart_by_distance_key"
|
||||
android:summaryOff="@string/settings_chart_by_time"
|
||||
android:summaryOn="@string/settings_chart_by_distance"
|
||||
<ListPreference
|
||||
android:defaultValue="@string/chart_x_axis_distance"
|
||||
android:key="@string/chart_x_axis_key"
|
||||
android:title="@string/settings_chart_x_axis" />
|
||||
<PreferenceCategory android:title="@string/settings_show" >
|
||||
<CheckBoxPreference
|
||||
|
||||
@@ -305,8 +305,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
*/
|
||||
private void checkChartSettings() {
|
||||
boolean needUpdate = false;
|
||||
if (chartByDistance != PreferencesUtils.getBoolean(getActivity(),
|
||||
R.string.chart_by_distance_key, PreferencesUtils.CHART_BY_DISTANCE_DEFAULT)) {
|
||||
if (chartByDistance != PreferencesUtils.isChartByDistance(getActivity())) {
|
||||
chartByDistance = !chartByDistance;
|
||||
chartView.setChartByDistance(chartByDistance);
|
||||
reloadTrackDataHub();
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
|
||||
/**
|
||||
* An activity for accessing chart settings.
|
||||
@@ -34,6 +35,7 @@ public class ChartSettingsActivity extends AbstractSettingsActivity {
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
addPreferencesFromResource(R.xml.chart_settings);
|
||||
configXAxisListPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,8 +48,21 @@ public class ChartSettingsActivity extends AbstractSettingsActivity {
|
||||
private void updateUi() {
|
||||
CheckBoxPreference speedCheckBoxPreference = (CheckBoxPreference) findPreference(
|
||||
getString(R.string.chart_show_speed_key));
|
||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(this);
|
||||
speedCheckBoxPreference.setTitle(reportSpeed ? R.string.stats_speed
|
||||
: R.string.stats_pace);
|
||||
speedCheckBoxPreference.setTitle(
|
||||
PreferencesUtils.isReportSpeed(this) ? R.string.stats_speed : R.string.stats_pace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the x axis list preference.
|
||||
*/
|
||||
private void configXAxisListPreference() {
|
||||
@SuppressWarnings("deprecation")
|
||||
ListPreference listPreference = (ListPreference) findPreference(
|
||||
getString(R.string.chart_x_axis_key));
|
||||
String value = PreferencesUtils.getString(
|
||||
this, R.string.chart_x_axis_key, PreferencesUtils.CHART_X_AXIS_DEFAULT);
|
||||
String[] values = getResources().getStringArray(R.array.chart_x_axis_values);
|
||||
String[] options = getResources().getStringArray(R.array.chart_x_axis_options);
|
||||
configureListPreference(listPreference, options, options, values, value, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ public class PreferencesUtils {
|
||||
|
||||
public static final String BLUETOOTH_SENSOR_DEFAULT = "";
|
||||
|
||||
public static final boolean CHART_BY_DISTANCE_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_CADENCE_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_ELEVATION_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_HEART_RATE_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_POWER_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_SPEED_DEFAULT = true;
|
||||
public static final String CHART_X_AXIS_DEFAULT = "DISTANCE";
|
||||
|
||||
public static final boolean CONFIRM_PLAY_EARTH_DEFAULT = true;
|
||||
|
||||
@@ -257,9 +257,10 @@ public class PreferencesUtils {
|
||||
return PreferencesUtils.STATS_UNITS_DEFAULT.equals(
|
||||
getString(context, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the preferred rate is speed, false if the preferred rate is pace.
|
||||
* Returns true if the preferred rate is speed, false if the preferred rate is
|
||||
* pace.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
@@ -267,4 +268,14 @@ public class PreferencesUtils {
|
||||
return PreferencesUtils.STATS_RATE_DEFAULT.equals(
|
||||
getString(context, R.string.stats_rate_key, PreferencesUtils.STATS_RATE_DEFAULT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if chart x axis is by distance, false if by time.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static boolean isChartByDistance(Context context) {
|
||||
return PreferencesUtils.CHART_X_AXIS_DEFAULT.equals(
|
||||
getString(context, R.string.chart_x_axis_key, PreferencesUtils.CHART_X_AXIS_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user