ConfigBuilderFragment -> kotlin
This commit is contained in:
parent
63e45fd549
commit
d2c01501a8
|
@ -8,6 +8,7 @@ import androidx.fragment.app.FragmentActivity;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui;
|
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -64,7 +65,7 @@ public abstract class PluginBase {
|
||||||
log.debug("First time HW pump allowed!");
|
log.debug("First time HW pump allowed!");
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
||||||
MainApp.bus().post(new EventConfigBuilderUpdateGui());
|
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
||||||
if (L.isEnabled(L.PUMP))
|
if (L.isEnabled(L.PUMP))
|
||||||
log.debug("User does not allow switching to HW pump!");
|
log.debug("User does not allow switching to HW pump!");
|
||||||
});
|
});
|
||||||
|
@ -78,11 +79,11 @@ public abstract class PluginBase {
|
||||||
private void performPluginSwitch(boolean enabled, PluginType type) {
|
private void performPluginSwitch(boolean enabled, PluginType type) {
|
||||||
setPluginEnabled(type, enabled);
|
setPluginEnabled(type, enabled);
|
||||||
setFragmentVisible(type, enabled);
|
setFragmentVisible(type, enabled);
|
||||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(this, getType());
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(this, getType());
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
|
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
|
||||||
MainApp.bus().post(new EventRefreshGui());
|
MainApp.bus().post(new EventRefreshGui());
|
||||||
MainApp.bus().post(new EventConfigBuilderChange());
|
MainApp.bus().post(new EventConfigBuilderChange());
|
||||||
MainApp.bus().post(new EventConfigBuilderUpdateGui());
|
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
||||||
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,180 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.configBuilder;
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
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 info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
|
||||||
import info.nightscout.androidaps.utils.PasswordProtection;
|
|
||||||
|
|
||||||
|
|
||||||
public class ConfigBuilderFragment extends SubscriberFragment {
|
|
||||||
|
|
||||||
private List<PluginViewHolder> pluginViewHolders = new ArrayList<>();
|
|
||||||
|
|
||||||
@BindView(R.id.categories)
|
|
||||||
LinearLayout categories;
|
|
||||||
|
|
||||||
@BindView(R.id.main_layout)
|
|
||||||
ScrollView mainLayout;
|
|
||||||
@BindView(R.id.unlock)
|
|
||||||
Button unlock;
|
|
||||||
|
|
||||||
@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);
|
|
||||||
|
|
||||||
createViews();
|
|
||||||
|
|
||||||
return view;
|
|
||||||
} catch (Exception e) {
|
|
||||||
FabricPrivacy.logException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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
|
|
||||||
protected void updateGUI() {
|
|
||||||
for (PluginViewHolder pluginViewHolder : pluginViewHolders) pluginViewHolder.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void on(EventConfigBuilderUpdateGui e) {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null)
|
|
||||||
activity.runOnUiThread(this::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));
|
|
||||||
createViewsForPlugins(R.string.configbuilder_bgsource, R.string.configbuilder_bgsource_description, PluginType.BGSOURCE, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginType.BGSOURCE));
|
|
||||||
createViewsForPlugins(R.string.configbuilder_pump, R.string.configbuilder_pump_description, PluginType.PUMP, MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP));
|
|
||||||
createViewsForPlugins(R.string.configbuilder_sensitivity, R.string.configbuilder_sensitivity_description, PluginType.SENSITIVITY, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginType.SENSITIVITY));
|
|
||||||
createViewsForPlugins(R.string.configbuilder_aps, R.string.configbuilder_aps_description, PluginType.APS, MainApp.getSpecificPluginsVisibleInList(PluginType.APS));
|
|
||||||
createViewsForPlugins(R.string.configbuilder_loop, R.string.configbuilder_loop_description, PluginType.LOOP, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP));
|
|
||||||
createViewsForPlugins(R.string.constraints, R.string.configbuilder_constraints_description, PluginType.CONSTRAINTS, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginType.CONSTRAINTS));
|
|
||||||
createViewsForPlugins(R.string.configbuilder_treatments, R.string.configbuilder_treatments_description, PluginType.TREATMENT, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT));
|
|
||||||
createViewsForPlugins(R.string.configbuilder_general, R.string.configbuilder_general_description, PluginType.GENERAL, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createViewsForPlugins(@StringRes int title, @StringRes int description, PluginType pluginType, List<PluginBase> plugins) {
|
|
||||||
if (plugins.size() == 0) return;
|
|
||||||
LinearLayout parent = (LinearLayout) getLayoutInflater().inflate(R.layout.configbuilder_single_category, null);
|
|
||||||
((TextView) parent.findViewById(R.id.category_title)).setText(MainApp.gs(title));
|
|
||||||
((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(this, pluginType, plugin);
|
|
||||||
pluginContainer.addView(pluginViewHolder.getBaseView());
|
|
||||||
pluginViewHolders.add(pluginViewHolder);
|
|
||||||
}
|
|
||||||
categories.addView(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
|
||||||
ArrayList<PluginBase> pluginsInCategory = null;
|
|
||||||
switch (type) {
|
|
||||||
// Multiple selection allowed
|
|
||||||
case GENERAL:
|
|
||||||
case CONSTRAINTS:
|
|
||||||
case LOOP:
|
|
||||||
break;
|
|
||||||
// Single selection allowed
|
|
||||||
case INSULIN:
|
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
|
|
||||||
break;
|
|
||||||
case SENSITIVITY:
|
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
|
||||||
break;
|
|
||||||
case APS:
|
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(APSInterface.class);
|
|
||||||
break;
|
|
||||||
case PROFILE:
|
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(ProfileInterface.class);
|
|
||||||
break;
|
|
||||||
case BGSOURCE:
|
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(BgSourceInterface.class);
|
|
||||||
break;
|
|
||||||
case TREATMENT:
|
|
||||||
case PUMP:
|
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(PumpInterface.class);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (pluginsInCategory != null) {
|
|
||||||
boolean newSelection = changedPlugin.isEnabled(type);
|
|
||||||
if (newSelection) { // new plugin selected -> disable others
|
|
||||||
for (PluginBase p : pluginsInCategory) {
|
|
||||||
if (p.getName().equals(changedPlugin.getName())) {
|
|
||||||
// this is new selected
|
|
||||||
} else {
|
|
||||||
p.setPluginEnabled(type, false);
|
|
||||||
p.setFragmentVisible(type, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // enable first plugin in list
|
|
||||||
if (type == PluginType.PUMP)
|
|
||||||
VirtualPumpPlugin.getPlugin().setPluginEnabled(type, true);
|
|
||||||
else if (type == PluginType.INSULIN)
|
|
||||||
InsulinOrefRapidActingPlugin.getPlugin().setPluginEnabled(type, true);
|
|
||||||
else if (type == PluginType.SENSITIVITY)
|
|
||||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(type, true);
|
|
||||||
else if (type == PluginType.PROFILE)
|
|
||||||
NSProfilePlugin.getPlugin().setPluginEnabled(type, true);
|
|
||||||
else
|
|
||||||
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package info.nightscout.androidaps.plugins.configBuilder
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.interfaces.*
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
import info.nightscout.androidaps.utils.PasswordProtection
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
import kotlinx.android.synthetic.main.configbuilder_fragment.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ConfigBuilderFragment : Fragment() {
|
||||||
|
|
||||||
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
private val pluginViewHolders = ArrayList<PluginViewHolder>()
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.configbuilder_fragment, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
if (PasswordProtection.isLocked("settings_password"))
|
||||||
|
configbuilder_main_layout.visibility = View.GONE
|
||||||
|
else
|
||||||
|
unlock.visibility = View.GONE
|
||||||
|
|
||||||
|
unlock.setOnClickListener {
|
||||||
|
PasswordProtection.QueryPassword(context, R.string.settings_password, "settings_password", {
|
||||||
|
configbuilder_main_layout.visibility = View.VISIBLE
|
||||||
|
unlock.visibility = View.GONE
|
||||||
|
}, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
createViews()
|
||||||
|
|
||||||
|
disposable.add(RxBus
|
||||||
|
.toObservable(EventConfigBuilderUpdateGui::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
for (pluginViewHolder in pluginViewHolders) pluginViewHolder.update()
|
||||||
|
}, {
|
||||||
|
FabricPrivacy.logException(it)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createViews() {
|
||||||
|
createViewsForPlugins(R.string.configbuilder_profile, R.string.configbuilder_profile_description, PluginType.PROFILE, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface::class.java, PluginType.PROFILE))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_insulin, R.string.configbuilder_insulin_description, PluginType.INSULIN, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface::class.java, PluginType.INSULIN))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_bgsource, R.string.configbuilder_bgsource_description, PluginType.BGSOURCE, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface::class.java, PluginType.BGSOURCE))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_pump, R.string.configbuilder_pump_description, PluginType.PUMP, MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_sensitivity, R.string.configbuilder_sensitivity_description, PluginType.SENSITIVITY, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface::class.java, PluginType.SENSITIVITY))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_aps, R.string.configbuilder_aps_description, PluginType.APS, MainApp.getSpecificPluginsVisibleInList(PluginType.APS))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_loop, R.string.configbuilder_loop_description, PluginType.LOOP, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP))
|
||||||
|
createViewsForPlugins(R.string.constraints, R.string.configbuilder_constraints_description, PluginType.CONSTRAINTS, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface::class.java, PluginType.CONSTRAINTS))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_treatments, R.string.configbuilder_treatments_description, PluginType.TREATMENT, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT))
|
||||||
|
createViewsForPlugins(R.string.configbuilder_general, R.string.configbuilder_general_description, PluginType.GENERAL, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createViewsForPlugins(@StringRes title: Int, @StringRes description: Int, pluginType: PluginType, plugins: List<PluginBase>) {
|
||||||
|
if (plugins.size == 0) return
|
||||||
|
val parent = layoutInflater.inflate(R.layout.configbuilder_single_category, null) as LinearLayout
|
||||||
|
(parent.findViewById<View>(R.id.category_title) as TextView).text = MainApp.gs(title)
|
||||||
|
(parent.findViewById<View>(R.id.category_description) as TextView).text = MainApp.gs(description)
|
||||||
|
val pluginContainer = parent.findViewById<LinearLayout>(R.id.category_plugins)
|
||||||
|
for (plugin in plugins) {
|
||||||
|
val pluginViewHolder = PluginViewHolder(this, pluginType, plugin)
|
||||||
|
pluginContainer.addView(pluginViewHolder.baseView)
|
||||||
|
pluginViewHolders.add(pluginViewHolder)
|
||||||
|
}
|
||||||
|
configbuilder_categories.addView(parent)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
|
@ -405,4 +406,58 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
||||||
|
ArrayList<PluginBase> pluginsInCategory = null;
|
||||||
|
switch (type) {
|
||||||
|
// Multiple selection allowed
|
||||||
|
case GENERAL:
|
||||||
|
case CONSTRAINTS:
|
||||||
|
case LOOP:
|
||||||
|
break;
|
||||||
|
// Single selection allowed
|
||||||
|
case INSULIN:
|
||||||
|
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
|
||||||
|
break;
|
||||||
|
case SENSITIVITY:
|
||||||
|
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
||||||
|
break;
|
||||||
|
case APS:
|
||||||
|
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(APSInterface.class);
|
||||||
|
break;
|
||||||
|
case PROFILE:
|
||||||
|
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(ProfileInterface.class);
|
||||||
|
break;
|
||||||
|
case BGSOURCE:
|
||||||
|
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(BgSourceInterface.class);
|
||||||
|
break;
|
||||||
|
case TREATMENT:
|
||||||
|
case PUMP:
|
||||||
|
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(PumpInterface.class);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pluginsInCategory != null) {
|
||||||
|
boolean newSelection = changedPlugin.isEnabled(type);
|
||||||
|
if (newSelection) { // new plugin selected -> disable others
|
||||||
|
for (PluginBase p : pluginsInCategory) {
|
||||||
|
if (p.getName().equals(changedPlugin.getName())) {
|
||||||
|
// this is new selected
|
||||||
|
} else {
|
||||||
|
p.setPluginEnabled(type, false);
|
||||||
|
p.setFragmentVisible(type, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // enable first plugin in list
|
||||||
|
if (type == PluginType.PUMP)
|
||||||
|
VirtualPumpPlugin.getPlugin().setPluginEnabled(type, true);
|
||||||
|
else if (type == PluginType.INSULIN)
|
||||||
|
InsulinOrefRapidActingPlugin.getPlugin().setPluginEnabled(type, true);
|
||||||
|
else if (type == PluginType.SENSITIVITY)
|
||||||
|
SensitivityOref0Plugin.getPlugin().setPluginEnabled(type, true);
|
||||||
|
else if (type == PluginType.PROFILE)
|
||||||
|
NSProfilePlugin.getPlugin().setPluginEnabled(type, true);
|
||||||
|
else
|
||||||
|
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class SWDefinition {
|
||||||
.action(() -> {
|
.action(() -> {
|
||||||
NSClientPlugin.getPlugin().setPluginEnabled(PluginType.GENERAL, true);
|
NSClientPlugin.getPlugin().setPluginEnabled(PluginType.GENERAL, true);
|
||||||
NSClientPlugin.getPlugin().setFragmentVisible(PluginType.GENERAL, true);
|
NSClientPlugin.getPlugin().setFragmentVisible(PluginType.GENERAL, true);
|
||||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
MainApp.bus().post(new EventConfigBuilderChange());
|
MainApp.bus().post(new EventConfigBuilderChange());
|
||||||
MainApp.bus().post(new EventSWUpdate(true));
|
MainApp.bus().post(new EventSWUpdate(true));
|
||||||
|
@ -386,7 +386,7 @@ public class SWDefinition {
|
||||||
.action(() -> {
|
.action(() -> {
|
||||||
LoopPlugin.getPlugin().setPluginEnabled(PluginType.LOOP, true);
|
LoopPlugin.getPlugin().setPluginEnabled(PluginType.LOOP, true);
|
||||||
LoopPlugin.getPlugin().setFragmentVisible(PluginType.LOOP, true);
|
LoopPlugin.getPlugin().setFragmentVisible(PluginType.LOOP, true);
|
||||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(LoopPlugin.getPlugin(), PluginType.LOOP);
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(LoopPlugin.getPlugin(), PluginType.LOOP);
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
MainApp.bus().post(new EventConfigBuilderChange());
|
MainApp.bus().post(new EventConfigBuilderChange());
|
||||||
MainApp.bus().post(new EventSWUpdate(true));
|
MainApp.bus().post(new EventSWUpdate(true));
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class SWPlugin extends SWItem {
|
||||||
PluginBase plugin = (PluginBase) rb.getTag();
|
PluginBase plugin = (PluginBase) rb.getTag();
|
||||||
plugin.setPluginEnabled(pType, rb.isChecked());
|
plugin.setPluginEnabled(pType, rb.isChecked());
|
||||||
plugin.setFragmentVisible(pType, rb.isChecked() && makeVisible);
|
plugin.setFragmentVisible(pType, rb.isChecked() && makeVisible);
|
||||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(plugin, pType);
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(plugin, pType);
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
MainApp.bus().post(new EventConfigBuilderChange());
|
MainApp.bus().post(new EventConfigBuilderChange());
|
||||||
MainApp.bus().post(new EventSWUpdate());
|
MainApp.bus().post(new EventSWUpdate());
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
android:text="@string/unlock_settings" />
|
android:text="@string/unlock_settings" />
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/main_layout"
|
android:id="@+id/configbuilder_main_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/categories"
|
android:id="@+id/configbuilder_categories"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|
Loading…
Reference in a new issue