plugin descritpions to setup wizard

This commit is contained in:
Milos Kozak 2018-06-26 12:28:53 +02:00
parent 77245c027e
commit 520f2e1518
13 changed files with 42 additions and 33 deletions

View file

@ -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)

View file

@ -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);
}

View file

@ -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());

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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();
}

View file

@ -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());

View file

@ -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());

View file

@ -78,7 +78,7 @@ public class SWItem {
return layout;
}
public void generateDialog(View view, LinearLayout layout) {
public void generateDialog(LinearLayout layout) {
}
public void processVisibility() {

View file

@ -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);
}
}

View file

@ -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) {