From 3f3959f785c880732a0aee82f261cd9dd14c21a4 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 2 May 2018 14:21:53 +0200 Subject: [PATCH] use MainApp.gs instead of getString from Activity/Dialog 2 --- .../nightscout/androidaps/MainActivity.java | 4 +-- .../androidaps/TDDStatsActivity.java | 26 +++++++++---------- .../plugins/Actions/dialogs/FillDialog.java | 4 +-- .../dialogs/NewExtendedBolusDialog.java | 6 ++--- .../Actions/dialogs/NewTempBasalDialog.java | 6 ++--- .../NSClientInternal/NSClientFragment.java | 4 +-- .../Overview/Dialogs/WizardDialog.java | 14 +++++----- .../plugins/Overview/OverviewFragment.java | 6 ++--- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index aade605241..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, MainApp.gs(R.string.pleaseallowpermission), String.format(getString(R.string.needwhitelisting), MainApp.gs(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() { @@ -399,7 +399,7 @@ 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 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/plugins/Actions/dialogs/FillDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java index 9842019802..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 @@ -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; @@ -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 22690bb554..3b986d9f4b 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 @@ -39,7 +39,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); @@ -84,7 +84,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getString(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 @@ -102,7 +102,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 9d9a45d8f6..15a45a32c6 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); @@ -146,7 +146,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(this.getContext().getString(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 @@ -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/NSClientInternal/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java index 44cd5c43a1..b1cad222e8 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 @@ -112,14 +112,14 @@ public class NSClientFragment extends SubscriberFragment implements View.OnClick builder.setTitle(this.getContext().getString(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: 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 bd0bc46fdf..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 @@ -318,7 +318,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com 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" + MainApp.gs(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; @@ -334,7 +334,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com final AlertDialog.Builder builder = new AlertDialog.Builder(context); 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) { @@ -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(); } 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 f8c78ad1cd..89b667e8dd 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 @@ -753,7 +753,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, 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" + MainApp.gs(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(); } }