This commit is contained in:
PoweRGbg 2018-06-13 11:02:52 +03:00
parent 2cb3c15d61
commit 5634aabd9f
39 changed files with 232 additions and 291 deletions

View file

@ -23,6 +23,9 @@ public class CareportalPlugin extends PluginBase {
.fragmentClass(CareportalFragment.class.getName())
.pluginName(R.string.careportal)
.shortName(R.string.careportal_shortname)
.visibleByDefault(true)
.enableByDefault(true)
.description(R.string.description_careportal)
);
}

View file

@ -21,7 +21,7 @@ abstract public class SubscriberFragment extends Fragment {
updateGUI();
}
@Override public void onDestroyView() {
@Override public synchronized void onDestroyView() {
super.onDestroyView();
if (unbinder != null)
unbinder.unbind();

View file

@ -1,30 +1,31 @@
package info.nightscout.androidaps.plugins.ConfigBuilder;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.TextView;
import com.crashlytics.android.answers.CustomEvent;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;
import info.nightscout.androidaps.Config;
import butterknife.Optional;
import butterknife.Unbinder;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.PreferencesActivity;
import info.nightscout.androidaps.R;
@ -50,69 +51,47 @@ import info.nightscout.utils.PasswordProtection;
public class ConfigBuilderFragment extends SubscriberFragment {
@BindView(R.id.configbuilder_insulinlistview)
ListView insulinListView;
@BindView(R.id.configbuilder_sensitivitylistview)
ListView sensitivityListView;
@BindView(R.id.configbuilder_bgsourcelistview)
ListView bgsourceListView;
@BindView(R.id.configbuilder_bgsourcelabel)
TextView bgsourceLabel;
@BindView(R.id.configbuilder_pumplistview)
ListView pumpListView;
@BindView(R.id.configbuilder_pumplabel)
TextView pumpLabel;
@BindView(R.id.configbuilder_looplistview)
ListView loopListView;
@BindView(R.id.configbuilder_looplabel)
TextView loopLabel;
@BindView(R.id.configbuilder_treatmentslistview)
ListView treatmentsListView;
@BindView(R.id.configbuilder_treatmentslabel)
TextView treatmentsLabel;
@BindView(R.id.configbuilder_profilelistview)
ListView profileListView;
@BindView(R.id.configbuilder_profilelabel)
TextView profileLabel;
@BindView(R.id.configbuilder_apslistview)
ListView apsListView;
@BindView(R.id.configbuilder_apslabel)
TextView apsLabel;
@BindView(R.id.configbuilder_constraintslistview)
ListView constraintsListView;
@BindView(R.id.configbuilder_constraintslabel)
TextView constraintsLabel;
@BindView(R.id.configbuilder_generallistview)
ListView generalListView;
private List<PluginView> pluginViews = new ArrayList<>();
@BindView(R.id.configbuilder_mainlayout)
LinearLayout mainLayout;
@BindView(R.id.configbuilder_unlock)
@BindView(R.id.profile_plugins)
LinearLayout profilePlugins;
@BindView(R.id.insulin_plugins)
LinearLayout insulinPlugins;
@BindView(R.id.bgsource_plugins)
LinearLayout bgSourcePlugins;
@BindView(R.id.pump_plugins)
LinearLayout pumpPlugins;
@BindView(R.id.sensitivity_plugins)
LinearLayout sensitivityPlugins;
@BindView(R.id.aps_plugins)
LinearLayout apsPlugins;
@BindView(R.id.loop_plugins)
LinearLayout loopPlugins;
@BindView(R.id.constraints_plugins)
LinearLayout constraintsPlugins;
@BindView(R.id.treatments_plugins)
LinearLayout treatmentsPlugins;
@BindView(R.id.general_plugins)
LinearLayout generalPlugins;
@BindView(R.id.main_layout)
ScrollView mainLayout;
@BindView(R.id.unlock)
Button unlock;
PluginCustomAdapter insulinDataAdapter = null;
PluginCustomAdapter sensivityDataAdapter = null;
PluginCustomAdapter bgsourceDataAdapter = null;
PluginCustomAdapter pumpDataAdapter = null;
PluginCustomAdapter loopDataAdapter = null;
PluginCustomAdapter treatmentDataAdapter = null;
PluginCustomAdapter profileDataAdapter = null;
PluginCustomAdapter apsDataAdapter = null;
PluginCustomAdapter constraintsDataAdapter = null;
PluginCustomAdapter generalDataAdapter = null;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
unbinder = ButterKnife.bind(this, view);
if (PasswordProtection.isLocked("settings_password"))
mainLayout.setVisibility(View.GONE);
else
unlock.setVisibility(View.GONE);
else unlock.setVisibility(View.GONE);
createViews();
return view;
} catch (Exception e) {
FabricPrivacy.logException(e);
@ -121,222 +100,49 @@ public class ConfigBuilderFragment extends SubscriberFragment {
return null;
}
@OnClick(R.id.configbuilder_unlock)
public void onClickUnlock() {
@OnClick(R.id.unlock)
void onClickUnlock() {
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", () -> {
mainLayout.setVisibility(View.VISIBLE);
unlock.setVisibility(View.GONE);
}, null);
}
@Override
public void onDestroyView() {
super.onDestroyView();
for (PluginView pluginView : pluginViews) pluginView.unbind();
pluginViews.clear();
}
@Override
protected void updateGUI() {
insulinDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginType.INSULIN), PluginType.INSULIN);
insulinListView.setAdapter(insulinDataAdapter);
setListViewHeightBasedOnChildren(insulinListView);
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginType.BGSOURCE), PluginType.BGSOURCE);
bgsourceListView.setAdapter(bgsourceDataAdapter);
if (MainApp.getSpecificPluginsVisibleInList(PluginType.BGSOURCE).size() == 0)
bgsourceLabel.setVisibility(View.GONE);
setListViewHeightBasedOnChildren(bgsourceListView);
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP), PluginType.PUMP);
pumpListView.setAdapter(pumpDataAdapter);
if (MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP).size() == 0 || Config.NSCLIENT || Config.G5UPLOADER) {
pumpLabel.setVisibility(View.GONE);
pumpListView.setVisibility(View.GONE);
}
setListViewHeightBasedOnChildren(pumpListView);
loopDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP), PluginType.LOOP);
loopListView.setAdapter(loopDataAdapter);
setListViewHeightBasedOnChildren(loopListView);
if (MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP).size() == 0)
loopLabel.setVisibility(View.GONE);
treatmentDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT), PluginType.TREATMENT);
treatmentsListView.setAdapter(treatmentDataAdapter);
setListViewHeightBasedOnChildren(treatmentsListView);
if (MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT).size() == 0)
treatmentsLabel.setVisibility(View.GONE);
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginType.PROFILE), PluginType.PROFILE);
profileListView.setAdapter(profileDataAdapter);
if (MainApp.getSpecificPluginsVisibleInList(PluginType.PROFILE).size() == 0)
profileLabel.setVisibility(View.GONE);
setListViewHeightBasedOnChildren(profileListView);
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.APS), PluginType.APS);
apsListView.setAdapter(apsDataAdapter);
setListViewHeightBasedOnChildren(apsListView);
if (MainApp.getSpecificPluginsVisibleInList(PluginType.APS).size() == 0)
apsLabel.setVisibility(View.GONE);
sensivityDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginType.SENSITIVITY), PluginType.SENSITIVITY);
sensitivityListView.setAdapter(sensivityDataAdapter);
setListViewHeightBasedOnChildren(sensitivityListView);
constraintsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginType.CONSTRAINTS), PluginType.CONSTRAINTS);
constraintsListView.setAdapter(constraintsDataAdapter);
setListViewHeightBasedOnChildren(constraintsListView);
if (MainApp.getSpecificPluginsVisibleInList(PluginType.CONSTRAINTS).size() == 0)
constraintsLabel.setVisibility(View.GONE);
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL), PluginType.GENERAL);
generalListView.setAdapter(generalDataAdapter);
setListViewHeightBasedOnChildren(generalListView);
for (PluginView pluginView : pluginViews) pluginView.update();
}
/*
* ConfigBuilderFragment code
*/
private class PluginCustomAdapter extends ArrayAdapter<PluginBase> {
private ArrayList<PluginBase> pluginList;
final private PluginType type;
PluginCustomAdapter(Context context, int textViewResourceId,
ArrayList<PluginBase> pluginList, PluginType type) {
super(context, textViewResourceId, pluginList);
this.pluginList = new ArrayList<>();
this.pluginList.addAll(pluginList);
this.type = type;
}
private class PluginViewHolder {
TextView name;
CheckBox checkboxEnabled;
CheckBox checkboxVisible;
ImageView settings;
}
@NonNull
@Override
public View getView(int position, View view, @NonNull ViewGroup parent) {
PluginViewHolder holder;
PluginBase plugin = pluginList.get(position);
if (view == null) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.configbuilder_simpleitem, null);
holder = new PluginViewHolder();
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(v -> {
CheckBox cb = (CheckBox) v;
PluginBase plugin1 = (PluginBase) cb.getTag();
plugin1.setPluginEnabled(type, cb.isChecked());
plugin1.setFragmentVisible(type, cb.isChecked());
onEnabledCategoryChanged(plugin1, type);
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
MainApp.bus().post(new EventRefreshGui());
MainApp.bus().post(new EventConfigBuilderChange());
ConfigBuilderPlugin.getPlugin().logPluginStatus();
FabricPrivacy.getInstance().logCustom(new CustomEvent("ConfigurationChange"));
});
holder.checkboxVisible.setOnClickListener(v -> {
CheckBox cb = (CheckBox) v;
PluginBase plugin12 = (PluginBase) cb.getTag();
plugin12.setFragmentVisible(type, cb.isChecked());
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible");
MainApp.bus().post(new EventRefreshGui());
ConfigBuilderPlugin.getPlugin().logPluginStatus();
});
holder.settings.setOnClickListener(v -> {
final PluginBase plugin13 = (PluginBase) v.getTag();
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(getContext(), PreferencesActivity.class);
i.putExtra("id", plugin13.getPreferencesId());
startActivity(i);
}, null);
});
holder.name.setOnLongClickListener(v -> {
final PluginBase plugin14 = (PluginBase) v.getTag();
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(getContext(), PreferencesActivity.class);
i.putExtra("id", plugin14.getPreferencesId());
startActivity(i);
}, null);
return false;
});
} else {
holder = (PluginViewHolder) view.getTag();
}
holder.name.setText(plugin.getName());
holder.checkboxEnabled.setChecked(plugin.isEnabled(type));
holder.checkboxVisible.setChecked(plugin.isFragmentVisible());
holder.name.setTag(plugin);
holder.checkboxEnabled.setTag(plugin);
holder.checkboxVisible.setTag(plugin);
holder.settings.setTag(plugin);
if (plugin.pluginDescription.alwaysEnabled) {
holder.checkboxEnabled.setEnabled(false);
}
if (plugin.pluginDescription.alwayVisible) {
holder.checkboxEnabled.setEnabled(false);
}
if (!plugin.isEnabled(type)) {
holder.checkboxVisible.setEnabled(false);
}
if (!plugin.hasFragment()) {
holder.checkboxVisible.setVisibility(View.INVISIBLE);
}
// Hide enabled control and force enabled plugin if there is only one plugin available
if (type == PluginType.INSULIN || type == PluginType.PUMP || type == PluginType.SENSITIVITY)
if (pluginList.size() < 2) {
holder.checkboxEnabled.setEnabled(false);
plugin.setPluginEnabled(type, true);
ConfigBuilderPlugin.getPlugin().storeSettings("ForceEnable");
}
// Constraints cannot be disabled
if (type == PluginType.CONSTRAINTS)
holder.checkboxEnabled.setEnabled(false);
// Hide disabled profiles by default
if (type == PluginType.PROFILE) {
if (!plugin.isEnabled(type)) {
holder.checkboxVisible.setEnabled(false);
holder.checkboxVisible.setChecked(false);
} else {
holder.checkboxVisible.setEnabled(true);
}
}
// Disable profile control for pump profiles if pump is not enabled
if (type == PluginType.PROFILE) {
if (PumpInterface.class.isAssignableFrom(plugin.getClass())) {
if (!plugin.isEnabled(PluginType.PUMP)) {
holder.checkboxEnabled.setEnabled(false);
holder.checkboxEnabled.setChecked(false);
}
}
}
if (plugin.isEnabled(type)) {
view.setBackgroundColor(MainApp.gc(R.color.configBuilderSelectedBackground));
}
return view;
private void createViews() {
createViewsForPlugins(profilePlugins, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginType.PROFILE));
createViewsForPlugins(insulinPlugins, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginType.INSULIN));
createViewsForPlugins(bgSourcePlugins, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginType.BGSOURCE));
createViewsForPlugins(pumpPlugins, MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP));
createViewsForPlugins(sensitivityPlugins, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginType.SENSITIVITY));
createViewsForPlugins(apsPlugins, MainApp.getSpecificPluginsVisibleInList(PluginType.APS));
createViewsForPlugins(loopPlugins, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP));
createViewsForPlugins(constraintsPlugins, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginType.CONSTRAINTS));
createViewsForPlugins(treatmentsPlugins, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT));
createViewsForPlugins(generalPlugins, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL));
}
private void createViewsForPlugins(LinearLayout parent, List<PluginBase> plugins) {
for (PluginBase plugin: plugins) {
PluginView pluginView = new PluginView(plugin);
parent.addView(pluginView.getBaseView());
pluginViews.add(pluginView);
}
}
private boolean areMultipleSelectionsAllowed(PluginType type) {
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS ||type == PluginType.LOOP;
}
public static void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
@ -394,35 +200,90 @@ public class ConfigBuilderFragment extends SubscriberFragment {
}
}
void onEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
processOnEnabledCategoryChanged(changedPlugin, type);
updateGUI();
}
class PluginView {
/****
* Method for Setting the Height of the ListView dynamically.
* *** Hack to fix the issue of not showing all the items of the ListView
* *** when placed inside a ScrollView
****/
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
private Unbinder unbinder;
private PluginBase plugin;
int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
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;
view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
public PluginView(PluginBase plugin) {
this.plugin = plugin;
baseView = (LinearLayout) getLayoutInflater().inflate(R.layout.configbuilder_single_plugin, null);
unbinder = ButterKnife.bind(this, baseView);
update();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
public LinearLayout getBaseView() {
return baseView;
}
public void update() {
enabledExclusive.setVisibility(areMultipleSelectionsAllowed(plugin.getType()) ? View.GONE : View.VISIBLE);
enabledInclusive.setVisibility(areMultipleSelectionsAllowed(plugin.getType()) ? View.VISIBLE : View.GONE);
enabledExclusive.setChecked(plugin.isEnabled(plugin.getType()));
enabledInclusive.setChecked(plugin.isEnabled(plugin.getType()));
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(plugin.getType()) ? View.INVISIBLE : View.VISIBLE);
pluginVisibility.setVisibility(plugin.hasFragment() ? View.VISIBLE : View.INVISIBLE);
pluginVisibility.setEnabled(!(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwayVisible) && plugin.isEnabled(plugin.getType()));
pluginVisibility.setChecked(plugin.isFragmentVisible());
}
@OnClick(R.id.plugin_visibility)
void onVisibilityChanged() {
plugin.setFragmentVisible(plugin.getType(), 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() {
boolean enabled = enabledExclusive.getVisibility() == View.VISIBLE ? enabledExclusive.isChecked() : enabledInclusive.isChecked();
plugin.setPluginEnabled(plugin.getType(), enabled);
plugin.setFragmentVisible(plugin.getType(), enabled);
processOnEnabledCategoryChanged(plugin, plugin.getType());
updateGUI();
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
MainApp.bus().post(new EventRefreshGui());
MainApp.bus().post(new EventConfigBuilderChange());
ConfigBuilderPlugin.getPlugin().logPluginStatus();
FabricPrivacy.getInstance().logCustom(new CustomEvent("ConfigurationChange"));
}
@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();
}
}
}

