From c93322f2dac03d67fc0caa16501a85333b9072e1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 7 Nov 2016 00:58:44 +0100 Subject: [PATCH 1/5] Overview Loopdisable on longclick 1 --- .../plugins/Overview/OverviewFragment.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 6efdfd0b0a..13f8dccd53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -53,6 +53,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTreatmentChange; +import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; @@ -404,7 +405,7 @@ public class OverviewFragment extends Fragment { if (Config.APS) { apsModeView.setVisibility(View.VISIBLE); apsModeView.setBackgroundResource(R.drawable.loopmodeborder); - LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop(); + final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop(); if(activeloop != null && activeloop.isEnabled(activeloop.getType())) { if (MainApp.getConfigBuilder().isClosedModeEnabled()) { apsModeView.setText(MainApp.sResources.getString(R.string.closedloop)); @@ -415,6 +416,28 @@ public class OverviewFragment extends Fragment { apsModeView.setBackgroundResource(R.drawable.loopmodedisabledborder); apsModeView.setText(MainApp.sResources.getString(R.string.disabledloop)); } + + + apsModeView.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View view) { + if (activeloop == null){ + log.error("no active loop?"); + return true; + } else if (activeloop.isEnabled(PluginBase.LOOP)){ + activeloop.setFragmentEnabled(PluginBase.LOOP, false); + activeloop.setFragmentVisible(PluginBase.LOOP, false); + } else { + activeloop.setFragmentEnabled(PluginBase.LOOP, true); + activeloop.setFragmentVisible(PluginBase.LOOP, true); + } + MainApp.getConfigBuilder().storeSettings(); + MainApp.bus().post(new EventRefreshGui(false)); + return true; + } + }); + apsModeView.setLongClickable(true); + } else { apsModeView.setVisibility(View.GONE); } From be39a35d685156cd7b0376f5b90a803cefc1b4fb Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 7 Nov 2016 00:59:47 +0100 Subject: [PATCH 2/5] Update ConfigBuilderFragment.java --- .../plugins/ConfigBuilder/ConfigBuilderFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 30f2abe664..70a526f1a2 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 @@ -178,7 +178,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { plugin.setFragmentVisible(type, cb.isChecked()); onEnabledCategoryChanged(plugin, type); configBuilderPlugin.storeSettings(); - MainApp.bus().post(new EventRefreshGui()); + MainApp.bus().post(new EventRefreshGui(true)); } }); @@ -188,7 +188,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { PluginBase plugin = (PluginBase) cb.getTag(); plugin.setFragmentVisible(type, cb.isChecked()); configBuilderPlugin.storeSettings(); - MainApp.bus().post(new EventRefreshGui()); + MainApp.bus().post(new EventRefreshGui(true)); } }); } else { From 68be6179f8a5ff7b20a2e4c4b3c6617a6a79a3f8 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 7 Nov 2016 01:00:50 +0100 Subject: [PATCH 3/5] Update EventRefreshGui.java --- .../nightscout/androidaps/events/EventRefreshGui.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java index f20dfb9329..cb57c361fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java @@ -4,4 +4,15 @@ package info.nightscout.androidaps.events; * Created by mike on 13.06.2016. */ public class EventRefreshGui { + + public boolean isSwitchToLast() { + return switchToLast; + } + + private final boolean switchToLast; + + public EventRefreshGui(boolean switchToLast){ + this.switchToLast = switchToLast; + } + } From c851aefc8ecb13b3889d4e3c8f85f3a4faf779fd Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 7 Nov 2016 01:01:33 +0100 Subject: [PATCH 4/5] Update MainActivity.java --- app/src/main/java/info/nightscout/androidaps/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 5876e05809..04177386c8 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -76,7 +76,7 @@ public class MainActivity extends AppCompatActivity { LocaleHelper.setLocale(getApplicationContext(), lang); recreate(); try { // activity may be destroyed - setUpTabs(true); + setUpTabs(ev.isSwitchToLast()); } catch (IllegalStateException e) { e.printStackTrace(); } From 686593986cfad863a963a3747ed5b4de222df7ac Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 7 Nov 2016 01:02:08 +0100 Subject: [PATCH 5/5] Update PreferencesActivity.java --- .../java/info/nightscout/androidaps/PreferencesActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index e11b858387..b088c25adf 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -37,7 +37,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre String lang = sharedPreferences.getString("language", "en"); LocaleHelper.setLocale(getApplicationContext(), lang); recreate(); - MainApp.bus().post(new EventRefreshGui()); + MainApp.bus().post(new EventRefreshGui(true)); } updatePrefSummary(myPreferenceFragment.getPreference(key)); } @@ -105,4 +105,4 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre return findPreference(key); } } -} \ No newline at end of file +}