mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 12:26:48 +01:00
Garmin: Allow fetching unknown files
This commit is contained in:
parent
bad29bbeb8
commit
d946053bcb
@ -127,6 +127,7 @@ public abstract class GarminCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
|
||||
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
|
||||
developer.add(R.xml.devicesettings_keep_activity_data_on_device);
|
||||
developer.add(R.xml.devicesettings_fetch_unknown_files);
|
||||
|
||||
return deviceSpecificSettings;
|
||||
}
|
||||
|
@ -776,8 +776,8 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(messageIntent);
|
||||
}
|
||||
|
||||
public Prefs getDevicePrefs() {
|
||||
return new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
public DevicePrefs getDevicePrefs() {
|
||||
return GBApplication.getDevicePrefs(gbDevice.getAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,6 +159,7 @@ public class FileTransferHandler implements MessageHandler {
|
||||
throw new IllegalArgumentException("Invalid directory data length");
|
||||
final GarminByteBufferReader reader = new GarminByteBufferReader(currentlyDownloading.dataHolder.array());
|
||||
reader.setByteOrder(ByteOrder.LITTLE_ENDIAN);
|
||||
final boolean fetchUnknownFiles = deviceSupport.getDevicePrefs().getFetchUnknownFiles();
|
||||
while (reader.remaining() > 0) {
|
||||
final int fileIndex = reader.readShort();//2
|
||||
final int fileDataType = reader.readByte();//3
|
||||
@ -175,7 +176,7 @@ public class FileTransferHandler implements MessageHandler {
|
||||
LOG.warn("Unsupported directory entry of type {}/{}", fileDataType, fileSubType);
|
||||
continue;
|
||||
}
|
||||
if (!FILE_TYPES_TO_PROCESS.contains(directoryEntry.filetype)) {
|
||||
if (!FILE_TYPES_TO_PROCESS.contains(directoryEntry.filetype) && !fetchUnknownFiles) {
|
||||
continue;
|
||||
}
|
||||
LOG.debug("Queueing {} for download", directoryEntry);
|
||||
@ -367,7 +368,7 @@ public class FileTransferHandler implements MessageHandler {
|
||||
public String toString() {
|
||||
return "DirectoryEntry{" +
|
||||
"fileIndex=" + fileIndex +
|
||||
", fileType=" + filetype.name() +
|
||||
", fileType=" + filetype +
|
||||
", fileNumber=" + fileNumber +
|
||||
", specificFlags=" + specificFlags +
|
||||
", fileFlags=" + fileFlags +
|
||||
|
@ -31,4 +31,8 @@ public class DevicePrefs extends Prefs {
|
||||
public int getBatteryNotifyFullThreshold(final BatteryConfig batteryConfig) {
|
||||
return getInt(PREF_BATTERY_NOTIFY_FULL_THRESHOLD + batteryConfig.getBatteryIndex(), batteryConfig.getDefaultFullThreshold());
|
||||
}
|
||||
|
||||
public boolean getFetchUnknownFiles() {
|
||||
return getBoolean("fetch_unknown_files", false);
|
||||
}
|
||||
}
|
||||
|
@ -2922,4 +2922,6 @@
|
||||
<string name="battery_full_threshold">Full battery threshold</string>
|
||||
<string name="default_percentage">Default (%1$d%%)</string>
|
||||
<string name="battery_percentage_str">%1$s%%</string>
|
||||
<string name="pref_fetch_unknown_files_title">Fetch unknown files</string>
|
||||
<string name="pref_fetch_unknown_files_summary">Fetch unknown activity files from the watch. They will not be processed, but will be saved in the phone.</string>
|
||||
</resources>
|
||||
|
10
app/src/main/res/xml/devicesettings_fetch_unknown_files.xml
Normal file
10
app/src/main/res/xml/devicesettings_fetch_unknown_files.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_activity_unknown_small"
|
||||
android:key="fetch_unknown_files"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_fetch_unknown_files_summary"
|
||||
android:title="@string/pref_fetch_unknown_files_title" />
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user