plugin descritpions to setup wizard
This commit is contained in:
parent
77245c027e
commit
520f2e1518
13 changed files with 42 additions and 33 deletions
|
@ -46,11 +46,11 @@ public class SWEventListener extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
|
|
||||||
textView = new TextView(context);
|
textView = new TextView(context);
|
||||||
textView.setId(view.generateViewId());
|
textView.setId(layout.generateViewId());
|
||||||
textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
|
textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
|
||||||
layout.addView(textView);
|
layout.addView(textView);
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
LinearLayout layout = SWItem.generateLayout(this.findViewById(R.id.sw_content_fields));
|
LinearLayout layout = SWItem.generateLayout(this.findViewById(R.id.sw_content_fields));
|
||||||
for (int i = 0; i < currentScreen.items.size(); i++) {
|
for (int i = 0; i < currentScreen.items.size(); i++) {
|
||||||
SWItem currentItem = currentScreen.items.get(i);
|
SWItem currentItem = currentScreen.items.get(i);
|
||||||
currentItem.generateDialog(this.findViewById(R.id.sw_content_fields), layout);
|
currentItem.generateDialog(layout);
|
||||||
}
|
}
|
||||||
scrollView.smoothScrollTo(0,0);
|
scrollView.smoothScrollTo(0,0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ public class SWBreak extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
|
|
||||||
l = new TextView(context);
|
l = new TextView(context);
|
||||||
l.setId(View.generateViewId());
|
l.setId(View.generateViewId());
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class SWButton extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
|
|
||||||
button = new Button(context);
|
button = new Button(context);
|
||||||
button.setText(buttonText);
|
button.setText(buttonText);
|
||||||
|
@ -50,7 +50,7 @@ public class SWButton extends SWItem {
|
||||||
});
|
});
|
||||||
processVisibility();
|
processVisibility();
|
||||||
layout.addView(button);
|
layout.addView(button);
|
||||||
super.generateDialog(view, layout);
|
super.generateDialog(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class SWCheckbox extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
// Get if there is already value in SP
|
// Get if there is already value in SP
|
||||||
Boolean previousValue;
|
Boolean previousValue;
|
||||||
previousValue = SP.getBoolean(preferenceId, false);
|
previousValue = SP.getBoolean(preferenceId, false);
|
||||||
|
@ -68,7 +68,7 @@ public class SWCheckbox extends SWItem {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
layout.addView(checkBox);
|
layout.addView(checkBox);
|
||||||
super.generateDialog(view, layout);
|
super.generateDialog(layout);
|
||||||
}
|
}
|
||||||
public void save(boolean value){
|
public void save(boolean value){
|
||||||
SP.putBoolean(preferenceID, value);
|
SP.putBoolean(preferenceID, value);
|
||||||
|
|
|
@ -27,28 +27,28 @@ public class SWEditString extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
|
|
||||||
TextView l = new TextView(context);
|
TextView l = new TextView(context);
|
||||||
l.setId(view.generateViewId());
|
l.setId(layout.generateViewId());
|
||||||
l.setText(label);
|
l.setText(label);
|
||||||
l.setTypeface(l.getTypeface(), Typeface.BOLD);
|
l.setTypeface(l.getTypeface(), Typeface.BOLD);
|
||||||
layout.addView(l);
|
layout.addView(l);
|
||||||
|
|
||||||
TextView c = new TextView(context);
|
TextView c = new TextView(context);
|
||||||
c.setId(view.generateViewId());
|
c.setId(layout.generateViewId());
|
||||||
c.setText(comment);
|
c.setText(comment);
|
||||||
c.setTypeface(c.getTypeface(), Typeface.ITALIC);
|
c.setTypeface(c.getTypeface(), Typeface.ITALIC);
|
||||||
layout.addView(c);
|
layout.addView(c);
|
||||||
|
|
||||||
EditText editText = new EditText(context);
|
EditText editText = new EditText(context);
|
||||||
editText.setId(view.generateViewId());
|
editText.setId(layout.generateViewId());
|
||||||
editText.setInputType(InputType.TYPE_CLASS_TEXT);
|
editText.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
editText.setMaxLines(1);
|
editText.setMaxLines(1);
|
||||||
editText.setText(SP.getString(preferenceId, ""));
|
editText.setText(SP.getString(preferenceId, ""));
|
||||||
layout.addView(editText);
|
layout.addView(editText);
|
||||||
super.generateDialog(view, layout);
|
super.generateDialog(layout);
|
||||||
|
|
||||||
editText.addTextChangedListener(new TextWatcher() {
|
editText.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,8 +27,8 @@ public class SWEditUrl extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
|
|
||||||
TextView l = new TextView(context);
|
TextView l = new TextView(context);
|
||||||
l.setId(View.generateViewId());
|
l.setId(View.generateViewId());
|
||||||
|
@ -48,7 +48,7 @@ public class SWEditUrl extends SWItem {
|
||||||
editText.setMaxLines(1);
|
editText.setMaxLines(1);
|
||||||
editText.setText(SP.getString(preferenceId, ""));
|
editText.setText(SP.getString(preferenceId, ""));
|
||||||
layout.addView(editText);
|
layout.addView(editText);
|
||||||
super.generateDialog(view, layout);
|
super.generateDialog(layout);
|
||||||
|
|
||||||
editText.addTextChangedListener(new TextWatcher() {
|
editText.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class SWFragment extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
definition.getActivity().getSupportFragmentManager().beginTransaction().add(layout.getId(), fragment, fragment.getTag()).commit();
|
definition.getActivity().getSupportFragmentManager().beginTransaction().add(layout.getId(), fragment, fragment.getTag()).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class SWHtmlLink extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
|
|
||||||
l = new TextView(context);
|
l = new TextView(context);
|
||||||
l.setId(View.generateViewId());
|
l.setId(View.generateViewId());
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class SWInfotext extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
|
|
||||||
l = new TextView(context);
|
l = new TextView(context);
|
||||||
l.setId(View.generateViewId());
|
l.setId(View.generateViewId());
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class SWItem {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processVisibility() {
|
public void processVisibility() {
|
||||||
|
|
|
@ -2,9 +2,11 @@ package info.nightscout.androidaps.setupwizard.elements;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -42,8 +44,9 @@ public class SWPlugin extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
|
||||||
|
Context context = layout.getContext();
|
||||||
radioGroup = new RadioGroup(context);
|
radioGroup = new RadioGroup(context);
|
||||||
radioGroup.clearCheck();
|
radioGroup.clearCheck();
|
||||||
|
|
||||||
|
@ -61,6 +64,12 @@ public class SWPlugin extends SWItem {
|
||||||
rdbtn.setChecked(true);
|
rdbtn.setChecked(true);
|
||||||
rdbtn.setTag(p);
|
rdbtn.setTag(p);
|
||||||
radioGroup.addView(rdbtn);
|
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) -> {
|
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
|
||||||
|
@ -74,6 +83,6 @@ public class SWPlugin extends SWItem {
|
||||||
MainApp.bus().post(new EventSWUpdate());
|
MainApp.bus().post(new EventSWUpdate());
|
||||||
});
|
});
|
||||||
layout.addView(radioGroup);
|
layout.addView(radioGroup);
|
||||||
super.generateDialog(view, layout);
|
super.generateDialog(layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class SWRadioButton extends SWItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = layout.getContext();
|
||||||
// Get if there is already value in SP
|
// Get if there is already value in SP
|
||||||
String previousValue = SP.getString(preferenceId, "none");
|
String previousValue = SP.getString(preferenceId, "none");
|
||||||
radioGroup = new RadioGroup(context);
|
radioGroup = new RadioGroup(context);
|
||||||
|
@ -62,7 +62,7 @@ public class SWRadioButton extends SWItem {
|
||||||
save(values()[i]);
|
save(values()[i]);
|
||||||
});
|
});
|
||||||
layout.addView(radioGroup);
|
layout.addView(radioGroup);
|
||||||
super.generateDialog(view, layout);
|
super.generateDialog(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWRadioButton preferenceId(int preferenceId) {
|
public SWRadioButton preferenceId(int preferenceId) {
|
||||||
|
|
Loading…
Reference in a new issue