mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-13 14:23:07 +02:00
merge heads
This commit is contained in:
@@ -25,6 +25,7 @@ limitations under the License.
|
|||||||
<string name="bluetooth_device_key">bluetoothDevice</string>
|
<string name="bluetooth_device_key">bluetoothDevice</string>
|
||||||
<string name="bluetooth_pairing_key">bluetoothPairing</string>
|
<string name="bluetooth_pairing_key">bluetoothPairing</string>
|
||||||
<string name="bluetooth_sensor_key">bluetoothSensor</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="default_map_public_key">defaultMapPublic</string>
|
||||||
<string name="max_recording_distance_key">maxRecordingDistance</string>
|
<string name="max_recording_distance_key">maxRecordingDistance</string>
|
||||||
<string name="metric_units_key">metricUnits</string>
|
<string name="metric_units_key">metricUnits</string>
|
||||||
|
|||||||
@@ -871,6 +871,16 @@ limitations under the License.
|
|||||||
recording will not be resumed after phone reboot.">
|
recording will not be resumed after phone reboot.">
|
||||||
Maximum time after which a previously recording track will not be resumed on phone reboot
|
Maximum time after which a previously recording track will not be resumed on phone reboot
|
||||||
</string>
|
</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"
|
<string name="settings_recording_distance"
|
||||||
translation_description="In the Recording settings, the dropdown option to configure the
|
translation_description="In the Recording settings, the dropdown option to configure the
|
||||||
distance between two recorded points.">
|
distance between two recorded points.">
|
||||||
|
|||||||
@@ -150,6 +150,12 @@ limitations under the License.
|
|||||||
android:summaryOn="@string/settings_recording_name_summary_on"
|
android:summaryOn="@string/settings_recording_name_summary_on"
|
||||||
android:summaryOff="@string/settings_recording_name_summary_off"
|
android:summaryOff="@string/settings_recording_name_summary_off"
|
||||||
android:defaultValue="true" />
|
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>
|
</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,
|
Log.d(TAG,
|
||||||
"Location listener now unregistered w/ TrackRecordingService.");
|
"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.
|
* Recording lifecycle.
|
||||||
@@ -582,6 +587,7 @@ public class TrackRecordingService extends Service {
|
|||||||
track.setId(recordingTrackId);
|
track.setId(recordingTrackId);
|
||||||
track.setName(new DefaultTrackNameFactory(this).newTrackName(
|
track.setName(new DefaultTrackNameFactory(this).newTrackName(
|
||||||
recordingTrackId, startTime));
|
recordingTrackId, startTime));
|
||||||
|
track.setCategory(getDefaultActivityType(this));
|
||||||
isRecording = true;
|
isRecording = true;
|
||||||
isMoving = true;
|
isMoving = true;
|
||||||
|
|
||||||
|
|||||||
+2
@@ -382,6 +382,8 @@ public class TrackRecordingServiceTest
|
|||||||
Track track = providerUtils.getTrack(id);
|
Track track = providerUtils.getTrack(id);
|
||||||
assertNotNull(track);
|
assertNotNull(track);
|
||||||
assertEquals(id, track.getId());
|
assertEquals(id, track.getId());
|
||||||
|
assertEquals(sharedPreferences.getString(context.getString(R.string.default_activity_key), ""),
|
||||||
|
track.getCategory());
|
||||||
assertEquals(id, sharedPreferences.getLong(
|
assertEquals(id, sharedPreferences.getLong(
|
||||||
context.getString(R.string.recording_track_key), -1));
|
context.getString(R.string.recording_track_key), -1));
|
||||||
assertEquals(id, service.getRecordingTrackId());
|
assertEquals(id, service.getRecordingTrackId());
|
||||||
|
|||||||
Reference in New Issue
Block a user