1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-08-15 20:01:01 +02:00

Merge branch 'master' into background-javascript

This commit is contained in:
Andreas Shimokawa 2017-10-04 21:49:39 +02:00
commit fbef490419
8 changed files with 42 additions and 1 deletions

View File

@ -1,5 +1,8 @@
### Changelog
#### Version 0.21.5
* Mi2/Bip: Support setting distance units (metric/imperial)
#### Version 0.21.4
* Mi2/Bip: Fix sleep detection for newer firmwares
* Mi2/Bip: Fix ancient bug resulting in wrong activity data at the beginning in diagrams and aggregate data

View File

@ -27,7 +27,7 @@ android {
// note: always bump BOTH versionCode and versionName!
versionName "0.21.5"
versionCode 105
versionCode 106
vectorDrawables.useSupportLibrary = true
}
buildTypes {

View File

@ -37,6 +37,7 @@ import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.miband2.MiBand2FWInstallHandler;
@ -189,6 +190,16 @@ public class MiBand2Coordinator extends MiBandCoordinator {
return new Date();
}
public static MiBandConst.DistanceUnit getDistanceUnit() {
Prefs prefs = GBApplication.getPrefs();
String unit = prefs.getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, GBApplication.getContext().getString(R.string.p_unit_metric));
if (unit.equals(GBApplication.getContext().getString(R.string.p_unit_metric))) {
return MiBandConst.DistanceUnit.METRIC;
} else {
return MiBandConst.DistanceUnit.IMPERIAL;
}
}
public static DoNotDisturb getDoNotDisturb(Context context) {
Prefs prefs = GBApplication.getPrefs();

View File

@ -144,6 +144,8 @@ public class MiBand2Service {
public static final byte[] COMMAND_DISABLE_DISPLAY_CALLER = new byte[]{ENDPOINT_DISPLAY, 0x10, 0x00, 0x00, 0x00};
public static final byte[] DISPLAY_XXX = new byte[] {ENDPOINT_DISPLAY, 0x03, 0x0, 0x0 };
public static final byte[] DISPLAY_YYY = new byte[] {ENDPOINT_DISPLAY, 0x10, 0x0, 0x1, 0x1 };
public static final byte[] COMMAND_DISTANCE_UNIT_METRIC = new byte[] { ENDPOINT_DISPLAY, 0x03, 0x00, 0x00 };
public static final byte[] COMMAND_DISTANCE_UNIT_IMPERIAL = new byte[] { ENDPOINT_DISPLAY, 0x03, 0x00, 0x01 };
// The third byte controls the threshold, in minutes
// The last 8 bytes represent 2 separate time intervals for the inactivity warnings

View File

@ -81,6 +81,11 @@ public final class MiBandConst {
public static final Version MI2_FW_VERSION_MIN_TEXT_NOTIFICATIONS = new Version("1.0.1.28");
public static final Version MI2_FW_VERSION_INTERMEDIATE_UPGRADE_53 = new Version("1.0.0.53");
public enum DistanceUnit {
METRIC,
IMPERIAL
}
public static int getNotificationPrefIntValue(String pref, String origin, Prefs prefs, int defaultValue) {
String key = getNotificationPrefKey(pref, origin);
return prefs.getInt(key, defaultValue);

View File

@ -48,6 +48,7 @@ import java.util.concurrent.TimeUnit;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.Logging;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
@ -1252,6 +1253,9 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
case MiBandConst.PREF_MI2_INACTIVITY_WARNINGS_DND_END:
setInactivityWarnings(builder);
break;
case SettingsActivity.PREF_MEASUREMENT_SYSTEM:
setDistanceUnit(builder);
break;
}
builder.queue(getQueue());
} catch (IOException e) {
@ -1452,6 +1456,17 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
return this;
}
private MiBand2Support setDistanceUnit(TransactionBuilder builder) {
MiBandConst.DistanceUnit unit = MiBand2Coordinator.getDistanceUnit();
LOG.info("Setting distance unit to " + unit);
if (unit == MiBandConst.DistanceUnit.METRIC) {
builder.write(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION), MiBand2Service.COMMAND_DISTANCE_UNIT_METRIC);
} else {
builder.write(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION), MiBand2Service.COMMAND_DISTANCE_UNIT_IMPERIAL);
}
return this;
}
public void phase2Initialize(TransactionBuilder builder) {
LOG.info("phase2Initialize...");
requestBatteryInfo(builder);
@ -1462,6 +1477,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
setDateDisplay(builder);
setTimeFormat(builder);
setUserInfo(builder);
setDistanceUnit(builder);
setWearLocation(builder);
setFitnessGoal(builder);
setDisplayItems(builder);

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="0.21.5" versioncode="106">
<change>Mi2/Bip: Support setting distance units (metric/imperial)</change>
</release>
<release version="0.21.4" versioncode="105">
<change>Mi2/Bip: Fix sleep detection for newer firmwares</change>
<change>Mi2/Bip: Fix ancient bug resulting in wrong activity data at the beginning in diagrams and aggregate data</change>

View File

@ -0,0 +1 @@
* Mi2/Bip: Support setting distance units (metric/imperial)