diff --git a/app/build.gradle b/app/build.gradle index b741af4a9..62e8fb689 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -249,6 +249,10 @@ dependencies { implementation 'com.google.protobuf:protobuf-javalite:3.10.0' implementation 'com.android.volley:volley:1.2.1' + // JSR-310 timezones backport for Android, since we're still API 21 + implementation 'com.jakewharton.threetenabp:threetenabp:1.4.0' + testImplementation 'org.threeten:threetenbp:1.6.0' + // Android SDK bundles org.json, but we need an actual implementation to replace the stubs in tests testImplementation 'org.json:json:20180813' } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index 06f171332..93f8c40a4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -99,6 +99,8 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.fromKey; import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_CHANNEL_HIGH_PRIORITY_ID; import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_ID_ERROR; +import com.jakewharton.threetenabp.AndroidThreeTen; + /** * Main Application class that initializes and provides access to certain things like * logging and DB access. @@ -184,6 +186,9 @@ public class GBApplication extends Application { return; } + // Initialize the timezones library + AndroidThreeTen.init(this); + sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); prefs = new Prefs(sharedPrefs); gbPrefs = new GBPrefs(prefs); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Weather.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Weather.java index 15f595a85..d3c02f617 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Weather.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Weather.java @@ -26,6 +26,8 @@ import net.e175.klaus.solarpositioning.SPA; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.threeten.bp.LocalDate; +import org.threeten.bp.format.DateTimeFormatter; import java.text.SimpleDateFormat; import java.util.ArrayList; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java index 33cc3d053..42e65a75d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java @@ -39,17 +39,16 @@ import net.e175.klaus.solarpositioning.SPA; import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import org.threeten.bp.Instant; +import org.threeten.bp.ZoneId; +import org.threeten.bp.zone.ZoneOffsetTransition; +import org.threeten.bp.zone.ZoneRules; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.time.ZoneId; -import java.time.zone.ZoneOffsetTransition; -import java.time.zone.ZoneRules; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar;