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)
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();
if (!isInitialized()) {
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));
result.comment = MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet);
result.comment = MainApp.gs(R.string.pumpNotInitializedProfileNotSet);
return result;
}
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);
if (ms.success()) {
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));
result.success = true;
result.enacted = true;
result.comment = "OK";
this.profileBlocks = profileBlocks;
} 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));
result.comment = MainApp.sResources.getString(R.string.failedupdatebasalprofile);
result.comment = MainApp.gs(R.string.failedupdatebasalprofile);
}
return result;
}
@ -425,7 +425,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
t.isSMB = detailedBolusInfo.isSMB;
final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
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.percent = 0;
MainApp.bus().post(bolusingEvent);
@ -464,7 +464,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
if (activeBolus == null) break;
else {
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);
}
} 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();
PumpEnactResult result = new PumpEnactResult();
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));
return result;
}
@ -209,14 +209,14 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
while (delivering < detailedBolusInfo.insulin) {
SystemClock.sleep(200);
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);
MainApp.bus().post(bolusingEvent);
delivering += 0.1d;
}
SystemClock.sleep(200);
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;
MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000);

View file

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

View file

@ -81,7 +81,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia());
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " 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.ns.setVisibility(NSUpload.isIdValid(t._id) ? View.VISIBLE : View.GONE);
holder.invalid.setVisibility(t.isValid ? View.GONE : View.VISIBLE);
@ -142,9 +142,9 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
switch (v.getId()) {
case R.id.treatments_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date));
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = treatment._id;
if (treatment.source == Source.PUMP) {
@ -162,7 +162,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
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();
break;
}

View file

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

View file

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

View file

@ -513,15 +513,15 @@ public class ActionStringHandler {
}
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) {
ret += MainApp.sResources.getString(R.string.canceltemp) + "\n";
ret += MainApp.gs(R.string.canceltemp) + "\n";
} 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" +
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;
}
@ -586,18 +586,18 @@ public class ActionStringHandler {
//check for validity
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) {
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();
if (profile == null) {
msg += MainApp.sResources.getString(R.string.notloadedplugins) + "\n";
msg += MainApp.gs(R.string.notloadedplugins) + "\n";
}
if (!"".equals(msg)) {
msg += MainApp.sResources.getString(R.string.valuesnotstored);
msg += MainApp.gs(R.string.valuesnotstored);
String rTitle = "STATUS";
String rAction = "statusmessage";
WearPlugin.getPlugin().requestActionConfirmation(rTitle, msg, rAction);
@ -634,7 +634,7 @@ public class ActionStringHandler {
@Override
public void run() {
if (!result.success) {
sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) +
sendError(MainApp.gs(R.string.treatmentdeliveryerror) +
"\n" +
result.comment);
}
@ -652,7 +652,7 @@ public class ActionStringHandler {
@Override
public void run() {
if (!result.success) {
sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) +
sendError(MainApp.gs(R.string.treatmentdeliveryerror) +
"\n" +
result.comment);
}

View file

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