View file

@ -92,6 +92,7 @@ public class ConfigBuilderPlugin extends PluginBase {
.alwayVisible(false)
.pluginName(R.string.configbuilder)
.shortName(R.string.configbuilder_shortname)
.description(R.string.description_config_builder)
);
}

View file

@ -56,6 +56,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
.showInList(!Config.NSCLIENT && !Config.G5UPLOADER)
.pluginName(R.string.objectives)
.shortName(R.string.objectives_shortname)
.description(R.string.description_objectives)
);
initializeData();
loadProgress();

View file

@ -26,6 +26,7 @@ public class FoodPlugin extends PluginBase {
.fragmentClass(FoodFragment.class.getName())
.pluginName(R.string.food)
.shortName(R.string.food_short)
.description(R.string.description_food)
);
this.service = new FoodService();
}

View file

@ -29,6 +29,7 @@ public abstract class InsulinOrefBasePlugin extends PluginBase implements Insuli
.fragmentClass(InsulinFragment.class.getName())
.pluginName(R.string.fastactinginsulin)
.shortName(R.string.insulin_shortname)
.visibleByDefault(false)
);
}

View file

@ -24,7 +24,8 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
super();
pluginDescription
.pluginName(R.string.free_peak_oref)
.preferencesId(R.xml.pref_insulinoreffreepeak);
.preferencesId(R.xml.pref_insulinoreffreepeak)
.description(R.string.description_insulin_free_peak);
}
@Override

