show upload profile button only when pump is capable to this

This commit is contained in:
Milos Kozak 2016-12-29 23:10:39 +01:00
parent b2be49e631
commit 2f52091b67
3 changed files with 57 additions and 25 deletions

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.CircadianPercentageProfile; package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
@ -19,10 +20,14 @@ import android.widget.LinearLayout;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.FragmentBase; import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
@ -60,8 +65,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
BasalEditDialog basalEditDialog; BasalEditDialog basalEditDialog;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -87,7 +90,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
isfeditIcon = (ImageView) layout.findViewById(R.id.circadianpercentageprofile_isfedit); isfeditIcon = (ImageView) layout.findViewById(R.id.circadianpercentageprofile_isfedit);
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl); mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
mmolView.setChecked(circadianPercentageProfilePlugin.mmol); mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
diaView.setText(circadianPercentageProfilePlugin.dia.toString()); diaView.setText(circadianPercentageProfilePlugin.dia.toString());
@ -232,6 +234,8 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
percentageView.addTextChangedListener(textWatch); percentageView.addTextChangedListener(textWatch);
timeshiftView.addTextChangedListener(textWatch); timeshiftView.addTextChangedListener(textWatch);
onStatusEvent(null);
return layout; return layout;
} }
@ -294,7 +298,8 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
ImageView copyprevbutton = (ImageView) childview.findViewById(R.id.basal_copyprev_elem); ImageView copyprevbutton = (ImageView) childview.findViewById(R.id.basal_copyprev_elem);
if (i == 0) { if (i == 0) {
copyprevbutton.setVisibility(View.INVISIBLE);; copyprevbutton.setVisibility(View.INVISIBLE);
;
} else { } else {
final int j = i; //needs to be final to be passed to inner class. final int j = i; //needs to be final to be passed to inner class.
copyprevbutton.setOnClickListener(new View.OnClickListener() { copyprevbutton.setOnClickListener(new View.OnClickListener() {
@ -334,11 +339,34 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
return view; return view;
} }
} }
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
onStatusEvent(null);
}
@Subscribe
public void onStatusEvent(final EventInitializationChanged e) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!MainApp.getConfigBuilder().isInitialized() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
profileswitchButton.setVisibility(View.GONE);
} else {
profileswitchButton.setVisibility(View.VISIBLE);
}
}
});
}
} }

View file

@ -57,7 +57,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
pumpDescription.highTempPercentDuration = 0; pumpDescription.highTempPercentDuration = 0;
pumpDescription.highTempAbsoluteDuration = 0; pumpDescription.highTempAbsoluteDuration = 0;
pumpDescription.isSetBasalProfileCapable = true; pumpDescription.isSetBasalProfileCapable = false;
pumpDescription.basalStep = 0d; pumpDescription.basalStep = 0d;
pumpDescription.basalMinimumRate = 0d; pumpDescription.basalMinimumRate = 0d;

View file

@ -136,6 +136,9 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
basalView.addTextChangedListener(textWatch); basalView.addTextChangedListener(textWatch);
targetlowView.addTextChangedListener(textWatch); targetlowView.addTextChangedListener(textWatch);
targethighView.addTextChangedListener(textWatch); targethighView.addTextChangedListener(textWatch);
onStatusEvent(null);
return layout; return layout;
} }
@ -149,6 +152,7 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
MainApp.bus().register(this); MainApp.bus().register(this);
onStatusEvent(null);
} }
@Subscribe @Subscribe
@ -158,7 +162,7 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!MainApp.getConfigBuilder().isInitialized()) { if (!MainApp.getConfigBuilder().isInitialized() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
profileswitchButton.setVisibility(View.GONE); profileswitchButton.setVisibility(View.GONE);
} else { } else {
profileswitchButton.setVisibility(View.VISIBLE); profileswitchButton.setVisibility(View.VISIBLE);