Move voice frequency and split frequency to menu items.

This commit is contained in:
Jimmy Shih
2012-05-11 15:04:08 -07:00
parent 2085e82312
commit 1fef0144b3
15 changed files with 200 additions and 96 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

+17 -7
View File
@@ -59,15 +59,25 @@ limitations under the License.
android:showAsAction="ifRoom"
android:title="@string/menu_markers"/>
<!-- android:orderInCategory="6" is in map.xml -->
<item
android:icon="@drawable/menu_voice_frequency"
android:id="@+id/track_detail_voice_frequency"
android:orderInCategory="7"
android:title="@string/menu_voice_frequency"/>
<item
android:icon="@drawable/menu_split_frequency"
android:id="@+id/track_detail_split_frequency"
android:orderInCategory="8"
android:title="@string/menu_split_frequency"/>
<item
android:icon="@drawable/menu_send_google"
android:id="@+id/track_detail_send_google"
android:orderInCategory="7"
android:orderInCategory="9"
android:title="@string/menu_send_google"/>
<item
android:icon="@drawable/menu_save"
android:id="@+id/track_detail_save"
android:orderInCategory="8"
android:orderInCategory="10"
android:title="@string/menu_save">
<menu>
<item android:id="@+id/track_detail_save_gpx"/>
@@ -79,26 +89,26 @@ limitations under the License.
<item
android:icon="@drawable/menu_edit"
android:id="@+id/track_detail_edit"
android:orderInCategory="9"
android:orderInCategory="11"
android:title="@string/menu_edit"/>
<item
android:icon="@drawable/menu_delete"
android:id="@+id/track_detail_delete"
android:orderInCategory="10"
android:orderInCategory="12"
android:title="@string/menu_delete"/>
<item
android:icon="@drawable/menu_sensor_state"
android:id="@+id/track_detail_sensor_state"
android:orderInCategory="11"
android:orderInCategory="13"
android:title="@string/menu_sensor_state"/>
<item
android:icon="@drawable/menu_settings"
android:id="@+id/track_detail_settings"
android:orderInCategory="12"
android:orderInCategory="14"
android:title="@string/menu_settings"/>
<item
android:icon="@drawable/menu_help"
android:id="@+id/track_detail_help"
android:orderInCategory="13"
android:orderInCategory="15"
android:title="@string/menu_help"/>
</menu>
+16 -16
View File
@@ -96,6 +96,22 @@ limitations under the License.
<item>CSV</item>
<item>TCX</item>
</string-array>
<string-array name="frequency_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>5</item>
<item>10</item>
<item>15</item>
<item>30</item>
<item>60</item>
<item>-1</item>
<item>-5</item>
<item>-10</item>
<item>-25</item>
<item>-50</item>
<item>-100</item>
</string-array>
<string-array name="max_recording_distance_values">
<item>50</item>
<item>100</item>
@@ -142,22 +158,6 @@ limitations under the License.
<item>2000</item>
<item>5000</item>
</string-array>
<string-array name="periodic_task_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>5</item>
<item>10</item>
<item>15</item>
<item>30</item>
<item>60</item>
<item>-1</item>
<item>-5</item>
<item>-10</item>
<item>-25</item>
<item>-50</item>
<item>-100</item>
</string-array>
<string-array name="sensor_type_all_options">
<item>@string/settings_sensor_type_none</item>
<item>@string/settings_sensor_type_ant</item>
+24 -28
View File
@@ -1117,14 +1117,24 @@ limitations under the License.
Map URL
</string>
<string name="menu_show_on_map"
translation_description="In the menu, to show a marker on map.">
translation_description="In the menu, to show a track or a marker on the map.">
Show on map
</string>
<string name="menu_split_frequency"
translation_description="In the menu, to configure the split frequency, how frequent to insert
a split marker.">
Split frequency
</string>
<string name="menu_stop_recording"
translation_description="In the menu, to stop recording a track.">
Stop recording
</string>
<string name="menu_voice_frequency"
translation_description="In the menu, to configure the voice frequency, how frequent to announce
status.">
Voice frequency
</string>
<!-- My Location -->
<string name="my_location_approximate_location"
translation_description="When displaying the user's current location, a status message
@@ -1647,19 +1657,6 @@ limitations under the License.
recordings of your position.">
Smallest time interval between two recordings of your position.
</string>
<string name="settings_recording_marker"
translation_description="In the 'Recording' settings, the dropdown option to configure the time
or distance a new marker will be inserted.
Character limit: ~23 (1 line)">
Marker
</string>
<string name="settings_recording_marker_summary"
translation_description="In the 'Recording' settings, the summary for the 'Marker'
dropdown option explaining that it configures the time or distance after which a new marker
will be inserted.">
Time/distance after which a new marker will be inserted.
</string>
<string name="settings_recording_track_distance"
translation_description="In the 'Recording' settings, the dropdown option to configure the
distance between two tracks.
@@ -1707,20 +1704,7 @@ limitations under the License.
list explaining that it chooses the default track name format.">
Default track name
</string>
<string name="settings_recording_voice"
translation_description="In the 'Recording' settings, the dropdown option to configure the voice
announcement frequency.
Character limit: ~23 (1 line)">
Voice
</string>
<string name="settings_recording_voice_summary"
translation_description="In the 'Recording' settings, the summary for the 'Voice'
dropdown option explaining that it configures the time or distance between two voice
announcements.">
Time/distance between two voice announcements.
</string>
<!-- Settings Reset -->
<string name="settings_reset"
translation_description="In the 'Settings' page, the option to reset everything to the defaults.
@@ -1945,6 +1929,12 @@ limitations under the License.
Remove any descriptive text when sharing a URL with friends.
</string>
<!-- Settings Split -->
<string name="settings_split_frequency_title"
translation_description="In title of the 'Split frequency' dialog.">
Time/distance between two split markers
</string>
<!-- Settings Stats -->
<string name="settings_stats_coordinate"
translation_description="In the 'Stats settings, the option to show latitude and longitude.">
@@ -2001,6 +1991,12 @@ limitations under the License.
Preferred units
</string>
<!-- Settings Voice -->
<string name="settings_voice_frequency_title"
translation_description="The title of the 'Voice frequency' dialog.">
Time/distance between two voice announcements
</string>
<!-- Share Track -->
<string name="share_track_file_body_format"
translation_description="When sharing a track file with friends, the body of the message.">
-12
View File
@@ -16,18 +16,6 @@ limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings_recording" >
<com.google.android.apps.mytracks.IntegerListPreference
android:defaultValue="0"
android:entryValues="@array/periodic_task_values"
android:key="@string/announcement_frequency_key"
android:summary="@string/settings_recording_voice_summary"
android:title="@string/settings_recording_voice" />
<com.google.android.apps.mytracks.IntegerListPreference
android:defaultValue="0"
android:entryValues="@array/periodic_task_values"
android:key="@string/split_frequency_key"
android:summary="@string/settings_recording_marker_summary"
android:title="@string/settings_recording_marker" />
<ListPreference
android:defaultValue="@string/settings_recording_track_name_date_local_value"
android:entries="@array/track_name_options"
@@ -24,6 +24,7 @@ import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.fragments.ChartFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment;
import com.google.android.apps.mytracks.fragments.MapFragment;
import com.google.android.apps.mytracks.fragments.StatsFragment;
@@ -83,6 +84,8 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
private MenuItem insertMarkerMenuItem;
private MenuItem playMenuItem;
private MenuItem shareMenuItem;
private MenuItem voiceFrequencyMenuItem;
private MenuItem splitFrequencyMenuItem;
private MenuItem sendGoogleMenuItem;
private MenuItem saveMenuItem;
@@ -222,6 +225,8 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
insertMarkerMenuItem = menu.findItem(R.id.track_detail_insert_marker);
playMenuItem = menu.findItem(R.id.track_detail_play);
shareMenuItem = menu.findItem(R.id.track_detail_share);
voiceFrequencyMenuItem = menu.findItem(R.id.track_detail_voice_frequency);
splitFrequencyMenuItem = menu.findItem(R.id.track_detail_split_frequency);
sendGoogleMenuItem = menu.findItem(R.id.track_detail_send_google);
saveMenuItem = menu.findItem(R.id.track_detail_save);
@@ -298,6 +303,17 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, trackId);
startActivity(intent);
return true;
case R.id.track_detail_voice_frequency:
FrequencyDialogFragment.newInstance(R.string.announcement_frequency_key,
PreferencesUtils.ANNOUNCEMENT_FREQUENCY_DEFAULT,
R.string.settings_voice_frequency_title)
.show(getSupportFragmentManager(), FrequencyDialogFragment.FREQUENCY_DIALOG_TAG);
return true;
case R.id.track_detail_split_frequency:
FrequencyDialogFragment.newInstance(R.string.split_frequency_key,
PreferencesUtils.SPLIT_FREQUENCY_DEFAULT, R.string.settings_split_frequency_title)
.show(getSupportFragmentManager(), FrequencyDialogFragment.FREQUENCY_DIALOG_TAG);
return true;
case R.id.track_detail_send_google:
intent = IntentUtils.newIntent(this, UploadServiceChooserActivity.class)
.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(trackId, true, true, true));
@@ -446,6 +462,12 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
if (shareMenuItem != null) {
shareMenuItem.setVisible(!isRecording);
}
if (voiceFrequencyMenuItem != null) {
voiceFrequencyMenuItem.setVisible(isRecording);
}
if (splitFrequencyMenuItem != null) {
splitFrequencyMenuItem.setVisible(isRecording);
}
if (sendGoogleMenuItem != null) {
sendGoogleMenuItem.setVisible(!isRecording);
}
@@ -0,0 +1,118 @@
/*
* 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.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
/**
* A DialogFragment to configure frequency.
*
* @author Jimmy Shih
*/
public class FrequencyDialogFragment extends DialogFragment {
public static final String FREQUENCY_DIALOG_TAG = "frequencyDialog";
private static final String KEY_PREFERENCE_ID = "preferenceId";
private static final String KEY_DEFAULT_VALUE = "defaultValue";
private static final String KEY_TITLE_ID = "titleId";
public static FrequencyDialogFragment newInstance(
int preferenceId, int defaultValue, int titleId) {
Bundle bundle = new Bundle();
bundle.putInt(KEY_PREFERENCE_ID, preferenceId);
bundle.putInt(KEY_DEFAULT_VALUE, defaultValue);
bundle.putInt(KEY_TITLE_ID, titleId);
FrequencyDialogFragment frequencyDialogFragment = new FrequencyDialogFragment();
frequencyDialogFragment.setArguments(bundle);
return frequencyDialogFragment;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final int preferenceId = getArguments().getInt(KEY_PREFERENCE_ID);
int defaultValue = getArguments().getInt(KEY_DEFAULT_VALUE);
int titleId = getArguments().getInt(KEY_TITLE_ID);
int frequencyValue = PreferencesUtils.getInt(getActivity(), preferenceId, defaultValue);
return new AlertDialog.Builder(getActivity())
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int listIndex = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
PreferencesUtils.setInt(getActivity(), preferenceId, getFrequencyValue(listIndex));
}
})
.setSingleChoiceItems(getFrequencyDisplayOptions(), getListIndex(frequencyValue), null)
.setTitle(titleId)
.create();
}
/**
* Gets the frequency display options.
*/
private String[] getFrequencyDisplayOptions() {
boolean metricUnits = PreferencesUtils.getBoolean(
getActivity(), R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
String[] values = getResources().getStringArray(R.array.frequency_values);
String[] options = new String[values.length];
for (int i = 0; i < values.length; i++) {
int value = Integer.parseInt(values[i]);
if (value == PreferencesUtils.FREQUENCY_OFF) {
options[i] = getString(R.string.value_off);
} else if (value < 0) {
options[i] = getString(metricUnits ? R.string.value_integer_kilometer
: R.string.value_integer_mile, Math.abs(value));
} else {
options[i] = getString(R.string.value_integer_minute, value);
}
}
return options;
}
/**
* Gets the list index for a frequency value. Returns 0 if the value is not on
* the list.
*/
private int getListIndex(int frequencyValue) {
String[] values = getResources().getStringArray(R.array.frequency_values);
for (int i = 0; i < values.length; i++) {
if (frequencyValue == Integer.parseInt(values[i])) {
return i;
}
}
return 0;
}
/**
* Gets the frequency value from a list index.
*
* @param listIndex the list index
*/
private int getFrequencyValue(int listIndex) {
String[] values = getResources().getStringArray(R.array.frequency_values);
return Integer.parseInt(values[listIndex]);
}
}
@@ -35,7 +35,7 @@ public class PeriodicTaskExecutor {
* A value greater than zero is a frequency in time.
* A value less than zero is considered a frequency in distance.
*/
private int taskFrequency = PreferencesUtils.PERIODIC_TASK_OFF;
private int taskFrequency = PreferencesUtils.FREQUENCY_OFF;
/**
* The next distance when the task should execute.
@@ -75,7 +75,7 @@ public class PeriodicTaskExecutor {
timerExecutor = null;
}
}
if (taskFrequency == PreferencesUtils.PERIODIC_TASK_OFF) {
if (taskFrequency == PreferencesUtils.FREQUENCY_OFF) {
return;
}
@@ -39,14 +39,6 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
boolean metricUnits = PreferencesUtils.getBoolean(
this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
ListPreference announcementFrequencyListPreference = (ListPreference) findPreference(
getString(R.string.announcement_frequency_key));
announcementFrequencyListPreference.setEntries(getPeriodicTaskDisplayOptions(metricUnits));
ListPreference splitFrequencyListPreference = (ListPreference) findPreference(
getString(R.string.split_frequency_key));
splitFrequencyListPreference.setEntries(getPeriodicTaskDisplayOptions(metricUnits));
ListPreference minRecordingIntervalListPreference = (ListPreference) findPreference(
getString(R.string.min_recording_interval_key));
minRecordingIntervalListPreference.setEntries(getMinRecordingIntervalDisplayOptions());
@@ -70,28 +62,6 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
autoResumeTrackTimeoutListPreference.setEntries(getAutoResumeTrackTimeoutDisplayOptions());
}
/**
* Gets the periodic task display options.
*
* @param metricUnits true to display metric units
*/
private String[] getPeriodicTaskDisplayOptions(boolean metricUnits) {
String[] values = getResources().getStringArray(R.array.periodic_task_values);
String[] options = new String[values.length];
for (int i = 0; i < values.length; i++) {
int value = Integer.parseInt(values[i]);
if (value == PreferencesUtils.PERIODIC_TASK_OFF) {
options[i] = getString(R.string.value_off);
} else if (value < 0) {
options[i] = getString(metricUnits ? R.string.value_integer_kilometer
: R.string.value_integer_mile, Math.abs(value));
} else {
options[i] = getString(R.string.value_integer_minute, value);
}
}
return options;
}
/**
* Gets the min recording interval display options.
*/
@@ -52,6 +52,7 @@ public class PreferencesUtils {
public static final String DEFAULT_ACTIVITY_DEFAULT = "";
public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = true;
public static final int FREQUENCY_OFF = 0;
public static final int MAX_RECORDING_DISTANCE_DEFAULT = 200;
public static final boolean METRIC_UNITS_DEFAULT = true;
public static final int MIN_RECORDING_DISTANCE_DEFAULT = 5;
@@ -64,7 +65,6 @@ public class PreferencesUtils {
public static final int MIN_REQUIRED_ACCURACY_EXCELLENT = 10;
public static final int MIN_REQUIRED_ACCURACY_POOR = 5000;
public static final int PERIODIC_TASK_OFF = 0;
public static final boolean PICK_EXISTING_MAP_DEFAULT = false;
public static final String PREFERRED_ACCOUNT_DEFAULT = "";
public static final long RECORDING_TRACK_ID_DEFAULT = -1L;