code cleanup
This commit is contained in:
parent
ef171dbccd
commit
11dc20faca
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.startupwizard;
|
package info.nightscout.androidaps.startupwizard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
@ -97,12 +98,10 @@ public class SWRadioButton extends SWItem {
|
||||||
MainApp.bus().post(new EventPreferenceChange(preferenceId));
|
MainApp.bus().post(new EventPreferenceChange(preferenceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return true if we have something checked
|
|
||||||
public boolean isValid(){
|
public String preferenceSet(){
|
||||||
if(getCheckedValue().equals("none"))
|
return SP.getString(preferenceId, "none");
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package info.nightscout.androidaps.startupwizard;
|
package info.nightscout.androidaps.startupwizard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.support.v4.widget.TextViewCompat;
|
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -20,10 +18,6 @@ public class SWString extends SWItem {
|
||||||
public SWString() {
|
public SWString() {
|
||||||
super(Type.STRING);
|
super(Type.STRING);
|
||||||
}
|
}
|
||||||
public void setOptions(List<String> labels, List<String> values){
|
|
||||||
this.labels = labels;
|
|
||||||
this.values = values;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name){
|
public void setName(String name){
|
||||||
this.groupName = name;
|
this.groupName = name;
|
||||||
|
@ -54,8 +48,4 @@ public class SWString extends SWItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid(){
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
package info.nightscout.androidaps.startupwizard;
|
package info.nightscout.androidaps.startupwizard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.support.v4.widget.TextViewCompat;
|
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
|
|
||||||
public class SWUrl extends SWItem {
|
public class SWUrl extends SWItem {
|
||||||
|
|
||||||
private List<String> labels;
|
private List<String> labels;
|
||||||
|
@ -53,9 +46,5 @@ public class SWUrl extends SWItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid(){
|
|
||||||
// checks for URL validation
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,16 @@ import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -62,7 +61,6 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
private TextView textlabel;
|
private TextView textlabel;
|
||||||
private TextView screenName;
|
private TextView screenName;
|
||||||
private Button skipButton;
|
private Button skipButton;
|
||||||
private boolean nextAllowed = false;
|
|
||||||
//logiing
|
//logiing
|
||||||
private static Logger log = LoggerFactory.getLogger(SetupWizardActivity.class);
|
private static Logger log = LoggerFactory.getLogger(SetupWizardActivity.class);
|
||||||
|
|
||||||
|
@ -147,12 +145,9 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
SWScreen currentScreen = screens.get(showPage);
|
SWScreen currentScreen = screens.get(showPage);
|
||||||
currentWizardPage = showPage;
|
currentWizardPage = showPage;
|
||||||
// show/hide prev/next buttons if we are at the beninning/end
|
// show/hide prev/next buttons if we are at the beninning/end
|
||||||
if(nextAllowed && showPage == screens.size() - 1) {
|
//showNextButton(showPage, screens.size()-1);
|
||||||
((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);
|
|
||||||
((Button) findViewById(R.id.next_button)).setVisibility(View.GONE);
|
if(showPage == 0)
|
||||||
} else if(nextAllowed && showPage != screens.size() - 1) {
|
|
||||||
((Button) findViewById(R.id.next_button)).setVisibility(View.VISIBLE);
|
|
||||||
}else if(showPage == 0)
|
|
||||||
((Button) findViewById(R.id.previous_button)).setVisibility(View.GONE);
|
((Button) findViewById(R.id.previous_button)).setVisibility(View.GONE);
|
||||||
//Set screen name
|
//Set screen name
|
||||||
screenName = (TextView) findViewById(R.id.fullscreen_content);
|
screenName = (TextView) findViewById(R.id.fullscreen_content);
|
||||||
|
@ -172,22 +167,23 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
comments.add(currentItem.getComment());
|
comments.add(currentItem.getComment());
|
||||||
|
|
||||||
} else if(currentItem.type == RADIOBUTTON){
|
} else if(currentItem.type == RADIOBUTTON){
|
||||||
//disable next before creating layout
|
|
||||||
nextAllowed = false;
|
|
||||||
// generate layout dynamically
|
// generate layout dynamically
|
||||||
SWRadioButton radioGroupItems = (SWRadioButton) currentItem;
|
SWRadioButton radioGroupItems = (SWRadioButton) currentItem;
|
||||||
radioGroupItems.generateDialog(this.findViewById(R.id.fullscreen_content_fields));
|
radioGroupItems.generateDialog(this.findViewById(R.id.fullscreen_content_fields));
|
||||||
|
//allow next button if we have something saved in preferences
|
||||||
|
if(!radioGroupItems.preferenceSet().equals("none")){
|
||||||
|
showNextButton(showPage, screens.size()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
radioGroupItems.getRadioGroup().setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
radioGroupItems.getRadioGroup().setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
radioGroupItems.save(radioGroupItems.getCheckedValue());
|
radioGroupItems.save(radioGroupItems.getCheckedValue());
|
||||||
nextAllowed = currentScreen.validator.isValid();
|
if(currentScreen.validator.isValid()) {
|
||||||
if(showPage == screens.size() - 1 && nextAllowed) {
|
showNextButton(showPage, screens.size() - 1);
|
||||||
((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);
|
show();
|
||||||
((Button) findViewById(R.id.next_button)).setVisibility(View.GONE);
|
}
|
||||||
} else if(nextAllowed)
|
|
||||||
((Button) findViewById(R.id.next_button)).setVisibility(View.VISIBLE);
|
|
||||||
show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -199,8 +195,11 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
swUrl.setOptions(labels, comments);
|
swUrl.setOptions(labels, comments);
|
||||||
swUrl.generateDialog(this.findViewById(R.id.fullscreen_content_fields));
|
swUrl.generateDialog(this.findViewById(R.id.fullscreen_content_fields));
|
||||||
log.debug("Valid input:" +currentScreen.validator.isValid());
|
log.debug("Valid input:" +currentScreen.validator.isValid());
|
||||||
nextAllowed = swUrl.isValid();
|
/* if(currentScreen.validator.isValid()) {
|
||||||
((Button) findViewById(R.id.next_button)).setVisibility(View.VISIBLE);
|
showNextButton(showPage, screens.size() - 1);
|
||||||
|
show();
|
||||||
|
}*/
|
||||||
|
showNextButton(showPage, screens.size()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +265,14 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
mHideHandler.postDelayed(mHideRunnable, delayMillis);
|
mHideHandler.postDelayed(mHideRunnable, delayMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showNextButton(int currentPage, int maxPages){
|
||||||
|
if(currentPage == maxPages) {
|
||||||
|
((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);
|
||||||
|
((Button) findViewById(R.id.next_button)).setVisibility(View.GONE);
|
||||||
|
} else
|
||||||
|
((Button) findViewById(R.id.next_button)).setVisibility(View.VISIBLE);
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
public void showNextPage(View view) {
|
public void showNextPage(View view) {
|
||||||
Intent intent = new Intent(this, SetupWizardActivity.class);
|
Intent intent = new Intent(this, SetupWizardActivity.class);
|
||||||
|
@ -283,4 +289,9 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Go back to overview
|
||||||
|
public void finishSetupWizard(View view){
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:onClick="finishSetupWizard"
|
||||||
android:text="@string/setupwizard_finish"
|
android:text="@string/setupwizard_finish"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue