smarter plugin selection and handling
This commit is contained in:
parent
8f6f6e326d
commit
4a2a15d394
|
@ -30,12 +30,12 @@ public class ActionsPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,12 +45,12 @@ public class ActionsPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ public class CareportalPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,12 +41,12 @@ public class CareportalPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,12 +69,12 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == PROFILE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == PROFILE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,12 +84,12 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == PROFILE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == PROFILE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
void storeSettings() {
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.ListView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
|
@ -34,6 +35,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
||||
import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
|
||||
|
||||
|
||||
public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
||||
|
@ -93,7 +96,8 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
nsclientVerView.setText(ConfigBuilderPlugin.nsClientVersionName);
|
||||
nightscoutVerView.setText(ConfigBuilderPlugin.nightscoutVersionName);
|
||||
if (ConfigBuilderPlugin.nsClientVersionCode < 117) nsclientVerView.setTextColor(Color.RED);
|
||||
if (ConfigBuilderPlugin.nightscoutVersionCode < 900) nightscoutVerView.setTextColor(Color.RED);
|
||||
if (ConfigBuilderPlugin.nightscoutVersionCode < 900)
|
||||
nightscoutVerView.setTextColor(Color.RED);
|
||||
setViews();
|
||||
return view;
|
||||
}
|
||||
|
@ -179,6 +183,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
onEnabledCategoryChanged(plugin, type);
|
||||
configBuilderPlugin.storeSettings();
|
||||
MainApp.bus().post(new EventRefreshGui(true));
|
||||
getPlugin().logPluginStatus();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -189,6 +194,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
plugin.setFragmentVisible(type, cb.isChecked());
|
||||
configBuilderPlugin.storeSettings();
|
||||
MainApp.bus().post(new EventRefreshGui(true));
|
||||
getPlugin().logPluginStatus();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -213,6 +219,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
if (pluginList.size() < 2) {
|
||||
holder.checkboxEnabled.setEnabled(false);
|
||||
plugin.setFragmentEnabled(type, true);
|
||||
getPlugin().storeSettings();
|
||||
}
|
||||
|
||||
// Constraints cannot be disabled
|
||||
|
@ -246,9 +253,8 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
}
|
||||
|
||||
void onEnabledCategoryChanged(PluginBase changedPlugin, int type) {
|
||||
int category = changedPlugin.getType();
|
||||
ArrayList<PluginBase> pluginsInCategory = null;
|
||||
switch (category) {
|
||||
switch (type) {
|
||||
// Multiple selection allowed
|
||||
case PluginBase.GENERAL:
|
||||
case PluginBase.CONSTRAINTS:
|
||||
|
@ -267,7 +273,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
case PluginBase.TEMPBASAL:
|
||||
case PluginBase.TREATMENT:
|
||||
case PluginBase.PUMP:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsList(category);
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(PumpInterface.class);
|
||||
break;
|
||||
}
|
||||
if (pluginsInCategory != null) {
|
||||
|
@ -282,7 +288,12 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
}
|
||||
}
|
||||
} else { // enable first plugin in list
|
||||
pluginsInCategory.get(0).setFragmentEnabled(type, true);
|
||||
if (type == PluginBase.PUMP)
|
||||
MainApp.getSpecificPlugin(VirtualPumpPlugin.class).setFragmentEnabled(type, true);
|
||||
else if (type == PluginBase.PROFILE)
|
||||
MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentEnabled(type, true);
|
||||
else
|
||||
pluginsInCategory.get(0).setFragmentEnabled(type, true);
|
||||
}
|
||||
setViews();
|
||||
}
|
||||
|
|
|
@ -98,12 +98,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
return type == GENERAL && true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return true;
|
||||
return type == GENERAL && true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,6 +192,22 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
return activeLoop;
|
||||
}
|
||||
|
||||
public void logPluginStatus() {
|
||||
for (PluginBase p : pluginList) {
|
||||
log.debug(p.getName() + ":" +
|
||||
(p.isEnabled(1) ? " GENERAL" : "") +
|
||||
(p.isEnabled(2) ? " TREATMENT" : "") +
|
||||
(p.isEnabled(3) ? " TEMPBASAL" : "") +
|
||||
(p.isEnabled(4) ? " PROFILE" : "") +
|
||||
(p.isEnabled(5) ? " APS" : "") +
|
||||
(p.isEnabled(6) ? " PUMP" : "") +
|
||||
(p.isEnabled(7) ? " CONSTRAINTS" : "") +
|
||||
(p.isEnabled(8) ? " LOOP" : "") +
|
||||
(p.isEnabled(9) ? " BGSOURCE" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifySelectionInCategories() {
|
||||
ArrayList<PluginBase> pluginsInCategory;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
||||
import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
@ -173,8 +174,17 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PluginBase.PROFILE) this.fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP) this.fragmentPumpEnabled = fragmentEnabled;
|
||||
if (type == PluginBase.PROFILE)
|
||||
this.fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpEnabled = fragmentEnabled;
|
||||
// if pump profile was enabled need to switch to another too
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
||||
setFragmentEnabled(PluginBase.PROFILE, false);
|
||||
setFragmentVisible(PluginBase.PROFILE, false);
|
||||
MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
|
||||
MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -648,7 +658,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
extended.put("BaseBasalRate", getBaseBasalRate());
|
||||
try {
|
||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile());
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
pump.put("battery", battery);
|
||||
pump.put("status", status);
|
||||
|
|
|
@ -36,6 +36,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
||||
import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
@ -173,8 +174,17 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PluginBase.PROFILE) this.fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP) this.fragmentPumpEnabled = fragmentEnabled;
|
||||
if (type == PluginBase.PROFILE)
|
||||
this.fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpEnabled = fragmentEnabled;
|
||||
// if pump profile was enabled need to switch to another too
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
||||
setFragmentEnabled(PluginBase.PROFILE, false);
|
||||
setFragmentVisible(PluginBase.PROFILE, false);
|
||||
MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
|
||||
MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -83,12 +83,12 @@ public class LoopPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == LOOP && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == LOOP && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,12 +98,12 @@ public class LoopPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == LOOP) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == LOOP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -51,12 +51,12 @@ public class NSProfileViewerPlugin implements PluginBase, ProfileInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == PROFILE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == PROFILE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,12 +66,12 @@ public class NSProfileViewerPlugin implements PluginBase, ProfileInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == PROFILE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == PROFILE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,13 +51,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
return type == CONSTRAINTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
LoopPlugin loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
return fragmentVisible && loopPlugin != null && loopPlugin.isVisibleInTabs(type);
|
||||
return type == CONSTRAINTS && fragmentVisible && loopPlugin != null && loopPlugin.isVisibleInTabs(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
public class Objective {
|
||||
|
|
|
@ -58,12 +58,12 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == APS && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == APS && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,12 +73,12 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == APS) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == APS) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class OverviewPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
return type == GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
return type == CONSTRAINTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +54,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(int tyep, boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == PROFILE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == PROFILE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,12 +75,12 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == PROFILE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == PROFILE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
public void storeSettings() {
|
||||
|
|
|
@ -100,12 +100,12 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,12 +115,12 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
SmsCommunicatorPlugin.fragmentEnabled = fragmentEnabled;
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
SmsCommunicatorPlugin.fragmentVisible = fragmentVisible;
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentVisible;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == BGSOURCE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,7 +43,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == BGSOURCE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
SourceXdripPlugin.fragmentEnabled = fragmentEnabled;
|
||||
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,12 +66,12 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == TEMPBASAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == TEMPBASAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,12 +81,12 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == TEMPBASAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == TEMPBASAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,12 +49,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == TREATMENT && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == TREATMENT && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,12 +64,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == TREATMENT) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == TREATMENT) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -80,12 +80,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == PUMP && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == PUMP && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,12 +95,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (type == PUMP) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
if (type == PUMP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ public class WearPlugin implements PluginBase {
|
|||
private static WatchUpdaterService watchUS;
|
||||
private final Context ctx;
|
||||
|
||||
WearPlugin(Context ctx){
|
||||
WearPlugin(Context ctx) {
|
||||
this.ctx = ctx;
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
@ -50,12 +50,12 @@ public class WearPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,39 +65,41 @@ public class WearPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
WearPlugin.fragmentEnabled = fragmentEnabled;
|
||||
if(watchUS!=null){
|
||||
watchUS.setSettings();
|
||||
if (type == GENERAL) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (watchUS != null) {
|
||||
watchUS.setSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
WearPlugin.fragmentVisible = fragmentVisible;
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
private void sendDataToWatch(boolean status, boolean basals, boolean bgValue){
|
||||
private void sendDataToWatch(boolean status, boolean basals, boolean bgValue) {
|
||||
if (isEnabled(getType())) { //only start service when this plugin is enabled
|
||||
|
||||
if(bgValue){
|
||||
if (bgValue) {
|
||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class));
|
||||
}
|
||||
|
||||
if(basals){
|
||||
if (basals) {
|
||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BASALS));
|
||||
}
|
||||
|
||||
if(status){
|
||||
if (status) {
|
||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_STATUS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resendDataToWatch(){
|
||||
void resendDataToWatch() {
|
||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_RESEND));
|
||||
}
|
||||
|
||||
void openSettings(){
|
||||
void openSettings() {
|
||||
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_OPEN_SETTINGS));
|
||||
}
|
||||
|
||||
|
@ -132,11 +134,11 @@ public class WearPlugin implements PluginBase {
|
|||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
public static void registerWatchUpdaterService(WatchUpdaterService wus){
|
||||
public static void registerWatchUpdaterService(WatchUpdaterService wus) {
|
||||
watchUS = wus;
|
||||
}
|
||||
|
||||
public static void unRegisterWatchUpdaterService(){
|
||||
public static void unRegisterWatchUpdaterService() {
|
||||
watchUS = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
|
||||
|
@ -51,13 +58,6 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" />
|
||||
|
|
Loading…
Reference in a new issue