hide pump control buttons when pump is not initialized
This commit is contained in:
parent
cb4330ddcd
commit
738d4c1c2a
|
@ -0,0 +1,8 @@
|
||||||
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 13.12.2016.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventInitializationChanged {
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.Actions;
|
package info.nightscout.androidaps.plugins.Actions;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
@ -13,6 +14,7 @@ import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
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.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||||
|
@ -72,29 +74,41 @@ public class ActionsFragment extends Fragment implements FragmentBase, View.OnCl
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventInitializationChanged ev) {
|
||||||
|
updateGUIIfVisible();
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventRefreshGui ev) {
|
public void onStatusEvent(final EventRefreshGui ev) {
|
||||||
updateGUIIfVisible();
|
updateGUIIfVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGUIIfVisible() {
|
void updateGUIIfVisible() {
|
||||||
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable)
|
Activity activity = getActivity();
|
||||||
|
if (activity != null)
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized())
|
||||||
profileSwitch.setVisibility(View.GONE);
|
profileSwitch.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
profileSwitch.setVisibility(View.VISIBLE);
|
profileSwitch.setVisibility(View.VISIBLE);
|
||||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable)
|
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized())
|
||||||
extendedBolus.setVisibility(View.GONE);
|
extendedBolus.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
extendedBolus.setVisibility(View.VISIBLE);
|
extendedBolus.setVisibility(View.VISIBLE);
|
||||||
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable)
|
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized())
|
||||||
tempBasal.setVisibility(View.GONE);
|
tempBasal.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
tempBasal.setVisibility(View.VISIBLE);
|
tempBasal.setVisibility(View.VISIBLE);
|
||||||
if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable)
|
if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized())
|
||||||
fill.setVisibility(View.GONE);
|
fill.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
fill.setVisibility(View.VISIBLE);
|
fill.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,6 +30,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
||||||
|
@ -328,6 +329,7 @@ public class ExecutionService extends Service {
|
||||||
|
|
||||||
danaRPump.lastConnection = now;
|
danaRPump.lastConnection = now;
|
||||||
MainApp.bus().post(new EventDanaRNewStatus());
|
MainApp.bus().post(new EventDanaRNewStatus());
|
||||||
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +44,8 @@ public class MsgInitConnStatusBolus extends MessageBase {
|
||||||
if (!pump.isExtendedBolusEnabled) {
|
if (!pump.isExtendedBolusEnabled) {
|
||||||
Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
|
Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
} else {
|
||||||
|
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.*;
|
import info.nightscout.androidaps.plugins.DanaR.comm.*;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
|
@ -319,6 +320,7 @@ public class ExecutionService extends Service {
|
||||||
|
|
||||||
danaRKoreanPump.lastConnection = now;
|
danaRKoreanPump.lastConnection = now;
|
||||||
MainApp.bus().post(new EventDanaRNewStatus());
|
MainApp.bus().post(new EventDanaRNewStatus());
|
||||||
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
|
||||||
public class MsgInitConnStatusBasic extends MessageBase {
|
public class MsgInitConnStatusBasic extends MessageBase {
|
||||||
|
@ -41,6 +42,8 @@ public class MsgInitConnStatusBasic extends MessageBase {
|
||||||
if (pump.isEasyModeEnabled) {
|
if (pump.isEasyModeEnabled) {
|
||||||
Notification notification = new Notification(Notification.EASYMODE_ENABLED, MainApp.sResources.getString(R.string.danar_disableeasymode), Notification.URGENT);
|
Notification notification = new Notification(Notification.EASYMODE_ENABLED, MainApp.sResources.getString(R.string.danar_disableeasymode), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
} else {
|
||||||
|
MainApp.bus().post(new EventDismissNotification(Notification.EASYMODE_ENABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +47,8 @@ public class MsgInitConnStatusBolus extends MessageBase {
|
||||||
if (!pump.isExtendedBolusEnabled) {
|
if (!pump.isExtendedBolusEnabled) {
|
||||||
Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
|
Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
} else {
|
||||||
|
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,10 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +27,7 @@ public class MsgSettingMeal extends MessageBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
public void handleMessage(byte[] bytes) {
|
||||||
DanaRPump pump = DanaRPlugin.getDanaRPump();
|
DanaRKoreanPump pump = DanaRKoreanPlugin.getDanaRPump();
|
||||||
pump.basalStep = intFromBuff(bytes, 0, 1) / 100d;
|
pump.basalStep = intFromBuff(bytes, 0, 1) / 100d;
|
||||||
pump.bolusStep = intFromBuff(bytes, 1, 1) / 100d;
|
pump.bolusStep = intFromBuff(bytes, 1, 1) / 100d;
|
||||||
boolean bolusEnabled = intFromBuff(bytes, 2, 1) == 1;
|
boolean bolusEnabled = intFromBuff(bytes, 2, 1) == 1;
|
||||||
|
@ -44,6 +47,8 @@ public class MsgSettingMeal extends MessageBase {
|
||||||
if (pump.isConfigUD) {
|
if (pump.isConfigUD) {
|
||||||
Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.sResources.getString(R.string.danar_switchtouhmode), Notification.URGENT);
|
Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.sResources.getString(R.string.danar_switchtouhmode), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
} else {
|
||||||
|
MainApp.bus().post(new EventDismissNotification(Notification.UD_MODE_ENABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
@ -364,6 +365,11 @@ public class OverviewFragment extends Fragment {
|
||||||
updateGUIIfVisible();
|
updateGUIIfVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventInitializationChanged ev) {
|
||||||
|
updateGUIIfVisible();
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventPreferenceChange ev) {
|
public void onStatusEvent(final EventPreferenceChange ev) {
|
||||||
updateGUIIfVisible();
|
updateGUIIfVisible();
|
||||||
|
@ -486,22 +492,22 @@ public class OverviewFragment extends Fragment {
|
||||||
apsModeView.setVisibility(View.GONE);
|
apsModeView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// **** Temp button ****
|
||||||
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
boolean showAcceptButton = !MainApp.getConfigBuilder().isClosedModeEnabled(); // Open mode needed
|
boolean showAcceptButton = !MainApp.getConfigBuilder().isClosedModeEnabled(); // Open mode needed
|
||||||
showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist
|
showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist
|
||||||
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
|
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
|
||||||
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested
|
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested
|
||||||
|
|
||||||
if (showAcceptButton) {
|
if (showAcceptButton && pump.isInitialized()) {
|
||||||
acceptTempLayout.setVisibility(View.VISIBLE);
|
acceptTempLayout.setVisibility(View.VISIBLE);
|
||||||
acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
||||||
} else {
|
} else {
|
||||||
acceptTempLayout.setVisibility(View.GONE);
|
acceptTempLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// **** Temp button ****
|
|
||||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
|
||||||
|
|
||||||
if (pump.isTempBasalInProgress()) {
|
if (pump.isTempBasalInProgress()) {
|
||||||
TempBasal activeTemp = pump.getTempBasal();
|
TempBasal activeTemp = pump.getTempBasal();
|
||||||
cancelTempLayout.setVisibility(View.VISIBLE);
|
cancelTempLayout.setVisibility(View.VISIBLE);
|
||||||
|
@ -531,7 +537,7 @@ public class OverviewFragment extends Fragment {
|
||||||
});
|
});
|
||||||
activeProfileView.setLongClickable(true);
|
activeProfileView.setLongClickable(true);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null || !pump.isInitialized()) {
|
||||||
// disable all treatment buttons because we are not able to check constraints without profile
|
// disable all treatment buttons because we are not able to check constraints without profile
|
||||||
wizardButton.setVisibility(View.INVISIBLE);
|
wizardButton.setVisibility(View.INVISIBLE);
|
||||||
treatmentButton.setVisibility(View.INVISIBLE);
|
treatmentButton.setVisibility(View.INVISIBLE);
|
||||||
|
@ -545,7 +551,7 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
// QuickWizard button
|
// QuickWizard button
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && lastBG != null) {
|
if (quickWizardEntry != null && lastBG != null && pump.isInitialized()) {
|
||||||
quickWizardLayout.setVisibility(View.VISIBLE);
|
quickWizardLayout.setVisibility(View.VISIBLE);
|
||||||
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||||
BolusWizard wizard = new BolusWizard();
|
BolusWizard wizard = new BolusWizard();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.SimpleProfile;
|
package info.nightscout.androidaps.plugins.SimpleProfile;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -12,13 +13,18 @@ import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
public class SimpleProfileFragment extends Fragment implements FragmentBase {
|
public class SimpleProfileFragment extends Fragment implements FragmentBase {
|
||||||
|
@ -56,6 +62,8 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
|
||||||
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
||||||
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
||||||
|
|
||||||
|
onStatusEvent(null);
|
||||||
|
|
||||||
mgdlView.setChecked(simpleProfilePlugin.mgdl);
|
mgdlView.setChecked(simpleProfilePlugin.mgdl);
|
||||||
mmolView.setChecked(simpleProfilePlugin.mmol);
|
mmolView.setChecked(simpleProfilePlugin.mmol);
|
||||||
diaView.setText(simpleProfilePlugin.dia.toString());
|
diaView.setText(simpleProfilePlugin.dia.toString());
|
||||||
|
@ -131,4 +139,32 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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()) {
|
||||||
|
profileswitchButton.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
profileswitchButton.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue