Replace Hardcoded key by string

This commit is contained in:
Philoul 2021-05-04 18:41:11 +02:00
parent 88f5eec306
commit 261fbbc759
5 changed files with 48 additions and 37 deletions

View file

@ -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;

View file

@ -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");

View file

@ -31,10 +31,20 @@
<string name="tube_changed">Tube changed</string>
<string name="insightpump_shortname">Sight</string>
<string name="insight_alert_notification_channel">Insight Pump Alerts</string>
<string name="key_disable_vibration" translatable="false">insight_disable_vibration</string>
<string name="disable_vibration">Disable vibrations on manual bolus delivery</string>
<string name="disable_vibration_summary">For bolus and extended bolus (only available with Insight firmware 3.x)</string>
<string name="key_disable_vibration_auto" translatable="false">insight_disable_vibration_auto</string>
<string name="key_insight_disable_vibration" translatable="false">insight_disable_vibration</string>
<string name="key_insight_disable_vibration_auto" translatable="false">insight_disable_vibration_auto</string>
<string name="key_insight_enable_tbr_emulation" translatable="false">insight_enable_tbr_emulation</string>
<string name="key_insight_log_site_changes" translatable="false">insight_log_site_changes</string>
<string name="key_insight_log_tube_changes" translatable="false">insight_log_tube_changes</string>
<string name="key_insight_log_reservoir_changes" translatable="false">insight_log_reservoir_changes</string>
<string name="key_insight_log_battery_changes" translatable="false">insight_log_battery_changes</string>
<string name="key_insight_log_operating_mode_changes" translatable="false">insight_log_operating_mode_changes</string>
<string name="key_insight_log_alerts" translatable="false">insight_log_alerts</string>
<string name="key_insight_min_recovery_duration" translatable="false">insight_min_recovery_duration</string>
<string name="key_insight_max_recovery_duration" translatable="false">insight_max_recovery_duration</string>
<string name="key_insight_disconnect_delay" translatable="false">insight_disconnect_delay</string>
<string name="disable_vibration_auto">Disable vibrations on automated bolus delivery</string>
<string name="disable_vibration_auto_summary">For SMB and Temp Basal with TBR emulation (only available with Insight firmware 3.x)</string>
<string name="timeout_during_handshake">Timeout during handshake - reset bluetooth</string>

View file

@ -15,68 +15,68 @@
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_reservoir_changes"
android:key="@string/key_insight_log_reservoir_changes"
android:title="@string/log_reservoir_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_tube_changes"
android:key="@string/key_insight_log_tube_changes"
android:title="@string/log_tube_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_site_changes"
android:key="@string/key_insight_log_site_changes"
android:title="@string/log_site_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_battery_changes"
android:key="@string/key_insight_log_battery_changes"
android:title="@string/log_battery_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_operating_mode_changes"
android:key="@string/key_insight_log_operating_mode_changes"
android:title="@string/log_operating_mode_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_alerts"
android:key="@string/key_insight_log_alerts"
android:title="@string/log_alerts" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_enable_tbr_emulation"
android:key="@string/key_insight_enable_tbr_emulation"
android:summary="@string/enable_tbr_emulation_summary"
android:title="@string/enable_tbr_emulation" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration"
android:key="@string/key_insight_disable_vibration"
android:summary="@string/disable_vibration_summary"
android:title="@string/disable_vibration" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration_auto"
android:key="@string/key_insight_disable_vibration_auto"
android:summary="@string/disable_vibration_auto_summary"
android:title="@string/disable_vibration_auto" />
<EditTextPreference
android:defaultValue="5"
android:inputType="number"
android:key="insight_min_recovery_duration"
android:key="@string/key_insight_min_recovery_duration"
android:title="@string/min_recovery_duration" />
<EditTextPreference
android:defaultValue="20"
android:inputType="number"
android:key="insight_max_recovery_duration"
android:key="@string/key_insight_max_recovery_duration"
android:title="@string/max_recovery_duration" />
<EditTextPreference
android:defaultValue="5"
android:inputType="number"
android:key="insight_disconnect_delay"
android:key="@string/key_insight_disconnect_delay"
android:title="@string/disconnect_delay" />
</PreferenceCategory>

View file

@ -15,62 +15,62 @@
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_reservoir_changes"
android:key="@string/key_insight_log_reservoir_changes"
android:title="@string/log_reservoir_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_tube_changes"
android:key="@string/key_insight_log_tube_changes"
android:title="@string/log_tube_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_site_changes"
android:key="@string/key_insight_log_site_changes"
android:title="@string/log_site_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_battery_changes"
android:key="@string/key_insight_log_battery_changes"
android:title="@string/log_battery_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_operating_mode_changes"
android:key="@string/key_insight_log_operating_mode_changes"
android:title="@string/log_operating_mode_changes" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_log_alerts"
android:key="@string/key_insight_log_alerts"
android:title="@string/log_alerts" />
<SwitchPreference
android:defaultValue="false"
android:key="insight_enable_tbr_emulation"
android:key="@string/key_insight_enable_tbr_emulation"
android:summary="@string/enable_tbr_emulation_summary"
android:title="@string/enable_tbr_emulation" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration"
android:key="@string/key_insight_disable_vibration"
android:summary="@string/disable_vibration_summary"
android:title="@string/disable_vibration" />
<EditTextPreference
android:defaultValue="5"
android:inputType="number"
android:key="insight_min_recovery_duration"
android:key="@string/key_insight_min_recovery_duration"
android:title="@string/min_recovery_duration" />
<EditTextPreference
android:defaultValue="20"
android:inputType="number"
android:key="insight_max_recovery_duration"
android:key="@string/key_insight_max_recovery_duration"
android:title="@string/max_recovery_duration" />
<EditTextPreference
android:defaultValue="5"
android:inputType="number"
android:key="insight_disconnect_delay"
android:key="@string/key_insight_disconnect_delay"
android:title="@string/disconnect_delay" />
</PreferenceCategory>