mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +01:00
Add switch to control if the GPS chip should be used to locate the location
This commit is contained in:
parent
0286559100
commit
6da6baa5e6
@ -80,6 +80,7 @@ public class DeviceSettingsPreferenceConst {
|
||||
|
||||
public static final String PREF_DEVICE_GPS_UPDATE = "banglejs_gps_update";
|
||||
public static final String PREF_DEVICE_GPS_UPDATE_INTERVAL = "banglejs_gps_update_interval";
|
||||
public static final String PREF_DEVICE_GPS_USE_NETWORK_ONLY = "banglejs_gps_use_network_only";
|
||||
|
||||
public static final String PREF_DEVICE_INTERNET_ACCESS = "device_internet_access";
|
||||
public static final String PREF_DEVICE_INTENTS = "device_intents";
|
||||
|
@ -21,6 +21,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BANGLEJS_TEXT_BITMAP_SIZE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_GPS_UPDATE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_GPS_UPDATE_INTERVAL;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_GPS_USE_NETWORK_ONLY;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_INTENTS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DEVICE_INTERNET_ACCESS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBHelper.getUser;
|
||||
@ -948,12 +949,15 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
if(devicePrefs.getBoolean(PREF_DEVICE_GPS_UPDATE, false)) {
|
||||
int intervalLength = devicePrefs.getInt(PREF_DEVICE_GPS_UPDATE_INTERVAL, 1000);
|
||||
LOG.info("Setup location listener with an update interval of " + intervalLength + " ms");
|
||||
|
||||
boolean onlyUseNetworkGPS = devicePrefs.getBoolean(PREF_DEVICE_GPS_USE_NETWORK_ONLY, false);
|
||||
LOG.info("Using combined GPS and NETWORK based location: " + onlyUseNetworkGPS);
|
||||
if (!onlyUseNetworkGPS) {
|
||||
try {
|
||||
GBLocationManager.start(getContext(), this, LocationProviderType.GPS, intervalLength);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOG.warn("GPS provider could not be started", e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
GBLocationManager.start(getContext(), this, LocationProviderType.NETWORK, intervalLength);
|
||||
|
@ -13,6 +13,14 @@
|
||||
android:key="banglejs_gps_update_interval"
|
||||
android:summary="This option is only active, if the gps data of the phone is being used. This option sets the interval in ms how often the gps position is being updated"
|
||||
android:title="GPS data update interval in ms" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="1000"
|
||||
android:inputType="number"
|
||||
android:icon="@drawable/ic_access_time"
|
||||
android:key="banglejs_gps_use_network_only"
|
||||
android:summary="This option is only active, if the gps data of the phone is being used. This option can be used to use only the network provider to reduce the power consumption for the cost of accuracy"
|
||||
android:title="Only use network to determine location" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_translate"
|
||||
|
Loading…
Reference in New Issue
Block a user