mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Automated merge with http://mytracks.googlecode.com/hg/
This commit is contained in:
@@ -49,4 +49,5 @@ limitations under the License.
|
||||
|
||||
<!-- Intent actions -->
|
||||
<string name="save_intent_action">android.intent.action.SAVE</string>
|
||||
<string name="open_settings_screen">android.intent.action.settings.OPEN</string>
|
||||
</resources>
|
||||
|
||||
@@ -53,4 +53,5 @@ limitations under the License.
|
||||
<string name="reset_key">resetToDefaults</string>
|
||||
<string name="sensor_options_key">sensorOptions</string>
|
||||
<string name="ant_options_key">antOptions</string>
|
||||
<string name="display_settings_screen_key">displaySettingsScreen</string>
|
||||
</resources>
|
||||
|
||||
@@ -18,7 +18,8 @@ limitations under the License.
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Display settings -->
|
||||
<PreferenceScreen android:title="@string/settings_display">
|
||||
<PreferenceScreen android:title="@string/settings_display"
|
||||
android:key="@string/display_settings_screen_key">
|
||||
<CheckBoxPreference
|
||||
android:key="@string/metric_units_key"
|
||||
android:title="@string/settings_metric_units"
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@@ -79,6 +80,8 @@ class CheckUnits {
|
||||
private static void accept(Context context, SharedPreferences preferences) {
|
||||
recordCheckPerformed(preferences);
|
||||
Intent startIntent = new Intent(context, SettingsActivity.class);
|
||||
startIntent.putExtra(context.getString(R.string.open_settings_screen),
|
||||
context.getString(R.string.display_settings_screen_key));
|
||||
context.startActivity(startIntent);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,11 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* An activity that let's the user see and edit the settings.
|
||||
*
|
||||
*
|
||||
* This activity has two entry points, "root" and "display" preference screen.
|
||||
* If bundle.getString("open_settings_screen") is set to "display_settings_screen_key", then
|
||||
* the "display" preference screen is shown, otherwise, the "root" display preference is shown.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
@@ -58,12 +62,22 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
private BackupPreferencesListener backupListener;
|
||||
private SharedPreferences preferences;
|
||||
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
initActivityCommons();
|
||||
|
||||
// If we only need the display setting screen nothing else needs to load.
|
||||
if (processIntent())
|
||||
return;
|
||||
|
||||
initActivitySpecifics();
|
||||
}
|
||||
|
||||
private void initActivityCommons() {
|
||||
// The volume we want to control is the Text-To-Speech volume
|
||||
ApiFeatures apiFeatures = ApiFeatures.getInstance();
|
||||
int volumeStream =
|
||||
@@ -83,6 +97,19 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
// Load the preferences to be displayed
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
// Disable TTS announcement preference if not available
|
||||
if (!apiFeatures.hasTextToSpeech()) {
|
||||
IntegerListPreference announcementFrequency =
|
||||
(IntegerListPreference) findPreference(
|
||||
getString(R.string.announcement_frequency_key));
|
||||
announcementFrequency.setEnabled(false);
|
||||
announcementFrequency.setValue("-1");
|
||||
announcementFrequency.setSummary(
|
||||
R.string.settings_not_available_summary);
|
||||
}
|
||||
}
|
||||
|
||||
private void initActivitySpecifics() {
|
||||
// Hook up switching of displayed list entries between metric and imperial
|
||||
// units
|
||||
CheckBoxPreference metricUnitsPreference =
|
||||
@@ -102,17 +129,6 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
customizeSensorOptionsPreferences();
|
||||
|
||||
// Disable TTS announcement preference if not available
|
||||
if (!apiFeatures.hasTextToSpeech()) {
|
||||
IntegerListPreference announcementFrequency =
|
||||
(IntegerListPreference) findPreference(
|
||||
getString(R.string.announcement_frequency_key));
|
||||
announcementFrequency.setEnabled(false);
|
||||
announcementFrequency.setValue("-1");
|
||||
announcementFrequency.setSummary(
|
||||
R.string.settings_not_available_summary);
|
||||
}
|
||||
|
||||
// Hook up action for resetting all settings
|
||||
Preference resetPreference = findPreference(getString(R.string.reset_key));
|
||||
resetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@@ -123,6 +139,23 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean processIntent() {
|
||||
boolean showDisplaySettings = false;
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
PreferenceScreen preferenceScreen;
|
||||
String intentString = getString(R.string.open_settings_screen);
|
||||
|
||||
if (bundle != null) {
|
||||
preferenceScreen = (PreferenceScreen) findPreference(bundle.getString(intentString));
|
||||
if (preferenceScreen != null) {
|
||||
showDisplaySettings = true;
|
||||
setPreferenceScreen(preferenceScreen);
|
||||
}
|
||||
}
|
||||
|
||||
return showDisplaySettings;
|
||||
}
|
||||
|
||||
private void customizeSensorOptionsPreferences() {
|
||||
ListPreference sensorTypePreference =
|
||||
@@ -174,6 +207,10 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// If we only need the display setting screen nothing else needs to load.
|
||||
if (processIntent())
|
||||
return;
|
||||
|
||||
configureBluetoothPreferences();
|
||||
Preference backupNowPreference =
|
||||
|
||||
@@ -153,6 +153,9 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(final Location location) {
|
||||
if (executorService.isShutdown() || executorService.isTerminated()) {
|
||||
return;
|
||||
}
|
||||
executorService.submit(
|
||||
new Runnable() {
|
||||
@Override
|
||||
@@ -342,7 +345,6 @@ public class TrackRecordingService extends Service {
|
||||
timer.purge();
|
||||
unregisterLocationListener();
|
||||
shutdownTaskExecutors();
|
||||
executorService.shutdown();
|
||||
if (sensorManager != null) {
|
||||
sensorManager.shutdown();
|
||||
sensorManager = null;
|
||||
@@ -358,6 +360,8 @@ public class TrackRecordingService extends Service {
|
||||
// This should be the last operation.
|
||||
releaseWakeLock();
|
||||
|
||||
// Shutdown the executor service last to avoid sending events to a dead executor.
|
||||
executorService.shutdown();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user