allow to use actual profile in wizard

This commit is contained in:
Milos Kozak 2017-10-19 19:35:35 +02:00
parent 65cb095dfd
commit c258b41f11
2 changed files with 8 additions and 6 deletions

View file

@ -32,6 +32,7 @@ import com.squareup.otto.Subscribe;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.mozilla.javascript.tools.debugger.Main;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -401,15 +402,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
ArrayList<CharSequence> profileList; ArrayList<CharSequence> profileList;
profileList = profileStore.getProfileList(); profileList = profileStore.getProfileList();
profileList.add(0, MainApp.sResources.getString(R.string.active));
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(), ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
R.layout.spinner_centered, profileList); R.layout.spinner_centered, profileList);
profileSpinner.setAdapter(adapter); profileSpinner.setAdapter(adapter);
// set selected to actual profile
for (int p = 0; p < profileList.size(); p++) {
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName()))
profileSpinner.setSelection(p);
}
String units = profile.getUnits(); String units = profile.getUnits();
bgUnits.setText(units); bgUnits.setText(units);
@ -451,7 +448,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
if (profileSpinner == null || profileSpinner.getSelectedItem() == null) if (profileSpinner == null || profileSpinner.getSelectedItem() == null)
return; // not initialized yet return; // not initialized yet
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString(); String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
Profile specificProfile = profile.getSpecificProfile(selectedAlternativeProfile); Profile specificProfile;
if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active)))
specificProfile = MainApp.getConfigBuilder().getProfile();
else
specificProfile = profile.getSpecificProfile(selectedAlternativeProfile);
// Entered values // Entered values
Double c_bg = SafeParse.stringToDouble(editBg.getText()); Double c_bg = SafeParse.stringToDouble(editBg.getText());

View file

@ -746,5 +746,6 @@
<string name="wearcontrol_title">Controls from Watch</string> <string name="wearcontrol_title">Controls from Watch</string>
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string> <string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
<string name="connectiontimedout">Connection timed out</string> <string name="connectiontimedout">Connection timed out</string>
<string name="active"><![CDATA[<Active>]]></string>
</resources> </resources>