aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-09-19 20:54:20 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-09-19 20:54:20 +0200
commitd386bdeb8ef3f2429820a322222227a429548d91 (patch)
tree30a8e3ca0e80429c4971fcfdb53c9c53faa00ce3
parent84cc9f94a03ad60799e46979731f22112dbc8396 (diff)
downloadBlueGPS-d386bdeb8ef3f2429820a322222227a429548d91.zip
BlueGPS-d386bdeb8ef3f2429820a322222227a429548d91.tar.gz
BlueGPS-d386bdeb8ef3f2429820a322222227a429548d91.tar.bz2
add new preferences options
add preferences in order to chose if we want to: * replace the internal GPS or * use a new location provider.
-rw-r--r--res/values-en/strings.xml15
-rw-r--r--res/values-fr/strings.xml11
-rw-r--r--res/values/strings.xml14
-rw-r--r--res/xml/pref.xml72
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java23
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java10
6 files changed, 114 insertions, 31 deletions
diff --git a/res/values-en/strings.xml b/res/values-en/strings.xml
index 52b03b6..2dcd198 100644
--- a/res/values-en/strings.xml
+++ b/res/values-en/strings.xml
@@ -20,10 +20,21 @@
-->
<resources>
<!-- we use the defaults values
- <string name="pref_recording_params_title">Recording parameters</string>
- <string name="pref_recording_title">Enable/Disable</string>
+ <string name="pref_start_gps_title">Start/Stop GPS</string>
+ <string name="pref_start_gps_summary_off">Bluetooth GPS is off</string>
+ <string name="pref_start_gps_summary_on">Bluetooth GPS is on</string>
+ <string name="pref_start_gps_params_title">GPS Options</string>
+ <string name="pref_gps_location_provider_title">Location provider options</string>
+ <string name="pref_gps_location_provider_summary">Bluetooth GPS will replace internal GPS</string>
+ <string name="pref_replace_std_gps_title">Replace internal GPS</string>
+ <string name="pref_replace_std_gps_summary_on">Bluetooth GPS will replace internal GPS</string>
+ <string name="pref_replace_std_gps_summary_off">Bluetooth GPS will use a new location provider</string>
+ <string name="pref_mock_gps_name_title">Mock location provider name</string>
+ <string name="pref_mock_gps_name_summary">Bluetooth GPS name: %s</string>
+ <string name="pref_recording_title">Enable/Disable NMEA log</string>
<string name="pref_recording_summary_off">Track recording is off</string>
<string name="pref_recording_summary_on">Track recording is on</string>
+ <string name="pref_recording_params_title">Recording parameters</string>
<string name="pref_mintime_title">Time between records</string>
<string name="pref_mintime_summary">Time between records in milliseconds</string>
<string name="pref_mindistance_title">Distance between records</string>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index 270f111..e80bca0 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -20,9 +20,16 @@
-->
<resources>
<string name="pref_start_gps_title">Start/Stop GPS</string>
- <string name="pref_start_gps_summary_off">le GPS Bluetooth est arrêté</string>
- <string name="pref_start_gps_summary_on">le GPS Bluetooth est démarré</string>
+ <string name="pref_start_gps_summary_off">Le GPS Bluetooth est arrêté</string>
+ <string name="pref_start_gps_summary_on">Le GPS Bluetooth est démarré</string>
<string name="pref_start_gps_params_title">Options du GPS</string>
+ <string name="pref_gps_location_provider_title">Location provider options</string>
+ <string name="pref_gps_location_provider_summary">Le GPS Bluetooth remplacera le GPS interne</string>
+ <string name="pref_replace_std_gps_title">Remplacer le GPS interne</string>
+ <string name="pref_replace_std_gps_summary_on">Le GPS Bluetooth remplacera le GPS interne</string>
+ <string name="pref_replace_std_gps_summary_off">Un nouveau location provider sera utilisé</string>
+ <string name="pref_mock_gps_name_title">Nom du location provider</string>
+ <string name="pref_mock_gps_name_summary">Nom du GPS Bluetooth : %s</string>
<string name="pref_recording_title">Activer/Désactiver NMEA log</string>
<string name="pref_recording_summary_off">Enregistrement du GPS inactif</string>
<string name="pref_recording_summary_on">Enregistrement du GPS actif</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4e08be9..734b643 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -42,6 +42,9 @@
<string name="sirf_dgps_sbas_on">A0A20007 85010000000000 0086B0B3</string>
<string name="pref_start_gps_key">startGps</string>
+ <string name="pref_gps_location_provider_key">gpsLocationProviderKey</string>
+ <string name="pref_replace_std_gps_key">replaceStdtGps</string>
+ <string name="pref_mock_gps_name_key">mockGpsName</string>
<string name="pref_recording_key">trackRecording</string>
<string name="pref_mindistance_key">trackMinDistance</string>
<string name="pref_mintime_key">trackMinTime</string>
@@ -53,11 +56,22 @@
<string name="defaultTrackMinTime">0</string>
<string name="defaultTrackFileDirectory">/sdcard/nmea</string>
<string name="defaultTrackFilePrefix">btnmeatrack</string>
+ <string name="defaultMockGpsName">bluetooth_gps</string>
<string name="pref_start_gps_title">Start/Stop GPS</string>
<string name="pref_start_gps_summary_off">Bluetooth GPS is off</string>
<string name="pref_start_gps_summary_on">Bluetooth GPS is on</string>
<string name="pref_start_gps_params_title">GPS Options</string>
+ <string name="pref_gps_location_provider_title">Location provider options</string>
+ <string name="pref_gps_location_provider_summary">Bluetooth GPS will replace internal GPS</string>
+ <string name="pref_replace_std_gps_title">Replace internal GPS</string>
+ <string name="pref_replace_std_gps_summary_on">Bluetooth GPS will replace internal GPS</string>
+ <!--
+ <string name="pref_replace_std_gps_summary_off">Internal GPS will remain available</string>
+ -->
+ <string name="pref_replace_std_gps_summary_off">Bluetooth GPS will use a new location provider</string>
+ <string name="pref_mock_gps_name_title">Mock location provider name</string>
+ <string name="pref_mock_gps_name_summary">Bluetooth GPS name: %s</string>
<string name="pref_recording_title">Enable/Disable NMEA log</string>
<string name="pref_recording_summary_off">Track recording is off</string>
<string name="pref_recording_summary_on">Track recording is on</string>
diff --git a/res/xml/pref.xml b/res/xml/pref.xml
index f436dbc..103a8cb 100644
--- a/res/xml/pref.xml
+++ b/res/xml/pref.xml
@@ -27,31 +27,51 @@
android:key="@string/pref_bluetooth_device_key"
android:summary="@string/pref_bluetooth_device_summary" />
<CheckBoxPreference
- android:enabled="true"
+ android:dependency="@string/pref_bluetooth_device_key"
android:key="@string/pref_start_gps_key"
android:persistent="true"
- android:disableDependentsState = "false"
+ android:disableDependentsState="true"
android:title="@string/pref_start_gps_title"
android:summaryOn="@string/pref_start_gps_summary_on"
android:summaryOff="@string/pref_start_gps_summary_off" />
- <PreferenceScreen android:title="@string/pref_start_gps_params_title"
+ <PreferenceScreen
+ android:dependency="@string/pref_start_gps_key"
+ android:shouldDisableView="true"
+ android:key="@string/pref_gps_location_provider_key"
+ android:summary="@string/pref_gps_location_provider_summary"
+ android:title="@string/pref_gps_location_provider_title" >
+ <CheckBoxPreference
+ android:key="@string/pref_replace_std_gps_key"
+ android:persistent="true"
+ android:disableDependentsState="true"
+ android:title="@string/pref_replace_std_gps_title"
+ android:summaryOn="@string/pref_replace_std_gps_summary_on"
+ android:summaryOff="@string/pref_replace_std_gps_summary_off" />
+ <EditTextPreference
+ android:dependency="@string/pref_replace_std_gps_key"
+ android:key="@string/pref_mock_gps_name_key"
+ android:title="@string/pref_mock_gps_name_title"
+ android:defaultValue="@string/defaultMockGpsName"
+ android:summary="@string/pref_mock_gps_name_summary" />
+ </PreferenceScreen>
+ <PreferenceScreen
+ android:title="@string/pref_start_gps_params_title"
android:shouldDisableView = "true"
android:enabled="false" >
- <EditTextPreference
- android:key="@string/pref_mintime_key"
- android:title="@string/pref_mintime_title"
- android:defaultValue="@string/defaultTrackMinTime"
- android:summary="@string/pref_mintime_summary"
- android:inputType="number"/>
- <EditTextPreference
- android:key="@string/pref_mindistance_key"
- android:title="@string/pref_mindistance_title"
- android:defaultValue="@string/defaultTrackMinDistance"
- android:inputType="numberDecimal"
- android:summary="@string/pref_mindistance_summary" />
+ <EditTextPreference
+ android:key="@string/pref_mintime_key"
+ android:title="@string/pref_mintime_title"
+ android:defaultValue="@string/defaultTrackMinTime"
+ android:summary="@string/pref_mintime_summary"
+ android:inputType="number" />
+ <EditTextPreference
+ android:key="@string/pref_mindistance_key"
+ android:title="@string/pref_mindistance_title"
+ android:defaultValue="@string/defaultTrackMinDistance"
+ android:inputType="numberDecimal"
+ android:summary="@string/pref_mindistance_summary" />
</PreferenceScreen>
<CheckBoxPreference
- android:dependency="@string/pref_start_gps_key"
android:enabled="true"
android:key="@string/pref_recording_key"
android:persistent="true"
@@ -59,15 +79,15 @@
android:summaryOn="@string/pref_recording_summary_on"
android:summaryOff="@string/pref_recording_summary_off" />
<PreferenceScreen android:title="@string/pref_recording_params_title" >
- <EditTextPreference
- android:key="@string/pref_trackfile_directory_key"
- android:title="@string/pref_trackfile_directory_title"
- android:defaultValue="@string/defaultTrackFileDirectory"
- android:summary="@string/pref_trackfile_directory_summary" />
- <EditTextPreference
- android:key="@string/pref_trackfile_prefix_key"
- android:title="@string/pref_trackfile_prefix_title"
- android:defaultValue="@string/defaultTrackFilePrefix"
- android:summary="@string/pref_trackfile_prefix_summary" />
+ <EditTextPreference
+ android:key="@string/pref_trackfile_directory_key"
+ android:title="@string/pref_trackfile_directory_title"
+ android:defaultValue="@string/defaultTrackFileDirectory"
+ android:summary="@string/pref_trackfile_directory_summary" />
+ <EditTextPreference
+ android:key="@string/pref_trackfile_prefix_key"
+ android:title="@string/pref_trackfile_prefix_title"
+ android:defaultValue="@string/defaultTrackFilePrefix"
+ android:summary="@string/pref_trackfile_prefix_summary" />
</PreferenceScreen>
</PreferenceScreen>
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
index 8ce8e62..9d4003d 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
@@ -37,6 +37,7 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
+import android.test.mock.MockPackageManager;
import android.util.Log;
/**
@@ -98,6 +99,27 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
}
prefDevices.setEntryValues(entryValues);
prefDevices.setEntries(entries);
+// if (sharedPref.getBoolean(BluetoothGpsProviderService.PREF_START_GPS_PROVIDER, false)){
+ Preference pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_TRACK_RECORDING);
+ pref.setEnabled(sharedPref.getBoolean(BluetoothGpsProviderService.PREF_START_GPS_PROVIDER, false));
+// }
+ pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_MOCK_GPS_NAME);
+ String mockProvider = sharedPref.getString(BluetoothGpsProviderService.PREF_MOCK_GPS_NAME, getString(R.string.defaultMockGpsName));
+ pref.setSummary(getString(R.string.pref_mock_gps_name_summary,mockProvider));
+
+ pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_GPS_LOCATION_PROVIDER);
+ if (sharedPref.getBoolean(BluetoothGpsProviderService.PREF_REPLACE_STD_GPS, true)){
+ String s = getString(R.string.pref_gps_location_provider_summary);
+ pref.setSummary(s);
+ Log.e("BT test", "loc. provider: "+s);
+ Log.e("BT test", "loc. provider: "+pref.getSummary());
+ } else {
+ String s = getString(R.string.pref_mock_gps_name_summary, mockProvider);
+ pref.setSummary(s);
+ Log.e("BT test", "loc. provider: "+s);
+ Log.e("BT test", "loc. provider: "+pref.getSummary());
+ }
+ this.onContentChanged();
}
@Override
@@ -140,5 +162,6 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
} else if (BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE.equals(key)){
updateDevicePreferenceSummary();
}
+ this.updateDevicePreferenceList();
}
} \ No newline at end of file
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
index 0ab972b..456c752 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
@@ -62,6 +62,9 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
public static final String ACTION_START_GPS_PROVIDER = "org.broeuschmeul.android.gps.bluetooth.provider.nmea.intent.action.START_GPS_PROVIDER";
public static final String ACTION_STOP_GPS_PROVIDER = "org.broeuschmeul.android.gps.bluetooth.provider.nmea.intent.action.STOP_GPS_PROVIDER";
public static final String PREF_START_GPS_PROVIDER = "startGps";
+ public static final String PREF_GPS_LOCATION_PROVIDER = "gpsLocationProviderKey";
+ public static final String PREF_REPLACE_STD_GPS = "replaceStdtGps";
+ public static final String PREF_MOCK_GPS_NAME = "mockGpsName";
public static final String PREF_TRACK_RECORDING = "trackRecording";
public static final String PREF_TRACK_MIN_DISTANCE = "trackMinDistance";
public static final String PREF_TRACK_MIN_TIME = "trackMinTime";
@@ -104,8 +107,13 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
notification.setLatestEventInfo(getApplicationContext(), this.getString(R.string.foreground_service_started_notification_title), this.getString(R.string.foreground_gps_provider_started_notification), myPendingIntent);
startForeground(R.string.foreground_gps_provider_started_notification, notification);
if (BluetoothAdapter.checkBluetoothAddress(deviceAddress)){
+ String mockProvider = LocationManager.GPS_PROVIDER;
+ if (! sharedPreferences.getBoolean(PREF_REPLACE_STD_GPS, true)){
+ mockProvider = sharedPreferences.getString(PREF_MOCK_GPS_NAME, getString(R.string.defaultMockGpsName));
+ }
gpsManager = new BlueetoothGpsManager(this, deviceAddress);
- gpsManager.enableMockLocationProvider(LocationManager.GPS_PROVIDER);
+ gpsManager.enableMockLocationProvider(mockProvider);
+// gpsManager.enableMockLocationProvider(LocationManager.GPS_PROVIDER);
gpsManager.enable();
if (! sharedPreferences.getBoolean(PREF_START_GPS_PROVIDER, false)){
edit.putBoolean(PREF_START_GPS_PROVIDER,true);