use MainApp.gs instead of getString from Activity/Dialog 2

This commit is contained in:
AdrianLxM 2018-05-02 14:21:53 +02:00
parent 611d761a41
commit 3f3959f785
8 changed files with 35 additions and 35 deletions

View file

@ -247,7 +247,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if (!pm.isIgnoringBatteryOptimizations(packageName)) { if (!pm.isIgnoringBatteryOptimizations(packageName)) {
log.debug("Requesting ignore battery optimization"); 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 @Override
public void run() { public void run() {
@ -399,7 +399,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
break; break;
case R.id.nav_about: case R.id.nav_about:
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); 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) if (Config.NSCLIENT || Config.G5UPLOADER)
builder.setIcon(R.mipmap.yellowowl); builder.setIcon(R.mipmap.yellowowl);
else else

View file

@ -141,27 +141,27 @@ public class TDDStatsActivity extends Activity {
TableLayout.LayoutParams.WRAP_CONTENT)); TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_date = new TextView(this); 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); label_date.setTextColor(Color.WHITE);
tr_head.addView(label_date); tr_head.addView(label_date);
TextView label_basalrate = new TextView(this); 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); label_basalrate.setTextColor(Color.WHITE);
tr_head.addView(label_basalrate); tr_head.addView(label_basalrate);
TextView label_bolus = new TextView(this); 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); label_bolus.setTextColor(Color.WHITE);
tr_head.addView(label_bolus); tr_head.addView(label_bolus);
TextView label_tdd = new TextView(this); 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); label_tdd.setTextColor(Color.WHITE);
tr_head.addView(label_tdd); tr_head.addView(label_tdd);
TextView label_ratio = new TextView(this); 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); label_ratio.setTextColor(Color.WHITE);
tr_head.addView(label_ratio); tr_head.addView(label_ratio);
@ -179,17 +179,17 @@ public class TDDStatsActivity extends Activity {
TableLayout.LayoutParams.WRAP_CONTENT)); TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_cum_amount_days = new TextView(this); 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); label_cum_amount_days.setTextColor(Color.WHITE);
ctr_head.addView(label_cum_amount_days); ctr_head.addView(label_cum_amount_days);
TextView label_cum_tdd = new TextView(this); 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); label_cum_tdd.setTextColor(Color.WHITE);
ctr_head.addView(label_cum_tdd); ctr_head.addView(label_cum_tdd);
TextView label_cum_ratio = new TextView(this); 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); label_cum_ratio.setTextColor(Color.WHITE);
ctr_head.addView(label_cum_ratio); ctr_head.addView(label_cum_ratio);
@ -207,17 +207,17 @@ public class TDDStatsActivity extends Activity {
TableLayout.LayoutParams.WRAP_CONTENT)); TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_exp_weight = new TextView(this); 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); label_exp_weight.setTextColor(Color.WHITE);
etr_head.addView(label_exp_weight); etr_head.addView(label_exp_weight);
TextView label_exp_tdd = new TextView(this); 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); label_exp_tdd.setTextColor(Color.WHITE);
etr_head.addView(label_exp_tdd); etr_head.addView(label_exp_tdd);
TextView label_exp_ratio = new TextView(this); 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); label_exp_ratio.setTextColor(Color.WHITE);
etr_head.addView(label_exp_ratio); etr_head.addView(label_exp_ratio);
@ -235,7 +235,7 @@ public class TDDStatsActivity extends Activity {
reloadButton.setVisibility(View.GONE); reloadButton.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE); statusView.setVisibility(View.VISIBLE);
statsMessage.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() { ConfigBuilderPlugin.getCommandQueue().loadTDDs( new Callback() {
@ -441,7 +441,7 @@ public class TDDStatsActivity extends Activity {
if (isOldData(historyList) && ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad) { if (isOldData(historyList) && ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad) {
statsMessage.setVisibility(View.VISIBLE); statsMessage.setVisibility(View.VISIBLE);
statsMessage.setText(getString(R.string.danar_stats_olddata_Message)); statsMessage.setText(MainApp.gs(R.string.danar_stats_olddata_Message));
} else { } else {
tl.setBackgroundColor(Color.TRANSPARENT); tl.setBackgroundColor(Color.TRANSPARENT);

View file

@ -197,7 +197,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) { if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) {
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(confirmMessage))); builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(confirmMessage)));
builder.setPositiveButton(getString(R.string.primefill), (dialog, id) -> { builder.setPositiveButton(MainApp.gs(R.string.primefill), (dialog, id) -> {
if (finalInsulinAfterConstraints > 0) { if (finalInsulinAfterConstraints > 0) {
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.insulin = finalInsulinAfterConstraints; detailedBolusInfo.insulin = finalInsulinAfterConstraints;
@ -228,7 +228,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
} else { } else {
builder.setMessage(MainApp.gs(R.string.no_action_selected)); 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(); builder.show();
dismiss(); dismiss();
} catch (RuntimeException e) { } catch (RuntimeException e) {

View file

@ -39,7 +39,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { 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); 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); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.confirmation)); builder.setTitle(context.getString(R.string.confirmation));
builder.setMessage(confirmMessage); 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) { public void onClick(DialogInterface dialog, int id) {
ConfigBuilderPlugin.getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() { ConfigBuilderPlugin.getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() {
@Override @Override
@ -102,7 +102,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
FabricPrivacy.getInstance().logCustom(new CustomEvent("ExtendedBolus")); FabricPrivacy.getInstance().logCustom(new CustomEvent("ExtendedBolus"));
} }
}); });
builder.setNegativeButton(getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
dismiss(); dismiss();

View file

@ -52,7 +52,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { 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); 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()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(this.getContext().getString(R.string.confirmation)); builder.setTitle(this.getContext().getString(R.string.confirmation));
builder.setMessage(confirmMessage); 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) { public void onClick(DialogInterface dialog, int id) {
Callback callback = new Callback() { Callback callback = new Callback() {
@Override @Override
@ -169,7 +169,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
FabricPrivacy.getInstance().logCustom(new CustomEvent("TempBasal")); FabricPrivacy.getInstance().logCustom(new CustomEvent("TempBasal"));
} }
}); });
builder.setNegativeButton(getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
dismiss(); dismiss();

View file

@ -112,14 +112,14 @@ public class NSClientFragment extends SubscriberFragment implements View.OnClick
builder.setTitle(this.getContext().getString(R.string.confirmation)); builder.setTitle(this.getContext().getString(R.string.confirmation));
builder.setMessage("Clear queue? All data in queue will be lost!"); 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) { public void onClick(DialogInterface dialog, int id) {
UploadQueue.clearQueue(); UploadQueue.clearQueue();
updateGUI(); updateGUI();
FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientClearQueue")); FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientClearQueue"));
} }
}); });
builder.setNegativeButton(getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
break; break;
case R.id.nsclientinternal_showqueue: case R.id.nsclientinternal_showqueue:

View file

@ -270,13 +270,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
} }
private void saveCheckedStates() { private void saveCheckedStates() {
SP.putBoolean(getString(R.string.key_wizard_include_cob), cobCheckbox.isChecked()); SP.putBoolean(MainApp.gs(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_trend_bg), bgtrendCheckbox.isChecked());
} }
private void loadCheckedStates() { private void loadCheckedStates() {
bgtrendCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_trend_bg), false)); bgtrendCheckbox.setChecked(SP.getBoolean(MainApp.gs(R.string.key_wizard_include_trend_bg), false));
cobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_cob), false)); cobCheckbox.setChecked(SP.getBoolean(MainApp.gs(R.string.key_wizard_include_cob), false));
} }
@Override @Override
@ -318,7 +318,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) { if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror)); 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.setPositiveButton(MainApp.gs(R.string.ok), null);
builder.show(); builder.show();
return; return;
@ -334,7 +334,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
final AlertDialog.Builder builder = new AlertDialog.Builder(context); final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(Html.fromHtml(confirmMessage)); 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) { public void onClick(DialogInterface dialog, int id) {
synchronized (builder) { synchronized (builder) {
if (accepted) { 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(); builder.show();
dismiss(); dismiss();
} }

View file

@ -753,7 +753,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) { if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror)); 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.setPositiveButton(MainApp.gs(R.string.ok), null);
builder.show(); builder.show();
return; return;
@ -766,7 +766,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
accepted = false; accepted = false;
builder.setTitle(MainApp.gs(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(confirmMessage); builder.setMessage(confirmMessage);
builder.setPositiveButton(getString(R.string.ok), (dialog, id) -> { builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
synchronized (builder) { synchronized (builder) {
if (accepted) { if (accepted) {
log.debug("guarding: already 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(); builder.show();
} }
} }