diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 440024f853..9a80c61904 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -247,7 +247,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe if (!pm.isIgnoringBatteryOptimizations(packageName)) { log.debug("Requesting ignore battery optimization"); - OKDialog.show(this, getString(R.string.pleaseallowpermission), String.format(getString(R.string.needwhitelisting), getString(R.string.app_name)), new Runnable() { + OKDialog.show(this, MainApp.gs(R.string.pleaseallowpermission), String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name)), new Runnable() { @Override public void run() { @@ -260,7 +260,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe startActivity(intent); } catch (ActivityNotFoundException e) { - final String msg = getString(R.string.batteryoptimalizationerror); + final String msg = MainApp.gs(R.string.batteryoptimalizationerror); ToastUtils.showToastInUiThread(getApplicationContext(), msg); log.error(msg); } @@ -399,21 +399,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe break; case R.id.nav_about: AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); - builder.setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION); + builder.setTitle(MainApp.gs(R.string.app_name) + " " + BuildConfig.VERSION); if (Config.NSCLIENT || Config.G5UPLOADER) builder.setIcon(R.mipmap.yellowowl); else builder.setIcon(R.mipmap.blueowl); String message = "Build: " + BuildConfig.BUILDVERSION + "\n"; message += "Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + "\n"; - message += getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName; + message += MainApp.gs(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName; if (MainApp.engineeringMode) message += "\n" + MainApp.gs(R.string.engineering_mode_enabled); - message += getString(R.string.about_link_urls); + message += MainApp.gs(R.string.about_link_urls); final SpannableString messageSpanned = new SpannableString(message); Linkify.addLinks(messageSpanned, Linkify.WEB_URLS); builder.setMessage(messageSpanned); - builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null); + builder.setPositiveButton(MainApp.gs(R.string.ok), null); AlertDialog alertDialog = builder.create(); alertDialog.show(); ((TextView)alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index 17dea50108..881f2e3bac 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -304,7 +304,7 @@ public class DataService extends IntentService { log.debug("Got versions: NSClient: " + ConfigBuilderPlugin.nsClientVersionName + " Nightscout: " + ConfigBuilderPlugin.nightscoutVersionName); try { if (ConfigBuilderPlugin.nsClientVersionCode < MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode) { - Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.sResources.getString(R.string.unsupportedclientver), Notification.URGENT); + Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.OLD_NSCLIENT)); @@ -313,13 +313,13 @@ public class DataService extends IntentService { log.error("Unhandled exception", e); } if (ConfigBuilderPlugin.nightscoutVersionCode < Config.SUPPORTEDNSVERSION) { - Notification notification = new Notification(Notification.OLD_NS, MainApp.sResources.getString(R.string.unsupportednsversion), Notification.NORMAL); + Notification notification = new Notification(Notification.OLD_NS, MainApp.gs(R.string.unsupportednsversion), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.OLD_NS)); } } else { - Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.sResources.getString(R.string.unsupportedclientver), Notification.URGENT); + Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } if (bundles.containsKey("status")) { diff --git a/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java b/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java index 369b2f42b5..7bc3ee31c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java @@ -141,27 +141,27 @@ public class TDDStatsActivity extends Activity { TableLayout.LayoutParams.WRAP_CONTENT)); TextView label_date = new TextView(this); - label_date.setText(getString(R.string.danar_stats_date)); + label_date.setText(MainApp.gs(R.string.danar_stats_date)); label_date.setTextColor(Color.WHITE); tr_head.addView(label_date); TextView label_basalrate = new TextView(this); - label_basalrate.setText(getString(R.string.danar_stats_basalrate)); + label_basalrate.setText(MainApp.gs(R.string.danar_stats_basalrate)); label_basalrate.setTextColor(Color.WHITE); tr_head.addView(label_basalrate); TextView label_bolus = new TextView(this); - label_bolus.setText(getString(R.string.danar_stats_bolus)); + label_bolus.setText(MainApp.gs(R.string.danar_stats_bolus)); label_bolus.setTextColor(Color.WHITE); tr_head.addView(label_bolus); TextView label_tdd = new TextView(this); - label_tdd.setText(getString(R.string.danar_stats_tdd)); + label_tdd.setText(MainApp.gs(R.string.danar_stats_tdd)); label_tdd.setTextColor(Color.WHITE); tr_head.addView(label_tdd); TextView label_ratio = new TextView(this); - label_ratio.setText(getString(R.string.danar_stats_ratio)); + label_ratio.setText(MainApp.gs(R.string.danar_stats_ratio)); label_ratio.setTextColor(Color.WHITE); tr_head.addView(label_ratio); @@ -179,17 +179,17 @@ public class TDDStatsActivity extends Activity { TableLayout.LayoutParams.WRAP_CONTENT)); TextView label_cum_amount_days = new TextView(this); - label_cum_amount_days.setText(getString(R.string.danar_stats_amount_days)); + label_cum_amount_days.setText(MainApp.gs(R.string.danar_stats_amount_days)); label_cum_amount_days.setTextColor(Color.WHITE); ctr_head.addView(label_cum_amount_days); TextView label_cum_tdd = new TextView(this); - label_cum_tdd.setText(getString(R.string.danar_stats_tdd)); + label_cum_tdd.setText(MainApp.gs(R.string.danar_stats_tdd)); label_cum_tdd.setTextColor(Color.WHITE); ctr_head.addView(label_cum_tdd); TextView label_cum_ratio = new TextView(this); - label_cum_ratio.setText(getString(R.string.danar_stats_ratio)); + label_cum_ratio.setText(MainApp.gs(R.string.danar_stats_ratio)); label_cum_ratio.setTextColor(Color.WHITE); ctr_head.addView(label_cum_ratio); @@ -207,17 +207,17 @@ public class TDDStatsActivity extends Activity { TableLayout.LayoutParams.WRAP_CONTENT)); TextView label_exp_weight = new TextView(this); - label_exp_weight.setText(getString(R.string.danar_stats_weight)); + label_exp_weight.setText(MainApp.gs(R.string.danar_stats_weight)); label_exp_weight.setTextColor(Color.WHITE); etr_head.addView(label_exp_weight); TextView label_exp_tdd = new TextView(this); - label_exp_tdd.setText(getString(R.string.danar_stats_tdd)); + label_exp_tdd.setText(MainApp.gs(R.string.danar_stats_tdd)); label_exp_tdd.setTextColor(Color.WHITE); etr_head.addView(label_exp_tdd); TextView label_exp_ratio = new TextView(this); - label_exp_ratio.setText(getString(R.string.danar_stats_ratio)); + label_exp_ratio.setText(MainApp.gs(R.string.danar_stats_ratio)); label_exp_ratio.setTextColor(Color.WHITE); etr_head.addView(label_exp_ratio); @@ -235,7 +235,7 @@ public class TDDStatsActivity extends Activity { reloadButton.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); statsMessage.setVisibility(View.VISIBLE); - statsMessage.setText(getString(R.string.danar_stats_warning_Message)); + statsMessage.setText(MainApp.gs(R.string.danar_stats_warning_Message)); } }); ConfigBuilderPlugin.getCommandQueue().loadTDDs( new Callback() { @@ -441,7 +441,7 @@ public class TDDStatsActivity extends Activity { if (isOldData(historyList) && ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad) { statsMessage.setVisibility(View.VISIBLE); - statsMessage.setText(getString(R.string.danar_stats_olddata_Message)); + statsMessage.setText(MainApp.gs(R.string.danar_stats_olddata_Message)); } else { tl.setBackgroundColor(Color.TRANSPARENT); diff --git a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java index 33fee529bc..755005cdae 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java +++ b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java @@ -95,7 +95,7 @@ public class CareportalEvent implements DataPointWithLabelInterface { if (OverviewFragment.shorttextmode) return diff.get(TimeUnit.DAYS) +"d" + diff.get(TimeUnit.HOURS) + "h"; else - return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours); + return diff.get(TimeUnit.DAYS) + " " + MainApp.gs(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.gs(R.string.hours); } public boolean isOlderThan(double hours) { diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java index f99cb54568..f23d4e802a 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java @@ -12,11 +12,11 @@ public class EventPreferenceChange extends Event { } public EventPreferenceChange(int resourceID) { - changedKey = MainApp.sResources.getString(resourceID); + changedKey = MainApp.gs(resourceID); } public boolean isChanged(int id) { - return changedKey.equals(MainApp.sResources.getString(id)); + return changedKey.equals(MainApp.gs(id)); } public boolean isChanged(String id) { diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java index 52c3183821..7d810702b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java @@ -46,13 +46,13 @@ public class EventPumpStatusChanged extends Event { public String textStatus() { if (sStatus == CONNECTING) - return String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), sSecondsElapsed); + return String.format(MainApp.gs(R.string.danar_history_connectingfor), sSecondsElapsed); else if (sStatus == CONNECTED) - return MainApp.sResources.getString(R.string.connected); + return MainApp.gs(R.string.connected); else if (sStatus == PERFORMING) return sPerfomingAction; else if (sStatus == DISCONNECTING) - return MainApp.sResources.getString(R.string.disconnecting); + return MainApp.gs(R.string.disconnecting); else if (sStatus == DISCONNECTED) return ""; return ""; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index cc73571b9d..84086d6117 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -158,7 +158,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL if (activeExtendedBolus != null) { extendedBolus.setVisibility(View.GONE); extendedBolusCancel.setVisibility(View.VISIBLE); - extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeExtendedBolus.toString()); + extendedBolusCancel.setText(MainApp.gs(R.string.cancel) + " " + activeExtendedBolus.toString()); } else { extendedBolus.setVisibility(View.VISIBLE); extendedBolusCancel.setVisibility(View.GONE); @@ -174,7 +174,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL if (activeTemp != null) { tempBasal.setVisibility(View.GONE); tempBasalCancel.setVisibility(View.VISIBLE); - tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeTemp.toStringShort()); + tempBasalCancel.setText(MainApp.gs(R.string.cancel) + " " + activeTemp.toStringShort()); } else { tempBasal.setVisibility(View.VISIBLE); tempBasalCancel.setVisibility(View.GONE); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java index 5e99a6ca17..828c7dbcc9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java @@ -179,10 +179,10 @@ public class FillDialog extends DialogFragment implements OnClickListener { } if (pumpSiteChangeCheckbox.isChecked()) - confirmMessage.add("" + "" + getString(R.string.record_pump_site_change) + ""); + confirmMessage.add("" + "" + MainApp.gs(R.string.record_pump_site_change) + ""); if (insulinCartridgeChangeCheckbox.isChecked()) - confirmMessage.add("" + "" + getString(R.string.record_insulin_cartridge_change) + ""); + confirmMessage.add("" + "" + MainApp.gs(R.string.record_insulin_cartridge_change) + ""); final String notes = notesEdit.getText().toString(); if (!notes.isEmpty()) { @@ -197,7 +197,7 @@ public class FillDialog extends DialogFragment implements OnClickListener { builder.setTitle(MainApp.gs(R.string.confirmation)); if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) { builder.setMessage(Html.fromHtml(Joiner.on("
").join(confirmMessage))); - builder.setPositiveButton(getString(R.string.primefill), (dialog, id) -> { + builder.setPositiveButton(MainApp.gs(R.string.primefill), (dialog, id) -> { if (finalInsulinAfterConstraints > 0) { DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); detailedBolusInfo.insulin = finalInsulinAfterConstraints; @@ -212,7 +212,7 @@ public class FillDialog extends DialogFragment implements OnClickListener { Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.boluserror); i.putExtra("status", result.comment); - i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror)); + i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); } @@ -228,7 +228,7 @@ public class FillDialog extends DialogFragment implements OnClickListener { } else { builder.setMessage(MainApp.gs(R.string.no_action_selected)); } - builder.setNegativeButton(getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); dismiss(); } catch (RuntimeException e) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java index 04dd783b04..45b6460392 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java @@ -12,6 +12,7 @@ import android.view.ViewGroup; import com.crashlytics.android.answers.CustomEvent; +import org.mozilla.javascript.tools.jsc.Main; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +40,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - getDialog().setTitle(getString(R.string.overview_extendedbolus_button)); + getDialog().setTitle(MainApp.gs(R.string.overview_extendedbolus_button)); View view = inflater.inflate(R.layout.overview_newextendedbolus_dialog, container, false); @@ -68,13 +69,13 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli Double insulin = SafeParse.stringToDouble(editInsulin.getText()); int durationInMinutes = SafeParse.stringToInt(editDuration.getText()); - String confirmMessage = getString(R.string.setextendedbolusquestion); + String confirmMessage = MainApp.gs(R.string.setextendedbolusquestion); Double insulinAfterConstraint = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value(); confirmMessage += " " + insulinAfterConstraint + " U "; - confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?"; + confirmMessage += MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?"; if (insulinAfterConstraint - insulin != 0d) - confirmMessage += "\n" + getString(R.string.constraintapllied); + confirmMessage += "\n" + MainApp.gs(R.string.constraintapllied); insulin = insulinAfterConstraint; final Double finalInsulin = insulin; @@ -82,9 +83,9 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli final Context context = getContext(); AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(context.getString(R.string.confirmation)); + builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setMessage(confirmMessage); - builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ConfigBuilderPlugin.getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() { @Override @@ -93,7 +94,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.boluserror); i.putExtra("status", result.comment); - i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror)); + i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); } @@ -102,7 +103,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli FabricPrivacy.getInstance().logCustom(new CustomEvent("ExtendedBolus")); } }); - builder.setNegativeButton(getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); dismiss(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java index fb00879ae4..7a03887cf6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java @@ -52,7 +52,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - getDialog().setTitle(getString(R.string.overview_tempbasal_button)); + getDialog().setTitle(MainApp.gs(R.string.overview_tempbasal_button)); View view = inflater.inflate(R.layout.overview_newtempbasal_dialog, container, false); @@ -122,21 +122,21 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi if (profile == null) return; - String confirmMessage = getString(R.string.setbasalquestion); + String confirmMessage = MainApp.gs(R.string.setbasalquestion); if (setAsPercent) { int basalPercentInput = SafeParse.stringToInt(basalPercent.getText()); percent = MainApp.getConstraintChecker().applyBasalPercentConstraints(new Constraint<>(basalPercentInput), profile).value(); confirmMessage += "\n" + percent + "% "; - confirmMessage += "\n" + getString(R.string.duration) + " " + durationInMinutes + "min ?"; + confirmMessage += "\n" + MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?"; if (percent != basalPercentInput) - confirmMessage += "\n" + getString(R.string.constraintapllied); + confirmMessage += "\n" + MainApp.gs(R.string.constraintapllied); } else { Double basalAbsoluteInput = SafeParse.stringToDouble(basalAbsolute.getText()); absolute = MainApp.getConstraintChecker().applyBasalConstraints(new Constraint<>(basalAbsoluteInput), profile).value(); confirmMessage += "\n" + absolute + " U/h "; - confirmMessage += "\n" + getString(R.string.duration) + " " + durationInMinutes + "min ?"; + confirmMessage += "\n" + MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?"; if (absolute - basalAbsoluteInput != 0d) - confirmMessage += "\n" + getString(R.string.constraintapllied); + confirmMessage += "\n" + MainApp.gs(R.string.constraintapllied); } final int finalBasalPercent = percent; @@ -144,9 +144,9 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi final int finalDurationInMinutes = durationInMinutes; AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setTitle(this.getContext().getString(R.string.confirmation)); + builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setMessage(confirmMessage); - builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Callback callback = new Callback() { @Override @@ -155,7 +155,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.boluserror); i.putExtra("status", result.comment); - i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror)); + i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); } @@ -169,7 +169,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi FabricPrivacy.getInstance().logCustom(new CustomEvent("TempBasal")); } }); - builder.setNegativeButton(getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); dismiss(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java index 4719ed525c..ac018e3101 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java @@ -225,7 +225,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 360); double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 240); - String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable); + String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.gs(R.string.notavailable); if (sage != null) { careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); if (careportalEvent != null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index df5b727749..35130c5209 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -429,17 +429,17 @@ public class ConfigBuilderPlugin extends PluginBase { request.rate = MainApp.getConstraintChecker().applyBasalConstraints(request.rateConstraint, profile).value(); if (!pump.isInitialized()) { - log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized)); + log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpNotInitialized)); if (callback != null) { - callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); + callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); } return; } if (pump.isSuspended()) { - log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpsuspended)); + log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpsuspended)); if (callback != null) { - callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpsuspended)).enacted(false).success(false)).run(); + callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run(); } return; } @@ -499,17 +499,17 @@ public class ConfigBuilderPlugin extends PluginBase { PumpInterface pump = getActivePump(); if (!pump.isInitialized()) { - log.debug("applySMBRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized)); + log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpNotInitialized)); if (callback != null) { - callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); + callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); } return; } if (pump.isSuspended()) { - log.debug("applySMBRequest: " + MainApp.sResources.getString(R.string.pumpsuspended)); + log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpsuspended)); if (callback != null) { - callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpsuspended)).enacted(false).success(false)).run(); + callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run(); } return; } @@ -538,7 +538,7 @@ public class ConfigBuilderPlugin extends PluginBase { Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.boluserror); i.putExtra("status", result.comment); - i.putExtra("title", MainApp.sResources.getString(R.string.failedupdatebasalprofile)); + i.putExtra("title", MainApp.gs(R.string.failedupdatebasalprofile)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java index e4cdab4c80..1424013440 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java @@ -59,7 +59,7 @@ public class ObjectivesFragment extends SubscriberFragment { holder.position.setText(String.valueOf(position + 1)); holder.objective.setText(o.objective); holder.gate.setText(o.gate); - holder.duration.setText(context.getString(R.string.objectives_minimalduration) + " " + o.durationInDays + " " + context.getString(R.string.days)); + holder.duration.setText(MainApp.gs(R.string.objectives_minimalduration) + " " + o.durationInDays + " " + MainApp.gs(R.string.days)); holder.progress.setText(requirementsMet.comment); holder.started.setText(o.started.toLocaleString()); holder.accomplished.setText(o.accomplished.toLocaleString()); @@ -241,20 +241,20 @@ public class ObjectivesFragment extends SubscriberFragment { }); // Add correct translations to array after app is initialized - ObjectivesPlugin.objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective); - ObjectivesPlugin.objectives.get(1).objective = MainApp.sResources.getString(R.string.objectives_1_objective); - ObjectivesPlugin.objectives.get(2).objective = MainApp.sResources.getString(R.string.objectives_2_objective); - ObjectivesPlugin.objectives.get(3).objective = MainApp.sResources.getString(R.string.objectives_3_objective); - ObjectivesPlugin.objectives.get(4).objective = MainApp.sResources.getString(R.string.objectives_4_objective); - ObjectivesPlugin.objectives.get(5).objective = MainApp.sResources.getString(R.string.objectives_5_objective); - ObjectivesPlugin.objectives.get(6).objective = MainApp.sResources.getString(R.string.objectives_6_objective); - ObjectivesPlugin.objectives.get(7).objective = MainApp.sResources.getString(R.string.objectives_7_objective); - ObjectivesPlugin.objectives.get(0).gate = MainApp.sResources.getString(R.string.objectives_0_gate); - ObjectivesPlugin.objectives.get(1).gate = MainApp.sResources.getString(R.string.objectives_1_gate); - ObjectivesPlugin.objectives.get(2).gate = MainApp.sResources.getString(R.string.objectives_2_gate); - ObjectivesPlugin.objectives.get(3).gate = MainApp.sResources.getString(R.string.objectives_3_gate); - ObjectivesPlugin.objectives.get(4).gate = MainApp.sResources.getString(R.string.objectives_4_gate); - ObjectivesPlugin.objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate); + ObjectivesPlugin.objectives.get(0).objective = MainApp.gs(R.string.objectives_0_objective); + ObjectivesPlugin.objectives.get(1).objective = MainApp.gs(R.string.objectives_1_objective); + ObjectivesPlugin.objectives.get(2).objective = MainApp.gs(R.string.objectives_2_objective); + ObjectivesPlugin.objectives.get(3).objective = MainApp.gs(R.string.objectives_3_objective); + ObjectivesPlugin.objectives.get(4).objective = MainApp.gs(R.string.objectives_4_objective); + ObjectivesPlugin.objectives.get(5).objective = MainApp.gs(R.string.objectives_5_objective); + ObjectivesPlugin.objectives.get(6).objective = MainApp.gs(R.string.objectives_6_objective); + ObjectivesPlugin.objectives.get(7).objective = MainApp.gs(R.string.objectives_7_objective); + ObjectivesPlugin.objectives.get(0).gate = MainApp.gs(R.string.objectives_0_gate); + ObjectivesPlugin.objectives.get(1).gate = MainApp.gs(R.string.objectives_1_gate); + ObjectivesPlugin.objectives.get(2).gate = MainApp.gs(R.string.objectives_2_gate); + ObjectivesPlugin.objectives.get(3).gate = MainApp.gs(R.string.objectives_3_gate); + ObjectivesPlugin.objectives.get(4).gate = MainApp.gs(R.string.objectives_4_gate); + ObjectivesPlugin.objectives.get(5).gate = MainApp.gs(R.string.objectives_5_gate); updateGUI(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java index 490146cc14..1acf6ea083 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java @@ -54,7 +54,7 @@ public class FoodFragment extends SubscriberFragment { ArrayList categories; ArrayList subcategories; - final String EMPTY = MainApp.sResources.getString(R.string.none); + final String EMPTY = MainApp.gs(R.string.none); @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -158,7 +158,7 @@ public class FoodFragment extends SubscriberFragment { // make it unique categories = new ArrayList<>(catSet); - categories.add(0, MainApp.sResources.getString(R.string.none)); + categories.add(0, MainApp.gs(R.string.none)); ArrayAdapter adapterCategories = new ArrayAdapter<>(getContext(), R.layout.spinner_centered, categories); @@ -180,7 +180,7 @@ public class FoodFragment extends SubscriberFragment { // make it unique subcategories = new ArrayList<>(subCatSet); - subcategories.add(0, MainApp.sResources.getString(R.string.none)); + subcategories.add(0, MainApp.gs(R.string.none)); ArrayAdapter adapterSubcategories = new ArrayAdapter<>(getContext(), R.layout.spinner_centered, subcategories); @@ -242,14 +242,14 @@ public class FoodFragment extends SubscriberFragment { holder.ns.setVisibility(food._id != null ? View.VISIBLE : View.GONE); holder.name.setText(food.name); holder.portion.setText(food.portion + food.units); - holder.carbs.setText(food.carbs + MainApp.sResources.getString(R.string.shortgramm)); - holder.fat.setText(MainApp.sResources.getString(R.string.shortfat) + ": " + food.fat + MainApp.sResources.getString(R.string.shortgramm)); + holder.carbs.setText(food.carbs + MainApp.gs(R.string.shortgramm)); + holder.fat.setText(MainApp.gs(R.string.shortfat) + ": " + food.fat + MainApp.gs(R.string.shortgramm)); if (food.fat == 0) holder.fat.setVisibility(View.INVISIBLE); - holder.protein.setText(MainApp.sResources.getString(R.string.shortprotein) + ": " + food.protein + MainApp.sResources.getString(R.string.shortgramm)); + holder.protein.setText(MainApp.gs(R.string.shortprotein) + ": " + food.protein + MainApp.gs(R.string.shortgramm)); if (food.protein == 0) holder.protein.setVisibility(View.INVISIBLE); - holder.energy.setText(MainApp.sResources.getString(R.string.shortenergy) + ": " + food.energy + MainApp.sResources.getString(R.string.shortkilojoul)); + holder.energy.setText(MainApp.gs(R.string.shortenergy) + ": " + food.energy + MainApp.gs(R.string.shortkilojoul)); if (food.energy == 0) holder.energy.setVisibility(View.INVISIBLE); holder.remove.setTag(food); @@ -291,9 +291,9 @@ public class FoodFragment extends SubscriberFragment { case R.id.food_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" + food.name); - 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" + food.name); + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final String _id = food._id; if (_id != null && !_id.equals("")) { @@ -302,7 +302,7 @@ public class FoodFragment extends SubscriberFragment { MainApp.getSpecificPlugin(FoodPlugin.class).getService().delete(food); } }); - builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java index 672c5cfeb6..2c46cd7bb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java @@ -56,7 +56,7 @@ public abstract class InsulinOrefBasePlugin extends PluginBase implements Insuli } public String getNotificationPattern() { - return MainApp.sResources.getString(R.string.dia_too_short); + return MainApp.gs(R.string.dia_too_short); } public double getUserDefinedDia() { @@ -98,7 +98,7 @@ public abstract class InsulinOrefBasePlugin extends PluginBase implements Insuli String comment = commentStandardText(); double userDia = getUserDefinedDia(); if (userDia < MIN_DIA) { - comment += "\n" + String.format(MainApp.sResources.getString(R.string.dia_too_short), userDia, MIN_DIA); + comment += "\n" + String.format(MainApp.gs(R.string.dia_too_short), userDia, MIN_DIA); } return comment; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java index 3a19573d71..a710f742a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java @@ -33,12 +33,12 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin { } public String getFriendlyName() { - return MainApp.sResources.getString(R.string.free_peak_oref); + return MainApp.gs(R.string.free_peak_oref); } @Override public String commentStandardText() { - return MainApp.sResources.getString(R.string.insulin_peak_time) + ": " + getPeak(); + return MainApp.gs(R.string.insulin_peak_time) + ": " + getPeak(); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java index cd7769b55b..a8f9761771 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java @@ -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 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java index 0e20f8dd42..ba5fc99011 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java @@ -32,17 +32,17 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin { @Override public String getName() { - return MainApp.sResources.getString(R.string.ultrarapid_oref); + return MainApp.gs(R.string.ultrarapid_oref); } @Override public String getFriendlyName() { - return MainApp.sResources.getString(R.string.ultrarapid_oref); + return MainApp.gs(R.string.ultrarapid_oref); } @Override public String commentStandardText() { - return MainApp.sResources.getString(R.string.ultrafastactinginsulincomment); + return MainApp.gs(R.string.ultrafastactinginsulincomment); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java index 7a9c4deae9..87e55c7dc6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java @@ -52,23 +52,23 @@ public class APSResult { String ret; // rate if (rate == 0 && duration == 0) - ret = MainApp.sResources.getString(R.string.canceltemp) + "\n"; + ret = MainApp.gs(R.string.canceltemp) + "\n"; else if (rate == -1) - ret = MainApp.sResources.getString(R.string.let_temp_basal_run) + "\n"; + ret = MainApp.gs(R.string.let_temp_basal_run) + "\n"; else - ret = MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " + + ret = MainApp.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " + "(" + DecimalFormatter.to2Decimal(rate / pump.getBaseBasalRate() * 100) + "%) \n" + - MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min\n"; + MainApp.gs(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min\n"; // smb if (smb != 0) ret += ("SMB: " + DecimalFormatter.toPumpSupportedBolus(smb) + " U\n"); // reason - ret += MainApp.sResources.getString(R.string.reason) + ": " + reason; + ret += MainApp.gs(R.string.reason) + ": " + reason; return ret; } else - return MainApp.sResources.getString(R.string.nochangerequested); + return MainApp.gs(R.string.nochangerequested); } public Spanned toSpanned() { @@ -77,23 +77,23 @@ public class APSResult { String ret; // rate if (rate == 0 && duration == 0) - ret = MainApp.sResources.getString(R.string.canceltemp) + "
"; + ret = MainApp.gs(R.string.canceltemp) + "
"; else if (rate == -1) - ret = MainApp.sResources.getString(R.string.let_temp_basal_run) + "
"; + ret = MainApp.gs(R.string.let_temp_basal_run) + "
"; else - ret = "" + MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " + + ret = "" + MainApp.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " + "(" + DecimalFormatter.to2Decimal(rate / pump.getBaseBasalRate() * 100) + "%)
" + - "" + MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min
"; + "" + MainApp.gs(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min
"; // smb if (smb != 0) ret += ("" + "SMB" + ": " + DecimalFormatter.toPumpSupportedBolus(smb) + " U
"); // reason - ret += "" + MainApp.sResources.getString(R.string.reason) + ": " + reason.replace("<", "<").replace(">", ">"); + ret += "" + MainApp.gs(R.string.reason) + ": " + reason.replace("<", "<").replace(">", ">"); return Html.fromHtml(ret); } else - return Html.fromHtml(MainApp.sResources.getString(R.string.nochangerequested)); + return Html.fromHtml(MainApp.gs(R.string.nochangerequested)); } public APSResult() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java index 5285dc7831..4ad35c0d02 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java @@ -65,7 +65,7 @@ public class LoopFragment extends SubscriberFragment { @OnClick(R.id.loop_run) void onRunClick() { - lastRunView.setText(MainApp.sResources.getString(R.string.executing)); + lastRunView.setText(MainApp.gs(R.string.executing)); new Thread(() -> LoopPlugin.getPlugin().invoke("Loop button", true)).start(); FabricPrivacy.getInstance().logCustom(new CustomEvent("Loop_Run")); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 43d00b24af..f6ec0ff7ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -258,7 +258,7 @@ public class LoopPlugin extends PluginBase { Constraint 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) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java index 39e24f8b38..3bff1c9be3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java @@ -110,16 +110,16 @@ public class NSClientFragment extends SubscriberFragment implements View.OnClick final Context context = getContext(); AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(this.getContext().getString(R.string.confirmation)); + builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setMessage("Clear queue? All data in queue will be lost!"); - builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { UploadQueue.clearQueue(); updateGUI(); FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientClearQueue")); } }); - builder.setNegativeButton(getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; case R.id.nsclientinternal_showqueue: @@ -165,7 +165,7 @@ public class NSClientFragment extends SubscriberFragment implements View.OnClick logScrollview.fullScroll(ScrollView.FOCUS_DOWN); } urlTextView.setText(NSClientPlugin.getPlugin().url()); - Spanned queuetext = Html.fromHtml(MainApp.sResources.getString(R.string.queue) + " " + UploadQueue.size() + ""); + Spanned queuetext = Html.fromHtml(MainApp.gs(R.string.queue) + " " + UploadQueue.size() + ""); queueTextView.setText(queuetext); statusTextView.setText(NSClientPlugin.getPlugin().status); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java index 79a66186fb..2723fc0748 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java @@ -22,7 +22,7 @@ public class DbLogger { public static void dbAdd(Intent intent, String data) { List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0); if (q.size() < 1) { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.sResources.getString(R.string.nsclientnotinstalled)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.gs(R.string.nsclientnotinstalled)); log.error("DBADD No receivers"); } else if (Config.logNSUpload) log.debug("DBADD dbAdd " + q.size() + " receivers " + data); @@ -31,7 +31,7 @@ public class DbLogger { public static void dbRemove(Intent intent, String data) { List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0); if (q.size() < 1) { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.sResources.getString(R.string.nsclientnotinstalled)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.gs(R.string.nsclientnotinstalled)); log.error("DBREMOVE No receivers"); } else if (Config.logNSUpload) log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index 445bef32fe..d50f9e2c9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -309,7 +309,7 @@ public class NSClientService extends Service { MainApp.bus().post(new EventNSClientNewLog("ERROR", "Write treatment permission not granted !!!!")); } if (!hasWriteAuth) { - Notification noperm = new Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, MainApp.sResources.getString(R.string.nowritepermission), Notification.URGENT); + Notification noperm = new Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, MainApp.gs(R.string.nowritepermission), Notification.URGENT); MainApp.bus().post(new EventNewNotification(noperm)); } else { MainApp.bus().post(new EventDismissNotification(Notification.NSCLIENT_NO_WRITE_PERMISSION)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java index 2e6bb277e6..f05b0ac696 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java @@ -107,7 +107,7 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam())); try { JSONArray iobArray = new JSONArray(determineBasalAdapterAMAJS.getIobDataParam()); - iobDataView.setText(String.format(MainApp.sResources.getString(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))); + iobDataView.setText(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))); } catch (JSONException e) { log.error("Unhandled exception", e); iobDataView.setText("JSONException"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index 17e1dd77e9..143456f6fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -104,23 +104,23 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { PumpInterface pump = ConfigBuilderPlugin.getActivePump(); if (profile == null) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.noprofileselected)); + log.debug(MainApp.gs(R.string.noprofileselected)); return; } if (!isEnabled(PluginType.APS)) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.openapsma_disabled)); + log.debug(MainApp.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata)); + log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index 00f1888851..14dac65625 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -104,23 +104,23 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { PumpInterface pump = ConfigBuilderPlugin.getActivePump(); if (profile == null) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.noprofileselected)); + log.debug(MainApp.gs(R.string.noprofileselected)); return; } if (!isEnabled(PluginType.APS)) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.openapsma_disabled)); + log.debug(MainApp.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata)); + log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java index 7780fcc9b4..724bfcf86c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java @@ -99,7 +99,7 @@ public class OpenAPSSMBFragment extends SubscriberFragment { currentTempView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getCurrentTempParam()).toString().trim()); try { JSONArray iobArray = new JSONArray(determineBasalAdapterSMBJS.getIobDataParam()); - iobDataView.setText((String.format(MainApp.sResources.getString(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))).trim()); + iobDataView.setText((String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))).trim()); } catch (JSONException e) { log.error("Unhandled exception", e); iobDataView.setText("JSONException see log for details"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index cd7872ecb1..49a81ea612 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -107,23 +107,23 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { PumpInterface pump = ConfigBuilderPlugin.getActivePump(); if (profile == null) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.noprofileselected)); + log.debug(MainApp.gs(R.string.noprofileselected)); return; } if (!isEnabled(PluginType.APS)) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.openapsma_disabled)); + log.debug(MainApp.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { - MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata))); + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); if (Config.logAPSResult) - log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata)); + log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); return; } @@ -255,9 +255,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { if (newvalue < lowLimit || newvalue > highLimit) { newvalue = Math.max(newvalue, lowLimit); newvalue = Math.min(newvalue, highLimit); - String msg = String.format(MainApp.sResources.getString(R.string.valueoutofrange), valueName); + String msg = String.format(MainApp.gs(R.string.valueoutofrange), valueName); msg += ".\n"; - msg += String.format(MainApp.sResources.getString(R.string.valuelimitedto), value, newvalue); + msg += String.format(MainApp.gs(R.string.valuelimitedto), value, newvalue); log.error(msg); NSUpload.uploadError(msg); ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java index 35906187a6..fbd4e0ece7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java @@ -53,7 +53,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - getDialog().setTitle(String.format(MainApp.sResources.getString(R.string.overview_bolusprogress_goingtodeliver), amount)); + getDialog().setTitle(String.format(MainApp.gs(R.string.overview_bolusprogress_goingtodeliver), amount)); View view = inflater.inflate(R.layout.overview_bolusprogress_dialog, container, false); stopButton = (Button) view.findViewById(R.id.overview_bolusprogress_stop); statusView = (TextView) view.findViewById(R.id.overview_bolusprogress_status); @@ -61,7 +61,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL progressBar = (ProgressBar) view.findViewById(R.id.overview_bolusprogress_progressbar); stopButton.setOnClickListener(this); progressBar.setMax(100); - statusView.setText(MainApp.sResources.getString(R.string.waitingforpump)); + statusView.setText(MainApp.gs(R.string.waitingforpump)); setCancelable(false); stopPressed = false; return view; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java index 2751b800bc..50de25b656 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java @@ -149,13 +149,13 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic int getSelection(Spinner spinner) { String value = spinner.getSelectedItem().toString(); - if (value.equals(MainApp.sResources.getString(R.string.yes))) + if (value.equals(MainApp.gs(R.string.yes))) return QuickWizardEntry.YES; - if (value.equals(MainApp.sResources.getString(R.string.no))) + if (value.equals(MainApp.gs(R.string.no))) return QuickWizardEntry.NO; - if (value.equals(MainApp.sResources.getString(R.string.positiveonly))) + if (value.equals(MainApp.gs(R.string.positiveonly))) return QuickWizardEntry.POSITIVE_ONLY; - if (value.equals(MainApp.sResources.getString(R.string.negativeonly))) + if (value.equals(MainApp.gs(R.string.negativeonly))) return QuickWizardEntry.NEGATIVE_ONLY; return QuickWizardEntry.NO; } @@ -164,19 +164,19 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic String selection; switch (value) { case QuickWizardEntry.YES: - selection = MainApp.sResources.getString(R.string.yes); + selection = MainApp.gs(R.string.yes); break; case QuickWizardEntry.NO: - selection = MainApp.sResources.getString(R.string.no); + selection = MainApp.gs(R.string.no); break; case QuickWizardEntry.POSITIVE_ONLY: - selection = MainApp.sResources.getString(R.string.positiveonly); + selection = MainApp.gs(R.string.positiveonly); break; case QuickWizardEntry.NEGATIVE_ONLY: - selection = MainApp.sResources.getString(R.string.negativeonly); + selection = MainApp.gs(R.string.negativeonly); break; default: - selection = MainApp.sResources.getString(R.string.no); + selection = MainApp.gs(R.string.no); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index e15c34bac8..718b1c6bfa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -270,13 +270,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com } private void saveCheckedStates() { - SP.putBoolean(getString(R.string.key_wizard_include_cob), cobCheckbox.isChecked()); - SP.putBoolean(getString(R.string.key_wizard_include_trend_bg), bgtrendCheckbox.isChecked()); + SP.putBoolean(MainApp.gs(R.string.key_wizard_include_cob), cobCheckbox.isChecked()); + SP.putBoolean(MainApp.gs(R.string.key_wizard_include_trend_bg), bgtrendCheckbox.isChecked()); } private void loadCheckedStates() { - bgtrendCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_trend_bg), false)); - cobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_cob), false)); + bgtrendCheckbox.setChecked(SP.getBoolean(MainApp.gs(R.string.key_wizard_include_trend_bg), false)); + cobCheckbox.setChecked(SP.getBoolean(MainApp.gs(R.string.key_wizard_include_cob), false)); } @Override @@ -287,7 +287,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com @Override public void onNothingSelected(AdapterView parent) { - ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.noprofileselected)); + ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.noprofileselected)); okButton.setVisibility(View.GONE); } @@ -306,20 +306,20 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com if (profile != null && (calculatedTotalInsulin > 0d || calculatedCarbs > 0d)) { DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00"); - String confirmMessage = getString(R.string.entertreatmentquestion); + String confirmMessage = MainApp.gs(R.string.entertreatmentquestion); Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(calculatedTotalInsulin)).value(); Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(calculatedCarbs)).value(); - confirmMessage += "
" + getString(R.string.bolus) + ": " + "" + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U" + ""; - confirmMessage += "
" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g"; + confirmMessage += "
" + MainApp.gs(R.string.bolus) + ": " + "" + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U" + ""; + confirmMessage += "
" + MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g"; if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) { AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror)); - builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput)); - builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null); + builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror)); + builder.setMessage(MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput)); + builder.setPositiveButton(MainApp.gs(R.string.ok), null); builder.show(); return; } @@ -332,9 +332,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com final String finalNotes = notesEdit.getText().toString(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); + builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setMessage(Html.fromHtml(confirmMessage)); - builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { synchronized (builder) { if (accepted) { @@ -356,7 +356,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.boluserror); i.putExtra("status", result.comment); - i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror)); + i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); } @@ -382,7 +382,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); i.putExtra("soundid", R.raw.boluserror); i.putExtra("status", result.comment); - i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror)); + i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); } @@ -396,7 +396,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com } } }); - builder.setNegativeButton(getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); dismiss(); } @@ -412,14 +412,14 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile(); if (profile == null) { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.noprofile)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile)); dismiss(); return; } ArrayList profileList; profileList = profileStore.getProfileList(); - profileList.add(0, MainApp.sResources.getString(R.string.active)); + profileList.add(0, MainApp.gs(R.string.active)); ArrayAdapter adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_centered, profileList); @@ -458,7 +458,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com return; // not initialized yet String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString(); Profile specificProfile; - if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active))) + if (selectedAlternativeProfile.equals(MainApp.gs(R.string.active))) specificProfile = MainApp.getConfigBuilder().getProfile(); else specificProfile = profileStore.getSpecificProfile(selectedAlternativeProfile); @@ -472,13 +472,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com c_correction = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(c_correction)).value(); if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work editCorr.setValue(0d); - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.bolusconstraintapplied)); return; } Integer carbsAfterConstraint = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(c_carbs)).value(); if (c_carbs - carbsAfterConstraint != 0) { editCarbs.setValue(0d); - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.carbsconstraintapplied)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.carbsconstraintapplied)); return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 3f126aba19..3d0970f8f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -678,9 +678,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun; if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setTitle(getContext().getString(R.string.confirmation)); - builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); - builder.setPositiveButton(getContext().getString(R.string.ok), (dialog, id) -> { + builder.setTitle(MainApp.gs(R.string.confirmation)); + builder.setMessage(MainApp.gs(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); + builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> { hideTempRecommendation(); clearNotification(); MainApp.getConfigBuilder().applyTBRRequest(finalLastRun.constraintsProcessed, profile, new Callback() { @@ -702,7 +702,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, }); FabricPrivacy.getInstance().logCustom(new CustomEvent("AcceptTemp")); }); - builder.setNegativeButton(getContext().getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); } } @@ -742,18 +742,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } if (wizard.calculatedTotalInsulin > 0d && quickWizardEntry.carbs() > 0d) { DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00"); - String confirmMessage = getString(R.string.entertreatmentquestion); + String confirmMessage = MainApp.gs(R.string.entertreatmentquestion); Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(wizard.calculatedTotalInsulin)).value(); Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(quickWizardEntry.carbs())).value(); - confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U"; - confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g"; + confirmMessage += "\n" + MainApp.gs(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U"; + confirmMessage += "\n" + MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g"; if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror)); - builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput)); + builder.setMessage(MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput)); builder.setPositiveButton(MainApp.gs(R.string.ok), null); builder.show(); return; @@ -766,7 +766,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, accepted = false; builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setMessage(confirmMessage); - builder.setPositiveButton(getString(R.string.ok), (dialog, id) -> { + builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> { synchronized (builder) { if (accepted) { log.debug("guarding: already accepted"); @@ -822,7 +822,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } } }); - builder.setNegativeButton(getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); } } @@ -1091,7 +1091,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) { acceptTempLayout.setVisibility(View.VISIBLE); - acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); + acceptTempButton.setText(MainApp.gs(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); } else { acceptTempLayout.setVisibility(View.GONE); } @@ -1269,14 +1269,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, iobView.setText(iobtext); iobView.setOnClickListener(v -> { String iobtext1 = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n" - + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n" - + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n"; + + MainApp.gs(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n" + + MainApp.gs(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n"; OKDialog.show(getActivity(), MainApp.gs(R.string.iob), iobtext1, null); }); } else if (MainApp.sResources.getBoolean(R.bool.isTablet)) { String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" - + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " - + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)"; + + MainApp.gs(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " + + MainApp.gs(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)"; iobView.setText(iobtext); } else { String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java index 6087ae0210..1b1487bbaa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java @@ -94,7 +94,7 @@ public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter { doEdit(); if (basalView != null) { - basalView.updateLabel(MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel()); + basalView.updateLabel(MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel()); } }; @@ -91,10 +91,10 @@ public class LocalProfileFragment extends SubscriberFragment { diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch); mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl); mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol); - icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save); - isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save); - basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save); - targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save); + icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save); + isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save); + basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save); + targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save); profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch); resetButton = (Button) layout.findViewById(R.id.localprofile_reset); saveButton = (Button) layout.findViewById(R.id.localprofile_save); @@ -144,10 +144,10 @@ public class LocalProfileFragment extends SubscriberFragment { mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl); mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol); diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch); - icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save); - isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save); - basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save); - targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save); + icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save); + isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save); + basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save); + targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save); updateGUI(); }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index 14fdd3c219..3e3a9a33fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -145,7 +145,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis // reservoir int reservoirLevel = plugin.getPump().reservoirLevel; if (reservoirLevel != -1) { - reservoirView.setText(reservoirLevel + " " + MainApp.sResources.getString(R.string.insulin_unit_shortname)); + reservoirView.setText(reservoirLevel + " " + MainApp.gs(R.string.insulin_unit_shortname)); } else if (ps.insulinState == PumpState.LOW) { reservoirView.setText(MainApp.gs(R.string.combo_reservoir_low)); } else if (ps.insulinState == PumpState.EMPTY) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 68db1658f6..3cf4557e54 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -458,7 +458,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint log.error("deliverTreatment: Invalid input"); return new PumpEnactResult().success(false).enacted(false) .bolusDelivered(0d).carbsDelivered(0d) - .comment(MainApp.instance().getString(R.string.danar_invalidinput)); + .comment(MainApp.gs(R.string.danar_invalidinput)); } else if (detailedBolusInfo.insulin > 0) { // bolus needed, ask pump to deliver it return deliverBolus(detailedBolusInfo); @@ -474,7 +474,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint return new PumpEnactResult().success(true).enacted(true) .bolusDelivered(0d).carbsDelivered(detailedBolusInfo.carbs) - .comment(MainApp.instance().getString(R.string.virtualpump_resultok)); + .comment(MainApp.gs(R.string.virtualpump_resultok)); } } finally { MainApp.bus().post(new EventComboPumpUpdateGUI()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java index ea83e6d4d6..903be558b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java @@ -95,22 +95,22 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte } 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; } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); } if (!sExecutionService.updateBasalsInPump(profile)) { - 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; } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); 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; @@ -166,7 +166,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.isTempCancel = false; result.enacted = false; result.success = false; - result.comment = MainApp.instance().getString(R.string.danar_invalidinput); + result.comment = MainApp.gs(R.string.danar_invalidinput); log.error("setTempBasalPercent: Invalid input"); return result; } @@ -178,7 +178,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.enacted = false; result.success = true; result.isTempCancel = false; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; @@ -191,7 +191,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) { result.enacted = true; result.success = true; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); result.isTempCancel = false; result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; @@ -202,7 +202,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte } result.enacted = false; result.success = false; - result.comment = MainApp.instance().getString(R.string.tempbasaldeliveryerror); + result.comment = MainApp.gs(R.string.tempbasaldeliveryerror); log.error("setTempBasalPercent: Failed to set temp basal"); return result; } @@ -219,7 +219,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) { result.enacted = false; result.success = true; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); result.duration = pump.extendedBolusRemainingMinutes; result.absolute = pump.extendedBolusAbsoluteRate; result.isPercent = false; @@ -232,7 +232,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) { result.enacted = true; result.success = true; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); result.isTempCancel = false; result.duration = pump.extendedBolusRemainingMinutes; result.absolute = pump.extendedBolusAbsoluteRate; @@ -245,7 +245,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte } result.enacted = false; result.success = false; - result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); + result.comment = MainApp.gs(R.string.danar_valuenotsetproperly); log.error("setExtendedBolus: Failed to extended bolus"); return result; } @@ -261,13 +261,13 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte } if (!pump.isExtendedInProgress) { result.success = true; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); if (Config.logPumpActions) log.debug("cancelExtendedBolus: OK"); return result; } else { result.success = false; - result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); + result.comment = MainApp.gs(R.string.danar_valuenotsetproperly); log.error("cancelExtendedBolus: Failed to cancel extended bolus"); return result; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index 7ef3d6a987..b8afdaf15a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -206,7 +206,7 @@ public class DanaRFragment extends SubscriberFragment { if (pump.lastConnection != 0) { Long agoMsec = System.currentTimeMillis() - pump.lastConnection; int agoMin = (int) (agoMsec / 60d / 1000d); - lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")"); + lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.gs(R.string.minago), agoMin) + ")"); SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d); } if (pump.lastBolusTime.getTime() != 0) { @@ -247,7 +247,7 @@ public class DanaRFragment extends SubscriberFragment { SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d); iobView.setText(pump.iob + " U"); if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) { - firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); + firmwareView.setText(String.format(MainApp.gs(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); } else { firmwareView.setText("OLD"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java index 7f90fb190b..97c5569b4b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java @@ -122,20 +122,20 @@ public class DanaRHistoryActivity extends Activity { // Types ArrayList typeList = new ArrayList<>(); - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ALARM, getString(R.string.danar_history_alarm))); - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, getString(R.string.danar_history_basalhours))); - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BOLUS, getString(R.string.danar_history_bolus))); - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, getString(R.string.danar_history_carbohydrates))); - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, getString(R.string.danar_history_dailyinsulin))); - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, getString(R.string.danar_history_glucose))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ALARM, MainApp.gs(R.string.danar_history_alarm))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, MainApp.gs(R.string.danar_history_basalhours))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BOLUS, MainApp.gs(R.string.danar_history_bolus))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, MainApp.gs(R.string.danar_history_carbohydrates))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, MainApp.gs(R.string.danar_history_dailyinsulin))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, MainApp.gs(R.string.danar_history_glucose))); if (!isKorean && !isRS) { - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, getString(R.string.danar_history_errors))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, MainApp.gs(R.string.danar_history_errors))); } if (isRS) - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_PRIME, getString(R.string.danar_history_prime))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_PRIME, MainApp.gs(R.string.danar_history_prime))); if (!isKorean) { - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, getString(R.string.danar_history_refill))); - typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, getString(R.string.danar_history_syspend))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, MainApp.gs(R.string.danar_history_refill))); + typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, MainApp.gs(R.string.danar_history_syspend))); } ArrayAdapter spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered, typeList); @@ -215,7 +215,7 @@ public class DanaRHistoryActivity extends Activity { }); profile = MainApp.getConfigBuilder().getProfile(); if (profile == null) { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.noprofile)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile)); finish(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java index e7813fac10..d505443c1d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java @@ -57,7 +57,7 @@ public class DanaRNSHistorySync { if (record._id != null) continue; //log.debug(record.bytes); JSONObject nsrec = new JSONObject(); - ev.message = MainApp.sResources.getString(R.string.uploading) + " " + processing + "/" + records + " "; // TODO: translations + ev.message = MainApp.gs(R.string.uploading) + " " + processing + "/" + records + " "; // TODO: translations switch (record.recordCode) { case RecordTypes.RECORD_TYPE_BOLUS: if ((what & SYNC_BOLUS) == 0) break; @@ -68,10 +68,10 @@ public class DanaRNSHistorySync { nsrec.put("eventType", "Meal Bolus"); nsrec.put("insulin", record.recordValue); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_sbolus); + ev.message += MainApp.gs(R.string.danar_sbolus); break; case "E": if (record.recordDuration > 0) { @@ -86,10 +86,10 @@ public class DanaRNSHistorySync { cal.setTimeInMillis(record.recordDate); cal.add(Calendar.MINUTE, -1 * record.recordDuration); nsrec.put("created_at", DateUtil.toISOString(cal.getTime())); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_ebolus); + ev.message += MainApp.gs(R.string.danar_ebolus); } else { log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration"); } @@ -102,10 +102,10 @@ public class DanaRNSHistorySync { nsrec.put("splitNow", 100); nsrec.put("splitExt", 0); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_dsbolus); + ev.message += MainApp.gs(R.string.danar_dsbolus); break; case "DE": log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); @@ -118,10 +118,10 @@ public class DanaRNSHistorySync { cal.setTimeInMillis(record.recordDate); cal.add(Calendar.MINUTE, -1 * record.recordDuration); nsrec.put("created_at", DateUtil.toISOString(cal.getTime())); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_debolus); + ev.message += MainApp.gs(R.string.danar_debolus); break; default: log.debug("Unknown bolus record"); @@ -135,10 +135,10 @@ public class DanaRNSHistorySync { nsrec.put("eventType", "Note"); nsrec.put("notes", "Error"); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_error); + ev.message += MainApp.gs(R.string.danar_error); break; case RecordTypes.RECORD_TYPE_REFILL: if ((what & SYNC_REFILL) == 0) break; @@ -147,10 +147,10 @@ public class DanaRNSHistorySync { nsrec.put("eventType", "Insulin Change"); nsrec.put("notes", "Refill " + record.recordValue + "U"); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_refill); + ev.message += MainApp.gs(R.string.danar_refill); break; case RecordTypes.RECORD_TYPE_BASALHOUR: if ((what & SYNC_BASALHOURS) == 0) break; @@ -160,10 +160,10 @@ public class DanaRNSHistorySync { nsrec.put("absolute", record.recordValue); nsrec.put("duration", 60); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_basalhour); + ev.message += MainApp.gs(R.string.danar_basalhour); break; case RecordTypes.RECORD_TYPE_TB: //log.debug("Ignoring TB record " + record.bytes + " " + DateUtil.toISOString(record.recordDate)); @@ -176,10 +176,10 @@ public class DanaRNSHistorySync { nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, MainApp.getConfigBuilder().getProfileUnits())); nsrec.put("glucoseType", "Finger"); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_glucose); + ev.message += MainApp.gs(R.string.danar_glucose); break; case RecordTypes.RECORD_TYPE_CARBO: if ((what & SYNC_CARBO) == 0) break; @@ -188,10 +188,10 @@ public class DanaRNSHistorySync { nsrec.put("eventType", "Meal Bolus"); nsrec.put("carbs", record.recordValue); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_carbohydrate); + ev.message += MainApp.gs(R.string.danar_carbohydrate); break; case RecordTypes.RECORD_TYPE_ALARM: if ((what & SYNC_ALARM) == 0) break; @@ -200,10 +200,10 @@ public class DanaRNSHistorySync { nsrec.put("eventType", "Note"); nsrec.put("notes", "Alarm: " + record.recordAlarm); nsrec.put("created_at", DateUtil.toISOString(record.recordDate)); - nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name)); + nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); NSUpload.uploadCareportalEntryToNS(nsrec); uploaded++; - ev.message += MainApp.sResources.getString(R.string.danar_alarm); + ev.message += MainApp.gs(R.string.danar_alarm); break; case RecordTypes.RECORD_TYPE_SUSPEND: // TODO: this too case RecordTypes.RECORD_TYPE_DAILY: @@ -216,7 +216,7 @@ public class DanaRNSHistorySync { } MainApp.bus().post(ev); } - ev.message = String.format(MainApp.sResources.getString(R.string.danar_totaluploaded), uploaded); + ev.message = String.format(MainApp.gs(R.string.danar_totaluploaded), uploaded); MainApp.bus().post(ev); } catch (JSONException e) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java index 79358526fa..cb01a7d901 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java @@ -36,7 +36,7 @@ public class MsgBolusProgress extends MessageBase { Double done = (amount * 100 - progress) / 100d; t.insulin = done; EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); - bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), done); + bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), done); bolusingEvent.t = t; bolusingEvent.percent = Math.min((int) (done / amount * 100), 100); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java index 6718d76194..5c677b813e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java @@ -34,10 +34,10 @@ public class MsgBolusStop extends MessageBase { stopped = true; if (!forced) { t.insulin = amount; - bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_delivered); + bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_delivered); bolusingEvent.percent = 100; } else { - bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_stoped); + bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_stoped); } MainApp.bus().post(bolusingEvent); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java index b180d4107b..e42327c3b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java @@ -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; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java index 83bd9dc77d..4fc9844b0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java @@ -41,7 +41,7 @@ public class MsgInitConnStatusBolus extends MessageBase { } if (!pump.isExtendedBolusEnabled) { - Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT); + Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java index 642f539f6c..84d9c413bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java @@ -27,7 +27,7 @@ public class MsgInitConnStatusTime extends MessageBase { @Override public void handleMessage(byte[] bytes) { if (bytes.length - 10 > 7) { - Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL); + Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); log.debug("Wrong model selected. Switching to Korean DanaR"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java index 01c80bc255..9f945e8b26 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java @@ -33,12 +33,12 @@ public class MsgSetBasalProfile extends MessageBase { if (result != 1) { failed = true; log.debug("Set basal profile result: " + result + " FAILED!!!"); - Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT); + Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); } else { if (Config.logDanaMessageDetail) log.debug("Set basal profile result: " + result); - Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60); MainApp.bus().post(new EventNewNotification(reportOK)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java index 1c79080093..7dd9ca522b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java @@ -32,12 +32,12 @@ public class MsgSetSingleBasalProfile extends MessageBase { if (result != 1) { failed = true; log.debug("Set basal profile result: " + result + " FAILED!!!"); - Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT); + Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); } else { if (Config.logDanaMessageDetail) log.debug("Set basal profile result: " + result); - Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60); MainApp.bus().post(new EventNewNotification(reportOK)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java index 6f87803868..8d94a1784d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java @@ -48,14 +48,14 @@ public class MsgSettingMeal extends MessageBase { } if (pump.basalStep != 0.01d) { - Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.sResources.getString(R.string.danar_setbasalstep001), Notification.URGENT); + Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.gs(R.string.danar_setbasalstep001), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.WRONGBASALSTEP)); } if (pump.isConfigUD) { - Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.sResources.getString(R.string.danar_switchtouhmode), Notification.URGENT); + Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.gs(R.string.danar_switchtouhmode), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.UD_MODE_ENABLED)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java index 5524cf5c5c..b7201c1163 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java @@ -134,7 +134,7 @@ public abstract class AbstractDanaRExecutionService extends Service { } protected void getBTSocketForSelectedPump() { - mDevName = SP.getString(MainApp.sResources.getString(R.string.key_danar_bt_name), ""); + mDevName = SP.getString(MainApp.gs(R.string.key_danar_bt_name), ""); BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter != null) { @@ -152,10 +152,10 @@ public abstract class AbstractDanaRExecutionService extends Service { } } } else { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.nobtadapter)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nobtadapter)); } if (mBTDevice == null) { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.devicenotfound)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.devicenotfound)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java index 944931569b..65a5d22d36 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java @@ -97,7 +97,7 @@ public class DanaRExecutionService 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; } @@ -138,7 +138,7 @@ public class DanaRExecutionService 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 statusMsg = new MsgStatus(); MsgStatusBasic statusBasicMsg = new MsgStatusBasic(); MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(); @@ -154,15 +154,15 @@ public class DanaRExecutionService 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(DanaRPlugin.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 MsgSettingActiveProfile()); mSerialIOThread.sendMessage(new MsgSettingMeal()); @@ -173,7 +173,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{ mSerialIOThread.sendMessage(new MsgSettingActiveProfile()); mSerialIOThread.sendMessage(new MsgSettingProfileRatios()); mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll()); - 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"); @@ -192,9 +192,9 @@ public class DanaRExecutionService 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); @@ -204,11 +204,11 @@ public class DanaRExecutionService 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)); @@ -217,7 +217,7 @@ public class DanaRExecutionService 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)); @@ -226,7 +226,7 @@ public class DanaRExecutionService 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)); @@ -235,7 +235,7 @@ public class DanaRExecutionService 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 DanaRExecutionService extends AbstractDanaRExecutionService{ while (System.currentTimeMillis() < expectedEnd) { long waitTime = expectedEnd - System.currentTimeMillis(); - bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + bolusingEvent.status = String.format(MainApp.gs(R.string.waitingforestimatedbolusend), waitTime / 1000); MainApp.bus().post(bolusingEvent); SystemClock.sleep(1000); } @@ -363,7 +363,7 @@ public class DanaRExecutionService 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); MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal); mSerialIOThread.sendMessage(msgSet); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java index 82beecc5e9..fa28e664ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java @@ -39,7 +39,7 @@ public class MsgInitConnStatusBasic_k extends MessageBase { } if (pump.isEasyModeEnabled) { - Notification notification = new Notification(Notification.EASYMODE_ENABLED, MainApp.sResources.getString(R.string.danar_disableeasymode), Notification.URGENT); + Notification notification = new Notification(Notification.EASYMODE_ENABLED, MainApp.gs(R.string.danar_disableeasymode), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.EASYMODE_ENABLED)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java index bf105b8db0..552511cf7c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java @@ -44,7 +44,7 @@ public class MsgInitConnStatusBolus_k extends MessageBase { } if (!pump.isExtendedBolusEnabled) { - Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT); + Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java index 2028411791..7553b0cc37 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java @@ -29,7 +29,7 @@ public class MsgInitConnStatusTime_k extends MessageBase { public void handleMessage(byte[] bytes) { if (bytes.length - 10 < 10) { - Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL); + Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); log.debug("Wrong model selected. Switching to export DanaR"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java index 106074ca3c..b9cc704aba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java @@ -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); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index a2ec13d184..1f30ed6c3f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -297,22 +297,22 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte } 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; } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); } if (!danaRSService.updateBasalsInPump(profile)) { - 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; } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); 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; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java index a663d14245..9f72e1d08f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java @@ -51,14 +51,14 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.danars_pairingprogressdialog, container, false); - getDialog().setTitle(MainApp.sResources.getString(R.string.pairing)); + getDialog().setTitle(MainApp.gs(R.string.pairing)); statusView = (TextView) view.findViewById(R.id.danars_paringprogress_status); progressBar = (ProgressBar) view.findViewById(R.id.danars_paringprogress_progressbar); button = (Button) view.findViewById(R.id.ok); progressBar.setMax(100); progressBar.setProgress(0); - statusView.setText(MainApp.sResources.getString(R.string.waitingforpairing)); + statusView.setText(MainApp.gs(R.string.waitingforpairing)); button.setVisibility(View.GONE); button.setOnClickListener(this); setCancelable(false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java index a707c5e0cc..181584df8e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java @@ -200,7 +200,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { 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)); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java index 048912a23d..f3fef0d49d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java @@ -53,7 +53,7 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet { } if (pump.basalStep != 0.01d) { - Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.sResources.getString(R.string.danar_setbasalstep001), Notification.URGENT); + Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.gs(R.string.danar_setbasalstep001), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.WRONGBASALSTEP)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java index eb4af6b25f..69c2f75ba6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java @@ -102,7 +102,7 @@ public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet { int missedBolus04EndMin = byteArrayToInt(getBytes(data, dataIndex, dataSize)); if (!pump.isExtendedBolusEnabled) { - Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT); + Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else { MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java index 83e84e28cc..78548ecab3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java @@ -47,10 +47,10 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet { stopped = true; if (!forced) { t.insulin = amount; - bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_delivered); + bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_delivered); bolusingEvent.percent = 100; } else { - bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_stoped); + bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_stoped); } MainApp.bus().post(bolusingEvent); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java index a9bb7157af..bdc5ab8d9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java @@ -43,7 +43,7 @@ public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet { } if (pump.productCode < 2) { - MainApp.bus().post(new EventNewNotification(new Notification(Notification.UNSUPPORTED_FIRMWARE, MainApp.sResources.getString(R.string.unsupportedfirmware), Notification.URGENT))); + MainApp.bus().post(new EventNewNotification(new Notification(Notification.UNSUPPORTED_FIRMWARE, MainApp.gs(R.string.unsupportedfirmware), Notification.URGENT))); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java index 88edd13a63..04737f0bdc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java @@ -30,23 +30,23 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { switch (alarmCode) { case 0x01: // Battery 0% Alarm - errorString = MainApp.sResources.getString(R.string.batterydischarged); + errorString = MainApp.gs(R.string.batterydischarged); break; case 0x02: // Pump Error - errorString = MainApp.sResources.getString(R.string.pumperror) + " " + alarmCode; + errorString = MainApp.gs(R.string.pumperror) + " " + alarmCode; break; case 0x03: // Occlusion - errorString = MainApp.sResources.getString(R.string.occlusion); + errorString = MainApp.gs(R.string.occlusion); break; case 0x04: // LOW BATTERY - errorString = MainApp.sResources.getString(R.string.lowbattery); + errorString = MainApp.gs(R.string.lowbattery); break; case 0x05: // Shutdown - errorString = MainApp.sResources.getString(R.string.lowbattery); + errorString = MainApp.gs(R.string.lowbattery); break; case 0x06: // Basal Compare @@ -54,20 +54,20 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { break; case 0x09: // Empty Reservoir - errorString = MainApp.sResources.getString(R.string.emptyreservoir); + errorString = MainApp.gs(R.string.emptyreservoir); break; // BT case 0x07: case 0xFF: // Blood sugar measurement alert - errorString = MainApp.sResources.getString(R.string.bloodsugarmeasurementalert); + errorString = MainApp.gs(R.string.bloodsugarmeasurementalert); break; case 0x08: case 0xFE: // Remaining insulin level - errorString = MainApp.sResources.getString(R.string.remaininsulinalert); + errorString = MainApp.gs(R.string.remaininsulinalert); break; case 0xFD: diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java index fb5793995c..2598c5efc9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java @@ -39,7 +39,7 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet { if (t != null) { t.insulin = deliveredInsulin; EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); - bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), deliveredInsulin); + bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), deliveredInsulin); bolusingEvent.t = t; bolusingEvent.percent = Math.min((int) (deliveredInsulin / amount * 100), 100); done = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java index 5354836375..34621d07ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java @@ -39,7 +39,7 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet { lastReceive = System.currentTimeMillis(); t.insulin = deliveredInsulin; EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); - bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), deliveredInsulin); + bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), deliveredInsulin); bolusingEvent.t = t; bolusingEvent.percent = Math.min((int) (deliveredInsulin / amount * 100), 100); MainApp.bus().post(bolusingEvent); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java index 2901c4b863..b552026279 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java @@ -433,7 +433,7 @@ public class BLEComm { if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') { log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer)); // Grab pairing key from preferences if exists - String pairingKey = SP.getString(MainApp.sResources.getString(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null); + String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null); log.debug("Using stored pairing key: " + pairingKey); if (pairingKey != null) { byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey); @@ -448,11 +448,11 @@ public class BLEComm { } else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') { log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); - MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.sResources.getString(R.string.pumpbusy))); + MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumpbusy))); } else { log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); - MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.sResources.getString(R.string.connectionerror))); + MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.connectionerror))); } break; // 2nd packet, pairing key @@ -480,7 +480,7 @@ public class BLEComm { SendTimeInfo(); byte[] pairingKey = {inputBuffer[2], inputBuffer[3]}; // store pairing key to preferences - SP.putString(MainApp.sResources.getString(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)); + SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)); log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)); break; // time and user password information. last packet in handshake diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java index 91859c759a..a6afd0aeb0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java @@ -123,19 +123,19 @@ public class DanaRSService extends Service { 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))); bleComm.sendMessage(new DanaRS_Packet_General_Initial_Screen_Information()); - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus))); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State()); - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus))); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus))); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State()); long now = System.currentTimeMillis(); if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) { - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpsettings))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); // serial no bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check()); // firmware bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number()); @@ -143,7 +143,7 @@ public class DanaRSService extends Service { bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information()); // target bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array()); - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumptime))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; log.debug("Pump time difference: " + timeDiff + " seconds"); @@ -165,9 +165,9 @@ public class DanaRSService extends Service { NSUpload.uploadDeviceStatus(); if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.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) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U"); + NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U"); } } catch (Exception e) { log.error("Unhandled exception", e); @@ -202,7 +202,7 @@ public class DanaRSService extends Service { if (!isConnected()) return false; if (BolusProgressDialog.stopPressed) return false; - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus))); bolusingTreatment = t; final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed); @@ -258,7 +258,7 @@ public class DanaRSService extends Service { long expectedEnd = bolusStart + bolusDurationInMSec + 2000; while (System.currentTimeMillis() < expectedEnd) { long waitTime = expectedEnd - System.currentTimeMillis(); - bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + bolusingEvent.status = String.format(MainApp.gs(R.string.waitingforestimatedbolusend), waitTime / 1000); MainApp.bus().post(bolusingEvent); SystemClock.sleep(1000); } @@ -267,10 +267,10 @@ public class DanaRSService extends Service { @Override public void run() { // reread bolus status - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus))); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus bolusingEvent.percent = 100; - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting))); } }); return !start.failed; @@ -295,11 +295,11 @@ public class DanaRSService extends Service { public boolean tempBasal(Integer percent, int durationInHours) { if (!isConnected()) return false; if (danaRPump.isTempBasalInProgress) { - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal()); SystemClock.sleep(500); } - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(percent, durationInHours)); SystemClock.sleep(200); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State()); @@ -310,11 +310,11 @@ public class DanaRSService extends Service { public boolean highTempBasal(Integer percent) { if (danaRPump.isTempBasalInProgress) { - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal()); SystemClock.sleep(500); } - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent)); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State()); loadEvents(); @@ -343,7 +343,7 @@ public class DanaRSService extends Service { 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))); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal()); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State()); loadEvents(); @@ -353,7 +353,7 @@ public class DanaRSService extends Service { 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))); bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus(insulin, durationInHalfHours)); SystemClock.sleep(200); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State()); @@ -364,7 +364,7 @@ public class DanaRSService extends Service { 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))); bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel()); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State()); loadEvents(); @@ -374,7 +374,7 @@ public class DanaRSService extends Service { public boolean updateBasalsInPump(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); DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal); bleComm.sendMessage(msgSet); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java index 9117ad1c98..0869844a1c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java @@ -39,7 +39,7 @@ public class MsgCheckValue_v2 extends MessageBase { pump.productCode = intFromBuff(bytes, 2, 1); if (pump.model != DanaRPump.EXPORT_MODEL) { pump.lastConnection = 0; - Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL); + Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); log.debug("Wrong model selected. Switching to Korean DanaR"); @@ -64,7 +64,7 @@ public class MsgCheckValue_v2 extends MessageBase { if (pump.protocol != 2) { pump.lastConnection = 0; - Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL); + Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); log.debug("Wrong model selected. Switching to non APS DanaR"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java index ac31d2df92..05c4087dcb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java @@ -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)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 25cac9da1c..b9eb8ae655 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -120,7 +120,7 @@ public class DanaRv2ExecutionService 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; } @@ -161,7 +161,7 @@ public class DanaRv2ExecutionService 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 statusMsg = new MsgStatus(); MsgStatusBasic statusBasicMsg = new MsgStatusBasic(); MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2(); @@ -175,17 +175,17 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } } - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus))); 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); long now = System.currentTimeMillis(); if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRv2Plugin.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 MsgSettingActiveProfile()); mSerialIOThread.sendMessage(new MsgSettingMeal()); @@ -196,7 +196,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(new MsgSettingActiveProfile()); mSerialIOThread.sendMessage(new MsgSettingProfileRatios()); mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll()); - 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"); @@ -218,9 +218,9 @@ public class DanaRv2ExecutionService 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); @@ -231,11 +231,11 @@ public class DanaRv2ExecutionService 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_v2()); loadEvents(); @@ -246,11 +246,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { public boolean highTempBasal(int percent) { 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 MsgSetAPSTempBasalStart_v2(percent)); mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2()); loadEvents(); @@ -280,7 +280,7 @@ public class DanaRv2ExecutionService 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_v2()); loadEvents(); @@ -290,7 +290,7 @@ public class DanaRv2ExecutionService 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_v2()); loadEvents(); @@ -300,7 +300,7 @@ public class DanaRv2ExecutionService 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_v2()); loadEvents(); @@ -312,7 +312,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { if (!isConnected()) return false; if (BolusProgressDialog.stopPressed) return false; - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus))); mBolusingTreatment = t; final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); MessageBase start; @@ -371,7 +371,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { long expectedEnd = bolusStart + bolusDurationInMSec + 2000; while (System.currentTimeMillis() < expectedEnd) { long waitTime = expectedEnd - System.currentTimeMillis(); - bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + bolusingEvent.status = String.format(MainApp.gs(R.string.waitingforestimatedbolusend), waitTime / 1000); MainApp.bus().post(bolusingEvent); SystemClock.sleep(1000); } @@ -380,10 +380,10 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { @Override public void run() { // load last bolus status - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus))); mSerialIOThread.sendMessage(new MsgStatus()); bolusingEvent.percent = 100; - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting))); } }); return !start.failed; @@ -442,7 +442,7 @@ public class DanaRv2ExecutionService 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); MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal); mSerialIOThread.sendMessage(msgSet); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java index c0e53ddaac..824a449f38 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java @@ -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; } @@ -395,7 +395,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai result.bolusDelivered = detailedBolusInfo.insulin; result.carbsDelivered = detailedBolusInfo.carbs; result.enacted = result.bolusDelivered > 0 || result.carbsDelivered > 0; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); result.percent = 100; @@ -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; @@ -796,7 +796,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai } private String gs(int id) { - return MainApp.instance().getString(id); + return MainApp.gs(id); } private boolean isPumpRunning() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java index 6a380067e4..82b6cc3cc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java @@ -95,7 +95,7 @@ public class Connector { } else { log("PROTOCOL VERSION MISMATCH! local: " + COMPATIBILITY_VERSION + " remote: " + remoteVersion); statusCallback.onStatusChange(Status.INCOMPATIBLE, 0, 0); - compatabilityMessage = gs(R.string.insight_incompatible_compantion_app_we_need_version) + " " + getLocalVersion(); + compatabilityMessage = MainApp.gs(R.string.insight_incompatible_compantion_app_we_need_version) + " " + getLocalVersion(); serviceConnector.disconnectFromService(); } @@ -179,33 +179,29 @@ public class Connector { switch (status) { case EXCHANGING_KEYS: - return gs(R.string.connecting).toUpperCase(); + return MainApp.gs(R.string.connecting).toUpperCase(); case WAITING_FOR_CODE_CONFIRMATION: - return gs(R.string.insight_waiting_for_code).toUpperCase(); + return MainApp.gs(R.string.insight_waiting_for_code).toUpperCase(); case CODE_REJECTED: - return gs(R.string.insight_code_rejected).toUpperCase(); + return MainApp.gs(R.string.insight_code_rejected).toUpperCase(); case APP_BINDING: - return gs(R.string.insight_app_binding).toUpperCase(); + return MainApp.gs(R.string.insight_app_binding).toUpperCase(); case CONNECTING: - return gs(R.string.connecting).toUpperCase(); + return MainApp.gs(R.string.connecting).toUpperCase(); case CONNECTED: - return gs(R.string.connected).toUpperCase(); + return MainApp.gs(R.string.connected).toUpperCase(); case DISCONNECTED: - return gs(R.string.disconnected).toUpperCase(); + return MainApp.gs(R.string.disconnected).toUpperCase(); case NOT_AUTHORIZED: - return gs(R.string.insight_not_authorized).toUpperCase(); + return MainApp.gs(R.string.insight_not_authorized).toUpperCase(); case INCOMPATIBLE: - return gs(R.string.insight_incompatible).toUpperCase(); + return MainApp.gs(R.string.insight_incompatible).toUpperCase(); default: return status.toString(); } } - private static String gs(int id) { - return MainApp.instance().getString(id); - } - private static synchronized void extendKeepAliveIfActive() { if (keepAliveActive()) { if (Helpers.ratelimit("extend-insight-keepalive", 10)) { @@ -221,7 +217,7 @@ public class Connector { public static String getKeepAliveString() { if (keepAliveActive()) { - return MainApp.instance().getString(R.string.insight_keepalive_format_string, + return MainApp.gs(R.string.insight_keepalive_format_string, stayConnectedTime / 1000, Helpers.hourMinuteSecondString(stayConnectedTill)); } else { @@ -384,7 +380,7 @@ public class Connector { public String getLastStatusMessage() { if (!companionAppInstalled) { - return gs(R.string.insight_companion_app_not_installed); + return MainApp.gs(R.string.insight_companion_app_not_installed); } if (!isConnected()) { @@ -398,13 +394,13 @@ public class Connector { // if disconnected but previous state was incompatible return compatabilityMessage; } else { - return gs(R.string.insight_not_connected_to_companion_app); + return MainApp.gs(R.string.insight_not_connected_to_companion_app); } } } if (lastStatus == null) { - return gs(R.string.insight_unknown); + return MainApp.gs(R.string.insight_unknown); } switch (lastStatus) { @@ -414,16 +410,16 @@ public class Connector { } break; case INCOMPATIBLE: - return statusToString(lastStatus) + " " + gs(R.string.insight_needs) + " " + getLocalVersion(); + return statusToString(lastStatus) + " " + MainApp.gs(R.string.insight_needs) + " " + getLocalVersion(); } return statusToString(lastStatus); } public String getNiceLastStatusTime() { if (lastStatusTime < 1) { - return gs(R.string.insight_startup_uppercase); + return MainApp.gs(R.string.insight_startup_uppercase); } else { - return Helpers.niceTimeScalar(Helpers.msSince(lastStatusTime)) + " " + gs(R.string.ago); + return Helpers.niceTimeScalar(Helpers.msSince(lastStatusTime)) + " " + MainApp.gs(R.string.ago); } } @@ -516,7 +512,7 @@ public class Connector { } for (Map.Entry entry : statistics.entrySet()) { if ((long) entry.getValue() > 1000) { - l.add(new StatusItem(gs(R.string.statistics) + " " + Helpers.capitalize(entry.getKey().toString()), + l.add(new StatusItem(MainApp.gs(R.string.statistics) + " " + Helpers.capitalize(entry.getKey().toString()), new Formatter().format("%4s %12s", percentage(getEntryTime(entry), total) + "%", Helpers.niceTimeScalar(getEntryTime(entry))).toString())); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java index 244537af3e..e7784287b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java @@ -161,7 +161,7 @@ class HistoryIntentAdapter { Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME); String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE); if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return; - logNote(date, MainApp.instance().getString(getAlertText(alertType))); + logNote(date, MainApp.gs(getAlertText(alertType))); } } @@ -171,13 +171,13 @@ class HistoryIntentAdapter { String newStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_NEW_STATUS); switch (newStatus) { case "STARTED": - logNote(newStatusTime, MainApp.instance().getString(R.string.pump_started)); + logNote(newStatusTime, MainApp.gs(R.string.pump_started)); break; case "STOPPED": - logNote(newStatusTime, MainApp.instance().getString(R.string.pump_stopped)); + logNote(newStatusTime, MainApp.gs(R.string.pump_stopped)); break; case "PAUSED": - logNote(newStatusTime, MainApp.instance().getString(R.string.pump_paused)); + logNote(newStatusTime, MainApp.gs(R.string.pump_paused)); break; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java index efce8d7a40..ca68a389c8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java @@ -131,7 +131,7 @@ public class HistoryReceiver { @Override public String toString() { - return MainApp.instance().getString(string_id); + return MainApp.gs(string_id); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java index ca3848e113..46af6bda98 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java @@ -17,7 +17,7 @@ public class LiveHistory { public static String getStatus() { if (status.equals("")) return status; - return status + " " + Helpers.niceTimeScalar(Helpers.msSince(status_time)) + " " + gs(R.string.ago); + return status + " " + Helpers.niceTimeScalar(Helpers.msSince(status_time)) + " " + MainApp.gs(R.string.ago); } public static long getStatusTime() { @@ -30,8 +30,4 @@ public class LiveHistory { status = mystatus; } } - - private static String gs(int id) { - return MainApp.instance().getString(id); - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java index a2abda40d7..344bf638b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java @@ -96,32 +96,28 @@ public class Helpers { } public static String niceTimeScalar(long t) { - String unit = gs(R.string.second); + String unit = MainApp.gs(R.string.second); t = t / 1000; if (t > 59) { - unit = gs(R.string.minute); + unit = MainApp.gs(R.string.minute); t = t / 60; if (t > 59) { - unit = gs(R.string.hour); + unit = MainApp.gs(R.string.hour); t = t / 60; if (t > 24) { - unit = gs(R.string.day); + unit = MainApp.gs(R.string.day); t = t / 24; if (t > 28) { - unit = gs(R.string.week); + unit = MainApp.gs(R.string.week); t = t / 7; } } } } - if (t != 1) unit = unit + gs(R.string.time_plural); + if (t != 1) unit = unit + MainApp.gs(R.string.time_plural); return qs((double) t, 0) + " " + unit; } - private static String gs(int id) { - return MainApp.instance().getString(id); - } - public static String qs(double x, int digits) { if (digits == -1) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java index 9c19a383ae..fed0c01c64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java @@ -134,7 +134,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { result.success = true; result.bolusDelivered = detailedBolusInfo.insulin; result.carbsDelivered = detailedBolusInfo.carbs; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo); return result; } @@ -147,7 +147,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) { PumpEnactResult result = new PumpEnactResult(); result.success = false; - result.comment = MainApp.instance().getString(R.string.pumperror); + result.comment = MainApp.gs(R.string.pumperror); if (Config.logPumpComm) log.debug("Setting temp basal absolute: " + result); return result; @@ -157,7 +157,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) { PumpEnactResult result = new PumpEnactResult(); result.success = false; - result.comment = MainApp.instance().getString(R.string.pumperror); + result.comment = MainApp.gs(R.string.pumperror); if (Config.logPumpComm) log.debug("Settings temp basal percent: " + result); return result; @@ -167,7 +167,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { PumpEnactResult result = new PumpEnactResult(); result.success = false; - result.comment = MainApp.instance().getString(R.string.pumperror); + result.comment = MainApp.gs(R.string.pumperror); if (Config.logPumpComm) log.debug("Setting extended bolus: " + result); return result; @@ -177,7 +177,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { public PumpEnactResult cancelTempBasal(boolean force) { PumpEnactResult result = new PumpEnactResult(); result.success = false; - result.comment = MainApp.instance().getString(R.string.pumperror); + result.comment = MainApp.gs(R.string.pumperror); if (Config.logPumpComm) log.debug("Cancel temp basal: " + result); return result; @@ -187,7 +187,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { public PumpEnactResult cancelExtendedBolus() { PumpEnactResult result = new PumpEnactResult(); result.success = false; - result.comment = MainApp.instance().getString(R.string.pumperror); + result.comment = MainApp.gs(R.string.pumperror); if (Config.logPumpComm) log.debug("Canceling extended basal: " + result); return result; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index 0491ce0f74..34d3fee80b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -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; } @@ -202,21 +202,21 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.bolusDelivered = detailedBolusInfo.insulin; result.carbsDelivered = detailedBolusInfo.carbs; result.enacted = result.bolusDelivered > 0 || result.carbsDelivered > 0; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); Double delivering = 0d; 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); @@ -246,7 +246,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.isTempCancel = false; result.absolute = absoluteRate; result.duration = durationInMinutes; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal); if (Config.logPumpComm) log.debug("Setting temp basal absolute: " + result); @@ -274,7 +274,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.isPercent = true; result.isTempCancel = false; result.duration = durationInMinutes; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal); if (Config.logPumpComm) log.debug("Settings temp basal percent: " + result); @@ -298,7 +298,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.bolusDelivered = insulin; result.isTempCancel = false; result.duration = durationInMinutes; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); if (Config.logPumpComm) log.debug("Setting extended bolus: " + result); @@ -312,7 +312,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { PumpEnactResult result = new PumpEnactResult(); result.success = true; result.isTempCancel = true; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) { result.enacted = true; TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER); @@ -337,7 +337,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.success = true; result.enacted = true; result.isTempCancel = true; - result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); + result.comment = MainApp.gs(R.string.virtualpump_resultok); if (Config.logPumpComm) log.debug("Canceling extended basal: " + result); MainApp.bus().post(new EventVirtualPumpUpdateGui()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java index 28c4192f99..75b1ea9675 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java @@ -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(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java index 2f59769f55..58f59701d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java @@ -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) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index a0192a528c..9de6cc6ad6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -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)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java index 7e959b78d4..3e9a79d459 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java @@ -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; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java index ae977d4024..57ad6833a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java @@ -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; } @@ -204,16 +204,16 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View. switch (view.getId()) { case R.id.treatments_reshreshfromnightscout: AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); - builder.setTitle(this.getContext().getString(R.string.confirmation)); - builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?"); - builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setTitle(MainApp.gs(R.string.confirmation)); + builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + "?"); + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { TreatmentsPlugin.getPlugin().getService().resetTreatments(); Intent restartNSClient = new Intent(Intents.ACTION_RESTART); MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); } }); - builder.setNegativeButton(this.getContext().getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java index 7218198b43..97c3a05274 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java @@ -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; } @@ -157,16 +157,16 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements switch (view.getId()) { case R.id.careportal_refreshfromnightscout: AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); - builder.setTitle(this.getContext().getString(R.string.confirmation)); - builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + " ?"); - builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setTitle(MainApp.gs(R.string.confirmation)); + builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + " ?"); + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MainApp.getDbHelper().resetCareportalEvents(); Intent restartNSClient = new Intent(Intents.ACTION_RESTART); MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); } }); - builder.setNegativeButton(this.getContext().getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java index c8fc539d02..05e18bfdc3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java @@ -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; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java index 8a6b0456f5..307f9c8ee6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java @@ -131,9 +131,9 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen switch (v.getId()) { case R.id.profileswitch_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(profileSwitch.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(profileSwitch.date)); + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final String _id = profileSwitch._id; if (NSUpload.isIdValid(_id)) { @@ -144,7 +144,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen MainApp.getDbHelper().delete(profileSwitch); } }); - builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; case R.id.profileswitch_date: @@ -190,16 +190,16 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen switch (view.getId()) { case R.id.profileswitch_refreshfromnightscout: AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); - builder.setTitle(this.getContext().getString(R.string.confirmation)); - builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?"); - builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setTitle(MainApp.gs(R.string.confirmation)); + builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + "?"); + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MainApp.getDbHelper().resetProfileSwitch(); Intent restartNSClient = new Intent(Intents.ACTION_RESTART); MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); } }); - builder.setNegativeButton(this.getContext().getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java index 5ce79636b5..df67349839 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java @@ -140,9 +140,9 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements switch (v.getId()) { case R.id.temptargetrange_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(tempTarget.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(tempTarget.date)); + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final String _id = tempTarget._id; if (NSUpload.isIdValid(_id)) { @@ -153,7 +153,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements MainApp.getDbHelper().delete(tempTarget); } }); - builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; } @@ -192,16 +192,16 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements switch (view.getId()) { case R.id.temptargetrange_refreshfromnightscout: AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); - builder.setTitle(this.getContext().getString(R.string.confirmation)); - builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + " ?"); - builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { + builder.setTitle(MainApp.gs(R.string.confirmation)); + builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + " ?"); + builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MainApp.getDbHelper().resetTempTargets(); Intent restartNSClient = new Intent(Intents.ACTION_RESTART); MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); } }); - builder.setNegativeButton(this.getContext().getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index fdc14f32d4..aca5100fb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -95,9 +95,9 @@ public class ActionStringHandler { return; } Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value(); - rMessage += MainApp.instance().getString(R.string.primefill) + ": " + insulinAfterConstraints + "U"; + rMessage += MainApp.gs(R.string.primefill) + ": " + insulinAfterConstraints + "U"; if (insulinAfterConstraints - amount != 0) - rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied); + rMessage += "\n" + MainApp.gs(R.string.constraintapllied); rAction += "fill " + insulinAfterConstraints; @@ -106,9 +106,9 @@ public class ActionStringHandler { double amount = SafeParse.stringToDouble(act[1]); Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value(); - rMessage += MainApp.instance().getString(R.string.primefill) + ": " + insulinAfterConstraints + "U"; + rMessage += MainApp.gs(R.string.primefill) + ": " + insulinAfterConstraints + "U"; if (insulinAfterConstraints - amount != 0) - rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied); + rMessage += "\n" + MainApp.gs(R.string.constraintapllied); rAction += "fill " + insulinAfterConstraints; @@ -118,11 +118,11 @@ public class ActionStringHandler { int carbs = SafeParse.stringToInt(act[2]); Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value(); Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbs)).value(); - rMessage += MainApp.instance().getString(R.string.bolus) + ": " + insulinAfterConstraints + "U\n"; - rMessage += MainApp.instance().getString(R.string.carbs) + ": " + carbsAfterConstraints + "g"; + rMessage += MainApp.gs(R.string.bolus) + ": " + insulinAfterConstraints + "U\n"; + rMessage += MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g"; if ((insulinAfterConstraints - insulin != 0) || (carbsAfterConstraints - carbs != 0)) { - rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied); + rMessage += "\n" + MainApp.gs(R.string.constraintapllied); } rAction += "bolus " + insulinAfterConstraints + " " + carbsAfterConstraints; @@ -283,7 +283,7 @@ public class ActionStringHandler { //if pump is not busy: try to fetch data final PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); if (pump.isBusy()) { - rMessage += MainApp.instance().getString(R.string.pumpbusy); + rMessage += MainApp.gs(R.string.pumpbusy); } else { rMessage += "trying to fetch data from pump."; @@ -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); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index dcda0bc0aa..7282ac0763 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -158,7 +158,7 @@ public class WearPlugin extends PluginBase { @Subscribe public void onStatusEvent(final EventBolusRequested ev) { - String status = String.format(MainApp.sResources.getString(R.string.bolusrequested), ev.getAmount()); + String status = String.format(MainApp.gs(R.string.bolusrequested), ev.getAmount()); Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS); intent.putExtra("progresspercent", 0); intent.putExtra("progressstatus", status); @@ -172,9 +172,9 @@ public class WearPlugin extends PluginBase { String status; if (ev.result.success) { - status = MainApp.sResources.getString(R.string.success); + status = MainApp.gs(R.string.success); } else { - status = MainApp.sResources.getString(R.string.nosuccess); + status = MainApp.gs(R.string.nosuccess); } Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS); intent.putExtra("progresspercent", 100); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 705bae47a7..db26cdec65 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -213,7 +213,7 @@ public class WatchUpdaterService extends WearableListenerService implements final DataMap dataMap = dataMapSingleBG(lastBG, glucoseStatus); if (dataMap == null) { - ToastUtils.showToastInUiThread(this, getString(R.string.noprofile)); + ToastUtils.showToastInUiThread(this, MainApp.gs(R.string.noprofile)); return; } @@ -330,7 +330,7 @@ public class WatchUpdaterService extends WearableListenerService implements if (!graph_bgs.isEmpty()) { DataMap entries = dataMapSingleBG(last_bg, glucoseStatus); if (entries == null) { - ToastUtils.showToastInUiThread(this, getString(R.string.noprofile)); + ToastUtils.showToastInUiThread(this, MainApp.gs(R.string.noprofile)); return; } final ArrayList dataMaps = new ArrayList<>(graph_bgs.size()); @@ -579,7 +579,7 @@ public class WatchUpdaterService extends WearableListenerService implements if (googleApiClient.isConnected()) { Profile profile = MainApp.getConfigBuilder().getProfile(); - String status = MainApp.instance().getString(R.string.noprofile); + String status = MainApp.gs(R.string.noprofile); String iobSum, iobDetail, cobString, currentBasal, bgiString; iobSum = iobDetail = cobString = currentBasal = bgiString = ""; if (profile != null) { @@ -662,14 +662,14 @@ 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; } LoopPlugin activeloop = LoopPlugin.getPlugin(); if (!activeloop.isEnabled(PluginType.LOOP)) { - status += getString(R.string.disabledloop) + "\n"; + status += MainApp.gs(R.string.disabledloop) + "\n"; lastLoopStatus = false; } else { lastLoopStatus = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java index 426acbe6ca..03c6c48a1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java @@ -113,7 +113,7 @@ public class StatuslinePlugin extends PluginBase { LoopPlugin loopPlugin = LoopPlugin.getPlugin(); if (!loopPlugin.isEnabled(PluginType.LOOP)) { - status += ctx.getString(R.string.disabledloop) + "\n"; + status += MainApp.gs(R.string.disabledloop) + "\n"; lastLoopStatus = false; } else if (loopPlugin.isEnabled(PluginType.LOOP)) { lastLoopStatus = true; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index 93b6f99db0..9085e3f762 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -81,7 +81,7 @@ public class CommandQueue { private QueueThread thread = null; private PumpEnactResult executingNowError() { - return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.executingrightnow)); + return new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.executingrightnow)); } public boolean isRunning(Command.CommandType type) { @@ -314,10 +314,10 @@ public class CommandQueue { } if (!MainApp.isEngineeringModeOrRelease()) { - Notification notification = new Notification(Notification.NOT_ENG_MODE_OR_RELEASE, MainApp.sResources.getString(R.string.not_eng_mode_or_release), Notification.URGENT); + Notification notification = new Notification(Notification.NOT_ENG_MODE_OR_RELEASE, MainApp.gs(R.string.not_eng_mode_or_release), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); if (callback != null) - callback.result(new PumpEnactResult().success(false).comment(MainApp.sResources.getString(R.string.not_eng_mode_or_release))).run(); + callback.result(new PumpEnactResult().success(false).comment(MainApp.gs(R.string.not_eng_mode_or_release))).run(); return false; } @@ -327,10 +327,10 @@ public class CommandQueue { for (Profile.BasalValue basalValue : basalValues) { if (basalValue.value < pump.getPumpDescription().basalMinimumRate) { - Notification notification = new Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, MainApp.sResources.getString(R.string.basalvaluebelowminimum), Notification.URGENT); + Notification notification = new Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, MainApp.gs(R.string.basalvaluebelowminimum), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); if (callback != null) - callback.result(new PumpEnactResult().success(false).comment(MainApp.sResources.getString(R.string.basalvaluebelowminimum))).run(); + callback.result(new PumpEnactResult().success(false).comment(MainApp.gs(R.string.basalvaluebelowminimum))).run(); return false; } } diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java index 8ec61932c8..a5ad59ca0b 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java @@ -55,7 +55,7 @@ public class QueueThread extends Thread { PumpInterface pump = ConfigBuilderPlugin.getActivePump(); if (pump == null) { log.debug("QUEUE: pump == null"); - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.pumpNotInitialized))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.pumpNotInitialized))); SystemClock.sleep(1000); continue; } @@ -63,7 +63,7 @@ public class QueueThread extends Thread { if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) { MainApp.bus().post(new EventDismissBolusprogressIfRunning(null)); - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout))); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.connectiontimedout))); log.debug("QUEUE: timed out"); pump.stopConnecting(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java index 8a8bc41dfa..03764dee0b 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java @@ -47,7 +47,7 @@ public class CommandSetProfile extends Command { if (r.enacted && profileSwitch.source == Source.NIGHTSCOUT) { SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class); if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) { - smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok)); + smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.gs(R.string.profile_set_ok)); } } } diff --git a/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java b/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java index b8eb49e98e..c2fbbf581e 100644 --- a/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java +++ b/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java @@ -33,7 +33,7 @@ import info.nightscout.androidaps.events.EventAppExit; public class ImportExportPrefs { private static Logger log = LoggerFactory.getLogger(ImportExportPrefs.class); static File path = new File(Environment.getExternalStorageDirectory().toString()); - static final File file = new File(path, MainApp.sResources.getString(R.string.app_name) + "Preferences"); + static final File file = new File(path, MainApp.gs(R.string.app_name) + "Preferences"); private static final int REQUEST_EXTERNAL_STORAGE = 1; private static String[] PERMISSIONS_STORAGE = { @@ -59,7 +59,7 @@ public class ImportExportPrefs { public static void exportSharedPreferences(final Activity c) { new AlertDialog.Builder(c) - .setMessage(MainApp.sResources.getString(R.string.export_to) + " " + file + " ?") + .setMessage(MainApp.gs(R.string.export_to) + " " + file + " ?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { @@ -73,9 +73,9 @@ public class ImportExportPrefs { } pw.close(); fw.close(); - ToastUtils.showToastInUiThread(c, MainApp.sResources.getString(R.string.exported)); + ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.exported)); } catch (FileNotFoundException e) { - ToastUtils.showToastInUiThread(c, MainApp.sResources.getString(R.string.filenotfound) + " " + file); + ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.filenotfound) + " " + file); log.error("Unhandled exception", e); } catch (IOException e) { log.error("Unhandled exception", e); @@ -88,7 +88,7 @@ public class ImportExportPrefs { public static void importSharedPreferences(final Activity c) { new AlertDialog.Builder(c) - .setMessage(MainApp.sResources.getString(R.string.import_from) + " " + file + " ?") + .setMessage(MainApp.gs(R.string.import_from) + " " + file + " ?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { @@ -113,7 +113,7 @@ public class ImportExportPrefs { } reader.close(); editor.commit(); - OKDialog.show(c, MainApp.sResources.getString(R.string.setting_imported), MainApp.sResources.getString(R.string.restartingapp), new Runnable() { + OKDialog.show(c, MainApp.gs(R.string.setting_imported), MainApp.gs(R.string.restartingapp), new Runnable() { @Override public void run() { log.debug("Exiting"); @@ -126,7 +126,7 @@ public class ImportExportPrefs { } }); } catch (FileNotFoundException e) { - ToastUtils.showToastInUiThread(c, MainApp.sResources.getString(R.string.filenotfound) + " " + file); + ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.filenotfound) + " " + file); log.error("Unhandled exception", e); } catch (IOException e) { log.error("Unhandled exception", e); diff --git a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java index cc1a22355a..5556cae935 100644 --- a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java +++ b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java @@ -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)); diff --git a/app/src/main/java/info/nightscout/utils/LogDialog.java b/app/src/main/java/info/nightscout/utils/LogDialog.java index b98582c05f..7e2468774e 100644 --- a/app/src/main/java/info/nightscout/utils/LogDialog.java +++ b/app/src/main/java/info/nightscout/utils/LogDialog.java @@ -25,7 +25,7 @@ public class LogDialog { String logCat = "no logs"; final String processId = Integer.toString(android.os.Process.myPid()); try { - Process process = Runtime.getRuntime().exec("logcat -d " + MainApp.sResources.getString(R.string.app_name) + ":D"); + Process process = Runtime.getRuntime().exec("logcat -d " + MainApp.gs(R.string.app_name) + ":D"); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); StringBuilder log = new StringBuilder(); String line; @@ -46,11 +46,11 @@ public class LogDialog { try { AlertDialog alertDialog = new AlertDialog.Builder(context) .setMessage(msg) - .setPositiveButton(MainApp.sResources.getString(R.string.copy_to_clipboard), new DialogInterface.OnClickListener() { + .setPositiveButton(MainApp.gs(R.string.copy_to_clipboard), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText(null, msg)); - ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.copied_to_clipboard)); + ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.copied_to_clipboard)); } }) .setNegativeButton(android.R.string.cancel, null) diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java index 3cd252f19a..2e5506f9c6 100644 --- a/app/src/main/java/info/nightscout/utils/NSUpload.java +++ b/app/src/main/java/info/nightscout/utils/NSUpload.java @@ -55,7 +55,7 @@ public class NSUpload { if (temporaryBasal.pumpId != 0) data.put("pumpId", temporaryBasal.pumpId); data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); - data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); if (originalExtendedAmount != null) data.put("originalExtendedAmount", originalExtendedAmount); // for back synchronization Bundle bundle = new Bundle(); @@ -93,7 +93,7 @@ public class NSUpload { if (temporaryBasal.pumpId != 0) data.put("pumpId", temporaryBasal.pumpId); data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); - data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); Bundle bundle = new Bundle(); bundle.putString("action", "dbAdd"); bundle.putString("collection", "treatments"); @@ -115,7 +115,7 @@ public class NSUpload { JSONObject data = new JSONObject(); data.put("eventType", CareportalEvent.TEMPBASAL); data.put("created_at", DateUtil.toISOString(time)); - data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); if (isFakedTempBasal) data.put("isFakedTempBasal", isFakedTempBasal); if (pumpId != 0) @@ -147,7 +147,7 @@ public class NSUpload { if (extendedBolus.pumpId != 0) data.put("pumpId", extendedBolus.pumpId); data.put("created_at", DateUtil.toISOString(extendedBolus.date)); - data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); Bundle bundle = new Bundle(); bundle.putString("action", "dbAdd"); bundle.putString("collection", "treatments"); @@ -173,7 +173,7 @@ public class NSUpload { data.put("enteredinsulin", 0); data.put("relative", 0); data.put("created_at", DateUtil.toISOString(time)); - data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); if (pumpId != 0) data.put("pumpId", pumpId); Bundle bundle = new Bundle(); @@ -301,7 +301,7 @@ public class NSUpload { data.put("percentage", profileSwitch.percentage); } data.put("created_at", DateUtil.toISOString(profileSwitch.date)); - data.put("enteredBy", MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", MainApp.gs(R.string.app_name)); uploadCareportalEntryToNS(data); } catch (JSONException e) { log.error("Unhandled exception", e); @@ -325,7 +325,7 @@ public class NSUpload { data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits())); data.put("created_at", DateUtil.toISOString(tempTarget.date)); data.put("units", profile.getUnits()); - data.put("enteredBy", MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", MainApp.gs(R.string.app_name)); uploadCareportalEntryToNS(data); } catch (JSONException e) { log.error("Unhandled exception", e); @@ -346,7 +346,7 @@ public class NSUpload { data.put("percentage", profileSwitch.percentage); } data.put("created_at", DateUtil.toISOString(profileSwitch.date)); - data.put("enteredBy", MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", MainApp.gs(R.string.app_name)); if (profileSwitch._id != null) { Context context = MainApp.instance().getApplicationContext(); Bundle bundle = new Bundle(); @@ -420,7 +420,7 @@ public class NSUpload { data.put("eventType", "OpenAPS Offline"); data.put("duration", durationInMinutes); data.put("created_at", DateUtil.toISOString(new Date())); - data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name)); + data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); Bundle bundle = new Bundle(); bundle.putString("action", "dbAdd"); bundle.putString("collection", "treatments"); @@ -496,7 +496,7 @@ public class NSUpload { try { data.put("eventType", "Note"); data.put("created_at", DateUtil.toISOString(new Date())); - data.put("notes", MainApp.sResources.getString(R.string.androidaps_start)+" - "+ Build.MANUFACTURER + " "+ Build.MODEL); + data.put("notes", MainApp.gs(R.string.androidaps_start)+" - "+ Build.MANUFACTURER + " "+ Build.MODEL); } catch (JSONException e) { log.error("Unhandled exception", e); } diff --git a/app/src/main/java/info/nightscout/utils/NumberPicker.java b/app/src/main/java/info/nightscout/utils/NumberPicker.java index 64239cbaee..102abedc7d 100644 --- a/app/src/main/java/info/nightscout/utils/NumberPicker.java +++ b/app/src/main/java/info/nightscout/utils/NumberPicker.java @@ -199,7 +199,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener, value += step * multiplier; if (value > maxValue) { value = maxValue; - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.youareonallowedlimit)); stopUpdating(); } updateEditText(); @@ -209,7 +209,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener, value -= step * multiplier; if (value < minValue) { value = minValue; - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.youareonallowedlimit)); stopUpdating(); } updateEditText(); diff --git a/app/src/main/java/info/nightscout/utils/OKDialog.java b/app/src/main/java/info/nightscout/utils/OKDialog.java index 3212e6b1fd..5185049678 100644 --- a/app/src/main/java/info/nightscout/utils/OKDialog.java +++ b/app/src/main/java/info/nightscout/utils/OKDialog.java @@ -25,7 +25,7 @@ public class OKDialog { AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme)); builder.setTitle(title); builder.setMessage(message); - 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 which) { dialog.dismiss(); if (runnable != null) { @@ -46,7 +46,7 @@ public class OKDialog { AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme)); builder.setTitle(title); builder.setMessage(message); - 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 which) { dialog.dismiss(); if (runnable != null) { diff --git a/app/src/main/java/info/nightscout/utils/PasswordProtection.java b/app/src/main/java/info/nightscout/utils/PasswordProtection.java index 1af10eb2d2..2a15dc7311 100644 --- a/app/src/main/java/info/nightscout/utils/PasswordProtection.java +++ b/app/src/main/java/info/nightscout/utils/PasswordProtection.java @@ -37,7 +37,7 @@ public class PasswordProtection { alertDialogBuilder.setView(promptsView); final TextView label = (TextView) promptsView.findViewById(R.id.passwordprompt_text); - label.setText(MainApp.sResources.getString(stringID)); + label.setText(MainApp.gs(stringID)); final EditText userInput = (EditText) promptsView.findViewById(R.id.passwordprompt_pass); // set dialog message @@ -50,7 +50,7 @@ public class PasswordProtection { if (password.equals(enteredPassword)) { if (ok != null) ok.run(); } else { - ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.wrongpassword)); + ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.wrongpassword)); if (fail != null) fail.run(); } } diff --git a/app/src/main/java/info/nightscout/utils/SP.java b/app/src/main/java/info/nightscout/utils/SP.java index 23a95840a8..eaf84946e6 100644 --- a/app/src/main/java/info/nightscout/utils/SP.java +++ b/app/src/main/java/info/nightscout/utils/SP.java @@ -17,7 +17,7 @@ public class SP { } static public String getString(int resourceID, String defaultValue) { - return sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue); + return sharedPreferences.getString(MainApp.gs(resourceID), defaultValue); } static public String getString(String key, String defaultValue) { @@ -26,7 +26,7 @@ public class SP { static public boolean getBoolean(int resourceID, Boolean defaultValue) { try { - return sharedPreferences.getBoolean(MainApp.sResources.getString(resourceID), defaultValue); + return sharedPreferences.getBoolean(MainApp.gs(resourceID), defaultValue); } catch (Exception e) { return defaultValue; } @@ -41,7 +41,7 @@ public class SP { } static public Double getDouble(int resourceID, Double defaultValue) { - return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString())); + return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString())); } static public Double getDouble(String key, Double defaultValue) { @@ -50,9 +50,9 @@ public class SP { static public int getInt(int resourceID, Integer defaultValue) { try { - return sharedPreferences.getInt(MainApp.sResources.getString(resourceID), defaultValue); + return sharedPreferences.getInt(MainApp.gs(resourceID), defaultValue); } catch (Exception e) { - return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString())); + return SafeParse.stringToInt(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString())); } } @@ -66,9 +66,9 @@ public class SP { static public long getLong(int resourceID, Long defaultValue) { try { - return sharedPreferences.getLong(MainApp.sResources.getString(resourceID), defaultValue); + return sharedPreferences.getLong(MainApp.gs(resourceID), defaultValue); } catch (Exception e) { - return SafeParse.stringToLong(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString())); + return SafeParse.stringToLong(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString())); } } @@ -88,7 +88,7 @@ public class SP { static public void putBoolean(int resourceID, boolean value) { SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putBoolean(MainApp.sResources.getString(resourceID), value); + editor.putBoolean(MainApp.gs(resourceID), value); editor.apply(); } @@ -100,7 +100,7 @@ public class SP { static public void putLong(int resourceID, long value) { SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putLong(MainApp.sResources.getString(resourceID), value); + editor.putLong(MainApp.gs(resourceID), value); editor.apply(); } @@ -112,13 +112,13 @@ public class SP { static public void putInt(int resourceID, int value) { SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putInt(MainApp.sResources.getString(resourceID), value); + editor.putInt(MainApp.gs(resourceID), value); editor.apply(); } static public void putString(int resourceID, String value) { SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(MainApp.sResources.getString(resourceID), value); + editor.putString(MainApp.gs(resourceID), value); editor.apply(); } @@ -130,7 +130,7 @@ public class SP { static public void remove(int resourceID) { SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.remove(MainApp.sResources.getString(resourceID)); + editor.remove(MainApp.gs(resourceID)); editor.apply(); } diff --git a/app/src/main/java/info/nightscout/utils/Translator.java b/app/src/main/java/info/nightscout/utils/Translator.java index 75ee881c21..98fdd32779 100644 --- a/app/src/main/java/info/nightscout/utils/Translator.java +++ b/app/src/main/java/info/nightscout/utils/Translator.java @@ -12,51 +12,51 @@ public class Translator { switch (text) { case "BG Check": - return MainApp.sResources.getString(R.string.careportal_bgcheck); + return MainApp.gs(R.string.careportal_bgcheck); case "Snack Bolus": - return MainApp.sResources.getString(R.string.careportal_snackbolus); + return MainApp.gs(R.string.careportal_snackbolus); case "Meal Bolus": - return MainApp.sResources.getString(R.string.careportal_mealbolus); + return MainApp.gs(R.string.careportal_mealbolus); case "Correction Bolus": - return MainApp.sResources.getString(R.string.careportal_correctionbolus); + return MainApp.gs(R.string.careportal_correctionbolus); case "Carb Correction": - return MainApp.sResources.getString(R.string.careportal_carbscorrection); + return MainApp.gs(R.string.careportal_carbscorrection); case "Combo Bolus": - return MainApp.sResources.getString(R.string.careportal_combobolus); + return MainApp.gs(R.string.careportal_combobolus); case "Announcement": - return MainApp.sResources.getString(R.string.careportal_announcement); + return MainApp.gs(R.string.careportal_announcement); case "Note": - return MainApp.sResources.getString(R.string.careportal_note); + return MainApp.gs(R.string.careportal_note); case "Question": - return MainApp.sResources.getString(R.string.careportal_question); + return MainApp.gs(R.string.careportal_question); case "Exercise": - return MainApp.sResources.getString(R.string.careportal_exercise); + return MainApp.gs(R.string.careportal_exercise); case "Site Change": - return MainApp.sResources.getString(R.string.careportal_pumpsitechange); + return MainApp.gs(R.string.careportal_pumpsitechange); case "Sensor Start": - return MainApp.sResources.getString(R.string.careportal_cgmsensorstart); + return MainApp.gs(R.string.careportal_cgmsensorstart); case "Sensor Change": - return MainApp.sResources.getString(R.string.careportal_cgmsensorinsert); + return MainApp.gs(R.string.careportal_cgmsensorinsert); case "Insulin Change": - return MainApp.sResources.getString(R.string.careportal_insulincartridgechange); + return MainApp.gs(R.string.careportal_insulincartridgechange); case "Temp Basal Start": - return MainApp.sResources.getString(R.string.careportal_tempbasalstart); + return MainApp.gs(R.string.careportal_tempbasalstart); case "Temp Basal End": - return MainApp.sResources.getString(R.string.careportal_tempbasalend); + return MainApp.gs(R.string.careportal_tempbasalend); case "Profile Switch": - return MainApp.sResources.getString(R.string.careportal_profileswitch); + return MainApp.gs(R.string.careportal_profileswitch); case "Temporary Target": - return MainApp.sResources.getString(R.string.careportal_temporarytarget); + return MainApp.gs(R.string.careportal_temporarytarget); case "Temporary Target Cancel": - return MainApp.sResources.getString(R.string.careportal_temporarytargetcancel); + return MainApp.gs(R.string.careportal_temporarytargetcancel); case "OpenAPS Offline": - return MainApp.sResources.getString(R.string.careportal_openapsoffline); + return MainApp.gs(R.string.careportal_openapsoffline); case "Finger": - return MainApp.sResources.getString(R.string.glucosetype_finger); + return MainApp.gs(R.string.glucosetype_finger); case "Sensor": - return MainApp.sResources.getString(R.string.glucosetype_sensor); + return MainApp.gs(R.string.glucosetype_sensor); case "Manual": - return MainApp.sResources.getString(R.string.manual); + return MainApp.gs(R.string.manual); } return text; } diff --git a/app/src/main/java/info/nightscout/utils/XdripCalibrations.java b/app/src/main/java/info/nightscout/utils/XdripCalibrations.java index 662b7a0c8f..66ec6bd3df 100644 --- a/app/src/main/java/info/nightscout/utils/XdripCalibrations.java +++ b/app/src/main/java/info/nightscout/utils/XdripCalibrations.java @@ -28,17 +28,17 @@ public class XdripCalibrations { public static void confirmAndSendCalibration(final Double bg, Context parentContext) { if (parentContext != null) { - String confirmMessage = String.format(MainApp.sResources.getString(R.string.send_calibration), bg); + String confirmMessage = String.format(MainApp.gs(R.string.send_calibration), bg); AlertDialog.Builder builder = new AlertDialog.Builder(parentContext); - builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); + builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setMessage(confirmMessage); - 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) { sendIntent(bg); } }); - builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); + builder.setNegativeButton(MainApp.gs(R.string.cancel), null); builder.show(); } } @@ -55,12 +55,12 @@ public class XdripCalibrations { context.sendBroadcast(intent); List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0); if (q.size() < 1) { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.xdripnotinstalled)); - log.debug(MainApp.sResources.getString(R.string.xdripnotinstalled)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.xdripnotinstalled)); + log.debug(MainApp.gs(R.string.xdripnotinstalled)); return false; } else { - ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.calibrationsent)); - log.debug(MainApp.sResources.getString(R.string.calibrationsent)); + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.calibrationsent)); + log.debug(MainApp.gs(R.string.calibrationsent)); return true; } }