View file

@ -22,7 +22,8 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
private InsulinOrefRapidActingPlugin() {
super();
pluginDescription
.pluginName(R.string.rapid_acting_oref);
.pluginName(R.string.rapid_acting_oref)
.description(R.string.description_insulin_rapid);
}
@Override

View file

@ -22,7 +22,8 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
private InsulinOrefUltraRapidActingPlugin() {
super();
pluginDescription
.pluginName(R.string.ultrarapid_oref);
.pluginName(R.string.ultrarapid_oref)
.description(R.string.description_insulin_ultra_rapid);
}
@Override

View file

@ -94,6 +94,7 @@ public class LoopPlugin extends PluginBase {
.pluginName(R.string.loop)
.shortName(R.string.loop_shortname)
.preferencesId(R.xml.pref_closedmode)
.description(R.string.description_loop)
);
loopSuspendedTill = SP.getLong("loopSuspendedTill", 0L);
isSuperBolus = SP.getBoolean("isSuperBolus", false);

View file

@ -69,6 +69,7 @@ public class NSClientPlugin extends PluginBase {
.pluginName(R.string.nsclientinternal)
.shortName(R.string.nsclientinternal_shortname)
.preferencesId(R.xml.pref_nsclientinternal)
.description(R.string.description_ns_client)
);
if (Config.NSCLIENT || Config.G5UPLOADER) {

View file

@ -62,6 +62,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
.pluginName(R.string.openapsama)
.shortName(R.string.oaps_shortname)
.preferencesId(R.xml.pref_openapsama)
.description(R.string.description_ama)
);
}

