merge heads

This commit is contained in:
Jimmy Shih
2011-11-10 16:26:30 -08:00
parent f19482985d
commit cc4d57bc0c
6 changed files with 89 additions and 0 deletions
+1
View File
@@ -25,6 +25,7 @@ limitations under the License.
<string name="bluetooth_device_key">bluetoothDevice</string>
<string name="bluetooth_pairing_key">bluetoothPairing</string>
<string name="bluetooth_sensor_key">bluetoothSensor</string>
<string name="default_activity_key">defaultActivity</string>
<string name="default_map_public_key">defaultMapPublic</string>
<string name="max_recording_distance_key">maxRecordingDistance</string>
<string name="metric_units_key">metricUnits</string>
+10
View File
@@ -871,6 +871,16 @@ limitations under the License.
recording will not be resumed after phone reboot.">
Maximum time after which a previously recording track will not be resumed on phone reboot
</string>
<string name="settings_recording_default_activity"
translation_description="In the Recording settings, the option to specify a new track's default
activity type.">
Default activity type
</string>
<string name="settings_recording_default_activity_summary"
translation_description="In the Recording settings, the summary for the 'Default activity type'
option explaining that it sets the default activity type for a new track.">
Default activity type for a new track.
</string>
<string name="settings_recording_distance"
translation_description="In the Recording settings, the dropdown option to configure the
distance between two recorded points.">
+6
View File
@@ -150,6 +150,12 @@ limitations under the License.
android:summaryOn="@string/settings_recording_name_summary_on"
android:summaryOff="@string/settings_recording_name_summary_off"
android:defaultValue="true" />
<com.google.android.apps.mytracks.AutoCompleteTextPreference
android:key="@string/default_activity_key"
android:title="@string/settings_recording_default_activity"
android:summary="@string/settings_recording_default_activity_summary"
android:defaultValue="" />
</PreferenceScreen>
@@ -0,0 +1,64 @@
package com.google.android.apps.mytracks;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.preference.EditTextPreference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
/**
* The {@link AutoCompleteTextPreference} class is a preference that allows for
* string input using auto complete . It is a subclass of
* {@link EditTextPreference} and shows the {@link AutoCompleteTextView} in a
* dialog.
* <p>
* This preference will store a string into the SharedPreferences.
*
* @author Rimas Trumpa (with Matt Levan)
*/
public class AutoCompleteTextPreference extends EditTextPreference {
private AutoCompleteTextView mEditText = null;
public AutoCompleteTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mEditText = new AutoCompleteTextView(context, attrs);
mEditText.setThreshold(0);
// Gets autocomplete values for 'Default Activity' preference
if (getKey().equals(context.getString(R.string.default_activity_key))) {
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context,
R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
mEditText.setAdapter(adapter);
}
}
@Override
protected void onBindDialogView(View view) {
AutoCompleteTextView editText = mEditText;
editText.setText(getText());
ViewParent oldParent = editText.getParent();
if (oldParent != view) {
if (oldParent != null) {
((ViewGroup) oldParent).removeView(editText);
}
onAddEditTextToDialogView(view, editText);
}
}
@Override
protected void onDialogClosed(boolean positiveResult) {
if (positiveResult) {
String value = mEditText.getText().toString();
if (callChangeListener(value)) {
setText(value);
}
}
}
}
@@ -559,6 +559,11 @@ public class TrackRecordingService extends Service {
Log.d(TAG,
"Location listener now unregistered w/ TrackRecordingService.");
}
private String getDefaultActivityType(Context context) {
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
return prefs.getString(context.getString(R.string.default_activity_key), "");
}
/*
* Recording lifecycle.
@@ -582,6 +587,7 @@ public class TrackRecordingService extends Service {
track.setId(recordingTrackId);
track.setName(new DefaultTrackNameFactory(this).newTrackName(
recordingTrackId, startTime));
track.setCategory(getDefaultActivityType(this));
isRecording = true;
isMoving = true;
@@ -382,6 +382,8 @@ public class TrackRecordingServiceTest
Track track = providerUtils.getTrack(id);
assertNotNull(track);
assertEquals(id, track.getId());
assertEquals(sharedPreferences.getString(context.getString(R.string.default_activity_key), ""),
track.getCategory());
assertEquals(id, sharedPreferences.getLong(
context.getString(R.string.recording_track_key), -1));
assertEquals(id, service.getRecordingTrackId());