diff --git a/app/build.gradle b/app/build.gradle index eb0aaff343..192cc7bc07 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -149,6 +149,7 @@ dependencies { compile('com.github.tony19:logback-android-classic:1.1.1-6') { exclude group: 'com.google.android', module: 'android' } + compile 'org.apache.commons:commons-lang3:3.6' compile 'org.slf4j:slf4j-api:1.7.12' compile 'com.jjoe64:graphview:4.0.1' compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1' diff --git a/app/src/main/java/com/squareup/otto/LoggingBus.java b/app/src/main/java/com/squareup/otto/LoggingBus.java new file mode 100644 index 0000000000..3417e7dd41 --- /dev/null +++ b/app/src/main/java/com/squareup/otto/LoggingBus.java @@ -0,0 +1,87 @@ +package com.squareup.otto; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import info.nightscout.androidaps.events.Event; + +/** Logs events has they're being posted to and dispatched from the event bus. + * + * A summary of event-receiver calls that occurred so far is logged + * after 10s (after startup) and then again every 60s. + * */ +public class LoggingBus extends Bus { + private static Logger log = LoggerFactory.getLogger(LoggingBus.class); + + private static long everyMinute = System.currentTimeMillis() + 10 * 1000; + private Map> event2Receiver = new HashMap<>(); + + public LoggingBus(ThreadEnforcer enforcer) { + super(enforcer); + } + + @Override + public void post(Object event) { + if (event instanceof DeadEvent) { + log.debug("Event has no receiver: " + ((DeadEvent) event).event + ", source: " + ((DeadEvent) event).source); + return; + } + + if (!(event instanceof Event)) { + log.error("Posted event not an event class: " + event.getClass()); + } + + log.debug("<<< " + event); + try { + StackTraceElement caller = new Throwable().getStackTrace()[1]; + String className = caller.getClassName(); + className = className.substring(className.lastIndexOf(".") + 1); + log.debug(" source: " + className + "." + caller.getMethodName() + ":" + caller.getLineNumber()); + } catch (RuntimeException e) { + log.debug(" source: "); + } + + super.post(event); + } + + @Override + protected void dispatch(Object event, EventHandler wrapper) { + try { + log.debug(">>> " + event); + Field methodField = wrapper.getClass().getDeclaredField("method"); + methodField.setAccessible(true); + Method targetMethod = (Method) methodField.get(wrapper); + String className = targetMethod.getDeclaringClass().getSimpleName(); + String methodName = targetMethod.getName(); + String receiverMethod = className + "." + methodName; + log.debug(" receiver: " + receiverMethod); + + String key = event.getClass().getSimpleName(); + if (!event2Receiver.containsKey(key)) event2Receiver.put(key, new HashSet()); + event2Receiver.get(key).add(receiverMethod); + } catch (ReflectiveOperationException e) { + log.debug(" receiver: "); + } + + if (everyMinute < System.currentTimeMillis()) { + log.debug("***************** Event -> receiver pairings seen so far ****************"); + for (Map.Entry> stringSetEntry : event2Receiver.entrySet()) { + log.debug(" " + stringSetEntry.getKey()); + for (String s : stringSetEntry.getValue()) { + log.debug(" -> " + s); + } + } + log.debug("*************************************************************************"); + everyMinute = System.currentTimeMillis() + 60 * 1000; + } + + super.dispatch(event, wrapper); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index 408cd64122..cdf68b5164 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -9,13 +9,9 @@ public class Config { // MAIN FUCTIONALITY public static final boolean APS = BuildConfig.APS; // PLUGINS - public static final boolean OPENAPSENABLED = APS; - public static final boolean LOOPENABLED = APS; - public static final boolean NSCLIENT = BuildConfig.NSCLIENTOLNY; public static final boolean DANAR = true && BuildConfig.PUMPDRIVERS; - public static final boolean DANARv2 = true && BuildConfig.PUMPDRIVERS; public static final boolean ACTION = !BuildConfig.NSCLIENTOLNY; public static final boolean VIRTUALPUMP = !BuildConfig.NSCLIENTOLNY; @@ -26,8 +22,6 @@ public class Config { public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY; - public static final boolean ALLPREFERENCES = !BuildConfig.NSCLIENTOLNY; - public static final boolean displayDeviationSlope = true; public static final boolean detailedLog = true; @@ -42,6 +36,7 @@ public class Config { public static final boolean logPumpActions = true; public static final boolean logCongigBuilderActions = true; public static final boolean logAutosensData = false; + public static final boolean logEvents = false; // DanaR specific public static final boolean logDanaBTComm = true; diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 291cdd94ac..8f08d284dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -336,6 +336,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe @Override public void run() { Intent i = new Intent(v.getContext(), PreferencesActivity.class); + i.putExtra("id", -1); startActivity(i); } }, null); diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 5b0e4d187d..97f8335041 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -13,6 +13,7 @@ import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.j256.ormlite.android.apptools.OpenHelperManager; import com.squareup.otto.Bus; +import com.squareup.otto.LoggingBus; import com.squareup.otto.ThreadEnforcer; import org.slf4j.Logger; @@ -26,7 +27,7 @@ import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.Actions.ActionsFragment; -import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; +import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin; @@ -69,7 +70,7 @@ import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin; import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin; import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; -import info.nightscout.androidaps.plugins.Wear.WearFragment; +import info.nightscout.androidaps.plugins.Wear.WearPlugin; import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin; import info.nightscout.androidaps.receivers.DataReceiver; import info.nightscout.androidaps.receivers.KeepAliveReceiver; @@ -105,7 +106,8 @@ public class MainApp extends Application { log.info("Version: " + BuildConfig.VERSION_NAME); log.info("BuildVersion: " + BuildConfig.BUILDVERSION); - sBus = new Bus(ThreadEnforcer.ANY); + sBus = Config.logEvents ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); + sInstance = this; sResources = getResources(); @@ -129,13 +131,13 @@ public class MainApp extends Application { if (Config.DANAR) pluginsList.add(DanaRKoreanPlugin.getPlugin()); if (Config.DANAR) pluginsList.add(DanaRv2Plugin.getPlugin()); if (Config.DANAR) pluginsList.add(DanaRSPlugin.getPlugin()); - pluginsList.add(CareportalFragment.getPlugin()); + pluginsList.add(CareportalPlugin.getPlugin()); if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin()); - if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance()); - if (Config.LOOPENABLED) pluginsList.add(LoopPlugin.getPlugin()); - if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAPlugin.getPlugin()); - if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAPlugin.getPlugin()); - if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSSMBPlugin.getPlugin()); + if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getPlugin()); + if (Config.APS) pluginsList.add(LoopPlugin.getPlugin()); + if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin()); + if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin()); + if (Config.APS) pluginsList.add(OpenAPSSMBPlugin.getPlugin()); pluginsList.add(NSProfilePlugin.getPlugin()); if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin()); if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin()); @@ -154,8 +156,8 @@ public class MainApp extends Application { if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin()); pluginsList.add(FoodPlugin.getPlugin()); - pluginsList.add(WearFragment.getPlugin(this)); - pluginsList.add(StatuslinePlugin.getPlugin(this)); + pluginsList.add(WearPlugin.initPlugin(this)); + pluginsList.add(StatuslinePlugin.initPlugin(this)); pluginsList.add(new PersistentNotificationPlugin(this)); pluginsList.add(NSClientInternalPlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index 7fc6efa4d1..cde687b3a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.EditTextPreference; @@ -15,19 +16,27 @@ import android.text.TextUtils; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginBase; +<<<<<<< HEAD import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin; +======= +import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin; +import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin; +>>>>>>> dev2 import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin; +import info.nightscout.androidaps.plugins.Loop.LoopPlugin; +import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin; +import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; +import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.BluetoothDevicePreference; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; -import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin; -import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin; import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin; import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin; +import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin; import info.nightscout.androidaps.plugins.Wear.WearPlugin; import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin; import info.nightscout.utils.LocaleHelper; @@ -41,6 +50,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); myPreferenceFragment = new MyPreferenceFragment(); + myPreferenceFragment.setCaller(getIntent()); getFragmentManager().beginTransaction().replace(android.R.id.content, myPreferenceFragment).commit(); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); } @@ -73,15 +83,14 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre if (pref.getKey().contains("password") || pref.getKey().contains("secret")) { pref.setSummary("******"); } else if (pref.getKey().equals(MainApp.sResources.getString(R.string.key_danars_name))) { - pref.setSummary(SP.getString(R.string.key_danars_name,"")); + pref.setSummary(SP.getString(R.string.key_danars_name, "")); } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) { ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); pref.setSummary(editTextPref.getText()); - } - else if(pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().toString().trim())){ + } else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().toString().trim())) { pref.setSummary(MainApp.sResources.getString(R.string.smscommunicator_allowednumbers_summary)); } - } + } if (pref instanceof MultiSelectListPreference) { EditTextPreference editTextPref = (EditTextPreference) pref; pref.setSummary(editTextPref.getText()); @@ -100,87 +109,79 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre } public static class MyPreferenceFragment extends PreferenceFragment { + Intent caller; + + public void setCaller(Intent i) { + caller = i; + } + + void addPreferencesFromResourceIfEnabled(PluginBase p, int type) { + if (p.isEnabled(type) && p.getPreferencesId() != -1) + addPreferencesFromResource(p.getPreferencesId()); + } + @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (Config.ALLPREFERENCES) { - addPreferencesFromResource(R.xml.pref_password); - } - addPreferencesFromResource(R.xml.pref_age); - addPreferencesFromResource(R.xml.pref_language); - if (Config.ALLPREFERENCES) { - addPreferencesFromResource(R.xml.pref_quickwizard); - } - addPreferencesFromResource(R.xml.pref_careportal); - if (Config.ALLPREFERENCES) { - addPreferencesFromResource(R.xml.pref_treatments); - } - if (Config.APS) - addPreferencesFromResource(R.xml.pref_closedmode); - if (Config.OPENAPSENABLED) { - addPreferencesFromResource(R.xml.pref_openapsma); - if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) - addPreferencesFromResource(R.xml.pref_openapsama); - if (MainApp.getSpecificPlugin(OpenAPSSMBPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSSMBPlugin.class).isEnabled(PluginBase.APS)) - addPreferencesFromResource(R.xml.pref_openapsama); - } - if (MainApp.getSpecificPlugin(SensitivityAAPSPlugin.class) != null && MainApp.getSpecificPlugin(SensitivityAAPSPlugin.class).isEnabled(PluginBase.SENSITIVITY) - || MainApp.getSpecificPlugin(SensitivityWeightedAveragePlugin.class) != null && MainApp.getSpecificPlugin(SensitivityWeightedAveragePlugin.class).isEnabled(PluginBase.SENSITIVITY)) - addPreferencesFromResource(R.xml.pref_absorption_aaps); - if (MainApp.getSpecificPlugin(SensitivityOref0Plugin.class) != null && MainApp.getSpecificPlugin(SensitivityOref0Plugin.class).isEnabled(PluginBase.SENSITIVITY)) - addPreferencesFromResource(R.xml.pref_absorption_oref0); - if (Config.ALLPREFERENCES) { - addPreferencesFromResource(R.xml.pref_profile); - } - if (Config.DANAR) { - DanaRPlugin danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class); - DanaRKoreanPlugin danaRKoreanPlugin = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class); - DanaRv2Plugin danaRv2Plugin = MainApp.getSpecificPlugin(DanaRv2Plugin.class); - DanaRSPlugin danaRSPlugin = MainApp.getSpecificPlugin(DanaRSPlugin.class); - if (danaRPlugin.isEnabled(PluginBase.PUMP)) { - addPreferencesFromResource(R.xml.pref_danar); - } - if (danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) { - addPreferencesFromResource(R.xml.pref_danarkorean); - } - if (danaRv2Plugin != null && danaRv2Plugin.isEnabled(PluginBase.PUMP)) { - addPreferencesFromResource(R.xml.pref_danarv2); - } - if (danaRSPlugin != null && danaRSPlugin.isEnabled(PluginBase.PUMP)) { - addPreferencesFromResource(R.xml.pref_danars); - } - if (danaRPlugin.isEnabled(PluginBase.PROFILE) || danaRKoreanPlugin.isEnabled(PluginBase.PROFILE) || danaRv2Plugin != null && danaRv2Plugin.isEnabled(PluginBase.PROFILE)) { - addPreferencesFromResource(R.xml.pref_danarprofile); - } - } - VirtualPumpPlugin virtualPumpPlugin = MainApp.getSpecificPlugin(VirtualPumpPlugin.class); - if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) { - addPreferencesFromResource(R.xml.pref_virtualpump); - } - InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin = MainApp.getSpecificPlugin(InsulinOrefFreePeakPlugin.class); - if (insulinOrefFreePeakPlugin.isEnabled(PluginBase.INSULIN)) { - addPreferencesFromResource(R.xml.pref_insulinoreffreepeak); - } - NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class); - if (nsClientInternalPlugin != null && nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) { - addPreferencesFromResource(R.xml.pref_nsclientinternal); - } - if (Config.SMSCOMMUNICATORENABLED) - addPreferencesFromResource(R.xml.pref_smscommunicator); - if (Config.ALLPREFERENCES) { - addPreferencesFromResource(R.xml.pref_others); - } - addPreferencesFromResource(R.xml.pref_advanced); + Integer id = caller.getIntExtra("id", -1); - WearPlugin wearPlugin = MainApp.getSpecificPlugin(WearPlugin.class); - if (wearPlugin != null && wearPlugin.isEnabled(PluginBase.GENERAL)) { - addPreferencesFromResource(R.xml.pref_wear); - } + if (id != -1) { + addPreferencesFromResource(id); + } else { + if (!Config.NSCLIENT) { + addPreferencesFromResource(R.xml.pref_password); + } + addPreferencesFromResource(R.xml.pref_age); + addPreferencesFromResource(R.xml.pref_language); - StatuslinePlugin statuslinePlugin = MainApp.getSpecificPlugin(StatuslinePlugin.class); - if (statuslinePlugin != null && statuslinePlugin.isEnabled(PluginBase.GENERAL)) { - addPreferencesFromResource(R.xml.pref_xdripstatus); + if (!Config.NSCLIENT) { + addPreferencesFromResource(R.xml.pref_quickwizard); + } + addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginBase.GENERAL); + addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginBase.CONSTRAINTS); + if (Config.APS) { + addPreferencesFromResourceIfEnabled(LoopPlugin.getPlugin(), PluginBase.LOOP); + addPreferencesFromResourceIfEnabled(OpenAPSMAPlugin.getPlugin(), PluginBase.APS); + addPreferencesFromResourceIfEnabled(OpenAPSAMAPlugin.getPlugin(), PluginBase.APS); + } + + addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), PluginBase.SENSITIVITY); + addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginBase.SENSITIVITY); + addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginBase.SENSITIVITY); + + if (!Config.NSCLIENT) { + addPreferencesFromResource(R.xml.pref_profile); + } + + if (Config.DANAR) { + addPreferencesFromResourceIfEnabled(DanaRPlugin.getPlugin(), PluginBase.PUMP); + addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginBase.PUMP); + addPreferencesFromResourceIfEnabled(DanaRv2Plugin.getPlugin(), PluginBase.PUMP); + addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginBase.PUMP); + + if (DanaRPlugin.getPlugin().isEnabled(PluginBase.PROFILE) + || DanaRKoreanPlugin.getPlugin().isEnabled(PluginBase.PROFILE) + || DanaRv2Plugin.getPlugin().isEnabled(PluginBase.PROFILE) + || DanaRSPlugin.getPlugin().isEnabled(PluginBase.PROFILE)) { + addPreferencesFromResource(R.xml.pref_danarprofile); + } + } + + addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginBase.PUMP); + + addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginBase.INSULIN); + + addPreferencesFromResourceIfEnabled(NSClientInternalPlugin.getPlugin(), PluginBase.GENERAL); + addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginBase.GENERAL); + + if (!Config.NSCLIENT) { + addPreferencesFromResource(R.xml.pref_others); + } + addPreferencesFromResource(R.xml.pref_advanced); + + addPreferencesFromResourceIfEnabled(WearPlugin.getPlugin(), PluginBase.GENERAL); + addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginBase.GENERAL); } initSummary(getPreferenceScreen()); diff --git a/app/src/main/java/info/nightscout/androidaps/events/Event.java b/app/src/main/java/info/nightscout/androidaps/events/Event.java new file mode 100644 index 0000000000..864d55d6f7 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/Event.java @@ -0,0 +1,16 @@ +package info.nightscout.androidaps.events; + +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** Base class for all events posted on the event bus. */ +public abstract class Event { + static { + ReflectionToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java b/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java index 0f23643fef..9ce91a9a39 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 07.07.2016. */ -public class EventAppExit { +public class EventAppExit extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java b/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java index 1f41119b4b..cb727758bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java @@ -4,7 +4,7 @@ package info.nightscout.androidaps.events; * Created by adrian on 07/02/17. */ -public class EventBolusRequested { +public class EventBolusRequested extends Event { private double amount; public EventBolusRequested (double amount){ diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java index d86fe679fb..9b47ed39cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 25.05.2017. */ -public class EventCareportalEventChange { +public class EventCareportalEventChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java index 38331ca581..ad5f558fe8 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 17.02.2017. */ -public class EventConfigBuilderChange { +public class EventConfigBuilderChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java index 78dee60388..8881b0ecc1 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 15.05.2017. */ -public class EventExtendedBolusChange { +public class EventExtendedBolusChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java index 075993c530..48e6be3a14 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 20.09.2017. */ -public class EventFoodDatabaseChanged { +public class EventFoodDatabaseChanged extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java index e9a9ce511d..f2bef1d3d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 13.12.2016. */ -public class EventInitializationChanged { +public class EventInitializationChanged extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventLoop.java b/app/src/main/java/info/nightscout/androidaps/events/EventLoop.java new file mode 100644 index 0000000000..d694d52537 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/EventLoop.java @@ -0,0 +1,5 @@ +package info.nightscout.androidaps.events; + +/** Supeclass for all events concerned with input or output into or from the LoopPlugin. */ +public abstract class EventLoop extends Event { +} diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java index 2d6454406a..2fb9919b00 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 05.06.2016. */ -public class EventNewBG { +public class EventNewBG extends EventLoop { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java index 1309625b98..f26a310b6b 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 04.06.2016. */ -public class EventNewBasalProfile { +public class EventNewBasalProfile extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java index 76da0a4e67..f99cb54568 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java @@ -5,7 +5,7 @@ import info.nightscout.androidaps.MainApp; /** * Created by mike on 19.06.2016. */ -public class EventPreferenceChange { +public class EventPreferenceChange extends Event { public String changedKey; public EventPreferenceChange(String key) { changedKey = key; diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java index 476a571d70..7bab9d4518 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 02.06.2017. */ -public class EventProfileSwitchChange { +public class EventProfileSwitchChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java index 3cfe7cc6a7..52c3183821 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java @@ -7,7 +7,7 @@ import info.nightscout.androidaps.R; * Created by mike on 19.02.2017. */ -public class EventPumpStatusChanged { +public class EventPumpStatusChanged extends Event { public static final int CONNECTING = 0; public static final int CONNECTED = 1; public static final int PERFORMING = 2; diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java index f20dfb9329..1dae34d2af 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 13.06.2016. */ -public class EventRefreshGui { +public class EventRefreshGui extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java index bf14f5f585..2ba78fa9ec 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java @@ -4,7 +4,7 @@ package info.nightscout.androidaps.events; * Created by mike on 16.06.2017. */ -public class EventRefreshOverview { +public class EventRefreshOverview extends Event { public String from; public EventRefreshOverview(String from) { diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java b/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java index 20073a7cf0..212e8856d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 12.06.2017. */ -public class EventReloadProfileSwitchData { +public class EventReloadProfileSwitchData extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java index 38b1b86186..80125cbb4a 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 29.05.2017. */ -public class EventReloadTempBasalData { +public class EventReloadTempBasalData extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java index d4ea0d3f70..0ba9b95ad7 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java @@ -4,7 +4,7 @@ package info.nightscout.androidaps.events; * Created by mike on 29.05.2017. */ -public class EventReloadTreatmentData { +public class EventReloadTreatmentData extends Event { public Object next; public EventReloadTreatmentData(Object next) { diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java index 5d8f961e75..73660bb00e 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 05.06.2016. */ -public class EventTempBasalChange { +public class EventTempBasalChange extends EventLoop { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java index d0ef42d830..4e3bf5c5f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 13.01.2017. */ -public class EventTempTargetChange { +public class EventTempTargetChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java index a8597189bc..439d9a7124 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 04.06.2016. */ -public class EventTreatmentChange { +public class EventTreatmentChange extends EventLoop { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java new file mode 100644 index 0000000000..3471d2e851 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java @@ -0,0 +1,5 @@ +package info.nightscout.androidaps.events; + +/** Base class for events to update the UI, mostly a specific tab. */ +public abstract class EventUpdateGui extends Event { +} diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java index bf5e66f2a1..08db6210d4 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java @@ -30,4 +30,5 @@ public interface PluginBase { boolean showInList(int type); void setFragmentEnabled(int type, boolean fragmentEnabled); void setFragmentVisible(int type, boolean fragmentVisible); + int getPreferencesId(); } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java index 74252e2689..3c71626e64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java @@ -74,4 +74,9 @@ public class ActionsPlugin implements PluginBase { if (type == GENERAL) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java index d832d2aab0..bee1c3b923 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java @@ -26,8 +26,6 @@ import info.nightscout.androidaps.plugins.Overview.OverviewFragment; public class CareportalFragment extends SubscriberFragment implements View.OnClickListener { - static CareportalPlugin careportalPlugin; - TextView iage; TextView cage; TextView sage; @@ -37,13 +35,6 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli LinearLayout butonsLayout; View noProfileView; - static public CareportalPlugin getPlugin() { - if (careportalPlugin == null) { - careportalPlugin = new CareportalPlugin(); - } - return careportalPlugin; - } - // date,bg,insulin,carbs,prebolus,duration,percent,absolute,profile,split,temptarget public static final OptionsToShow BGCHECK = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck).date().bg(); public static final OptionsToShow SNACKBOLUS = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus).date().bg().insulin().carbs().prebolus(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java index ceab1b1650..fc6dd7fd05 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java @@ -10,6 +10,15 @@ public class CareportalPlugin implements PluginBase { private boolean fragmentEnabled = true; private boolean fragmentVisible = true; + static CareportalPlugin careportalPlugin; + + static public CareportalPlugin getPlugin() { + if (careportalPlugin == null) { + careportalPlugin = new CareportalPlugin(); + } + return careportalPlugin; + } + @Override public int getType() { return PluginBase.GENERAL; @@ -71,4 +80,9 @@ public class CareportalPlugin implements PluginBase { if (type == GENERAL) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_careportal; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java index 1b976195ae..16cfd89404 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java @@ -138,6 +138,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + if (options==null) return null; getDialog().setTitle(getString(options.eventName)); setStyle(DialogFragment.STYLE_NORMAL, getTheme()); View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java index 4c868bcc3f..46c2083d0b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.ConfigBuilder; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; @@ -10,6 +11,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListAdapter; import android.widget.ListView; @@ -22,6 +24,7 @@ import com.crashlytics.android.answers.CustomEvent; import java.util.ArrayList; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.PreferencesActivity; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventConfigBuilderChange; import info.nightscout.androidaps.events.EventRefreshGui; @@ -194,7 +197,7 @@ public class ConfigBuilderFragment extends Fragment { public PluginCustomAdapter(Context context, int textViewResourceId, ArrayList pluginList, int type) { super(context, textViewResourceId, pluginList); - this.pluginList = new ArrayList(); + this.pluginList = new ArrayList<>(); this.pluginList.addAll(pluginList); this.type = type; } @@ -203,12 +206,14 @@ public class ConfigBuilderFragment extends Fragment { TextView name; CheckBox checkboxEnabled; CheckBox checkboxVisible; + ImageView settings; } @Override public View getView(int position, View view, ViewGroup parent) { PluginViewHolder holder = null; + PluginBase plugin = pluginList.get(position); if (view == null) { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.configbuilder_simpleitem, null); @@ -217,6 +222,13 @@ public class ConfigBuilderFragment extends Fragment { holder.name = (TextView) view.findViewById(R.id.configbuilder_simpleitem_name); holder.checkboxEnabled = (CheckBox) view.findViewById(R.id.configbuilder_simpleitem_checkboxenabled); holder.checkboxVisible = (CheckBox) view.findViewById(R.id.configbuilder_simpleitem_checkboxvisible); + holder.settings = (ImageView) view.findViewById(R.id.configbuilder_simpleitem_settings); + + if (plugin.isEnabled(type) && plugin.getPreferencesId() != -1) + holder.settings.setVisibility(View.VISIBLE); + else + holder.settings.setVisibility(View.INVISIBLE); + view.setTag(holder); holder.checkboxEnabled.setOnClickListener(new View.OnClickListener() { @@ -244,17 +256,31 @@ public class ConfigBuilderFragment extends Fragment { getPlugin().logPluginStatus(); } }); + + holder.settings.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + final PluginBase plugin = (PluginBase) v.getTag(); + PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", new Runnable() { + @Override + public void run() { + Intent i = new Intent(getContext(), PreferencesActivity.class); + i.putExtra("id", plugin.getPreferencesId()); + startActivity(i); + } + }, null); + } + }); } else { holder = (PluginViewHolder) view.getTag(); } - PluginBase plugin = pluginList.get(position); holder.name.setText(plugin.getName()); holder.checkboxEnabled.setChecked(plugin.isEnabled(type)); holder.checkboxVisible.setChecked(plugin.isVisibleInTabs(type)); holder.name.setTag(plugin); holder.checkboxEnabled.setTag(plugin); holder.checkboxVisible.setTag(plugin); + holder.settings.setTag(plugin); if (!plugin.canBeHidden(type)) { holder.checkboxEnabled.setEnabled(false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 8be6a5475c..cd40adb712 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -148,6 +148,11 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain // Always visible } + @Override + public int getPreferencesId() { + return -1; + } + public void initialize() { pluginList = MainApp.getPluginsList(); loadSettings(); @@ -303,7 +308,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP); activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP); if (activePump == null) - activePump = VirtualPumpPlugin.getInstance(); // for NSClient build + activePump = VirtualPumpPlugin.getPlugin(); // for NSClient build if (Config.logConfigBuilder) log.debug("Selected pump interface: " + ((PluginBase) activePump).getName()); for (PluginBase p : pluginsInCategory) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java index 7c353e48e2..04edeb43a1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java @@ -104,6 +104,11 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface { if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + class Objective { Integer num; String objective; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java index 6880d1a21e..a64241a4b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java @@ -86,6 +86,11 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { public void setFragmentVisible(int type, boolean fragmentVisible) { } + @Override + public int getPreferencesId() { + return R.xml.pref_safety; + } + @Override public boolean isLoopEnabled() { return MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodPlugin.java index dbd1549c11..255b4fd951 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodPlugin.java @@ -76,5 +76,10 @@ public class FoodPlugin implements PluginBase { if (type == GENERAL) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingPlugin.java index 46f0b46864..c7164ea60e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingPlugin.java @@ -80,6 +80,11 @@ public class InsulinFastactingPlugin implements PluginBase, InsulinInterface { if (type == INSULIN) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + // Insulin interface @Override public int getId() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingProlongedPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingProlongedPlugin.java index 540151e237..99c35a6c0b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingProlongedPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFastactingProlongedPlugin.java @@ -80,6 +80,11 @@ public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInte if (type == INSULIN) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + // Insulin interface @Override public int getId() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java index 8d19eeb4af..3cc2e6b9ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java @@ -68,6 +68,11 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin { if (type == INSULIN) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_insulinoreffreepeak; + } + @Override int getPeak() { return SP.getInt(R.string.key_insulin_oref_peak, DEFAULT_PEAK); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java index be6f70c01f..cae9ac540d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java @@ -67,6 +67,11 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin { if (type == INSULIN) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + @Override int getPeak() { return PEAK; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java index 453620933e..0d390a3ba2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java @@ -67,6 +67,11 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin { if (type == INSULIN) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + @Override int getPeak() { return PEAK; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 927126941b..5087d75bbd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -126,6 +126,11 @@ public class IobCobCalculatorPlugin implements PluginBase { } + @Override + public int getPreferencesId() { + return -1; + } + IobCobCalculatorPlugin() { MainApp.bus().register(this); if (sHandlerThread == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java index f2977c90c5..ea73915436 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.IobCobCalculator.events; +import info.nightscout.androidaps.events.EventLoop; + /** * Created by mike on 30.04.2017. */ -public class EventAutosensCalculationFinished { +public class EventAutosensCalculationFinished extends EventLoop { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java index 7499fad383..8814741099 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.IobCobCalculator.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 26.04.2017. */ -public class EventNewHistoryData { +public class EventNewHistoryData extends Event { public long time = 0; public EventNewHistoryData(long time) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 5a62644e71..4f03ca54c3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -148,6 +148,11 @@ public class LoopPlugin implements PluginBase { if (type == LOOP) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_closedmode; + } + @Subscribe public void onStatusEvent(final EventTreatmentChange ev) { invoke("EventTreatmentChange", true); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java index 7baf556546..1ef5dc4c94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.Loop.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventLoopSetLastRunGui { +public class EventLoopSetLastRunGui extends EventUpdateGui { public String text = null; public EventLoopSetLastRunGui(String text) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java index d671b3bd64..d4417dbb12 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.Loop.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventLoopUpdateGui { +public class EventLoopUpdateGui extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java index 7a6184e406..001d11661e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.Loop.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 07.08.2016. */ -public class EventNewOpenLoopNotification { +public class EventNewOpenLoopNotification extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java index 7e8a76ce1b..d5ca87a479 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java @@ -135,6 +135,11 @@ public class NSClientInternalPlugin implements PluginBase { if (type == GENERAL) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_nsclientinternal; + } + private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java index 709c53f6d4..e90dce3bec 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java @@ -7,14 +7,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart; -import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import io.socket.client.Ack; /** * Created by mike on 29.12.2015. */ -public class NSAddAck implements Ack { +public class NSAddAck extends Event implements Ack { private static Logger log = LoggerFactory.getLogger(NSAddAck.class); public String _id = null; public String nsClientID = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java index 3c3b173173..56055351d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java @@ -3,13 +3,14 @@ package info.nightscout.androidaps.plugins.NSClientInternal.acks; import org.json.JSONObject; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog; import io.socket.client.Ack; /** * Created by mike on 02.01.2016. */ -public class NSAuthAck implements Ack{ +public class NSAuthAck extends Event implements Ack{ public boolean read = false; public boolean write = false; public boolean write_treatment = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSPingAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSPingAck.java deleted file mode 100644 index 1ec6e3991c..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSPingAck.java +++ /dev/null @@ -1,44 +0,0 @@ -package info.nightscout.androidaps.plugins.NSClientInternal.acks; - -import android.os.SystemClock; - -import org.json.JSONException; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import io.socket.client.Ack; - -/** - * Created by mike on 29.12.2015. - */ -public class NSPingAck implements Ack { - private static Logger log = LoggerFactory.getLogger(NSPingAck.class); - - public long mills = 0; - public boolean received = false; - public boolean auth_received = false; - public boolean read = false; - public boolean write = false; - public boolean write_treatment = false; - - public void call(Object...args) { - JSONObject response = (JSONObject)args[0]; - mills = response.optLong("mills"); - if (response.has("authorization")) { - auth_received = true; - try { - JSONObject authorization = response.getJSONObject("authorization"); - read = authorization.optBoolean("read"); - write = authorization.optBoolean("write"); - write_treatment = authorization.optBoolean("write_treatment"); - } catch (JSONException e) { - log.error("Unhandled exception", e); - } - } - received = true; - synchronized(this) { - this.notify(); - } - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java index 5aef754d8c..2bf520da64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java @@ -6,12 +6,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.events.Event; import io.socket.client.Ack; /** * Created by mike on 21.02.2016. */ -public class NSUpdateAck implements Ack { +public class NSUpdateAck extends Event implements Ack { private static Logger log = LoggerFactory.getLogger(NSUpdateAck.class); public boolean result = false; public String _id = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java index 7caafbd28a..82b11a812d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java @@ -1,19 +1,15 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; -import android.text.Html; -import android.text.Spanned; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.text.SimpleDateFormat; import java.util.Date; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 15.02.2017. */ -public class EventNSClientNewLog { +public class EventNSClientNewLog extends Event { public Date date = new Date(); public String action; public String logText; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java index 9bf90be31b..b968878da8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 15.02.2017. */ -public class EventNSClientRestart { +public class EventNSClientRestart extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java index 6a1c721535..977c0e31fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 02.01.2016. */ -public class EventNSClientStatus { +public class EventNSClientStatus extends Event { public String status = ""; public EventNSClientStatus(String status) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java index 8f00bd3424..dd78d2cd28 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 17.02.2017. */ -public class EventNSClientUpdateGUI { +public class EventNSClientUpdateGUI extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index be7b830880..b64d4b6b08 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -103,6 +103,11 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface { if (type == APS) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_openapsama; + } + @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { if (type == APS) this.fragmentEnabled = fragmentEnabled; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index 4d5f97c1b0..a0d5cddd88 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -101,6 +101,11 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface { if (type == APS) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_openapsma; + } + @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { if (type == APS) this.fragmentEnabled = fragmentEnabled; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java index 65b3b49d53..40f3c31973 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.OpenAPSMA.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventOpenAPSUpdateGui { +public class EventOpenAPSUpdateGui extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java index 2aa2365eff..e65cdd2c57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.OpenAPSMA.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventOpenAPSUpdateResultGui { +public class EventOpenAPSUpdateResultGui extends EventUpdateGui { public String text = null; public EventOpenAPSUpdateResultGui(String text) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index a7567508a8..6c35a7de17 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -996,7 +996,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, tempTargetView.setTextColor(Color.BLACK); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground)); tempTargetView.setVisibility(View.VISIBLE); - tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units)); + tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end())); } else { tempTargetView.setTextColor(Color.WHITE); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java index d779b82ae9..7eecbada25 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java @@ -103,6 +103,11 @@ public class OverviewPlugin implements PluginBase { // Always visible } + @Override + public int getPreferencesId() { + return -1; + } + @Override public int getType() { return PluginBase.GENERAL; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java index 9d8435eaf1..af336cd74c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java @@ -1,12 +1,13 @@ package info.nightscout.androidaps.plugins.Overview.events; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.events.Event; /** * Created by adrian on 20/02/17. */ -public class EventDismissBolusprogressIfRunning { +public class EventDismissBolusprogressIfRunning extends Event { public final PumpEnactResult result; public EventDismissBolusprogressIfRunning(PumpEnactResult result) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java index f2414e2a4e..1fa71febbe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 03.12.2016. */ -public class EventDismissNotification { +public class EventDismissNotification extends Event { public int id; public EventDismissNotification(int did) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java index 8a80019f3e..59ad1a335d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java @@ -1,12 +1,13 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.plugins.Overview.Notification; /** * Created by mike on 03.12.2016. */ -public class EventNewNotification { +public class EventNewNotification extends Event { public Notification notification; public EventNewNotification(Notification n) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java index 0882032362..e0fd53a1fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java @@ -4,8 +4,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.events.Event; -public class EventOverviewBolusProgress { +public class EventOverviewBolusProgress extends Event { private static Logger log = LoggerFactory.getLogger(EventOverviewBolusProgress.class); public String status = ""; public Treatment t = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java index 1a9923f606..b72c2548e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 20.10.2016. */ -public class EventQuickWizardChange { +public class EventQuickWizardChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java index 519341172d..49ccf9fbfb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 02.07.2017. */ -public class EventSetWakeLock { +public class EventSetWakeLock extends Event { public boolean lock = false; public EventSetWakeLock(boolean val) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index 9432552c1a..f0745afe94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -205,6 +205,11 @@ public class PersistentNotificationPlugin implements PluginBase { //no visible fragment } + @Override + public int getPreferencesId() { + return -1; + } + private String deltastring(double deltaMGDL, double deltaMMOL, String units) { String deltastring = ""; if (deltaMGDL >= 0) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java index 2afb47e034..ea4f32e794 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java @@ -119,6 +119,11 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte if (type == PROFILE) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + void storeSettings() { if (Config.logPrefsChange) log.debug("Storing settings"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java index 61bff582a5..b9780d7493 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java @@ -108,6 +108,11 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface { if (type == PROFILE) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + public void storeSettings() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); SharedPreferences.Editor editor = settings.edit(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java index 53900da781..e4fdabecf9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java @@ -104,6 +104,11 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface { if (type == PROFILE) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + @Override public int getType() { return PluginBase.PROFILE; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java index 7bb5df792f..d24c59e511 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.ProfileNS.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventNSProfileUpdateGUI { +public class EventNSProfileUpdateGUI extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java index 8f38cecb92..d0b36d34ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java @@ -111,6 +111,11 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface { if (type == PROFILE) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + public void storeSettings() { if (Config.logPrefsChange) log.debug("Storing settings"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index d48013b0e6..0c4a5beded 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -226,7 +226,7 @@ public class DanaRFragment extends SubscriberFragment { Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime(); double agoHours = agoMsec / 60d / 60d / 1000d; if (agoHours < 6) // max 6h back - lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U"); + lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime.getTime()) + " " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U"); else lastBolusView.setText(""); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java index 65dd5192e4..115f612f6c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java @@ -217,6 +217,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C fragmentPumpVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_danar; + } + @Override public boolean isFakingTempsByExtendedBoluses() { return useExtendedBoluses; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java index 8217b51432..9e3af48fb2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 03.08.2016. */ -public class EventDanaRBolusStart { +public class EventDanaRBolusStart extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java index a04f27f2d6..55b0ab0998 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 08.07.2016. */ -public class EventDanaRNewStatus { +public class EventDanaRNewStatus extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java index b64cf22748..4e3f28de9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.PumpDanaR.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 20.07.2016. */ -public class EventDanaRSyncStatus { +public class EventDanaRSyncStatus extends Event { public String message; public EventDanaRSyncStatus() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java index c8b2d04759..c0071ecfca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java @@ -219,6 +219,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf this.fragmentPumpVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_danarkorean; + } + @Override public boolean isFakingTempsByExtendedBoluses() { return useExtendedBoluses; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index 468626fe26..5f97999bfa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -137,6 +137,11 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, this.fragmentPumpVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_danars; + } + static boolean fragmentPumpEnabled = false; static boolean fragmentProfileEnabled = false; static boolean fragmentPumpVisible = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java index 4a224bd57b..f9156bb430 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java @@ -204,6 +204,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, this.fragmentPumpVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_danarv2; + } + @Override public boolean isFakingTempsByExtendedBoluses() { return false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java index ca3f7a62a0..da4ea8157d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java @@ -99,6 +99,11 @@ public class MDIPlugin implements PluginBase, PumpInterface { if (type == PUMP) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + @Override public int getType() { return PluginBase.PUMP; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java index 9d19f9f132..3590af80fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java @@ -79,7 +79,7 @@ public class VirtualPumpFragment extends SubscriberFragment { activity.runOnUiThread(new Runnable() { @Override public void run() { - VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getInstance(); + VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getPlugin(); basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U"); if (MainApp.getConfigBuilder().isTempBasalInProgress()) { tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index e7323f48af..2e3be7ab95 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -64,12 +64,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { return fromNSAreCommingFakedExtendedBoluses; } - private static VirtualPumpPlugin instance = null; - public static VirtualPumpPlugin getInstance() { + private static VirtualPumpPlugin plugin = null; + public static VirtualPumpPlugin getPlugin() { loadFakingStatus(); - if (instance == null) - instance = new VirtualPumpPlugin(); - return instance; + if (plugin == null) + plugin = new VirtualPumpPlugin(); + return plugin; } private VirtualPumpPlugin() { @@ -154,6 +154,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { if (type == PUMP) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_virtualpump; + } + @Override public int getType() { return PluginBase.PUMP; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java index 110e0f4a56..e035ea3aba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.PumpVirtual.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventVirtualPumpUpdateGui { +public class EventVirtualPumpUpdateGui extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java index 2cf6b5a4e4..39af16e0ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java @@ -96,6 +96,11 @@ public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{ if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_absorption_aaps; + } + @Override public AutosensResult detectSensitivity(long fromTime, long toTime) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java index da89882a27..6817e17503 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java @@ -94,6 +94,11 @@ public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_absorption_oref0; + } + @Override public AutosensResult detectSensitivity(long fromTime, long toTime) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java index 68537cf47c..596c2477f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java @@ -93,6 +93,11 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_absorption_aaps; + } + @Override public AutosensResult detectSensitivity(long fromTime, long toTime) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index 67c497a06d..9fdb0152d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -186,6 +186,11 @@ public class SmsCommunicatorPlugin implements PluginBase { if (type == GENERAL) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_smscommunicator; + } + @Subscribe public void processSettings(final EventPreferenceChange ev) { if (ev == null || ev.isChanged(R.string.key_smscommunicator_allowednumbers)) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java index 2b890fb59c..dfaebb3942 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java @@ -2,10 +2,12 @@ package info.nightscout.androidaps.plugins.SmsCommunicator.events; import android.os.Bundle; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 13.07.2016. */ -public class EventNewSMS { +public class EventNewSMS extends Event { public Bundle bundle; public EventNewSMS(Bundle bundle) { this.bundle = bundle; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java index 7c1d480e72..02956a5d67 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.SmsCommunicator.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventSmsCommunicatorUpdateGui { +public class EventSmsCommunicatorUpdateGui extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpPlugin.java index 2fbe60cbf5..934635f03b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpPlugin.java @@ -75,5 +75,10 @@ public class SourceGlimpPlugin implements PluginBase, BgSourceInterface { } + @Override + public int getPreferencesId() { + return -1; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceMM640g/SourceMM640gPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceMM640g/SourceMM640gPlugin.java index 57b32c1ad1..aba07ffe05 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceMM640g/SourceMM640gPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceMM640g/SourceMM640gPlugin.java @@ -75,5 +75,10 @@ public class SourceMM640gPlugin implements PluginBase, BgSourceInterface { } + @Override + public int getPreferencesId() { + return -1; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java index cc2cb15878..0e85793850 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java @@ -77,5 +77,10 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface { } + @Override + public int getPreferencesId() { + return -1; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java index 0d0fb07c45..8363f13566 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java @@ -75,5 +75,10 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface { public void setFragmentVisible(int type, boolean fragmentVisible) { } + @Override + public int getPreferencesId() { + return -1; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index 441f6eec88..4b134086d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -122,6 +122,11 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { if (type == TREATMENT) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return -1; + } + @Override public int getType() { return PluginBase.TREATMENT; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 9fbcc31685..a7b90775f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -324,7 +324,7 @@ public class ActionStringHandler { // send result - WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(rTitle, rMessage, rAction); + WearPlugin.getPlugin().requestActionConfirmation(rTitle, rMessage, rAction); lastSentTimestamp = System.currentTimeMillis(); lastConfirmActionString = rAction; } @@ -596,7 +596,7 @@ public class ActionStringHandler { msg += MainApp.sResources.getString(R.string.cpp_valuesnotstored); String rTitle = "STATUS"; String rAction = "statusmessage"; - WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(rTitle, msg, rAction); + WearPlugin.getPlugin().requestActionConfirmation(rTitle, msg, rAction); lastSentTimestamp = System.currentTimeMillis(); lastConfirmActionString = rAction; return; @@ -667,14 +667,14 @@ public class ActionStringHandler { } private synchronized static void sendError(String errormessage) { - WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("ERROR", errormessage, "error"); + WearPlugin.getPlugin().requestActionConfirmation("ERROR", errormessage, "error"); lastSentTimestamp = System.currentTimeMillis(); lastConfirmActionString = null; lastBolusWizard = null; } private synchronized static void sendStatusmessage(String title, String message) { - WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(title, message, "statusmessage"); + WearPlugin.getPlugin().requestActionConfirmation(title, message, "statusmessage"); lastSentTimestamp = System.currentTimeMillis(); lastConfirmActionString = null; lastBolusWizard = null; @@ -682,7 +682,7 @@ public class ActionStringHandler { public synchronized static void expectNotificationAction(String message, int id) { String actionstring = "dismissoverviewnotification " + id; - WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("DISMISS", message, actionstring); + WearPlugin.getPlugin().requestActionConfirmation("DISMISS", message, actionstring); lastSentTimestamp = System.currentTimeMillis(); lastConfirmActionString = actionstring; lastBolusWizard = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java index d243da7d60..b1b47a4ae2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java @@ -15,17 +15,6 @@ import info.nightscout.androidaps.R; public class WearFragment extends Fragment { - private static WearPlugin wearPlugin; - - public static WearPlugin getPlugin(Context ctx) { - - if (wearPlugin == null) { - wearPlugin = new WearPlugin(ctx); - } - - return wearPlugin; - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -34,14 +23,14 @@ public class WearFragment extends Fragment { view.findViewById(R.id.wear_resend).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - getPlugin(getContext()).resendDataToWatch(); + WearPlugin.getPlugin().resendDataToWatch(); } }); view.findViewById(R.id.wear_opensettings).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - getPlugin(getContext()).openSettings(); + WearPlugin.getPlugin().openSettings(); } }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index e0d8d9210d..00f62bd2c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -34,6 +34,20 @@ public class WearPlugin implements PluginBase { private static WatchUpdaterService watchUS; private final Context ctx; + private static WearPlugin wearPlugin; + + public static WearPlugin getPlugin() { + return wearPlugin; + } + public static WearPlugin initPlugin(Context ctx) { + + if (wearPlugin == null) { + wearPlugin = new WearPlugin(ctx); + } + + return wearPlugin; + } + WearPlugin(Context ctx) { this.ctx = ctx; MainApp.bus().register(this); @@ -105,6 +119,11 @@ public class WearPlugin implements PluginBase { if (type == GENERAL) this.fragmentVisible = fragmentVisible; } + @Override + public int getPreferencesId() { + return R.xml.pref_wear; + } + private void sendDataToWatch(boolean status, boolean basals, boolean bgValue) { if (isEnabled(getType())) { //only start service when this plugin is enabled diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java index 38bb014274..300a2827c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java @@ -47,7 +47,11 @@ public class StatuslinePlugin implements PluginBase { private static StatuslinePlugin statuslinePlugin; - public static StatuslinePlugin getPlugin(Context ctx) { + public static StatuslinePlugin getPlugin() { + return statuslinePlugin; + } + + public static StatuslinePlugin initPlugin(Context ctx) { if (statuslinePlugin == null) { statuslinePlugin = new StatuslinePlugin(ctx); @@ -138,6 +142,11 @@ public class StatuslinePlugin implements PluginBase { // do nothing, no gui } + @Override + public int getPreferencesId() { + return R.xml.pref_xdripstatus; + } + private void sendStatus() { diff --git a/app/src/main/java/info/nightscout/utils/DateUtil.java b/app/src/main/java/info/nightscout/utils/DateUtil.java index 3e32557adb..691a4f371e 100644 --- a/app/src/main/java/info/nightscout/utils/DateUtil.java +++ b/app/src/main/java/info/nightscout/utils/DateUtil.java @@ -146,4 +146,20 @@ public class DateUtil { } -} \ No newline at end of file + public static String timeFrameString(long timeInMillis){ + long remainingTimeMinutes = timeInMillis/(1000*60); + long remainingTimeHours = remainingTimeMinutes/60; + remainingTimeMinutes = remainingTimeMinutes%60; + return "(" + ((remainingTimeHours >0)?(remainingTimeHours + "h "):"") + remainingTimeMinutes + "')"; + } + + public static String sinceString(long timestamp){ + return timeFrameString(System.currentTimeMillis()-timestamp); + } + + public static String untilString(long timestamp){ + return timeFrameString(timestamp- System.currentTimeMillis()); + } + + +} diff --git a/app/src/main/res/drawable-hdpi-v11/ic_settings.png b/app/src/main/res/drawable-hdpi-v11/ic_settings.png new file mode 100644 index 0000000000..8a55c0221f Binary files /dev/null and b/app/src/main/res/drawable-hdpi-v11/ic_settings.png differ diff --git a/app/src/main/res/drawable-hdpi-v9/ic_settings.png b/app/src/main/res/drawable-hdpi-v9/ic_settings.png new file mode 100644 index 0000000000..23b7ef3529 Binary files /dev/null and b/app/src/main/res/drawable-hdpi-v9/ic_settings.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_settings.png b/app/src/main/res/drawable-hdpi/ic_settings.png new file mode 100644 index 0000000000..20d9681376 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_settings.png differ diff --git a/app/src/main/res/drawable-mdpi-v11/ic_settings.png b/app/src/main/res/drawable-mdpi-v11/ic_settings.png new file mode 100644 index 0000000000..9053263239 Binary files /dev/null and b/app/src/main/res/drawable-mdpi-v11/ic_settings.png differ diff --git a/app/src/main/res/drawable-mdpi-v9/ic_settings.png b/app/src/main/res/drawable-mdpi-v9/ic_settings.png new file mode 100644 index 0000000000..3c39ceb390 Binary files /dev/null and b/app/src/main/res/drawable-mdpi-v9/ic_settings.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_settings.png b/app/src/main/res/drawable-mdpi/ic_settings.png new file mode 100644 index 0000000000..60b53e614e Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_settings.png differ diff --git a/app/src/main/res/drawable-xhdpi-v11/ic_settings.png b/app/src/main/res/drawable-xhdpi-v11/ic_settings.png new file mode 100644 index 0000000000..e433609716 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi-v11/ic_settings.png differ diff --git a/app/src/main/res/drawable-xhdpi-v9/ic_settings.png b/app/src/main/res/drawable-xhdpi-v9/ic_settings.png new file mode 100644 index 0000000000..8caf4ecbdd Binary files /dev/null and b/app/src/main/res/drawable-xhdpi-v9/ic_settings.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_settings.png b/app/src/main/res/drawable-xhdpi/ic_settings.png new file mode 100644 index 0000000000..58099b4ce7 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_settings.png differ diff --git a/app/src/main/res/drawable-xxhdpi-v11/ic_settings.png b/app/src/main/res/drawable-xxhdpi-v11/ic_settings.png new file mode 100644 index 0000000000..4130b7aa9f Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi-v11/ic_settings.png differ diff --git a/app/src/main/res/drawable-xxhdpi-v9/ic_settings.png b/app/src/main/res/drawable-xxhdpi-v9/ic_settings.png new file mode 100644 index 0000000000..4f61e7d059 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi-v9/ic_settings.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_settings.png b/app/src/main/res/drawable-xxhdpi/ic_settings.png new file mode 100644 index 0000000000..8f3d91a45a Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_settings.png differ diff --git a/app/src/main/res/layout/configbuilder_simpleitem.xml b/app/src/main/res/layout/configbuilder_simpleitem.xml index 806ae3ea98..5acea76ac3 100644 --- a/app/src/main/res/layout/configbuilder_simpleitem.xml +++ b/app/src/main/res/layout/configbuilder_simpleitem.xml @@ -1,6 +1,7 @@ @@ -20,6 +21,16 @@ android:layout_weight="1" android:text="ConfigBuilder plugin text" /> + + + +