WIP: initial work

This commit is contained in:
Roumen Georgiev 2018-04-23 15:58:27 +03:00
parent daafe9c548
commit 76685c3cff
4 changed files with 179 additions and 5 deletions

View file

@ -29,6 +29,8 @@ public class SWDefinition {
}
SWDefinition() {
// List all the screens here
// todo: SWValidator ?!?
add(new SWScreen(R.string.nsclientinternal_title)
.skippable(false)
.add(new SWUrl().preferenceId(R.string.key_nsclientinternal_url).label(R.string.nsclientinternal_url_title).comment(R.string.nsclientinternal_url_dialogmessage))

View file

@ -7,9 +7,21 @@ import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import java.util.List;
import info.nightscout.androidaps.R;
import static info.nightscout.androidaps.startupwizard.SWItem.Type.RADIOBUTTON;
import static info.nightscout.androidaps.startupwizard.SWItem.Type.STRING;
import static info.nightscout.androidaps.startupwizard.SWItem.Type.URL;
/**
* An example full-screen activity that shows and hides the system UI (i.e.
* status bar and navigation/system bar) with user interaction.
@ -34,6 +46,21 @@ public class SetupWizardActivity extends AppCompatActivity {
private static final int UI_ANIMATION_DELAY = 300;
private final Handler mHideHandler = new Handler();
private View mContentView;
private LinearLayout linearLayout;
private TextView radioLabel;
private RadioGroup radioGroup;
private RadioButton[] radioButtons;
private RadioButton radioButton1;
private RadioButton radioButton2;
private RadioButton radioButton3;
private RadioButton radioButton4;
private RadioButton radioButton5;
private TextView screenName;
private TextView label1;
private EditText editText1;
private TextView label2;
private EditText editText2;
private Button skipButton;
private final Runnable mHidePart2Runnable = new Runnable() {
@SuppressLint("InlinedApi")
@Override
@ -104,10 +131,56 @@ public class SetupWizardActivity extends AppCompatActivity {
}
});
SWDefinition swDefinition = SWDefinition.getInstance();
List<SWScreen> screens = swDefinition.getScreens();
if(screens.size() > 0){
SWScreen currentScreen = screens.get(1);
//Set screen name
screenName = (TextView) findViewById(R.id.fullscreen_content);
screenName.setText(currentScreen.getHeader());
//Display screen items in the order entered
linearLayout = (LinearLayout) findViewById(R.id.fullscreen_content_controls);
// is it skippable ?
if(currentScreen.skippable) {
//display skip button
skipButton = (Button) findViewById(R.id.skip_button);
}
for(int i = 0; i < currentScreen.items.size(); i++){
SWItem currentItem = currentScreen.items.get(i);
if(currentItem.type == URL){
label1 = (TextView) findViewById(R.id.textLabel1);
editText1 = (EditText) findViewById(R.id.editText1);
label1.setText(currentItem.getLabel());
label1.setVisibility(View.VISIBLE);
editText1.setText(currentItem.getComment());
editText1.setVisibility(View.VISIBLE);
} else if(currentItem.type == STRING){
label2 = (TextView) findViewById(R.id.textLabel2);
editText2 = (EditText) findViewById(R.id.editText2);
label2.setText(currentItem.getLabel());
label2.setVisibility(View.VISIBLE);
editText2.setText(currentItem.getComment());
editText2.setVisibility(View.VISIBLE);
} else if(currentItem.type == RADIOBUTTON){
((LinearLayout) findViewById(R.id.radio_group_layout)).setVisibility(View.VISIBLE);
radioLabel = (TextView) findViewById(R.id.radio_group_label);
radioLabel.setText(currentScreen.getHeader());
SWRadioButton radioGroupItems = (SWRadioButton) currentItem;
addRadioButtons(radioGroupItems.labels().length, radioGroupItems.labels(), radioGroupItems.values());
}
}
}
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
findViewById(R.id.next_button).setOnTouchListener(mDelayHideTouchListener);
}
@Override
@ -162,4 +235,23 @@ public class SetupWizardActivity extends AppCompatActivity {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
public void addRadioButtons(int number, String[] labels, String[] values) {
for (int row = 0; row < 1; row++) {
RadioGroup ll = new RadioGroup(this);
ll.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < number; i++) {
RadioButton rdbtn = new RadioButton(this);
rdbtn.setId((row * 2) + i);
// rdbtn.setText("Radio " + rdbtn.getId());
rdbtn.setText(labels[i]);
ll.addView(rdbtn);
}
((RadioGroup) findViewById(R.id.radiogroup)).addView(ll);
((RadioGroup) findViewById(R.id.radiogroup)).setVisibility(View.VISIBLE);
}
}
}

View file

@ -27,6 +27,67 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id="@+id/fullscreen_content_fields"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textLabel1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextLabel"
android:visibility="gone"/>
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text|text"
android:text="Enter your setting here"
android:visibility="gone"/>
<TextView
android:id="@+id/textLabel2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextLabel2"
android:visibility="gone"/>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text|text"
android:text="Enter your setting here"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/radio_group_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/radio_group_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="radio button group label" />
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/fullscreen_content_controls"
style="?metaButtonBarStyle"
@ -38,12 +99,29 @@
tools:ignore="UselessParent">
<Button
android:id="@+id/dummy_button"
android:id="@+id/next_button"
style="?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/dummy_button" />
android:text="@string/next_button"
android:visibility="invisible" />
<Button
android:id="@+id/previous_button"
style="?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/previous_button" />
<Button
android:id="@+id/skip_button"
style="?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/skip_button"
android:visibility="invisible" />
</LinearLayout>
</FrameLayout>

View file

@ -482,7 +482,7 @@
<string name="restart">Restart</string>
<string name="nsclientinternal_title">NSClient</string>
<string name="nsclientinternal_url_title">Nightscout URL</string>
<string name="nsclientinternal_url_dialogmessage">Enter Nightscout URL</string>
<string name="nsclientinternal_url_dialogmessage">Enter Your Nightscout URL</string>
<string name="nsclientinternal_secret_title">NS API secret</string>
<string name="nsclientinternal_secret_dialogtitle">NS API secret</string>
<string name="nsclientinternal_secret_dialogmessage">Enter NS API secret (min 12 chars)</string>
@ -1002,7 +1002,9 @@
<string name="overview_show_notes_field_in_dialogs_title">Show notes field in treatment dialogs</string>
<string name="title_activity_setup_wizard">SetupWizardActivity</string>
<string name="dummy_button">Dummy Button</string>
<string name="next_button">Next</string>
<string name="previous_button">Prev</string>
<string name="skip_button">Skip</string>
<string name="dummy_content">DUMMY\nCONTENT</string>
<string name="nav_setupwizard">Setup Wizard</string>
</resources>