remove direct access to sResources 8

This commit is contained in:
AdrianLxM 2018-05-02 13:58:52 +02:00
parent de4643d16f
commit 166f2843df
9 changed files with 41 additions and 41 deletions

View file

@ -170,6 +170,6 @@ public class MsgHistoryEvents_v2 extends MessageBase {
if (datetime.getTime() > lastEventTimeLoaded) if (datetime.getTime() > lastEventTimeLoaded)
lastEventTimeLoaded = datetime.getTime(); lastEventTimeLoaded = datetime.getTime();
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status)); MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.processinghistory) + ": " + status));
} }
} }

View file

@ -320,9 +320,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
if (!isInitialized()) { if (!isInitialized()) {
log.error("setNewBasalProfile not initialized"); log.error("setNewBasalProfile not initialized");
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT); Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
result.comment = MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet); result.comment = MainApp.gs(R.string.pumpNotInitializedProfileNotSet);
return result; return result;
} }
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
@ -339,16 +339,16 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
final Mstatus ms = async.busyWaitForCommandResult(uuid, BUSY_WAIT_TIME); final Mstatus ms = async.busyWaitForCommandResult(uuid, BUSY_WAIT_TIME);
if (ms.success()) { if (ms.success()) {
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
result.success = true; result.success = true;
result.enacted = true; result.enacted = true;
result.comment = "OK"; result.comment = "OK";
this.profileBlocks = profileBlocks; this.profileBlocks = profileBlocks;
} else { } else {
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT); Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
result.comment = MainApp.sResources.getString(R.string.failedupdatebasalprofile); result.comment = MainApp.gs(R.string.failedupdatebasalprofile);
} }
return result; return result;
} }
@ -425,7 +425,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
t.isSMB = detailedBolusInfo.isSMB; t.isSMB = detailedBolusInfo.isSMB;
final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = t; bolusingEvent.t = t;
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), 0F); bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), 0F);
bolusingEvent.bolusId = bolusId; bolusingEvent.bolusId = bolusId;
bolusingEvent.percent = 0; bolusingEvent.percent = 0;
MainApp.bus().post(bolusingEvent); MainApp.bus().post(bolusingEvent);
@ -464,7 +464,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
if (activeBolus == null) break; if (activeBolus == null) break;
else { else {
bolusingEvent.percent = (int) (100D / activeBolus.getInitialAmount() * (activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount())); bolusingEvent.percent = (int) (100D / activeBolus.getInitialAmount() * (activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount()));
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount()); bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount());
MainApp.bus().post(bolusingEvent); MainApp.bus().post(bolusingEvent);
} }
} else break; } else break;

View file

@ -171,7 +171,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile(); // Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = true; result.success = true;
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
return result; return result;
} }
@ -209,14 +209,14 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
while (delivering < detailedBolusInfo.insulin) { while (delivering < detailedBolusInfo.insulin) {
SystemClock.sleep(200); SystemClock.sleep(200);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), delivering); bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), delivering);
bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100); bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100);
MainApp.bus().post(bolusingEvent); MainApp.bus().post(bolusingEvent);
delivering += 0.1d; delivering += 0.1d;
} }
SystemClock.sleep(200); SystemClock.sleep(200);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivered), detailedBolusInfo.insulin); bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivered), detailedBolusInfo.insulin);
bolusingEvent.percent = 100; bolusingEvent.percent = 100;
MainApp.bus().post(bolusingEvent); MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000); SystemClock.sleep(1000);

View file

