From 13cb4c28ed0a6f8d0aa2d866bc44312aae375a70 Mon Sep 17 00:00:00 2001 From: TebbeUbben Date: Thu, 7 Jun 2018 22:54:27 +0200 Subject: [PATCH] ConfigBuilder styling --- .../androidaps/interfaces/PluginBase.java | 6 + .../interfaces/PluginDescription.java | 6 + .../ConfigBuilder/ConfigBuilderFragment.java | 433 +++++------- .../androidaps/tabs/TabPageAdapter.java | 9 +- .../info/nightscout/utils/HardLimits.java | 2 +- .../main/res/drawable-hdpi/ic_visibility.png | Bin 0 -> 953 bytes .../main/res/drawable-mdpi/ic_visibility.png | Bin 0 -> 413 bytes .../main/res/drawable-xhdpi/ic_visibility.png | Bin 0 -> 847 bytes .../res/drawable-xxhdpi/ic_visibility.png | Bin 0 -> 2094 bytes .../res/drawable-xxxhdpi/ic_visibility.png | Bin 0 -> 2090 bytes .../res/drawable/visibility_black_16x16.png | Bin 233 -> 0 bytes .../res/layout/configbuilder_fragment.xml | 622 ++++++++++++------ .../res/layout/configbuilder_simpleitem.xml | 42 -- .../layout/configbuilder_single_plugin.xml | 60 ++ .../main/res/layout/objectives_fragment.xml | 2 +- app/src/main/res/values/strings.xml | 10 + 16 files changed, 645 insertions(+), 547 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_visibility.png create mode 100644 app/src/main/res/drawable-mdpi/ic_visibility.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_visibility.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_visibility.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_visibility.png delete mode 100644 app/src/main/res/drawable/visibility_black_16x16.png delete mode 100644 app/src/main/res/layout/configbuilder_simpleitem.xml create mode 100644 app/src/main/res/layout/configbuilder_single_plugin.xml diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java index 1173936430..b6c5c6cb96 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.java @@ -57,6 +57,12 @@ public abstract class PluginBase { return getName(); } + public String getDescription() { + return "This is an example description."; + /*if (pluginDescription.description == -1) return null; + else return MainApp.gs(pluginDescription.description);*/ + } + public PluginType getType() { return pluginDescription.mainType; } diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java index c86ae639fa..1634fc672d 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java @@ -9,6 +9,7 @@ public class PluginDescription { boolean showInList = true; int pluginName = -1; int shortName = -1; + int description = -1; int preferencesId = -1; int advancedPreferencesId = -1; public boolean enableByDefault = false; @@ -74,6 +75,11 @@ public class PluginDescription { return this; } + public PluginDescription description(int description) { + this.description = description; + return this; + } + public String getFragmentClass() { return fragmentClass; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java index e92ca52cd9..b4971f4d7a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java @@ -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 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,48 @@ 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(); + } @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 { - - private ArrayList pluginList; - final private PluginType type; - - PluginCustomAdapter(Context context, int textViewResourceId, - ArrayList 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 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 +199,95 @@ 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; + private boolean updating = false; - 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() { + updating = true; + 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.GONE : 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()); + updating = false; + } + + @OnCheckedChanged(R.id.plugin_visibility) + void onVisibilityChanged() { + if (updating) return; + plugin.setFragmentVisible(plugin.getType(), pluginVisibility.isChecked()); + ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible"); + MainApp.bus().post(new EventRefreshGui()); + ConfigBuilderPlugin.getPlugin().logPluginStatus(); + } + + @OnCheckedChanged({R.id.plugin_enabled_exclusive, R.id.plugin_enabled_inclusive}) + void onEnabledChanged() { + if (updating) return; + 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(); + } + } } diff --git a/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java b/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java index c17646e901..79037ebcd8 100644 --- a/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java @@ -3,9 +3,11 @@ package info.nightscout.androidaps.tabs; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter; import android.view.ViewGroup; @@ -19,7 +21,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; /** * Created by mike on 30.05.2016. */ -public class TabPageAdapter extends FragmentStatePagerAdapter { +public class TabPageAdapter extends FragmentPagerAdapter { ArrayList visibleFragmentList = new ArrayList<>(); @@ -76,5 +78,8 @@ public class TabPageAdapter extends FragmentStatePagerAdapter { } } - + @Override + public long getItemId(int position) { + return System.identityHashCode(visibleFragmentList.get(position)); + } } diff --git a/app/src/main/java/info/nightscout/utils/HardLimits.java b/app/src/main/java/info/nightscout/utils/HardLimits.java index 8e1a05db0d..ed58687f8f 100644 --- a/app/src/main/java/info/nightscout/utils/HardLimits.java +++ b/app/src/main/java/info/nightscout/utils/HardLimits.java @@ -40,7 +40,7 @@ public class HardLimits { public static final double MAXISF = 720; // mgdl public static final double[] MAXIOB_AMA = {3, 5, 7, 12}; - public static final double[] MAXIOB_SMB = {3, 7, 12, 25}; + public static final double[] MAXIOB_SMB = {3, 7, 20, 25}; public static final double[] MAXBASAL = {2, 5, 10, 12}; diff --git a/app/src/main/res/drawable-hdpi/ic_visibility.png b/app/src/main/res/drawable-hdpi/ic_visibility.png new file mode 100644 index 0000000000000000000000000000000000000000..a014628e30b96b396a207ea86b52c54e81c2b28e GIT binary patch literal 953 zcmV;q14jIbP)eP6?gL`upo2_f0a0b^*4$r93#LP<@A14|MPXc9TGWEsnFVmUAeI1nLA zvgbgN2^q$ivE|bBx&L~<_kExD{~a)WQ{R2^9{lg;ey-=buX}mLEHlkAJj?;=%g7u< z{|iI5w*C}#T3x|sT|K;0_EKgWBE!xD>dhQq+o< z%VU$`tp{!f?w7Q>6{s1&_94Jcz-ho1V*>mRyajv!tO5dRHz4PZEEb24{RzARER~eA zBQ_S0?daqoU>{(Up;Ni|3t$QGI!iBAIuHXipLuu#(H-S=q>*?t6AG|*QD~wj=Ohflr!Z zKUGCtDCx)YI|X>Ip{b;Ag`|ZefNY;tscL27ZQu+^-`L&?cpRADa9#gZ$FhV#$BWs;WL-n`mIilAkY!l{zJno3!* zld9UjaU!C-ThcYreZBeii!DsGpwwEV9I?wZi2(xa}GbZ-Y}0q_8@-3$R;0W9kQ zbcdwt3eZ(~&;&pkIZGrh>j2HJl+`OzT@h-_-UQ}JT4j6N($MJ*=a);=Yi#cXJOxB| zExTA!Bs0>7(lb(R!`(T)85Q#-y;u+EE;+I5C0PPJuZTqG$&wQ08Z1s(>DX*}+G;Cx`Eq*UdUwT9~n zrKjvZ^v)?QRt{+%a z$E9f|3tD>3oxpwBp9UxVV8FgLbjr8%aBIz@4AqQ-zOw(SQtsa`UO~%-&Sf`O!d*;$MApteGX6`rE?5z bbPW9sBP~=k&$Y&)00000NkvXXu0mjfyXMBt literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_visibility.png b/app/src/main/res/drawable-mdpi/ic_visibility.png new file mode 100644 index 0000000000000000000000000000000000000000..d5a9dc9ca4226dbae86a19e095a11d8f721b15a0 GIT binary patch literal 413 zcmV;O0b>4%P)qa1UHcdZ|ZqO^R#}04u;W z&{ZSIGjIf~OS;Q?^9vwmyap@+ttqF^_}!Aa{{VJ?)pSKw0Ji&pQ=pItVBi4Q1a9K} z5KsbUp=waBfC)(t75^Uq+ugt!FqjHnlC+gozU^WJP9}N_j7us9pCrIxT?*VhE1db%l`~cXV1dcPZ9FufmJ5;cgvTsW&+8zbYGkm8coqShd zJ8(Cg(a;V_@3xo!R@CGV7wz(k3c;F zIXzHMp_~rPEj}s{FtbI#dSDf>1Xu_(0MmknKY`D{Ti_+|1b86nO^zAM<IIz?&3(-*!c)hPEE*edCDmRu$PGiwHJ0JE}`0pEZt zz#ZV3q%SUGX0w46z$Rb^Ff&2dSD;nWy=uHw0hpN=Xcv&>K`%(>J5n;b(xU;)iO>MD z9Ow~jljMb7mMSVRvn|1!p8M74H?UXI#RRVou$b9y;5;xfL(XeqyClzoVN@1?nXLmn zbdxibyXW`RYJ5p&0C6Fq1^)t?Bt0Bz&oBUHHV=3X%uVoUr=(pmpP4!6eIeI}LfyfZ|{G%$ymslOdnm7_>b_Up=_->1&+a=zC2$-37 znpc4L{1j@IbUy-c5IB`02pp1hI+AS)HJ2jp(ON92f5yZBd^PZVOr?e)>EoXDUY|lf zBL>neq>(RssnjmX+x8#;FTzrmqNGpKpblkbzRyfe5e9lCl{VFW5i|4R&YCwR^*xf7 zjW&Q@V9Iy`D0~VPyNE*`7NL!9mUL@a8;x38aR*t5La|qg0AelRL#lYoT$DvRO7xIZ)zh~oZIMj(p&Qy+mS?pYf`cY5Ie5stg>{+r`&;@UjsY*~k;F*hLZ19bp-J(yR%9)Y|b%qw4yKwb~#l`nh* Z{sK;sc0e^r-If3V002ovPDHLkV1fe;bmjm6 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_visibility.png b/app/src/main/res/drawable-xxhdpi/ic_visibility.png new file mode 100644 index 0000000000000000000000000000000000000000..dbc192368f897f52b0c1c502ba56492247021f47 GIT binary patch literal 2094 zcmV+}2+{Y6P)C)(p%GMSi>U#OAZn|v)*9!zz#lf&iGbFDYKuYz z5@ZO-P*96$Vxnl8Qd^BiY89-F^UzxAu*~QNSU9f3y4t*bDpv_%rZ(;C^7Iq zfRlhDfk!4#9sxWII0$%1n*RTQ{{sI849LHL-M}A#9|Cs(8zud--g4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)bc{bKBe_k{XhT)yg&~s{ z9%7zmu&In?z}|+FP3%XAY3+GAU}cp}MsiYGu{vvRuxtIP)#<~D zj=c_Dr@NIVLwVev;tgT$fXGFsZwyuK?ZCiZQ|XM=yrM%uS1vDq5mq>^#k!Jin$VDmgLj?~x=^r!+}$Xs|5R9%JgC4CXEO z4p*`obwL(_3yz{)V^Z7vPKzpmC}P(+a|J0m5t&mC;vYmiwXGrTgz}T%<(q%H&-(ey zN%p<7A6XLoOk%yE^85gv$`_8&Tw*$}pX3nGqH>8BwTyV`^0nGkyYq$|A|RRAtRY;=usrB6-J~uM3QW9 z@Y7Oy@Q9t2@ep}ZdZ1!!vZLwK%FVpxS3Pdp(>Ic^)K5ifjyvuJKs|cA+IN*TaWCxP z+SpCNV49zg_3cLC~RQj$g=8^EWem5i;_UnfV5 zHY7~u4DbGZmcEA6uz_nErODgaZu@mK8fcV1@l>_ZgDIubd@*U8luAlwR$(feHXFn6h?;z$eD49`!9beJxbC?n^ zefbYqYa>Wy#g#vfz$n?3cMFhABs}S8R3LHx87c2Ut@ns@a9x`C`f-Z}$Cyt9~oheGeoeH=Vu(1C)~Fp5DEtQ0II$ zZs3pbKneC=q2scS>oeyQg%C5euJATBkzn8Rn#H1G)Z`@WUavjy^Mw3#~!nhT|VO+-JHY6gkpwcR< z`SZe>@wZ+)W2jZ1>}u7%U2gSd2Nghn@(D zs%m@qbA%;Rhn7iOW zI4bYLE8dJAhbWhTE$>5318z}fd}iu3d*?Bamq%!q>`uBv=}(|0M0GavHNT*`_BV@+|;f4gim^`b81 zMZNi^m6i1K_yu!adaa{C5EFWQ7gn<1YnFO4_p4u6Zf|$R8{6l{&m^;pkBV08Z2^<^ kLh1i27yoN?R)MxG^l$9oPj$^>4}Jgu<>~Ly<`!M}Z@sqTT>t<8 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/visibility_black_16x16.png b/app/src/main/res/drawable/visibility_black_16x16.png deleted file mode 100644 index d24867dcdf25e7cf90ddd1c90d999359b2410d3f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6Hh8)?hG>ZHJ?QP_#K^#UA$dlw z!^Ox823=u7mli2?D4ek4o@lVxlkb*Op!5sVugwxwpJxi2Kd{WX*vTHBmS%U?dRyZ8 zxvdf}D@{bW&9km$#kuTRrESXN@+D+#OsB+3>);<3ubGGyCcZqdzC(^nkoA{R+PCr} z`&qTT99=b&UIrZraE^X>d*!swj$-ZI^IUjLrbgX!DG6PBwdBmvi2Iv6XY3B!`tZbB h{@~#ER(!eV + android:gravity="center" + android:orientation="vertical"> + +