From 448ebbc7bf9b26584038a22a1a4bba38d91b3c62 Mon Sep 17 00:00:00 2001 From: Jamorham Date: Sun, 18 Feb 2018 14:27:30 +0000 Subject: [PATCH] Add FeatureRunning event triggered by activities --- .../nightscout/androidaps/MainActivity.java | 3 +- .../events/EventFeatureRunning.java | 36 +++++++++++++++++++ .../Overview/Dialogs/WizardDialog.java | 4 +-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/events/EventFeatureRunning.java diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index b702897ba4..fe6ab112ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -35,9 +35,9 @@ import com.squareup.otto.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Services.AlarmSoundService; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.events.EventAppExit; +import info.nightscout.androidaps.events.EventFeatureRunning; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginBase; @@ -209,6 +209,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe super.onResume(); askForSMSPermissions(); askForLocationPermissions(); + MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN)); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventFeatureRunning.java b/app/src/main/java/info/nightscout/androidaps/events/EventFeatureRunning.java new file mode 100644 index 0000000000..0d07cd6c61 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/EventFeatureRunning.java @@ -0,0 +1,36 @@ +package info.nightscout.androidaps.events; + +/** + * Created by jamorham on 07/02/2018. + * + * Event to indicate that an app feature is being used, for example bolus wizard being opened + * + * The purpose this has been created for is to enable opportunistic connection to the pump + * so that it is already connected before the user wishes to enact a pump function + * + */ + +public class EventFeatureRunning extends Event { + + private Feature feature = Feature.UNKNOWN; + + public EventFeatureRunning() { + } + + public EventFeatureRunning(Feature feature) { + this.feature = feature; + } + + public Feature getFeature() { + return feature; + } + + public enum Feature { + UNKNOWN, + MAIN, + WIZARD, + + JUST_ADD_MORE_HERE + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index fd720e9499..9d4e728d25 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -50,6 +50,7 @@ import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TempTarget; +import info.nightscout.androidaps.events.EventFeatureRunning; import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; @@ -57,8 +58,6 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; -import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; -import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.queue.Callback; import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; @@ -132,6 +131,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com public void onResume() { super.onResume(); MainApp.bus().register(this); + MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.WIZARD)); } @Override