@ -143,9 +143,9 @@ public class BGSourceFragment extends SubscriberFragment {
case R.id.bgsource_remove: case R.id.bgsource_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profile.getUnits())); builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profile.getUnits()));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
/* final String _id = bgReading._id; /* final String _id = bgReading._id;
if (NSUpload.isIdValid(_id)) { if (NSUpload.isIdValid(_id)) {
@ -159,7 +159,7 @@ public class BGSourceFragment extends SubscriberFragment {
updateGUI(); updateGUI();
} }
}); });
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
break; break;

View file

@ -81,7 +81,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia()); Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia());
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U"); holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U");
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U"); holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
holder.mealOrCorrection.setText(t.isSMB ? "SMB" : t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous)); holder.mealOrCorrection.setText(t.isSMB ? "SMB" : t.mealBolus ? MainApp.gs(R.string.mealbolus) : MainApp.gs(R.string.correctionbous));
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE); holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
holder.ns.setVisibility(NSUpload.isIdValid(t._id) ? View.VISIBLE : View.GONE); holder.ns.setVisibility(NSUpload.isIdValid(t._id) ? View.VISIBLE : View.GONE);
holder.invalid.setVisibility(t.isValid ? View.GONE : View.VISIBLE); holder.invalid.setVisibility(t.isValid ? View.GONE : View.VISIBLE);
@ -142,9 +142,9 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
switch (v.getId()) { switch (v.getId()) {
case R.id.treatments_remove: case R.id.treatments_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date)); builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
final String _id = treatment._id; final String _id = treatment._id;
if (treatment.source == Source.PUMP) { if (treatment.source == Source.PUMP) {
@ -162,7 +162,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveTreatment")); FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
} }
}); });
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
break; break;
} }

View file

@ -105,9 +105,9 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
switch (v.getId()) { switch (v.getId()) {
case R.id.careportal_remove: case R.id.careportal_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(careportalEvent.date)); builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(careportalEvent.date));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
final String _id = careportalEvent._id; final String _id = careportalEvent._id;
if (NSUpload.isIdValid(_id)) { if (NSUpload.isIdValid(_id)) {
@ -118,7 +118,7 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
MainApp.getDbHelper().delete(careportalEvent); MainApp.getDbHelper().delete(careportalEvent);
} }
}); });
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
break; break;
} }

View file

@ -67,7 +67,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
holder.ns.setVisibility(NSUpload.isIdValid(extendedBolus._id) ? View.VISIBLE : View.GONE); holder.ns.setVisibility(NSUpload.isIdValid(extendedBolus._id) ? View.VISIBLE : View.GONE);
if (extendedBolus.isEndingEvent()) { if (extendedBolus.isEndingEvent()) {
holder.date.setText(DateUtil.dateAndTimeString(extendedBolus.date)); holder.date.setText(DateUtil.dateAndTimeString(extendedBolus.date));
holder.duration.setText(MainApp.sResources.getString(R.string.cancel)); holder.duration.setText(MainApp.gs(R.string.cancel));
holder.insulin.setText(""); holder.insulin.setText("");
holder.realDuration.setText(""); holder.realDuration.setText("");
holder.iob.setText(""); holder.iob.setText("");
@ -144,9 +144,9 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
switch (v.getId()) { switch (v.getId()) {
case R.id.extendedboluses_remove: case R.id.extendedboluses_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(extendedBolus.date)); builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(extendedBolus.date));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
final String _id = extendedBolus._id; final String _id = extendedBolus._id;
if (NSUpload.isIdValid(_id)) { if (NSUpload.isIdValid(_id)) {
@ -158,7 +158,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveExtendedBolus")); FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveExtendedBolus"));
} }
}); });
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
break; break;
} }

View file

@ -513,15 +513,15 @@ public class ActionStringHandler {
} }
if (!result.isChangeRequested()) { if (!result.isChangeRequested()) {
ret += MainApp.sResources.getString(R.string.nochangerequested) + "\n"; ret += MainApp.gs(R.string.nochangerequested) + "\n";
} else if (result.rate == 0 && result.duration == 0) { } else if (result.rate == 0 && result.duration == 0) {
ret += MainApp.sResources.getString(R.string.canceltemp) + "\n"; ret += MainApp.gs(R.string.canceltemp) + "\n";
} else { } else {
ret += MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " + ret += MainApp.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " +
"(" + DecimalFormatter.to2Decimal(result.rate / ConfigBuilderPlugin.getActivePump().getBaseBasalRate() * 100) + "%)\n" + "(" + DecimalFormatter.to2Decimal(result.rate / ConfigBuilderPlugin.getActivePump().getBaseBasalRate() * 100) + "%)\n" +
MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration) + " min\n"; MainApp.gs(R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration) + " min\n";
} }
ret += "\n" + MainApp.sResources.getString(R.string.reason) + ": " + result.reason; ret += "\n" + MainApp.gs(R.string.reason) + ": " + result.reason;
return ret; return ret;
} }
@ -586,18 +586,18 @@ public class ActionStringHandler {
//check for validity //check for validity
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) { if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
msg += String.format(MainApp.sResources.getString(R.string.valueoutofrange), "Profile-Percentage") + "\n"; msg += String.format(MainApp.gs(R.string.valueoutofrange), "Profile-Percentage") + "\n";
} }
if (timeshift < 0 || timeshift > 23) { if (timeshift < 0 || timeshift > 23) {
msg += String.format(MainApp.sResources.getString(R.string.valueoutofrange), "Profile-Timeshift") + "\n"; msg += String.format(MainApp.gs(R.string.valueoutofrange), "Profile-Timeshift") + "\n";
} }
final Profile profile = MainApp.getConfigBuilder().getProfile(); final Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) { if (profile == null) {
msg += MainApp.sResources.getString(R.string.notloadedplugins) + "\n"; msg += MainApp.gs(R.string.notloadedplugins) + "\n";
} }
if (!"".equals(msg)) { if (!"".equals(msg)) {
msg += MainApp.sResources.getString(R.string.valuesnotstored); msg += MainApp.gs(R.string.valuesnotstored);
String rTitle = "STATUS"; String rTitle = "STATUS";
String rAction = "statusmessage"; String rAction = "statusmessage";
WearPlugin.getPlugin().requestActionConfirmation(rTitle, msg, rAction); WearPlugin.getPlugin().requestActionConfirmation(rTitle, msg, rAction);
@ -634,7 +634,7 @@ public class ActionStringHandler {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) + sendError(MainApp.gs(R.string.treatmentdeliveryerror) +
"\n" + "\n" +
result.comment); result.comment);
} }
@ -652,7 +652,7 @@ public class ActionStringHandler {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) + sendError(MainApp.gs(R.string.treatmentdeliveryerror) +
"\n" + "\n" +
result.comment); result.comment);
} }

View file

@ -661,7 +661,7 @@ public class WatchUpdaterService extends WearableListenerService implements
String status = ""; String status = "";
if (profile == null) { if (profile == null) {
status = MainApp.sResources.getString(R.string.noprofile); status = MainApp.gs(R.string.noprofile);
return status; return status;
} }