From 5f3aaf6b549790835e8db721edef22ec420ff4bc Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 6 Dec 2020 15:09:32 +0100 Subject: [PATCH] code cleanup --- .../androidaps/dialogs/CareDialog.kt | 2 +- .../DetermineBasalAdapterAMAJS.java | 4 +- .../DetermineBasalAdapterSMBJS.java | 2 +- .../events/EventConfigBuilderUpdateGui.kt | 3 +- .../objectives/objectives/Objective.java | 17 ++--- .../objectives/objectives/Objective0.java | 4 +- .../objectives/objectives/Objective3.java | 3 +- .../phoneChecker/PhoneCheckerPlugin.kt | 4 +- .../general/automation/triggers/TriggerBg.kt | 2 +- .../automation/triggers/TriggerDelta.kt | 2 +- .../androidaps/plugins/general/food/Food.java | 4 +- .../plugins/general/food/FoodFragment.kt | 6 +- .../plugins/general/food/FoodService.java | 2 +- .../general/maintenance/ImportExportPrefs.kt | 8 +-- .../maintenance/PrefFileListProvider.kt | 4 +- .../formats/EncryptedPrefsFormat.kt | 2 +- .../general/nsclient/NSClientFragment.java | 2 +- .../general/nsclient/NSClientPlugin.java | 8 +-- .../general/nsclient/data/NSDeviceStatus.java | 2 +- .../general/nsclient/data/NSTreatment.java | 4 +- .../nsclient/services/NSClientService.java | 28 ++++---- .../activities/QuickWizardListActivity.kt | 4 +- .../graphExtensions/AreaGraphSeries.java | 2 +- .../graphExtensions/DoubleDataPoint.java | 6 +- .../graphExtensions/ScaledDataPoint.java | 6 +- .../PersistentNotificationPlugin.kt | 2 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 4 +- .../activities/SmsCommunicatorOtpActivity.kt | 2 +- .../SendToDataLayerThread.java | 6 +- .../wearintegration/WatchUpdaterService.java | 2 +- .../plugins/insulin/InsulinFragment.kt | 4 +- .../iob/iobCobCalculator/GlucoseStatus.java | 2 +- .../IobCobCalculatorPlugin.java | 2 +- .../iobCobCalculator/IobCobOref1Thread.java | 18 ++--- .../iob/iobCobCalculator/IobCobThread.java | 8 +-- .../local/events/EventLocalProfileChanged.kt | 3 +- .../plugins/pump/combo/ComboFragment.java | 2 +- .../plugins/pump/combo/ComboPlugin.java | 6 +- .../combo/ruffyscripter/RuffyScripter.java | 4 +- .../commands/ReadHistoryCommand.java | 2 +- .../pump/insight/InsightAlertService.java | 6 +- .../pump/insight/LocalInsightFragment.java | 2 +- .../pump/insight/LocalInsightPlugin.java | 4 +- .../activities/InsightAlertActivity.java | 2 +- .../activities/InsightPairingActivity.java | 10 +-- .../InsightPairingInformationActivity.java | 2 +- .../pump/insight/app_layer/Service.java | 2 +- .../ConfigurationMessageRequest.java | 4 +- .../InsightConnectionService.java | 14 ++-- .../exceptions/ConnectionFailedException.java | 2 +- .../AppLayerErrorException.java | 2 +- .../pump/insight/satl/SatlMessage.java | 3 +- .../plugins/pump/insight/utils/ByteBuf.java | 2 +- .../insight/utils/ConnectionEstablisher.java | 8 +-- .../insight/utils/DelayedActionThread.java | 4 +- .../plugins/pump/insight/utils/IDStorage.java | 4 +- .../pump/insight/utils/InputStreamReader.java | 4 +- .../insight/utils/OutputStreamWriter.java | 4 +- .../insight/utils/PairingDataStorage.java | 2 +- .../plugins/pump/mdi/MDIPlugin.java | 4 +- .../sensitivity/SensitivityAAPSPlugin.java | 4 +- .../SensitivityWeightedAveragePlugin.java | 6 +- .../plugins/treatments/TreatmentService.java | 2 +- .../plugins/treatments/TreatmentsPlugin.java | 2 +- .../TreatmentsTempTargetFragment.java | 2 +- .../androidaps/queue/QueueThread.java | 12 ++-- .../androidaps/utils/JSONFormatter.java | 2 +- .../androidaps/utils/TimeListEdit.java | 34 ++++----- .../alertDialogs/PrefImportSummaryDialog.kt | 8 +-- .../androidaps/utils/stats/TddCalculator.kt | 2 +- .../androidaps/utils/wizard/BolusWizard.kt | 2 +- .../utils/wizard/QuickWizardEntry.kt | 2 +- .../d/ruffy/ruffy/driver/display/Menu.java | 6 +- .../activities/TDDStatsActivity.java | 2 +- .../nightscout/androidaps/data/Profile.java | 4 +- .../data/defaultProfile/DefaultProfile.kt | 2 +- .../data/defaultProfile/DefaultProfileDPV.kt | 2 +- .../androidaps/interfaces/Constraint.java | 4 +- .../plugins/aps/loop/APSResult.java | 2 +- .../plugins/common/ManufacturerType.java | 2 +- .../plugins/general/nsclient/NSUpload.java | 4 +- .../plugins/general/nsclient/data/NSMbg.java | 2 +- .../plugins/general/nsclient/data/NSSgv.java | 4 +- .../PointsWithLabelGraphSeries.java | 2 +- .../overview/graphExtensions/Scale.java | 2 +- .../pump/common/PumpPluginAbstract.java | 2 +- .../pump/common/data/DoseSettings.java | 10 +-- .../common/defs/PumpHistoryEntryGroup.java | 2 +- .../pump/common/defs/PumpStatusType.java | 2 +- .../plugins/pump/common/defs/PumpType.java | 6 +- .../plugins/pump/common/utils/ByteUtil.java | 2 +- .../pump/common/utils/ProfileUtil.java | 4 +- .../plugins/pump/common/utils/StringUtil.java | 3 +- .../androidaps/services/AlarmSoundService.kt | 2 +- .../info/nightscout/androidaps/utils/CRC.java | 2 +- .../nightscout/androidaps/utils/DateUtil.java | 6 +- .../androidaps/utils/DecimalFormatter.java | 8 +-- .../utils/alertDialogs/AlertDialogHelper.kt | 2 +- .../extensions/HexByteArrayConversion.kt | 4 +- .../utils/protection/PasswordCheck.kt | 6 +- .../resources/ResourceHelperImplementation.kt | 2 +- .../utils/ui/DigitsKeyListenerWithComma.java | 12 ++-- .../androidaps/utils/ui/NumberPicker.java | 2 +- .../utils/ui/SingleClickButton.java | 2 +- .../nightscout/androidaps/dana/DanaPump.kt | 2 +- .../danaRKorean/DanaRKoreanPlugin.java | 4 +- .../androidaps/danaRv2/DanaRv2Plugin.java | 4 +- .../androidaps/danar/DanaRPlugin.java | 4 +- .../androidaps/danar/SerialIOThread.java | 8 +-- .../AbstractDanaRExecutionService.java | 2 +- ...DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt | 3 +- .../DanaRS_Packet_Option_Get_User_Option.kt | 2 +- .../danars/dialogs/PairingProgressDialog.java | 2 +- .../danars/encryption/BleEncryption.java | 2 +- .../pump/medtronic/MedtronicFragment.kt | 6 +- .../pump/medtronic/MedtronicPumpPlugin.java | 20 +++--- .../comm/MedtronicCommunicationManager.java | 6 +- .../history/cgms/CGMSHistoryEntryType.java | 16 ++--- .../pump/MedtronicPumpHistoryDecoder.java | 4 +- .../history/pump/PumpHistoryEntryType.java | 16 ++--- .../comm/history/pump/PumpHistoryResult.java | 2 +- .../medtronic/comm/message/PacketType.java | 2 +- .../medtronic/comm/message/PumpMessage.java | 4 +- .../comm/ui/MedtronicUIPostprocessor.java | 4 +- .../medtronic/data/MedtronicHistoryData.java | 4 +- .../data/dto/RLHistoryItemMedtronic.java | 2 +- .../medtronic/defs/MedtronicDeviceType.java | 2 +- .../defs/MedtronicNotificationType.java | 4 +- .../defs/MedtronicStatusRefreshType.java | 4 +- .../RileyLinkStatusDeviceMedtronic.java | 12 ++-- .../service/RileyLinkMedtronicService.java | 2 +- .../pump/medtronic/util/MedtronicUtil.java | 10 +-- .../definition/OmnipodCommandType.java | 2 +- .../definition/PodHistoryEntryType.java | 4 +- .../queue/command/CommandPlayTestBeep.java | 2 +- .../omnipod/ui/OmnipodOverviewFragment.kt | 2 +- .../dialog/RileyLinkBLEScanActivity.java | 10 +-- .../EventRileyLinkDeviceStatusChange.kt | 3 +- .../common/hw/rileylink/RileyLinkUtil.java | 2 +- .../pump/common/hw/rileylink/ble/RFSpy.java | 8 +-- .../common/hw/rileylink/ble/RFSpyReader.java | 4 +- .../common/hw/rileylink/ble/RileyLinkBLE.java | 8 +-- .../ble/RileyLinkCommunicationException.java | 2 +- .../rileylink/ble/command/SendAndListen.java | 16 ++--- .../hw/rileylink/ble/command/SetPreamble.java | 2 +- .../hw/rileylink/ble/data/GattAttributes.java | 4 +- .../hw/rileylink/ble/data/RadioPacket.java | 2 +- .../hw/rileylink/ble/data/RadioResponse.java | 4 +- .../rileylink/ble/defs/RileyLinkBLEError.java | 2 +- .../CharacteristicReadOperation.java | 2 +- .../CharacteristicWriteOperation.java | 2 +- .../operations/DescriptorWriteOperation.java | 2 +- .../hw/rileylink/data/BleAdvertisedData.java | 4 +- .../hw/rileylink/data/RLHistoryItem.java | 2 +- .../rileylink/defs/RileyLinkTargetDevice.java | 4 +- .../dialog/RileyLinkStatusDevice.java | 10 +-- .../RileyLinkStatusGeneralFragment.java | 2 +- .../RileyLinkStatusHistoryFragment.java | 19 +++-- .../service/tasks/ServiceTaskExecutor.java | 2 +- .../BaseComplicationProviderService.java | 2 +- .../CobDetailedComplication.java | 2 +- .../complications/CobIconComplication.java | 2 +- .../IobDetailedComplication.java | 2 +- .../complications/IobIconComplication.java | 2 +- .../complications/UploaderBattery.java | 2 +- .../WallpaperDarkComplication.java | 2 +- .../WallpaperGrayComplication.java | 2 +- .../WallpaperLightComplication.java | 2 +- .../androidaps/data/ListenerService.java | 6 +- .../interaction/actions/AcceptActivity.java | 10 +-- .../interaction/actions/BolusActivity.java | 6 +- .../interaction/actions/CPPActivity.java | 6 +- .../interaction/actions/ECarbActivity.java | 6 +- .../interaction/actions/FillActivity.java | 6 +- .../actions/TempTargetActivity.java | 8 +-- .../actions/ViewSelectorActivity.java | 4 +- .../interaction/actions/WizardActivity.java | 6 +- .../interaction/utils/MenuListActivity.java | 8 +-- .../interaction/utils/PlusMinusEditText.java | 10 +-- .../utils/SmallestDoubleString.java | 2 +- .../utils/WatchfaceSettingsPreference.java | 3 +- .../utils/WearableListItemLayout.java | 2 +- .../androidaps/watchfaces/BIGChart.java | 18 ++--- .../androidaps/watchfaces/BaseWatchFace.java | 72 +++++++++---------- .../androidaps/watchfaces/BgGraphBuilder.java | 32 ++++----- .../watchfaces/CircleWatchface.java | 20 +++--- .../androidaps/watchfaces/DigitalStyle.java | 4 +- .../androidaps/watchfaces/NOChart.java | 16 ++--- .../androidaps/watchfaces/Steampunk.java | 2 +- 189 files changed, 495 insertions(+), 527 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index bad46290aa..3dae80e53f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -122,7 +122,7 @@ class CareDialog : DialogFragmentWithDate() { } } - val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).getGlucoseStatusData()?.glucose + val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).glucoseStatusData?.glucose ?: 0.0, profileFunction.getUnits()) val bgTextWatcher: TextWatcher = object : TextWatcher { override fun afterTextChanged(s: Editable) {} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java index a5b4fdff9b..a6876a3144 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java @@ -40,7 +40,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.sharedPreferences.SP; public class DetermineBasalAdapterAMAJS { - private HasAndroidInjector injector; + private final HasAndroidInjector injector; @Inject AAPSLogger aapsLogger; @Inject ConstraintChecker constraintChecker; @Inject SP sp; @@ -48,7 +48,7 @@ public class DetermineBasalAdapterAMAJS { @Inject TreatmentsPlugin treatmentsPlugin; @Inject OpenHumansUploader openHumansUploader; - private ScriptReader mScriptReader; + private final ScriptReader mScriptReader; private JSONObject mProfile; private JSONObject mGlucoseStatus; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java index f25dfee9c0..1013434c95 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java @@ -55,7 +55,7 @@ public class DetermineBasalAdapterSMBJS { @Inject OpenHumansUploader openHumansUploader; - private ScriptReader mScriptReader; + private final ScriptReader mScriptReader; private JSONObject mProfile; private JSONObject mGlucoseStatus; private JSONArray mIobData; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/events/EventConfigBuilderUpdateGui.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/events/EventConfigBuilderUpdateGui.kt index 26904127dd..8d24c912ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/events/EventConfigBuilderUpdateGui.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/events/EventConfigBuilderUpdateGui.kt @@ -2,5 +2,4 @@ package info.nightscout.androidaps.plugins.configBuilder.events import info.nightscout.androidaps.events.EventUpdateGui -class EventConfigBuilderUpdateGui : EventUpdateGui() { -} \ No newline at end of file +class EventConfigBuilderUpdateGui : EventUpdateGui() \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java index 28efcf6f55..feef4a4222 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java @@ -26,9 +26,9 @@ public abstract class Objective { @Inject public SP sp; @Inject public ResourceHelper resourceHelper; - private String spName; - @StringRes private int objective; - @StringRes private int gate; + private final String spName; + @StringRes private final int objective; + @StringRes private final int gate; private long startedOn; private long accomplishedOn; List tasks = new ArrayList<>(); @@ -116,7 +116,7 @@ public abstract class Objective { public abstract class Task { @StringRes - private int task; + private final int task; private Objective objective; ArrayList hints = new ArrayList<>(); @@ -138,8 +138,6 @@ public abstract class Objective { return isCompleted(); } - ; - public String getProgress() { return resourceHelper.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet); } @@ -160,7 +158,7 @@ public abstract class Objective { public class MinimumDurationTask extends Task { - private long minimumDuration; + private final long minimumDuration; MinimumDurationTask(long minimumDuration) { super(R.string.time_elapsed); @@ -197,7 +195,7 @@ public abstract class Objective { @StringRes int question; ArrayList