mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-29 03:55:49 +01:00
Zepp OS: Change default fetch operation time unit resolution to minutes
Reverts the default behavior introduced by 1335f0bd8
since it was
causing issues on the GTR 3, but keeps it optional as a developer
option.
This commit is contained in:
parent
08a41f655c
commit
bc2d5aa16d
@ -247,6 +247,7 @@ public abstract class Huami2021Coordinator extends HuamiCoordinator {
|
||||
//
|
||||
settings.add(R.xml.devicesettings_header_developer);
|
||||
settings.add(R.xml.devicesettings_keep_activity_data_on_device);
|
||||
settings.add(R.xml.devicesettings_huami2021_fetch_operation_time_unit);
|
||||
|
||||
return ArrayUtils.toPrimitive(settings.toArray(new Integer[0]));
|
||||
}
|
||||
|
@ -1393,6 +1393,15 @@ public abstract class Huami2021Support extends HuamiSupport {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimeUnit getFetchOperationsTimeUnit() {
|
||||
// This is configurable because using seconds was causing issues on Amazfit GTR 3
|
||||
// However, using minutes can cause issues while fetching workouts shorter than 1 minute
|
||||
final Prefs devicePrefs = getDevicePrefs();
|
||||
final boolean truncate = devicePrefs.getBoolean("huami_truncate_fetch_operation_timestamps", true);
|
||||
return truncate ? TimeUnit.MINUTES : TimeUnit.SECONDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean force2021Protocol() {
|
||||
return true;
|
||||
|
@ -165,9 +165,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ACTIVATE_DISPLAY_ON_LIFT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALWAYS_ON_DISPLAY_END;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALWAYS_ON_DISPLAY_MODE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALWAYS_ON_DISPLAY_START;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BT_CONNECTED_ADVERTISEMENT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DISPLAY_ON_LIFT_SENSITIVITY;
|
||||
@ -198,9 +195,6 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LANGUAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SCREEN_BRIGHTNESS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SCREEN_ON_ON_NOTIFICATIONS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SCREEN_TIMEOUT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SOUNDS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||
@ -4100,6 +4094,10 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
return mActivitySampleSize;
|
||||
}
|
||||
|
||||
public TimeUnit getFetchOperationsTimeUnit() {
|
||||
return TimeUnit.MINUTES;
|
||||
}
|
||||
|
||||
public boolean force2021Protocol() {
|
||||
return GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean("force_new_protocol", false);
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.Logging;
|
||||
@ -162,11 +161,12 @@ public abstract class AbstractFetchOperation extends AbstractHuamiOperation {
|
||||
|
||||
protected void startFetching(TransactionBuilder builder, byte fetchType, GregorianCalendar sinceWhen) {
|
||||
final String taskName = StringUtils.ensureNotNull(builder.getTaskName());
|
||||
final boolean isHuami2021 = getSupport() instanceof Huami2021Support;
|
||||
final HuamiSupport support = getSupport();
|
||||
final boolean isHuami2021 = support instanceof Huami2021Support;
|
||||
byte[] fetchBytes = BLETypeConversions.join(new byte[]{
|
||||
HuamiService.COMMAND_ACTIVITY_DATA_START_DATE,
|
||||
fetchType},
|
||||
getSupport().getTimeBytes(sinceWhen, isHuami2021 ? TimeUnit.SECONDS : TimeUnit.MINUTES));
|
||||
support.getTimeBytes(sinceWhen, support.getFetchOperationsTimeUnit()));
|
||||
builder.add(new AbstractGattListenerWriteAction(getQueue(), characteristicFetch, fetchBytes) {
|
||||
@Override
|
||||
protected boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
||||
|
@ -775,6 +775,8 @@
|
||||
<string name="lack_of_step">Lack of steps: %1$d</string>
|
||||
<string name="overstep">Overstep: %1$d</string>
|
||||
<string name="average">Average: %1$s</string>
|
||||
<string name="pref_huami_truncate_fetch_operation_timestamps_title">Truncate fetch operation timestamps</string>
|
||||
<string name="pref_huami_truncate_fetch_operation_timestamps_summary">Truncate the fetch operation timestamps to minutes. Disable this setting to keep the timestamps in seconds, if you face issues while fetching very short workouts.</string>
|
||||
<string name="pref_title_dont_ack_transfer">Do not ACK activity data transfer</string>
|
||||
<string name="pref_summary_dont_ack_transfers">If not ACKed to the band, activity data is not cleared. Useful if GB is used together with other apps.</string>
|
||||
<string name="pref_summary_keep_data_on_device">Will keep activity data on the device even after synchronization. Useful if GB is used together with other apps.</string>
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_timer"
|
||||
android:key="huami_truncate_fetch_operation_timestamps"
|
||||
android:summary="@string/pref_huami_truncate_fetch_operation_timestamps_summary"
|
||||
android:title="@string/pref_huami_truncate_fetch_operation_timestamps_title" />
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user