remove direct access to sResources 3
This commit is contained in:
parent
a8382daefd
commit
2af62d8e4e
9 changed files with 89 additions and 89 deletions
|
@ -32,12 +32,12 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
|
|||
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return MainApp.sResources.getString(R.string.rapid_acting_oref);
|
||||
return MainApp.gs(R.string.rapid_acting_oref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String commentStandardText() {
|
||||
return MainApp.sResources.getString(R.string.fastactinginsulincomment);
|
||||
return MainApp.gs(R.string.fastactinginsulincomment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -258,7 +258,7 @@ public class LoopPlugin extends PluginBase {
|
|||
Constraint<Boolean> loopEnabled = MainApp.getConstraintChecker().isLoopInvokationAllowed();
|
||||
|
||||
if (!loopEnabled.value()) {
|
||||
String message = MainApp.sResources.getString(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
|
||||
String message = MainApp.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
|
||||
log.debug(message);
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(message));
|
||||
return;
|
||||
|
@ -272,8 +272,8 @@ public class LoopPlugin extends PluginBase {
|
|||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
if (!MainApp.getConfigBuilder().isProfileValid("Loop")) {
|
||||
log.debug(MainApp.sResources.getString(R.string.noprofileselected));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected)));
|
||||
log.debug(MainApp.gs(R.string.noprofileselected));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ public class LoopPlugin extends PluginBase {
|
|||
|
||||
// Check if we have any result
|
||||
if (result == null) {
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noapsselected)));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noapsselected)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -317,14 +317,14 @@ public class LoopPlugin extends PluginBase {
|
|||
NSUpload.uploadDeviceStatus();
|
||||
|
||||
if (isSuspended()) {
|
||||
log.debug(MainApp.sResources.getString(R.string.loopsuspended));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopsuspended)));
|
||||
log.debug(MainApp.gs(R.string.loopsuspended));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (pump.isSuspended()) {
|
||||
log.debug(MainApp.sResources.getString(R.string.pumpsuspended));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.pumpsuspended)));
|
||||
log.debug(MainApp.gs(R.string.pumpsuspended));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ public class LoopPlugin extends PluginBase {
|
|||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(MainApp.instance().getApplicationContext(), CHANNEL_ID);
|
||||
builder.setSmallIcon(R.drawable.notif_icon)
|
||||
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
|
||||
.setContentTitle(MainApp.gs(R.string.openloop_newsuggestion))
|
||||
.setContentText(resultAfterConstraints.toString())
|
||||
.setAutoCancel(true)
|
||||
.setPriority(Notification.PRIORITY_HIGH)
|
||||
|
|
|
@ -60,7 +60,7 @@ public class NotificationStore {
|
|||
}
|
||||
store.add(n);
|
||||
|
||||
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_raise_notifications_as_android_notifications), false)) {
|
||||
if (SP.getBoolean(MainApp.gs(R.string.key_raise_notifications_as_android_notifications), false)) {
|
||||
raiseSystemNotification(n);
|
||||
} else {
|
||||
if (n.soundId != null) {
|
||||
|
@ -105,7 +105,7 @@ public class NotificationStore {
|
|||
|
||||
public void unSnooze() {
|
||||
if (Notification.isAlarmForStaleData()) {
|
||||
Notification notification = new Notification(Notification.NSALARM, MainApp.sResources.getString(R.string.nsalarm_staledata), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.NSALARM, MainApp.gs(R.string.nsalarm_staledata), Notification.URGENT);
|
||||
SP.putLong("snoozedTo", System.currentTimeMillis());
|
||||
add(notification);
|
||||
log.debug("Snoozed to current time and added back notification!");
|
||||
|
@ -126,11 +126,11 @@ public class NotificationStore {
|
|||
.setDeleteIntent(DismissNotificationService.deleteIntent(n.id));
|
||||
if (n.level == Notification.URGENT) {
|
||||
notificationBuilder.setVibrate(new long[]{1000, 1000, 1000, 1000})
|
||||
.setContentTitle(MainApp.sResources.getString(R.string.urgent_alarm))
|
||||
.setContentTitle(MainApp.gs(R.string.urgent_alarm))
|
||||
.setSound(sound, AudioAttributes.USAGE_ALARM);
|
||||
} else {
|
||||
notificationBuilder.setVibrate(new long[]{0, 100, 50, 100, 50})
|
||||
.setContentTitle(MainApp.sResources.getString(R.string.info))
|
||||
.setContentTitle(MainApp.gs(R.string.info))
|
||||
;
|
||||
}
|
||||
mgr.notify(n.id, notificationBuilder.build());
|
||||
|
|
|
@ -25,19 +25,19 @@ public class MsgError extends MessageBase {
|
|||
case 1:
|
||||
case 2:
|
||||
case 3: // Pump error
|
||||
errorString = MainApp.sResources.getString(R.string.pumperror) + " " + errorCode;
|
||||
errorString = MainApp.gs(R.string.pumperror) + " " + errorCode;
|
||||
break;
|
||||
case 4: // Shutdown
|
||||
errorString = MainApp.sResources.getString(R.string.pumpshutdown);
|
||||
errorString = MainApp.gs(R.string.pumpshutdown);
|
||||
break;
|
||||
case 5: // Occlusion
|
||||
errorString = MainApp.sResources.getString(R.string.occlusion);
|
||||
errorString = MainApp.gs(R.string.occlusion);
|
||||
break;
|
||||
case 7: // Low Battery
|
||||
errorString = MainApp.sResources.getString(R.string.lowbattery);
|
||||
errorString = MainApp.gs(R.string.lowbattery);
|
||||
break;
|
||||
case 8: // Battery 0%
|
||||
errorString = MainApp.sResources.getString(R.string.batterydischarged);
|
||||
errorString = MainApp.gs(R.string.batterydischarged);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public void connect() {
|
||||
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.wrongpumppassword), R.raw.error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public void getPumpStatus() {
|
||||
try {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||
//MsgStatus_k statusMsg = new MsgStatus_k();
|
||||
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k();
|
||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||
|
@ -162,15 +162,15 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
//mSerialIOThread.sendMessage(statusMsg);
|
||||
mSerialIOThread.sendMessage(statusBasicMsg);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
||||
mSerialIOThread.sendMessage(tempStatusMsg);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
||||
mSerialIOThread.sendMessage(exStatusMsg);
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isInitialized()) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpsettings)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||
mSerialIOThread.sendMessage(new MsgSettingBasal_k());
|
||||
|
@ -178,7 +178,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
||||
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumptime)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
|
@ -197,9 +197,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
NSUpload.uploadDeviceStatus();
|
||||
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.sResources.getString(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
@ -209,11 +209,11 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
public boolean tempBasal(int percent, int durationInHours) {
|
||||
if (!isConnected()) return false;
|
||||
if (mDanaRPump.isTempBasalInProgress) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||
SystemClock.sleep(500);
|
||||
}
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
|
@ -222,7 +222,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public boolean tempBasalStop() {
|
||||
if (!isConnected()) return false;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
|
@ -231,7 +231,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||
if (!isConnected()) return false;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
|
@ -240,7 +240,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public boolean extendedBolusStop() {
|
||||
if (!isConnected()) return false;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
|
@ -310,7 +310,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public boolean updateBasalsInPump(final Profile profile) {
|
||||
if (!isConnected()) return false;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||
double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
|
||||
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
||||
mSerialIOThread.sendMessage(msgSet);
|
||||
|
|
|
@ -56,9 +56,9 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
|
|||
|
||||
String age = SP.getString(R.string.key_age, "");
|
||||
int defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 4;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
|
||||
if (age.equals(MainApp.gs(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.gs(R.string.key_teenage))) defaultHours = 4;
|
||||
if (age.equals(MainApp.gs(R.string.key_child))) defaultHours = 4;
|
||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
|
|
@ -52,9 +52,9 @@ public class SensitivityWeightedAveragePlugin extends PluginBase implements Sens
|
|||
|
||||
String age = SP.getString(R.string.key_age, "");
|
||||
int defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 4;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
|
||||
if (age.equals(MainApp.gs(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.gs(R.string.key_teenage))) defaultHours = 4;
|
||||
if (age.equals(MainApp.gs(R.string.key_child))) defaultHours = 4;
|
||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||
|
||||
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
||||
|
|
|
@ -206,24 +206,24 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
|
||||
if (actualBG != null) {
|
||||
reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
||||
reply = MainApp.gs(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
||||
} else if (lastBG != null) {
|
||||
Long agoMsec = System.currentTimeMillis() - lastBG.date;
|
||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||
reply = MainApp.sResources.getString(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.sResources.getString(R.string.sms_minago), agoMin) + ", ";
|
||||
reply = MainApp.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.gs(R.string.sms_minago), agoMin) + ", ";
|
||||
}
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
if (glucoseStatus != null)
|
||||
reply += MainApp.sResources.getString(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
|
||||
reply += MainApp.gs(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
|
||||
|
||||
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round();
|
||||
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
||||
|
||||
reply += MainApp.sResources.getString(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||
+ MainApp.sResources.getString(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||
+ MainApp.sResources.getString(R.string.sms_basal) + " " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
|
||||
reply += MainApp.gs(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||
+ MainApp.gs(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||
+ MainApp.gs(R.string.sms_basal) + " " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
|
||||
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
receivedSms.processed = true;
|
||||
|
@ -241,8 +241,8 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
@Override
|
||||
public void run() {
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled) + " " +
|
||||
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
String reply = MainApp.gs(R.string.smscommunicator_loophasbeendisabled) + " " +
|
||||
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
});
|
||||
|
@ -255,7 +255,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled);
|
||||
reply = MainApp.gs(R.string.smscommunicator_loophasbeenenabled);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
|
||||
}
|
||||
|
@ -267,11 +267,11 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
if (loopPlugin != null) {
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
if (loopPlugin.isSuspended())
|
||||
reply = String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend());
|
||||
reply = String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend());
|
||||
else
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loopisenabled);
|
||||
reply = MainApp.gs(R.string.smscommunicator_loopisenabled);
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loopisdisabled);
|
||||
reply = MainApp.gs(R.string.smscommunicator_loopisdisabled);
|
||||
}
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
LoopPlugin.getPlugin().suspendTo(0);
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_RESUME"));
|
||||
NSUpload.uploadOpenAPSOffline(0);
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loopresumed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_loopresumed);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Resume"));
|
||||
break;
|
||||
|
@ -292,18 +292,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
duration = Math.max(0, duration);
|
||||
duration = Math.min(180, duration);
|
||||
if (duration == 0) {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_wrongduration);
|
||||
reply = MainApp.gs(R.string.smscommunicator_wrongduration);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else if (remoteCommandsAllowed) {
|
||||
passCode = generatePasscode();
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_suspendreplywithcode), duration, passCode);
|
||||
reply = String.format(MainApp.gs(R.string.smscommunicator_suspendreplywithcode), duration, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(suspendWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
suspendWaitingForConfirmation.duration = duration;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Suspend"));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotecommandnotallowed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotecommandnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
break;
|
||||
|
@ -350,7 +350,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.readstatusfailed);
|
||||
String reply = MainApp.gs(R.string.readstatusfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
|
@ -363,33 +363,33 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
if (splited[1].toUpperCase().equals("CANCEL") || splited[1].toUpperCase().equals("STOP")) {
|
||||
if (remoteCommandsAllowed) {
|
||||
passCode = generatePasscode();
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_basalstopreplywithcode), passCode);
|
||||
reply = String.format(MainApp.gs(R.string.smscommunicator_basalstopreplywithcode), passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(cancelTempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal"));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotebasalnotallowed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebasalnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
} else {
|
||||
tempBasal = SafeParse.stringToDouble(splited[1]);
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if (profile == null) {
|
||||
reply = MainApp.sResources.getString(R.string.noprofile);
|
||||
reply = MainApp.gs(R.string.noprofile);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
tempBasal = MainApp.getConstraintChecker().applyBasalConstraints(new Constraint<>(tempBasal), profile).value();
|
||||
if (remoteCommandsAllowed) {
|
||||
passCode = generatePasscode();
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_basalreplywithcode), tempBasal, passCode);
|
||||
reply = String.format(MainApp.gs(R.string.smscommunicator_basalreplywithcode), tempBasal, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(tempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
tempBasalWaitingForConfirmation.tempBasal = tempBasal;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal"));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotebasalnotallowed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebasalnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
|
@ -398,24 +398,24 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
break;
|
||||
case "BOLUS":
|
||||
if (System.currentTimeMillis() - lastRemoteBolusTime.getTime() < Constants.remoteBolusMinDistance) {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebolusnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else if (ConfigBuilderPlugin.getActivePump().isSuspended()) {
|
||||
reply = MainApp.sResources.getString(R.string.pumpsuspended);
|
||||
reply = MainApp.gs(R.string.pumpsuspended);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else if (splited.length > 1) {
|
||||
amount = SafeParse.stringToDouble(splited[1]);
|
||||
amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
|
||||
if (amount > 0d && remoteCommandsAllowed) {
|
||||
passCode = generatePasscode();
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusreplywithcode), amount, passCode);
|
||||
reply = String.format(MainApp.gs(R.string.smscommunicator_bolusreplywithcode), amount, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(bolusWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
bolusWaitingForConfirmation.bolusRequested = amount;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Bolus"));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotebolusnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
|
@ -425,14 +425,14 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
amount = SafeParse.stringToDouble(splited[1]);
|
||||
if (amount > 0d && remoteCommandsAllowed) {
|
||||
passCode = generatePasscode();
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
|
||||
reply = String.format(MainApp.gs(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(calibrationWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
calibrationWaitingForConfirmation.calibrationRequested = amount;
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Cal"));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotecalibrationnotallowed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_remotecalibrationnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
|
@ -449,13 +449,13 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
public void run() {
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (result.success) {
|
||||
String reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
|
||||
String reply = String.format(MainApp.gs(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
|
||||
if (pump != null)
|
||||
reply += "\n" + pump.shortStatus(true);
|
||||
lastRemoteBolusTime = new Date();
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_bolusfailed);
|
||||
String reply = MainApp.gs(R.string.smscommunicator_bolusfailed);
|
||||
if (pump != null)
|
||||
reply += "\n" + pump.shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
|
@ -471,11 +471,11 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
@Override
|
||||
public void run() {
|
||||
if (result.success) {
|
||||
String reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
|
||||
String reply = String.format(MainApp.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalfailed);
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
|
@ -488,11 +488,11 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
@Override
|
||||
public void run() {
|
||||
if (result.success) {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalcanceled);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
|
@ -503,10 +503,10 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
calibrationWaitingForConfirmation.processed = true;
|
||||
boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested);
|
||||
if (result) {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_calibrationsent);
|
||||
reply = MainApp.gs(R.string.smscommunicator_calibrationsent);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_calibrationfailed);
|
||||
reply = MainApp.gs(R.string.smscommunicator_calibrationfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
} else if (suspendWaitingForConfirmation != null && !suspendWaitingForConfirmation.processed &&
|
||||
|
@ -519,18 +519,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
|
||||
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
||||
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
String reply = MainApp.gs(R.string.smscommunicator_loopsuspended) + " " +
|
||||
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.gs(R.string.smscommunicator_unknowncommand), new Date()));
|
||||
}
|
||||
resetWaitingMessages();
|
||||
break;
|
||||
|
@ -563,10 +563,10 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
|
||||
messages.add(sms);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.sResources.getString(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
|
||||
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.gs(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
} catch (java.lang.SecurityException e) {
|
||||
Notification notification = new Notification(Notification.MISSING_SMS_PERMISSION, MainApp.sResources.getString(R.string.smscommunicator_missingsmspermission), Notification.NORMAL);
|
||||
Notification notification = new Notification(Notification.MISSING_SMS_PERMISSION, MainApp.gs(R.string.smscommunicator_missingsmspermission), Notification.NORMAL);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,21 +26,21 @@ public class LocalAlertUtils {
|
|||
private static Logger log = LoggerFactory.getLogger(LocalAlertUtils.class);
|
||||
|
||||
public static long missedReadingsThreshold() {
|
||||
return T.mins(SP.getInt(MainApp.sResources.getString(R.string.key_missed_bg_readings_threshold), 30)).msecs();
|
||||
return T.mins(SP.getInt(MainApp.gs(R.string.key_missed_bg_readings_threshold), 30)).msecs();
|
||||
}
|
||||
|
||||
private static long pumpUnreachableThreshold() {
|
||||
return T.mins(SP.getInt(MainApp.sResources.getString(R.string.key_pump_unreachable_threshold), 30)).msecs();
|
||||
return T.mins(SP.getInt(MainApp.gs(R.string.key_pump_unreachable_threshold), 30)).msecs();
|
||||
}
|
||||
|
||||
public static void checkPumpUnreachableAlarm(Date lastConnection, boolean isStatusOutdated) {
|
||||
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
||||
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis();
|
||||
|
||||
if (Config.APS && SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
|
||||
if (Config.APS && SP.getBoolean(MainApp.gs(R.string.key_enable_pump_unreachable_alert), true)
|
||||
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !LoopPlugin.getPlugin().isDisconnected()) {
|
||||
log.debug("Generating pump unreachable alarm. lastConnection: " + DateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated);
|
||||
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
||||
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.gs(R.string.pump_unreachable), Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
||||
MainApp.bus().post(new EventNewNotification(n));
|
||||
|
@ -91,10 +91,10 @@ public class LocalAlertUtils {
|
|||
|
||||
public static void checkStaleBGAlert() {
|
||||
BgReading bgReading = DatabaseHelper.lastBg();
|
||||
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_missed_bg_readings_alert), false)
|
||||
if (SP.getBoolean(MainApp.gs(R.string.key_enable_missed_bg_readings_alert), false)
|
||||
&& bgReading != null && bgReading.date + missedReadingsThreshold() < System.currentTimeMillis()
|
||||
&& SP.getLong("nextMissedReadingsAlarm", 0l) < System.currentTimeMillis()) {
|
||||
Notification n = new Notification(Notification.BG_READINGS_MISSED, MainApp.sResources.getString(R.string.missed_bg_readings), Notification.URGENT);
|
||||
Notification n = new Notification(Notification.BG_READINGS_MISSED, MainApp.gs(R.string.missed_bg_readings), Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
|
||||
MainApp.bus().post(new EventNewNotification(n));
|
||||
|
|
Loading…
Reference in a new issue