2018-04-20 17:27:31 +02:00
|
|
|
package info.nightscout.androidaps.startupwizard;
|
|
|
|
|
2018-04-25 14:29:20 +02:00
|
|
|
import android.content.Context;
|
2018-05-03 20:06:13 +02:00
|
|
|
import android.text.Editable;
|
2018-04-25 14:29:20 +02:00
|
|
|
import android.text.InputType;
|
2018-05-03 20:06:13 +02:00
|
|
|
import android.text.TextWatcher;
|
2018-04-25 14:29:20 +02:00
|
|
|
import android.view.View;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.LinearLayout;
|
2018-05-03 20:06:13 +02:00
|
|
|
import android.widget.TextView;
|
2018-04-25 14:29:20 +02:00
|
|
|
|
2018-04-27 12:30:45 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-05-03 20:06:13 +02:00
|
|
|
import info.nightscout.androidaps.MainApp;
|
|
|
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
|
|
|
import info.nightscout.androidaps.startupwizard.events.EventSWUpdate;
|
|
|
|
import info.nightscout.utils.SP;
|
2018-04-25 14:29:20 +02:00
|
|
|
|
2018-04-20 17:27:31 +02:00
|
|
|
public class SWUrl extends SWItem {
|
2018-04-27 12:30:45 +02:00
|
|
|
private static Logger log = LoggerFactory.getLogger(SWUrl.class);
|
2018-05-03 20:06:13 +02:00
|
|
|
|
2018-04-20 17:27:31 +02:00
|
|
|
public SWUrl() {
|
|
|
|
super(Type.URL);
|
|
|
|
}
|
2018-04-25 14:29:20 +02:00
|
|
|
|
2018-04-25 15:45:15 +02:00
|
|
|
@Override
|
2018-04-27 12:30:45 +02:00
|
|
|
public void generateDialog(View view, LinearLayout layout) {
|
2018-04-25 14:29:20 +02:00
|
|
|
Context context = view.getContext();
|
2018-04-27 12:30:45 +02:00
|
|
|
|
2018-05-03 20:06:13 +02:00
|
|
|
TextView l = new TextView(context);
|
|
|
|
l.setId(View.generateViewId());
|
|
|
|
l.setText(label);
|
|
|
|
layout.addView(l);
|
2018-04-27 12:30:45 +02:00
|
|
|
|
2018-05-03 20:06:13 +02:00
|
|
|
TextView c = new TextView(context);
|
|
|
|
c.setId(View.generateViewId());
|
|
|
|
c.setText(comment);
|
|
|
|
layout.addView(c);
|
|
|
|
|
|
|
|
EditText editText = new EditText(context);
|
|
|
|
editText.setId(View.generateViewId());
|
|
|
|
editText.setInputType(InputType.TYPE_CLASS_TEXT);
|
|
|
|
editText.setMaxLines(1);
|
|
|
|
layout.addView(editText);
|
2018-04-26 14:18:01 +02:00
|
|
|
|
2018-05-03 20:06:13 +02:00
|
|
|
editText.addTextChangedListener(new TextWatcher() {
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
}
|
2018-04-26 14:18:01 +02:00
|
|
|
|
2018-05-03 20:06:13 +02:00
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
SP.putString(preferenceId, s.toString());
|
|
|
|
MainApp.bus().post(new EventPreferenceChange(preferenceId));
|
|
|
|
MainApp.bus().post(new EventSWUpdate());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-04-20 17:27:31 +02:00
|
|
|
}
|