diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWEventListener.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWEventListener.java index 40979a3efd..487a80d91c 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWEventListener.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWEventListener.java @@ -46,11 +46,11 @@ public class SWEventListener extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); textView = new TextView(context); - textView.setId(view.generateViewId()); + textView.setId(layout.generateViewId()); textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status); layout.addView(textView); if (listener != null) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index 523970d6df..5102e36ac6 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -129,7 +129,7 @@ public class SetupWizardActivity extends AppCompatActivity { LinearLayout layout = SWItem.generateLayout(this.findViewById(R.id.sw_content_fields)); for (int i = 0; i < currentScreen.items.size(); i++) { SWItem currentItem = currentScreen.items.get(i); - currentItem.generateDialog(this.findViewById(R.id.sw_content_fields), layout); + currentItem.generateDialog(layout); } scrollView.smoothScrollTo(0,0); } diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWBreak.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWBreak.java index f513cccf4e..c6a9cf3f86 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWBreak.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWBreak.java @@ -27,8 +27,8 @@ public class SWBreak extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); l = new TextView(context); l.setId(View.generateViewId()); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWButton.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWButton.java index 4f22720091..afa28c1803 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWButton.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWButton.java @@ -39,8 +39,8 @@ public class SWButton extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); button = new Button(context); button.setText(buttonText); @@ -50,7 +50,7 @@ public class SWButton extends SWItem { }); processVisibility(); layout.addView(button); - super.generateDialog(view, layout); + super.generateDialog(layout); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWCheckbox.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWCheckbox.java index 816fb79a97..ed96b37944 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWCheckbox.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWCheckbox.java @@ -40,8 +40,8 @@ public class SWCheckbox extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); // Get if there is already value in SP Boolean previousValue; previousValue = SP.getBoolean(preferenceId, false); @@ -68,7 +68,7 @@ public class SWCheckbox extends SWItem { } }); layout.addView(checkBox); - super.generateDialog(view, layout); + super.generateDialog(layout); } public void save(boolean value){ SP.putBoolean(preferenceID, value); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditString.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditString.java index b464ae6316..d02f10acf0 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditString.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditString.java @@ -27,28 +27,28 @@ public class SWEditString extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); TextView l = new TextView(context); - l.setId(view.generateViewId()); + l.setId(layout.generateViewId()); l.setText(label); l.setTypeface(l.getTypeface(), Typeface.BOLD); layout.addView(l); TextView c = new TextView(context); - c.setId(view.generateViewId()); + c.setId(layout.generateViewId()); c.setText(comment); c.setTypeface(c.getTypeface(), Typeface.ITALIC); layout.addView(c); EditText editText = new EditText(context); - editText.setId(view.generateViewId()); + editText.setId(layout.generateViewId()); editText.setInputType(InputType.TYPE_CLASS_TEXT); editText.setMaxLines(1); editText.setText(SP.getString(preferenceId, "")); layout.addView(editText); - super.generateDialog(view, layout); + super.generateDialog(layout); editText.addTextChangedListener(new TextWatcher() { @Override diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditUrl.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditUrl.java index 6039577bff..04b02a5bc2 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditUrl.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditUrl.java @@ -27,8 +27,8 @@ public class SWEditUrl extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); TextView l = new TextView(context); l.setId(View.generateViewId()); @@ -48,7 +48,7 @@ public class SWEditUrl extends SWItem { editText.setMaxLines(1); editText.setText(SP.getString(preferenceId, "")); layout.addView(editText); - super.generateDialog(view, layout); + super.generateDialog(layout); editText.addTextChangedListener(new TextWatcher() { @Override diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWFragment.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWFragment.java index 9e470fa687..a061f57eb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWFragment.java @@ -27,7 +27,7 @@ public class SWFragment extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { + public void generateDialog(LinearLayout layout) { definition.getActivity().getSupportFragmentManager().beginTransaction().add(layout.getId(), fragment, fragment.getTag()).commit(); } diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWHtmlLink.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWHtmlLink.java index 1ee27be6ae..fd4ffdd524 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWHtmlLink.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWHtmlLink.java @@ -39,8 +39,8 @@ public class SWHtmlLink extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); l = new TextView(context); l.setId(View.generateViewId()); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWInfotext.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWInfotext.java index f98fbee82f..91e5c2da2d 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWInfotext.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWInfotext.java @@ -38,8 +38,8 @@ public class SWInfotext extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); l = new TextView(context); l.setId(View.generateViewId()); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.java index c82d4f5683..4f454b843d 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.java @@ -78,7 +78,7 @@ public class SWItem { return layout; } - public void generateDialog(View view, LinearLayout layout) { + public void generateDialog(LinearLayout layout) { } public void processVisibility() { diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.java index 06735ee72e..15c9befdc2 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.java @@ -2,9 +2,11 @@ package info.nightscout.androidaps.setupwizard.elements; import android.content.Context; import android.view.View; +import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RadioGroup; +import android.widget.TextView; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,8 +44,9 @@ public class SWPlugin extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + + Context context = layout.getContext(); radioGroup = new RadioGroup(context); radioGroup.clearCheck(); @@ -61,6 +64,12 @@ public class SWPlugin extends SWItem { rdbtn.setChecked(true); rdbtn.setTag(p); radioGroup.addView(rdbtn); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + params.setMargins(80, 0, 0, 0); + TextView desc = new TextView(context); + desc.setText(p.getDescription()); + desc.setLayoutParams(params); + radioGroup.addView(desc); } radioGroup.setOnCheckedChangeListener((group, checkedId) -> { @@ -74,6 +83,6 @@ public class SWPlugin extends SWItem { MainApp.bus().post(new EventSWUpdate()); }); layout.addView(radioGroup); - super.generateDialog(view, layout); + super.generateDialog(layout); } } diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWRadioButton.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWRadioButton.java index e034e86ba8..80346c433c 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWRadioButton.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWRadioButton.java @@ -38,8 +38,8 @@ public class SWRadioButton extends SWItem { } @Override - public void generateDialog(View view, LinearLayout layout) { - Context context = view.getContext(); + public void generateDialog(LinearLayout layout) { + Context context = layout.getContext(); // Get if there is already value in SP String previousValue = SP.getString(preferenceId, "none"); radioGroup = new RadioGroup(context); @@ -62,7 +62,7 @@ public class SWRadioButton extends SWItem { save(values()[i]); }); layout.addView(radioGroup); - super.generateDialog(view, layout); + super.generateDialog(layout); } public SWRadioButton preferenceId(int preferenceId) {