View file

@ -62,6 +62,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
.pluginName(R.string.openapsma)
.shortName(R.string.oaps_shortname)
.preferencesId(R.xml.pref_openapsma)
.description(R.string.description_ma)
);
}

View file

@ -65,6 +65,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
.pluginName(R.string.openapssmb)
.shortName(R.string.smb_shortname)
.preferencesId(R.xml.pref_openapssmb)
.description(R.string.description_smb)
);
}

View file

@ -315,6 +315,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
confirmMessage += "<br/>" + MainApp.gs(R.string.carbs) + ": " + "<font color='" + MainApp.gc(R.color.carbs) + "'>" + carbsAfterConstraints + "g" + "</font>";
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) {
okClicked = false;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
builder.setMessage(MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
@ -408,9 +409,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
private void initDialog() {
Profile profile = MainApp.getConfigBuilder().getProfile();
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface() != null ? MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() : null;
if (profile == null) {
if (profile == null || profileStore == null) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile));
dismiss();
return;

View file

@ -672,12 +672,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
private void onClickAcceptTemp() {
Profile profile = MainApp.getConfigBuilder().getProfile();
Context context = getContext();
if (context == null) return;
if (LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && profile != null) {
LoopPlugin.getPlugin().invoke("Accept temp button", false);
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.gs(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {

View file

@ -50,6 +50,7 @@ public class OverviewPlugin extends PluginBase {
.pluginName(R.string.overview)
.shortName(R.string.overview_shortname)
.preferencesId(R.xml.pref_overview)
.description(R.string.description_overview)
);
String storedData = SP.getString("QuickWizard", "[]");
try {

View file

@ -57,6 +57,7 @@ public class PersistentNotificationPlugin extends PluginBase {
.neverVisible(true)
.pluginName(R.string.ongoingnotificaction)
.enableByDefault(true)
.description(R.string.description_persistent_notification)
);
this.ctx = ctx;
}

View file

@ -64,6 +64,7 @@ public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
.fragmentClass(LocalProfileFragment.class.getName())
.pluginName(R.string.localprofile)
.shortName(R.string.localprofile_shortname)
.description(R.string.description_profile_local)
);
loadSettings();
}

View file

@ -49,6 +49,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
.alwaysEnabled(Config.NSCLIENT)
.alwayVisible(Config.NSCLIENT)
.showInList(!Config.NSCLIENT)
.description(R.string.description_profile_nightscout)
);
loadNSProfile();
}

View file

@ -52,6 +52,7 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
.fragmentClass(SimpleProfileFragment.class.getName())
.pluginName(R.string.simpleprofile)
.shortName(R.string.simpleprofile_shortname)
.description(R.string.description_profile_simple)
);
loadSettings();
}

