mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-03 18:03:06 +02:00
Some string corrections + getDefaultCategory moved to TrackRecordingService.
This commit is contained in:
@@ -23,7 +23,7 @@ import android.widget.AutoCompleteTextView;
|
||||
*/
|
||||
public class AutoCompleteTextPreference extends EditTextPreference {
|
||||
|
||||
private static AutoCompleteTextView mEditText = null;
|
||||
private AutoCompleteTextView mEditText = null;
|
||||
|
||||
public AutoCompleteTextPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 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.services;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/**
|
||||
* Creates a default track category (activity type) based on current default
|
||||
* category settings.
|
||||
*
|
||||
* @author Rimas Trumpa
|
||||
*/
|
||||
class DefaultCategoryFactory {
|
||||
private final Context context;
|
||||
|
||||
DefaultCategoryFactory(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new track category (activity type).
|
||||
*
|
||||
* @return The new track category.
|
||||
*/
|
||||
String newTrackCategory() {
|
||||
if (getDefaultCategory() != null) {
|
||||
return getDefaultCategory();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
protected String getDefaultCategory() {
|
||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||
return prefs.getString(context.getString(R.string.default_category_key), null);
|
||||
}
|
||||
}
|
||||
@@ -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_category_key), "");
|
||||
}
|
||||
|
||||
/*
|
||||
* Recording lifecycle.
|
||||
@@ -582,7 +587,7 @@ public class TrackRecordingService extends Service {
|
||||
track.setId(recordingTrackId);
|
||||
track.setName(new DefaultTrackNameFactory(this).newTrackName(
|
||||
recordingTrackId, startTime));
|
||||
track.setCategory(new DefaultCategoryFactory(this).newTrackCategory());
|
||||
track.setCategory(getDefaultActivityType(this));
|
||||
isRecording = true;
|
||||
isMoving = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user