use MainApp.gs instead of getString from Activity/Dialog
This commit is contained in:
parent
4a22fd355d
commit
611d761a41
8 changed files with 41 additions and 41 deletions
|
@ -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(getString(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);
|
||||
}
|
||||
|
@ -406,10 +406,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
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);
|
||||
|
|
|
@ -179,10 +179,10 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
}
|
||||
|
||||
if (pumpSiteChangeCheckbox.isChecked())
|
||||
confirmMessage.add("" + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + getString(R.string.record_pump_site_change) + "</font>");
|
||||
confirmMessage.add("" + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + MainApp.gs(R.string.record_pump_site_change) + "</font>");
|
||||
|
||||
if (insulinCartridgeChangeCheckbox.isChecked())
|
||||
confirmMessage.add("" + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + getString(R.string.record_insulin_cartridge_change) + "</font>");
|
||||
confirmMessage.add("" + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + MainApp.gs(R.string.record_insulin_cartridge_change) + "</font>");
|
||||
|
||||
final String notes = notesEdit.getText().toString();
|
||||
if (!notes.isEmpty()) {
|
||||
|
|
|
@ -68,13 +68,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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -306,19 +306,19 @@ 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 += "<br/>" + getString(R.string.bolus) + ": " + "<font color='" + MainApp.sResources.getColor(R.color.bolus) + "'>" + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U" + "</font>";
|
||||
confirmMessage += "<br/>" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||
confirmMessage += "<br/>" + MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.sResources.getColor(R.color.bolus) + "'>" + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U" + "</font>";
|
||||
confirmMessage += "<br/>" + MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||
|
||||
|
||||
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
|
||||
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
||||
builder.setMessage(getString(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), null);
|
||||
builder.show();
|
||||
return;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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(getString(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), null);
|
||||
builder.show();
|
||||
return;
|
||||
|
@ -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 ("
|
||||
|
|
|
@ -122,20 +122,20 @@ public class DanaRHistoryActivity extends Activity {
|
|||
// Types
|
||||
|
||||
ArrayList<TypeList> 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<TypeList> spinnerAdapter = new ArrayAdapter<>(this,
|
||||
R.layout.spinner_centered, typeList);
|
||||
|
|
|
@ -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<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
|
||||
|
@ -669,7 +669,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue