eliminate PluginSwitcher

This commit is contained in:
Milos Kozak 2019-08-06 02:34:57 +02:00
parent c1a1cc3108
commit 9e962b953f
15 changed files with 205 additions and 179 deletions

View file

@ -1,10 +1,14 @@
package info.nightscout.androidaps.interfaces;
import android.os.SystemClock;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui;
import info.nightscout.androidaps.utils.SP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -41,25 +45,25 @@ public abstract class PluginBase {
// Default always calls invoke
// Plugins that have special constraints if they get switched to may override this method
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
pluginSwitcher.invoke();
public void switchAllowed(boolean newState, FragmentActivity activity) {
performPluginSwitch(newState);
}
protected void confirmPumpPluginActivation(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
protected void confirmPumpPluginActivation(boolean newState, FragmentActivity activity) {
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
if (allowHardwarePump || activity == null) {
pluginSwitcher.invoke();
performPluginSwitch(newState);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(R.string.allow_hardware_pump_text)
.setPositiveButton(R.string.yes, (dialog, id) -> {
pluginSwitcher.invoke();
performPluginSwitch(newState);
SP.putBoolean("allow_hardware_pump", true);
if (L.isEnabled(L.PUMP))
log.debug("First time HW pump allowed!");
})
.setNegativeButton(R.string.cancel, (dialog, id) -> {
pluginSwitcher.cancel();
MainApp.bus().post(new EventConfigBuilderUpdateGui());
if (L.isEnabled(L.PUMP))
log.debug("User does not allow switching to HW pump!");
});
@ -67,13 +71,15 @@ public abstract class PluginBase {
}
}
// public PluginType getType() {
// return mainType;
// }
// public String getFragmentClass() {
// return fragmentClass;
// }
private void performPluginSwitch(boolean enabled) {
setPluginEnabled(getType(), enabled);
setFragmentVisible(getType(), enabled);
ConfigBuilderFragment.processOnEnabledCategoryChanged(this, getType());
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
MainApp.bus().post(new EventRefreshGui());
MainApp.bus().post(new EventConfigBuilderChange());
ConfigBuilderPlugin.getPlugin().logPluginStatus();
}
public String getName() {
if (pluginDescription.pluginName == -1)
@ -168,7 +174,7 @@ public abstract class PluginBase {
}
public boolean isFragmentVisible() {
if (pluginDescription.alwayVisible)
if (pluginDescription.alwaysVisible)
return true;
if (pluginDescription.neverVisible)
return false;

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.interfaces;
public class PluginDescription {
PluginType mainType = PluginType.GENERAL;
String fragmentClass = null;
public boolean alwayVisible = false;
public boolean alwaysVisible = false;
public boolean neverVisible = false;
public boolean alwaysEnabled = false;
boolean showInList = true;
@ -11,7 +11,6 @@ public class PluginDescription {
int shortName = -1;
int description = -1;
int preferencesId = -1;
int advancedPreferencesId = -1;
public boolean enableByDefault = false;
public boolean visibleByDefault = false;
@ -30,8 +29,8 @@ public class PluginDescription {
return this;
}
public PluginDescription alwayVisible(boolean alwayVisible) {
this.alwayVisible = alwayVisible;
public PluginDescription alwaysVisible(boolean alwayVisible) {
this.alwaysVisible = alwayVisible;
return this;
}
@ -60,11 +59,6 @@ public class PluginDescription {
return this;
}
public PluginDescription advancedPreferencesId(int advancedPreferencesId) {
this.advancedPreferencesId = advancedPreferencesId;
return this;
}
public PluginDescription enableByDefault(boolean enableByDefault) {
this.enableByDefault = enableByDefault;
return this;

View file

@ -1,33 +1,29 @@
package info.nightscout.androidaps.plugins.configBuilder;
import android.content.Intent;
import android.app.Activity;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import com.squareup.otto.Subscribe;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.activities.PreferencesActivity;
import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
@ -99,6 +95,15 @@ public class ConfigBuilderFragment extends SubscriberFragment {
for (PluginViewHolder pluginViewHolder : pluginViewHolders) pluginViewHolder.update();
}
@Subscribe
public void on(EventConfigBuilderUpdateGui e) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(() -> {
updateGUI();
});
}
private void createViews() {
createViewsForPlugins(R.string.configbuilder_profile, R.string.configbuilder_profile_description, PluginType.PROFILE, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginType.PROFILE));
createViewsForPlugins(R.string.configbuilder_insulin, R.string.configbuilder_insulin_description, PluginType.INSULIN, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginType.INSULIN));
@ -119,17 +124,13 @@ public class ConfigBuilderFragment extends SubscriberFragment {
((TextView) parent.findViewById(R.id.category_description)).setText(MainApp.gs(description));
LinearLayout pluginContainer = parent.findViewById(R.id.category_plugins);
for (PluginBase plugin: plugins) {
PluginViewHolder pluginViewHolder = new PluginViewHolder(pluginType, plugin);
PluginViewHolder pluginViewHolder = new PluginViewHolder(this, pluginType, plugin);
pluginContainer.addView(pluginViewHolder.getBaseView());
pluginViewHolders.add(pluginViewHolder);
}
categories.addView(parent);
}
private boolean areMultipleSelectionsAllowed(PluginType type) {
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS ||type == PluginType.LOOP;
}
public static void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
ArrayList<PluginBase> pluginsInCategory = null;
switch (type) {
@ -185,99 +186,4 @@ public class ConfigBuilderFragment extends SubscriberFragment {
}
}
public class PluginViewHolder {
private Unbinder unbinder;
private PluginType pluginType;
private PluginBase plugin;
LinearLayout baseView;
@BindView(R.id.plugin_enabled_exclusive)
RadioButton enabledExclusive;
@BindView(R.id.plugin_enabled_inclusive)
CheckBox enabledInclusive;
@BindView(R.id.plugin_name)
TextView pluginName;
@BindView(R.id.plugin_description)
TextView pluginDescription;
@BindView(R.id.plugin_preferences)
ImageButton pluginPreferences;
@BindView(R.id.plugin_visibility)
CheckBox pluginVisibility;
public PluginViewHolder(PluginType pluginType, PluginBase plugin) {
this.pluginType = pluginType;
this.plugin = plugin;
baseView = (LinearLayout) getLayoutInflater().inflate(R.layout.configbuilder_single_plugin, null);
unbinder = ButterKnife.bind(this, baseView);
update();
}
public LinearLayout getBaseView() {
return baseView;
}
public void update() {
enabledExclusive.setVisibility(areMultipleSelectionsAllowed(pluginType) ? View.GONE : View.VISIBLE);
enabledInclusive.setVisibility(areMultipleSelectionsAllowed(pluginType) ? View.VISIBLE : View.GONE);
enabledExclusive.setChecked(plugin.isEnabled(pluginType));
enabledInclusive.setChecked(plugin.isEnabled(pluginType));
enabledInclusive.setEnabled(!plugin.pluginDescription.alwaysEnabled);
enabledExclusive.setEnabled(!plugin.pluginDescription.alwaysEnabled);
pluginName.setText(plugin.getName());
if (plugin.getDescription() == null) pluginDescription.setVisibility(View.GONE);
else {
pluginDescription.setVisibility(View.VISIBLE);
pluginDescription.setText(plugin.getDescription());
}
pluginPreferences.setVisibility(plugin.getPreferencesId() == -1 || !plugin.isEnabled(pluginType) ? View.INVISIBLE : View.VISIBLE);
pluginVisibility.setVisibility(plugin.hasFragment() ? View.VISIBLE : View.INVISIBLE);
pluginVisibility.setEnabled(!(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwayVisible) && plugin.isEnabled(pluginType));
pluginVisibility.setChecked(plugin.isFragmentVisible());
}
@OnClick(R.id.plugin_visibility)
void onVisibilityChanged() {
plugin.setFragmentVisible(pluginType, pluginVisibility.isChecked());
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible");
MainApp.bus().post(new EventRefreshGui());
ConfigBuilderPlugin.getPlugin().logPluginStatus();
}
@OnClick({R.id.plugin_enabled_exclusive, R.id.plugin_enabled_inclusive})
void onEnabledChanged() {
plugin.switchAllowed(new PluginSwitcher(), getActivity());
}
@OnClick(R.id.plugin_preferences)
void onPluginPreferencesClicked() {
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(getContext(), PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId());
startActivity(i);
}, null);
}
public void unbind() {
unbinder.unbind();
}
public class PluginSwitcher {
public void invoke() {
boolean enabled = enabledExclusive.getVisibility() == View.VISIBLE ? enabledExclusive.isChecked() : enabledInclusive.isChecked();
plugin.setPluginEnabled(pluginType, enabled);
plugin.setFragmentVisible(pluginType, enabled);
processOnEnabledCategoryChanged(plugin, pluginType);
updateGUI();
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
MainApp.bus().post(new EventRefreshGui());
MainApp.bus().post(new EventConfigBuilderChange());
ConfigBuilderPlugin.getPlugin().logPluginStatus();
}
public void cancel(){
updateGUI();
}
}
}
}

View file

@ -57,7 +57,7 @@ public class ConfigBuilderPlugin extends PluginBase {
.fragmentClass(ConfigBuilderFragment.class.getName())
.showInList(true)
.alwaysEnabled(true)
.alwayVisible(false)
.alwaysVisible(false)
.pluginName(R.string.configbuilder)
.shortName(R.string.configbuilder_shortname)
.description(R.string.description_config_builder)
@ -102,7 +102,7 @@ public class ConfigBuilderPlugin extends PluginBase {
for (PluginBase p : pluginList) {
PluginType type = p.getType();
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwayVisible)
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwaysVisible)
continue;
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible)
continue;
@ -262,7 +262,7 @@ public class ConfigBuilderPlugin extends PluginBase {
return activeSensitivity;
}
void logPluginStatus() {
public void logPluginStatus() {
if (L.isEnabled(L.CONFIGBUILDER))
for (PluginBase p : pluginList) {
log.debug(p.getName() + ":" +

View file

@ -0,0 +1,6 @@
package info.nightscout.androidaps.plugins.configBuilder
import info.nightscout.androidaps.events.EventUpdateGui
class EventConfigBuilderUpdateGui : EventUpdateGui() {
}

View file

@ -0,0 +1,106 @@
package info.nightscout.androidaps.plugins.configBuilder;
import android.content.Intent;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.activities.PreferencesActivity;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.utils.PasswordProtection;
public class PluginViewHolder {
private Unbinder unbinder;
private PluginType pluginType;
private PluginBase plugin;
private ConfigBuilderFragment fragment;
LinearLayout baseView;
@BindView(R.id.plugin_enabled_exclusive)
RadioButton enabledExclusive;
@BindView(R.id.plugin_enabled_inclusive)
CheckBox enabledInclusive;
@BindView(R.id.plugin_name)
TextView pluginName;
@BindView(R.id.plugin_description)
TextView pluginDescription;
@BindView(R.id.plugin_preferences)
ImageButton pluginPreferences;
@BindView(R.id.plugin_visibility)
CheckBox pluginVisibility;
public PluginViewHolder(ConfigBuilderFragment fragment, PluginType pluginType, PluginBase plugin) {
this.pluginType = pluginType;
this.plugin = plugin;
this.fragment = fragment;
baseView = (LinearLayout) fragment.getLayoutInflater().inflate(R.layout.configbuilder_single_plugin, null);
unbinder = ButterKnife.bind(this, baseView);
update();
}
public LinearLayout getBaseView() {
return baseView;
}
public void update() {
enabledExclusive.setVisibility(areMultipleSelectionsAllowed(pluginType) ? View.GONE : View.VISIBLE);
enabledInclusive.setVisibility(areMultipleSelectionsAllowed(pluginType) ? View.VISIBLE : View.GONE);
enabledExclusive.setChecked(plugin.isEnabled(pluginType));
enabledInclusive.setChecked(plugin.isEnabled(pluginType));
enabledInclusive.setEnabled(!plugin.pluginDescription.alwaysEnabled);
enabledExclusive.setEnabled(!plugin.pluginDescription.alwaysEnabled);
pluginName.setText(plugin.getName());
if (plugin.getDescription() == null) pluginDescription.setVisibility(View.GONE);
else {
pluginDescription.setVisibility(View.VISIBLE);
pluginDescription.setText(plugin.getDescription());
}
pluginPreferences.setVisibility(plugin.getPreferencesId() == -1 || !plugin.isEnabled(pluginType) ? View.INVISIBLE : View.VISIBLE);
pluginVisibility.setVisibility(plugin.hasFragment() ? View.VISIBLE : View.INVISIBLE);
pluginVisibility.setEnabled(!(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwaysVisible) && plugin.isEnabled(pluginType));
pluginVisibility.setChecked(plugin.isFragmentVisible());
}
@OnClick(R.id.plugin_visibility)
void onVisibilityChanged() {
plugin.setFragmentVisible(pluginType, pluginVisibility.isChecked());
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible");
MainApp.bus().post(new EventRefreshGui());
ConfigBuilderPlugin.getPlugin().logPluginStatus();
}
@OnClick({R.id.plugin_enabled_exclusive, R.id.plugin_enabled_inclusive})
void onEnabledChanged() {
plugin.switchAllowed(enabledExclusive.getVisibility() == View.VISIBLE ? enabledExclusive.isChecked() : enabledInclusive.isChecked(), fragment.getActivity());
}
@OnClick(R.id.plugin_preferences)
void onPluginPreferencesClicked() {
PasswordProtection.QueryPassword(fragment.getContext(), R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(fragment.getContext(), PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId());
fragment.startActivity(i);
}, null);
}
public void unbind() {
unbinder.unbind();
}
private boolean areMultipleSelectionsAllowed(PluginType type) {
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS ||type == PluginType.LOOP;
}
}

View file

@ -62,7 +62,7 @@ public class MaintenancePlugin extends PluginBase {
super(new PluginDescription()
.mainType(PluginType.GENERAL)
.fragmentClass(MaintenanceFragment.class.getName())
.alwayVisible(false)
.alwaysVisible(false)
.alwaysEnabled(true)
.pluginName(R.string.maintenance)
.shortName(R.string.maintenance_shortname)

View file

@ -47,7 +47,7 @@ public class OverviewPlugin extends PluginBase {
super(new PluginDescription()
.mainType(PluginType.GENERAL)
.fragmentClass(OverviewFragment.class.getName())
.alwayVisible(true)
.alwaysVisible(true)
.alwaysEnabled(true)
.pluginName(R.string.overview)
.shortName(R.string.overview_shortname)

View file

@ -47,7 +47,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
.pluginName(R.string.nsprofile)
.shortName(R.string.profileviewer_shortname)
.alwaysEnabled(Config.NSCLIENT)
.alwayVisible(Config.NSCLIENT)
.alwaysVisible(Config.NSCLIENT)
.showInList(!Config.NSCLIENT)
.description(R.string.description_profile_nightscout)
);

View file

@ -1,11 +1,10 @@
package info.nightscout.androidaps.plugins.pump.combo;
import android.content.DialogInterface;
import android.os.SystemClock;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.appcompat.app.AlertDialog;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -40,7 +39,6 @@ import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
@ -164,8 +162,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
}
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
confirmPumpPluginActivation(pluginSwitcher, activity);
public void switchAllowed(boolean newState, FragmentActivity activity) {
confirmPumpPluginActivation(newState, activity);
}
@Override

View file

@ -1,20 +1,20 @@
package info.nightscout.androidaps.plugins.pump.common;
import java.util.Date;
import androidx.fragment.app.FragmentActivity;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import androidx.fragment.app.FragmentActivity;
import com.squareup.otto.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@ -108,8 +108,8 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
public abstract void onStartCustomActions();
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
confirmPumpPluginActivation(pluginSwitcher, activity);
public void switchAllowed(boolean newState, FragmentActivity activity) {
confirmPumpPluginActivation(newState, activity);
}
/**

View file

@ -1,9 +1,8 @@
package info.nightscout.androidaps.plugins.pump.danaR;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -80,8 +79,8 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
}
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
confirmPumpPluginActivation(pluginSwitcher, activity);
public void switchAllowed(boolean newState, FragmentActivity activity) {
confirmPumpPluginActivation(newState, activity);
}
@Override

View file

@ -5,9 +5,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.appcompat.app.AlertDialog;
import com.squareup.otto.Subscribe;
@ -39,7 +39,6 @@ import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.configBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
@ -127,8 +126,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
confirmPumpPluginActivation(pluginSwitcher, activity);
public void switchAllowed(boolean newState, FragmentActivity activity) {
confirmPumpPluginActivation(newState, activity);
}
private ServiceConnection mConnection = new ServiceConnection() {

View file

@ -9,12 +9,7 @@ import android.os.IBinder;
import android.os.Looper;
import androidx.fragment.app.FragmentActivity;
import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.*;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.*;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -48,8 +43,11 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
@ -76,6 +74,13 @@ import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.StartOfTBREvent;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TotalDailyDoseEvent;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TubeFilledEvent;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.ActiveBRProfileBlock;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.BRProfile1Block;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.BRProfileBlock;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.FactoryMinBolusAmountBlock;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.MaxBasalAmountBlock;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.MaxBolusAmountBlock;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.TBROverNotificationBlock;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelBolusMessage;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelTBRMessage;
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.ChangeTBRMessage;
@ -99,6 +104,19 @@ import info.nightscout.androidaps.plugins.pump.insight.connection_service.Insigh
import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID;
import info.nightscout.androidaps.plugins.pump.insight.database.InsightHistoryOffset;
import info.nightscout.androidaps.plugins.pump.insight.database.InsightPumpID;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBasalRate;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBolus;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveTBR;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertType;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BasalProfile;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BasalProfileBlock;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BatteryStatus;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BolusType;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.CartridgeStatus;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.OperatingMode;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.PumpTime;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightException;
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
@ -232,8 +250,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
}
@Override
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
confirmPumpPluginActivation(pluginSwitcher, activity);
public void switchAllowed(boolean newState, FragmentActivity activity) {
confirmPumpPluginActivation(newState, activity);
}
@Override

View file

@ -30,8 +30,8 @@ public class PluginDescriptionTest {
@Test
public void alwayVisibleTest() {
PluginDescription pluginDescription = new PluginDescription().alwayVisible(true);
Assert.assertEquals(true, pluginDescription.alwayVisible);
PluginDescription pluginDescription = new PluginDescription().alwaysVisible(true);
Assert.assertEquals(true, pluginDescription.alwaysVisible);
}
@Test
@ -64,12 +64,6 @@ public class PluginDescriptionTest {
Assert.assertEquals(10, pluginDescription.preferencesId);
}
@Test
public void advancedPreferencesIdTest() {
PluginDescription pluginDescription = new PluginDescription().advancedPreferencesId(10);
Assert.assertEquals(10, pluginDescription.advancedPreferencesId);
}
@Test
public void enableByDefault() {
PluginDescription pluginDescription = new PluginDescription().enableByDefault(true);