View file

@ -167,6 +167,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
.fragmentClass(ComboFragment.class.getName())
.pluginName(R.string.combopump)
.shortName(R.string.combopump_shortname)
.description(R.string.description_pump_combo)
);
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
}

View file

@ -112,6 +112,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
.pluginName(R.string.insightpump)
.shortName(R.string.insightpump_shortname)
.preferencesId(R.xml.pref_insightpump)
.description(R.string.description_pump_insight)
);
log("InsightPlugin instantiated");
pumpDescription.isBolusCapable = true;

View file

@ -42,6 +42,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
super(new PluginDescription()
.mainType(PluginType.PUMP)
.pluginName(R.string.mdi)
.description(R.string.description_pump_mdi)
);
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.5d;

View file

@ -77,6 +77,8 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
.pluginName(R.string.virtualpump)
.shortName(R.string.virtualpump_shortname)
.preferencesId(R.xml.pref_virtualpump)
.neverVisible(BuildConfig.NSCLIENTOLNY || BuildConfig.G5UPLOADER)
.description(R.string.description_pump_virtual)
);
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.1d;

View file

@ -47,6 +47,7 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
.pluginName(R.string.sensitivityaaps)
.shortName(R.string.sensitivity_shortname)
.preferencesId(R.xml.pref_absorption_aaps)
.description(R.string.description_sensitivity_aaps)
);
}

