From 261fbbc7596909b772303a9ba390099a0d66e325 Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 4 May 2021 18:41:11 +0200 Subject: [PATCH] Replace Hardcoded key by string --- .../pump/insight/LocalInsightPlugin.java | 18 +++++++------- .../InsightConnectionService.java | 7 +++--- insight/src/main/res/values/strings.xml | 14 +++++++++-- .../main/res/xml/pref_insight_local_full.xml | 24 +++++++++---------- .../xml/pref_insight_local_pumpcontrol.xml | 22 ++++++++--------- 5 files changed, 48 insertions(+), 37 deletions(-) diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 5626f4cdb1..6f230dee15 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -579,7 +579,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai bolusMessage.setDuration(0); bolusMessage.setExtendedAmount(0); bolusMessage.setImmediateAmount(insulin); - bolusMessage.setVibration(sp.getBoolean(detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB ? R.string.key_disable_vibration_auto : R.string.key_disable_vibration, false)); + bolusMessage.setVibration(sp.getBoolean(detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB ? R.string.key_insight_disable_vibration_auto : R.string.key_insight_disable_vibration, false)); bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); bolusCancelled = false; } @@ -701,7 +701,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai if (cancelTBRResult.getSuccess()) { PumpEnactResult ebResult = setExtendedBolusOnly((absoluteRate - getBaseBasalRate()) / 60D * ((double) durationInMinutes), durationInMinutes, - sp.getBoolean(R.string.key_disable_vibration_auto, false)); + sp.getBoolean(R.string.key_insight_disable_vibration_auto, false)); if (ebResult.getSuccess()) { result.success(true) .enacted(true) @@ -780,7 +780,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai public PumpEnactResult setExtendedBolus(double insulin, int durationInMinutes) { PumpEnactResult result = cancelExtendedBolusOnly(); if (result.getSuccess()) - result = setExtendedBolusOnly(insulin, durationInMinutes, sp.getBoolean(R.string.key_disable_vibration, false)); + result = setExtendedBolusOnly(insulin, durationInMinutes, sp.getBoolean(R.string.key_insight_disable_vibration, false)); try { fetchStatus(); readHistory(); @@ -1130,7 +1130,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai @Override public boolean isFakingTempsByExtendedBoluses() { - return sp.getBoolean("insight_enable_tbr_emulation", false); + return sp.getBoolean(R.string.key_insight_enable_tbr_emulation, false); } @NonNull @Override @@ -1254,7 +1254,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai } private void processCannulaFilledEvent(CannulaFilledEvent event) { - if (!sp.getBoolean("insight_log_site_changes", false)) return; + if (!sp.getBoolean(R.string.key_insight_log_site_changes, false)) return; long timestamp = parseDate(event.getEventYear(), event.getEventMonth(), event.getEventDay(), event.getEventHour(), event.getEventMinute(), event.getEventSecond()) + timeOffset; uploadCareportalEvent(timestamp, DetailedBolusInfo.EventType.CANNULA_CHANGE); @@ -1278,21 +1278,21 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai } private void processTubeFilledEvent(TubeFilledEvent event) { - if (!sp.getBoolean("insight_log_tube_changes", false)) return; + if (!sp.getBoolean(R.string.key_insight_log_tube_changes, false)) return; long timestamp = parseDate(event.getEventYear(), event.getEventMonth(), event.getEventDay(), event.getEventHour(), event.getEventMinute(), event.getEventSecond()) + timeOffset; logNote(timestamp, resourceHelper.gs(R.string.tube_changed)); } private void processSniffingDoneEvent(SniffingDoneEvent event) { - if (!sp.getBoolean("insight_log_reservoir_changes", false)) return; + if (!sp.getBoolean(R.string.key_insight_log_reservoir_changes, false)) return; long timestamp = parseDate(event.getEventYear(), event.getEventMonth(), event.getEventDay(), event.getEventHour(), event.getEventMinute(), event.getEventSecond()) + timeOffset; uploadCareportalEvent(timestamp, DetailedBolusInfo.EventType.INSULIN_CHANGE); } private void processPowerUpEvent(PowerUpEvent event) { - if (!sp.getBoolean("insight_log_battery_changes", false)) return; + if (!sp.getBoolean(R.string.key_insight_log_battery_changes, false)) return; long timestamp = parseDate(event.getEventYear(), event.getEventMonth(), event.getEventDay(), event.getEventHour(), event.getEventMinute(), event.getEventSecond()) + timeOffset; uploadCareportalEvent(timestamp, DetailedBolusInfo.EventType.PUMP_BATTERY_CHANGE); @@ -1446,7 +1446,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai } private void processOccurrenceOfAlertEvent(OccurrenceOfAlertEvent event) { - if (!sp.getBoolean("insight_log_alerts", false)) return; + if (!sp.getBoolean(R.string.key_insight_log_alerts, false)) return; long timestamp = parseDate(event.getEventYear(), event.getEventMonth(), event.getEventDay(), event.getEventHour(), event.getEventMinute(), event.getEventSecond()) + timeOffset; Integer code = null; diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java index cddceb1ddd..40edeebc7b 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/connection_service/InsightConnectionService.java @@ -20,6 +20,7 @@ import java.util.List; import javax.inject.Inject; import dagger.android.DaggerService; +import info.nightscout.androidaps.insight.R; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.insight.app_layer.AppLayerMessage; @@ -141,10 +142,10 @@ public class InsightConnectionService extends DaggerService implements Connectio } private void increaseRecoveryDuration() { - long maxRecoveryDuration = sp.getInt("insight_max_recovery_duration", 20); + long maxRecoveryDuration = sp.getInt(R.string.key_insight_max_recovery_duration, 20); maxRecoveryDuration = Math.min(maxRecoveryDuration, 20); maxRecoveryDuration = Math.max(maxRecoveryDuration, 0); - long minRecoveryDuration = sp.getInt("insight_min_recovery_duration", 5); + long minRecoveryDuration = sp.getInt(R.string.key_insight_min_recovery_duration, 5); minRecoveryDuration = Math.min(minRecoveryDuration, 20); minRecoveryDuration = Math.max(minRecoveryDuration, 0); recoveryDuration += 1000; @@ -295,7 +296,7 @@ public class InsightConnectionService extends DaggerService implements Connectio setState(InsightState.DISCONNECTED); cleanup(true); } else if (state != InsightState.DISCONNECTED) { - long disconnectTimeout = sp.getInt("insight_disconnect_delay", 5); + long disconnectTimeout = sp.getInt(R.string.key_insight_disconnect_delay, 5); disconnectTimeout = Math.min(disconnectTimeout, 15); disconnectTimeout = Math.max(disconnectTimeout, 0); aapsLogger.info(LTag.PUMP, "Last connection lock released, will disconnect in " + disconnectTimeout + " seconds"); diff --git a/insight/src/main/res/values/strings.xml b/insight/src/main/res/values/strings.xml index 8b235730bc..dd12e644a3 100644 --- a/insight/src/main/res/values/strings.xml +++ b/insight/src/main/res/values/strings.xml @@ -31,10 +31,20 @@ Tube changed Sight Insight Pump Alerts - insight_disable_vibration Disable vibrations on manual bolus delivery For bolus and extended bolus (only available with Insight firmware 3.x) - insight_disable_vibration_auto + insight_disable_vibration + insight_disable_vibration_auto + insight_enable_tbr_emulation + insight_log_site_changes + insight_log_tube_changes + insight_log_reservoir_changes + insight_log_battery_changes + insight_log_operating_mode_changes + insight_log_alerts + insight_min_recovery_duration + insight_max_recovery_duration + insight_disconnect_delay Disable vibrations on automated bolus delivery For SMB and Temp Basal with TBR emulation (only available with Insight firmware 3.x) Timeout during handshake - reset bluetooth diff --git a/insight/src/main/res/xml/pref_insight_local_full.xml b/insight/src/main/res/xml/pref_insight_local_full.xml index 1329db7de3..69fbec43a0 100644 --- a/insight/src/main/res/xml/pref_insight_local_full.xml +++ b/insight/src/main/res/xml/pref_insight_local_full.xml @@ -15,68 +15,68 @@ diff --git a/insight/src/main/res/xml/pref_insight_local_pumpcontrol.xml b/insight/src/main/res/xml/pref_insight_local_pumpcontrol.xml index b73c01f1f7..ca7743ec3a 100644 --- a/insight/src/main/res/xml/pref_insight_local_pumpcontrol.xml +++ b/insight/src/main/res/xml/pref_insight_local_pumpcontrol.xml @@ -15,62 +15,62 @@