From c37603440979f9abe3ccec07de25fe98a0750f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 4 Jul 2024 20:20:00 +0100 Subject: [PATCH] Enable core library desugaring --- app/build.gradle | 8 +- .../gadgetbridge/GBApplication.java | 5 -- .../activities/charts/PaiChartFragment.java | 2 +- .../devices/AbstractSampleProvider.java | 9 +-- .../samples/CmfActivitySampleProvider.java | 2 +- .../GarminRealtimeSettingsActivity.java | 3 +- .../PineTimeActivitySampleProvider.java | 7 +- .../externalevents/TimeChangeReceiver.java | 8 +- .../service/btle/BLETypeConversions.java | 4 +- .../devices/casio/Casio2C2DSupport.java | 3 +- .../service/devices/casio/CasioSupport.java | 2 +- .../gb6900/CasioGB6900DeviceSupport.java | 12 +-- .../gbx100/CasioGBX100DeviceSupport.java | 22 +----- .../devices/casio/gbx100/InitOperation.java | 7 +- .../casio/gwb5600/CasioGWB5600TimeZone.java | 23 +++--- .../devices/casio/gwb5600/InitOperation.java | 19 ++--- .../service/devices/garmin/GarminSupport.java | 3 +- .../devices/garmin/GarminTimeUtils.java | 4 +- .../devices/garmin/agps/AgpsHandler.java | 2 +- .../devices/garmin/fit/FitImporter.java | 2 +- .../garmin/fit/codegen/FitCodeGen.java | 21 ++++- .../devices/garmin/fit/enums/GarminSport.java | 2 +- .../FieldDefinitionDayOfWeek.java | 7 +- .../garmin/fit/messages/FitAlarmSettings.java | 4 +- .../garmin/fit/messages/FitMonitoring.java | 3 +- .../garmin/fit/messages/FitWeather.java | 9 ++- .../messages/CurrentTimeRequestMessage.java | 9 +-- .../service/devices/huami/HuamiSupport.java | 8 +- .../devices/huami/zeppos/ZeppOsWeather.java | 4 +- .../devices/pinetime/PineTimeJFSupport.java | 14 +--- .../communication/datastructures/Time.java | 9 +-- .../gadgetbridge/util/Optional.java | 76 ------------------- .../language/impl/KoreanTransliterator.java | 2 +- .../datastructures/TimeTest.java | 2 +- 34 files changed, 98 insertions(+), 219 deletions(-) delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Optional.java diff --git a/app/build.gradle b/app/build.gradle index 2edfe4402..229fec9f5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,6 +61,8 @@ def getGitHashShort = { -> android { compileOptions { + coreLibraryDesugaringEnabled true + // for Android 5+ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -196,6 +198,8 @@ android { } dependencies { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation "androidx.camera:camera-core:1.2.3" implementation "androidx.camera:camera-camera2:1.2.3" @@ -245,10 +249,6 @@ dependencies { //implementation 'org.bouncycastle:bcpkix-jdk18on:1.76' //implementation 'org.bouncycastle:bcprov-jdk18on:1.76' - // JSR-310 timezones backport for Android, since we're still API 21 - implementation 'com.jakewharton.threetenabp:threetenabp:1.4.7' - testImplementation 'org.threeten:threetenbp:1.6.9' - // Android SDK bundles org.json, but we need an actual implementation to replace the stubs in tests testImplementation 'org.json:json:20240303' diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index 1b0763a46..956a18fa5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -104,8 +104,6 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.WATCHXPLUS; 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; - import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; @@ -206,9 +204,6 @@ public class GBApplication extends Application { return; } - // Initialize the timezones library - AndroidThreeTen.init(this); - sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); prefs = new GBPrefs(sharedPrefs); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/PaiChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/PaiChartFragment.java index b73bd5160..29a4f8e93 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/PaiChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/PaiChartFragment.java @@ -49,6 +49,7 @@ import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.Optional; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; @@ -58,7 +59,6 @@ import nodomain.freeyourgadget.gadgetbridge.devices.TimeSampleProvider; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.PaiSample; import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; public class PaiChartFragment extends AbstractChartFragment { protected static final Logger LOG = LoggerFactory.getLogger(PaiChartFragment.class); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java index f7886e44b..4c48e51f9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java @@ -17,16 +17,15 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import java.time.LocalDate; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.List; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import org.threeten.bp.LocalDate; - import de.greenrobot.dao.AbstractDao; import de.greenrobot.dao.Property; import de.greenrobot.dao.query.QueryBuilder; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/cmfwatchpro/samples/CmfActivitySampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/cmfwatchpro/samples/CmfActivitySampleProvider.java index 5f63b97e4..2709efaff 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/cmfwatchpro/samples/CmfActivitySampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/cmfwatchpro/samples/CmfActivitySampleProvider.java @@ -21,8 +21,8 @@ import androidx.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.threeten.bp.LocalDate; +import java.time.LocalDate; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminRealtimeSettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminRealtimeSettingsActivity.java index 52b756599..eb8c041eb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminRealtimeSettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminRealtimeSettingsActivity.java @@ -13,11 +13,12 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.preference.PreferenceFragmentCompat; +import java.util.Optional; + import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivityV2; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.util.GB; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; public class GarminRealtimeSettingsActivity extends AbstractSettingsActivityV2 { private GBDevice device; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeActivitySampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeActivitySampleProvider.java index a308ec741..52ffc9618 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeActivitySampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeActivitySampleProvider.java @@ -18,6 +18,10 @@ package nodomain.freeyourgadget.gadgetbridge.devices.pinetime; import androidx.annotation.NonNull; import androidx.annotation.Nullable; + +import java.util.List; +import java.util.Optional; + import de.greenrobot.dao.AbstractDao; import de.greenrobot.dao.Property; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractSampleProvider; @@ -26,9 +30,6 @@ import nodomain.freeyourgadget.gadgetbridge.entities.PineTimeActivitySample; import nodomain.freeyourgadget.gadgetbridge.entities.PineTimeActivitySampleDao; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; - -import java.util.List; public class PineTimeActivitySampleProvider extends AbstractSampleProvider { private GBDevice mDevice; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/TimeChangeReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/TimeChangeReceiver.java index af9e0a2f8..acc5956a4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/TimeChangeReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/TimeChangeReceiver.java @@ -26,11 +26,11 @@ import android.os.SystemClock; 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.time.Instant; +import java.time.ZoneId; +import java.time.zone.ZoneOffsetTransition; +import java.time.zone.ZoneRules; import java.util.Date; import java.util.GregorianCalendar; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java index 9de991709..8c5984a55 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java @@ -19,13 +19,11 @@ package nodomain.freeyourgadget.gadgetbridge.service.btle; import java.nio.charset.StandardCharsets; +import java.time.ZonedDateTime; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; -import org.threeten.bp.ZonedDateTime; - -import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandCoordinator; import nodomain.freeyourgadget.gadgetbridge.model.NotificationType; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertCategory; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java index 3c4828b7f..6670eb568 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java @@ -16,13 +16,12 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.service.devices.casio; +import java.time.ZonedDateTime; import java.util.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.threeten.bp.ZonedDateTime; - import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java index 8cdf0c430..8f3ff85fb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java @@ -21,7 +21,7 @@ import android.net.Uri; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.threeten.bp.ZonedDateTime; +import java.time.ZonedDateTime; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900DeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900DeviceSupport.java index 5df7370ed..e9f558aa3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900DeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900DeviceSupport.java @@ -22,7 +22,6 @@ import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import android.bluetooth.BluetoothGattService; import android.content.SharedPreferences; -import android.net.Uri; import android.widget.Toast; import org.slf4j.Logger; @@ -30,13 +29,12 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Calendar; import java.util.UUID; import java.util.concurrent.TimeUnit; -import org.threeten.bp.ZonedDateTime; - import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone; @@ -44,23 +42,15 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicContr import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.Alarm; -import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; -import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; -import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; -import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService; import nodomain.freeyourgadget.gadgetbridge.service.btle.ServerTransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.CasioGB6900HandlerThread; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.InitOperation; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.SetAlarmOperation; -import nodomain.freeyourgadget.gadgetbridge.util.BondingUtil; import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java index 6e8263426..15a3ee180 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java @@ -19,29 +19,23 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; import android.content.SharedPreferences; -import android.net.Uri; import android.os.Handler; import android.widget.Toast; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; +import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.threeten.bp.ZonedDateTime; - import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst; @@ -49,28 +43,15 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone; import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; -import nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100.CasioGBX100DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100.CasioGBX100SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.makibeshr3.MakibesHR3Constants; import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySample; import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.entities.User; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.Alarm; -import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; -import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; -import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; -import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; -import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.Casio2C2DSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.FetchStepCountDataOperation; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.GetConfigurationOperation; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.InitOperation; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.SetConfigurationOperation; import nodomain.freeyourgadget.gadgetbridge.util.GB; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_AUTOLIGHT; @@ -87,7 +68,6 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_OPERATING_SOUNDS; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_PREVIEW_MESSAGE_IN_TITLE; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT; -import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION; import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_ACTIVETIME_MINUTES; import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_DISTANCE_METERS; import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_GENDER; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/InitOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/InitOperation.java index 9752c037b..36dc695eb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/InitOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/InitOperation.java @@ -18,24 +18,19 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; -import android.os.Handler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.threeten.bp.ZonedDateTime; - import java.io.IOException; -import java.util.Calendar; +import java.time.ZonedDateTime; import java.util.UUID; -import java.util.concurrent.TimeUnit; import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport; public class InitOperation extends AbstractBTLEOperation { private static final Logger LOG = LoggerFactory.getLogger(InitOperation.class); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/CasioGWB5600TimeZone.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/CasioGWB5600TimeZone.java index 6993b5ac8..7cd1b1917 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/CasioGWB5600TimeZone.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/CasioGWB5600TimeZone.java @@ -17,19 +17,18 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600; -import java.util.List; -import java.util.Arrays; import java.nio.charset.StandardCharsets; - -import org.threeten.bp.Instant; -import org.threeten.bp.LocalTime; -import org.threeten.bp.Month; -import org.threeten.bp.DayOfWeek; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZoneOffset; -import org.threeten.bp.zone.ZoneRules; -import org.threeten.bp.zone.ZoneOffsetTransition; -import org.threeten.bp.zone.ZoneOffsetTransitionRule; +import java.time.DayOfWeek; +import java.time.Instant; +import java.time.LocalTime; +import java.time.Month; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.zone.ZoneOffsetTransition; +import java.time.zone.ZoneOffsetTransitionRule; +import java.time.zone.ZoneRules; +import java.util.Arrays; +import java.util.List; import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/InitOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/InitOperation.java index d5072c2d6..3b4eb42fa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/InitOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/InitOperation.java @@ -24,24 +24,21 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.List; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.TextStyle; import java.util.LinkedList; -import java.util.UUID; +import java.util.List; import java.util.Locale; +import java.util.UUID; -import org.threeten.bp.Instant; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.TextStyle; - +import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus; import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction; -import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600.CasioGWB5600DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600.CasioGWB5600TimeZone; +import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus; public class InitOperation extends AbstractBTLEOperation { private static final Logger LOG = LoggerFactory.getLogger(InitOperation.class); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java index 3572518f6..801ba875f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java @@ -17,13 +17,13 @@ import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.Queue; import java.util.Set; import java.util.Timer; @@ -81,7 +81,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.Supp import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.SystemEventMessage; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.status.NotificationSubscriptionStatusMessage; import nodomain.freeyourgadget.gadgetbridge.util.GB; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminTimeUtils.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminTimeUtils.java index 1cdef52aa..2742482d6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminTimeUtils.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminTimeUtils.java @@ -1,7 +1,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin; -import org.threeten.bp.Instant; -import org.threeten.bp.ZoneId; +import java.time.Instant; +import java.time.ZoneId; public class GarminTimeUtils { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/agps/AgpsHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/agps/AgpsHandler.java index 5ea9a6e5a..ef86c64e8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/agps/AgpsHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/agps/AgpsHandler.java @@ -4,10 +4,10 @@ import androidx.documentfile.provider.DocumentFile; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.threeten.bp.Instant; import java.io.IOException; import java.io.InputStream; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.List; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/FitImporter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/FitImporter.java index f3d7cae88..36e6edf4c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/FitImporter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/FitImporter.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.SortedMap; import java.util.TreeMap; @@ -62,7 +63,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages. import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages.FitStressLevel; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages.FitTimeInZone; import nodomain.freeyourgadget.gadgetbridge.util.GB; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; public class FitImporter { private static final Logger LOG = LoggerFactory.getLogger(FitImporter.class); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/codegen/FitCodeGen.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/codegen/FitCodeGen.java index 0a36285f8..a3caa5d34 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/codegen/FitCodeGen.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/codegen/FitCodeGen.java @@ -6,12 +6,11 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; -import org.threeten.bp.DayOfWeek; - import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.time.DayOfWeek; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -33,6 +32,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefi import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionLanguage; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionMeasurementSystem; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionSleepStage; +import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionWeatherAqi; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionWeatherCondition; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; @@ -138,7 +138,7 @@ public class FitCodeGen { anyImport = false; } for (final String i : uniqueImports) { - if (i.startsWith("nodomain.freeyourgadget")) { + if (i.startsWith("java.")) { sb.append("import ").append(i).append(";\n"); anyImport = true; } @@ -149,7 +149,18 @@ public class FitCodeGen { anyImport = false; } for (final String i : uniqueImports) { - if (!i.startsWith("androidx") && !i.startsWith("nodomain.freeyourgadget")) { + if (i.startsWith("nodomain.freeyourgadget") && !i.startsWith("java.")) { + sb.append("import ").append(i).append(";\n"); + anyImport = true; + } + } + + if (anyImport) { + sb.append("\n"); + anyImport = false; + } + for (final String i : uniqueImports) { + if (!i.startsWith("androidx") && !i.startsWith("nodomain.freeyourgadget") && !i.startsWith("java.")) { sb.append("import ").append(i).append(";\n"); anyImport = true; } @@ -236,6 +247,8 @@ public class FitCodeGen { return FieldDefinitionLanguage.Language.class; case SLEEP_STAGE: return FieldDefinitionSleepStage.SleepStage.class; + case WEATHER_AQI: + return FieldDefinitionWeatherAqi.AQI_LEVELS.class; } throw new RuntimeException("Unknown field type " + primitive.getType()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/enums/GarminSport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/enums/GarminSport.java index 0d287600b..1d9a7cc36 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/enums/GarminSport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/enums/GarminSport.java @@ -1,6 +1,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.enums; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; +import java.util.Optional; // Taken from CHANGELOG.fit of a Venu 3 public enum GarminSport { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/fieldDefinitions/FieldDefinitionDayOfWeek.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/fieldDefinitions/FieldDefinitionDayOfWeek.java index a1dfefeec..caea1ac3e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/fieldDefinitions/FieldDefinitionDayOfWeek.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/fieldDefinitions/FieldDefinitionDayOfWeek.java @@ -1,10 +1,9 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions; -import org.threeten.bp.DayOfWeek; -import org.threeten.bp.Instant; -import org.threeten.bp.ZoneId; - import java.nio.ByteBuffer; +import java.time.DayOfWeek; +import java.time.Instant; +import java.time.ZoneId; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.FieldDefinition; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.baseTypes.BaseType; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitAlarmSettings.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitAlarmSettings.java index 05b37173c..68b0ac8f9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitAlarmSettings.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitAlarmSettings.java @@ -2,12 +2,12 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages import androidx.annotation.Nullable; +import java.util.Calendar; + import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordData; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDefinition; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader; -import java.util.Calendar; - // // WARNING: This class was auto-generated, please avoid modifying it directly. // See nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.codegen.FitCodeGen diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitMonitoring.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitMonitoring.java index 963754d0a..77441935c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitMonitoring.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitMonitoring.java @@ -2,11 +2,12 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages import androidx.annotation.Nullable; +import java.util.Optional; + import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.GarminTimeUtils; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordData; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDefinition; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; // // WARNING: This class was auto-generated, please avoid modifying it directly. diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitWeather.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitWeather.java index 95f42d432..648c8c9b4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitWeather.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitWeather.java @@ -2,13 +2,14 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages import androidx.annotation.Nullable; +import java.time.DayOfWeek; + import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordData; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDefinition; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader; +import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionWeatherAqi.AQI_LEVELS; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionWeatherCondition.Condition; -import org.threeten.bp.DayOfWeek; - // // WARNING: This class was auto-generated, please avoid modifying it directly. // See nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.codegen.FitCodeGen @@ -109,8 +110,8 @@ public class FitWeather extends RecordData { } @Nullable - public Integer getAirQuality() { - return (Integer) getFieldByNumber(17); + public AQI_LEVELS getAirQuality() { + return (AQI_LEVELS) getFieldByNumber(17); } @Nullable diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/messages/CurrentTimeRequestMessage.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/messages/CurrentTimeRequestMessage.java index be7a364f2..d263414c3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/messages/CurrentTimeRequestMessage.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/messages/CurrentTimeRequestMessage.java @@ -1,11 +1,10 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages; -import org.threeten.bp.Instant; -import org.threeten.bp.ZoneId; -import org.threeten.bp.zone.ZoneOffsetTransition; -import org.threeten.bp.zone.ZoneRules; - +import java.time.Instant; +import java.time.ZoneId; +import java.time.zone.ZoneOffsetTransition; +import java.time.zone.ZoneRules; import java.util.TimeZone; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.GarminTimeUtils; 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 6811c3296..d142a20a9 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 @@ -42,16 +42,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; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsWeather.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsWeather.java index 8456ff417..f74fd6a6a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsWeather.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsWeather.java @@ -32,11 +32,11 @@ 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.lang.reflect.Type; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java index 4cfc1ab66..7498650e9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java @@ -20,10 +20,10 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.pinetime; import static nodomain.freeyourgadget.gadgetbridge.devices.pinetime.weather.WeatherData.mapOpenWeatherConditionToCloudCover; +import static nodomain.freeyourgadget.gadgetbridge.devices.pinetime.weather.WeatherData.mapOpenWeatherConditionToPineTimeCondition; import static nodomain.freeyourgadget.gadgetbridge.devices.pinetime.weather.WeatherData.mapOpenWeatherConditionToPineTimeObscuration; import static nodomain.freeyourgadget.gadgetbridge.devices.pinetime.weather.WeatherData.mapOpenWeatherConditionToPineTimePrecipitation; import static nodomain.freeyourgadget.gadgetbridge.devices.pinetime.weather.WeatherData.mapOpenWeatherConditionToPineTimeSpecial; -import static nodomain.freeyourgadget.gadgetbridge.devices.pinetime.weather.WeatherData.mapOpenWeatherConditionToPineTimeCondition; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -31,7 +31,6 @@ import android.content.Intent; import android.net.Uri; import android.os.Build; import android.widget.Toast; -import android.content.SharedPreferences; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @@ -48,14 +47,9 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; +import java.util.Optional; import java.util.TimeZone; import java.util.UUID; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; import co.nstant.in.cbor.CborBuilder; import co.nstant.in.cbor.CborEncoder; @@ -86,10 +80,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.User; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; -import nodomain.freeyourgadget.gadgetbridge.model.Alarm; -import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; -import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; import nodomain.freeyourgadget.gadgetbridge.model.DeviceService; import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; @@ -112,7 +103,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotificat import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.battery.BatteryInfoProfile; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfoProfile; import nodomain.freeyourgadget.gadgetbridge.util.GB; -import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper; public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuLogListener { private static final Logger LOG = LoggerFactory.getLogger(PineTimeJFSupport.class); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/Time.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/Time.java index 1212105fb..5a4232863 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/Time.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/Time.java @@ -16,12 +16,11 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.service.devices.withingssteelhr.communication.datastructures; -import org.threeten.bp.Instant; -import org.threeten.bp.ZoneId; -import org.threeten.bp.zone.ZoneOffsetTransition; -import org.threeten.bp.zone.ZoneRules; - import java.nio.ByteBuffer; +import java.time.Instant; +import java.time.ZoneId; +import java.time.zone.ZoneOffsetTransition; +import java.time.zone.ZoneRules; import java.util.TimeZone; public class Time extends WithingsStructure { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Optional.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Optional.java deleted file mode 100644 index 89438d193..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Optional.java +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.util; - -import java.util.NoSuchElementException; -import java.util.Objects; - -/** - * An API21-compatible alternative to java.util.Optional. - */ -public final class Optional { - private final T value; - - private Optional() { - this.value = null; - } - - private Optional(final T value) { - this.value = Objects.requireNonNull(value); - } - - public T get() { - if (value == null) { - throw new NoSuchElementException("No value present"); - } - return value; - } - - public boolean isEmpty() { - return value == null; - } - - public boolean isPresent() { - return value != null; - } - - public T orElse(final T other) { - return value != null ? value : other; - } - - public void ifPresent(final Consumer consumer) { - if (value != null) { - consumer.consume(value); - } - } - - public static Optional empty() { - return new Optional<>(); - } - - public static Optional of(final T value) { - return new Optional<>(value); - } - - public static Optional ofNullable(final T value) { - return value == null ? empty() : of(value); - } - - public static interface Consumer { - void consume(final T value); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/impl/KoreanTransliterator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/impl/KoreanTransliterator.java index c8f7e86a3..b19e1df9a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/impl/KoreanTransliterator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/impl/KoreanTransliterator.java @@ -17,8 +17,8 @@ package nodomain.freeyourgadget.gadgetbridge.util.language.impl; import java.text.Normalizer; +import java.util.Optional; -import nodomain.freeyourgadget.gadgetbridge.util.Optional; import nodomain.freeyourgadget.gadgetbridge.util.language.Transliterator; // Implements Revised Romanization of Korean as well as we can without understanding any grammar. diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/TimeTest.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/TimeTest.java index 49e0c2407..5b08a72d8 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/TimeTest.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/withingssteelhr/communication/datastructures/TimeTest.java @@ -3,9 +3,9 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.withingssteelhr.com import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.threeten.bp.Instant; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.Date; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;