View file

@ -46,6 +46,7 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt
.pluginName(R.string.sensitivityoref0)
.shortName(R.string.sensitivity_shortname)
.preferencesId(R.xml.pref_absorption_oref0)
.description(R.string.description_sensitivity_oref0)
);
}

View file

@ -43,6 +43,7 @@ public class SensitivityWeightedAveragePlugin extends PluginBase implements Sens
.pluginName(R.string.sensitivityweightedaverage)
.shortName(R.string.sensitivity_shortname)
.preferencesId(R.xml.pref_absorption_aaps)
.description(R.string.description_sensitivity_weighted_average)
);
}

View file

@ -124,6 +124,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
.pluginName(R.string.smscommunicator)
.shortName(R.string.smscommunicator_shortname)
.preferencesId(R.xml.pref_smscommunicator)
.description(R.string.description_sms_communicator)
);
processSettings(null);
}

View file

@ -29,6 +29,7 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac
.shortName(R.string.dexcomG5_shortname)
.showInList(!Config.NSCLIENT)
.preferencesId(R.xml.pref_dexcomg5)
.description(R.string.description_source_dexcom_g5)
);
}

View file

@ -24,6 +24,7 @@ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
.mainType(PluginType.BGSOURCE)
.fragmentClass(BGSourceFragment.class.getName())
.pluginName(R.string.Glimp)
.description(R.string.description_source_glimp)
);
}

