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