View file

@ -23,6 +23,7 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface
.mainType(PluginType.BGSOURCE)
.fragmentClass(BGSourceFragment.class.getName())
.pluginName(R.string.MM640g)
.description(R.string.description_source_mm640g)
);
}

View file

@ -27,6 +27,7 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
.pluginName(R.string.nsclientbg)
.showInList(!Config.NSCLIENT)
.alwaysEnabled(Config.NSCLIENT)
.description(R.string.description_source_ns_client)
);
}

View file

@ -0,0 +1,39 @@
package info.nightscout.androidaps.plugins.Source;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
/**
* Created by mike on 05.08.2016.
*/
public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface {
private static SourcePoctechPlugin plugin = null;
public static SourcePoctechPlugin getPlugin() {
if (plugin == null)
plugin = new SourcePoctechPlugin();
return plugin;
}
private SourcePoctechPlugin() {
super(new PluginDescription()
.mainType(PluginType.BGSOURCE)
.fragmentClass(BGSourceFragment.class.getName())
.pluginName(R.string.poctech)
.showInList(!Config.NSCLIENT)
.preferencesId(R.xml.pref_poctech)
.description(R.string.description_source_poctech)
);
}
@Override
public boolean advancedFilteringSupported() {
return false;
}
}

View file

@ -26,6 +26,7 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
.mainType(PluginType.BGSOURCE)
.fragmentClass(BGSourceFragment.class.getName())
.pluginName(R.string.xdrip)
.description(R.string.description_source_xdrip)
);
}

View file

@ -80,6 +80,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
.shortName(R.string.treatments_shortname)
.preferencesId(R.xml.pref_absorption_oref0)
.alwaysEnabled(true)
.description(R.string.description_treatments)
);
this.service = new TreatmentService();
}

View file

@ -56,6 +56,7 @@ public class WearPlugin extends PluginBase {
.pluginName(R.string.wear)
.shortName(R.string.wear_shortname)
.preferencesId(R.xml.pref_wear)
.description(R.string.description_wear)
);
this.ctx = ctx;
}

View file

@ -70,6 +70,7 @@ public class StatuslinePlugin extends PluginBase {
.shortName(R.string.xdripstatus_shortname)
.neverVisible(true)
.preferencesId(R.xml.pref_xdripstatus)
.description(R.string.description_xdrip_status_line)
);
this.ctx = ctx;
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);