From 45ffc18d25484228edcf5522633d42805cffa671 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 5 Nov 2016 20:12:58 +0100 Subject: [PATCH] move set temp and set extended buttons to actions --- .../plugins/Actions/ActionsFragment.java | 20 +++++++---- .../dialogs}/NewExtendedBolusDialog.java | 2 +- .../dialogs}/NewTempBasalDialog.java | 2 +- .../Dialogs/NewNSTreatmentDialog.java | 9 ----- .../ConfigBuilder/ConfigBuilderPlugin.java | 2 +- .../plugins/Overview/OverviewFragment.java | 33 ------------------- app/src/main/res/layout/actions_fragment.xml | 28 +++++++++++++++- app/src/main/res/layout/overview_fragment.xml | 33 ------------------- 8 files changed, 44 insertions(+), 85 deletions(-) rename app/src/main/java/info/nightscout/androidaps/plugins/{Overview/Dialogs => Actions/dialogs}/NewExtendedBolusDialog.java (99%) rename app/src/main/java/info/nightscout/androidaps/plugins/{Overview/Dialogs => Actions/dialogs}/NewTempBasalDialog.java (99%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index add18ff4fd..245d189660 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -10,9 +10,10 @@ import android.view.ViewGroup; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.FragmentBase; -import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; +import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog; +import info.nightscout.androidaps.plugins.Actions.dialogs.NewTempBasalDialog; /** * A simple {@link Fragment} subclass. @@ -34,6 +35,8 @@ public class ActionsFragment extends Fragment implements FragmentBase, View.OnCl View view = inflater.inflate(R.layout.actions_fragment, container, false); view.findViewById(R.id.actions_profileswitch).setOnClickListener(this); + view.findViewById(R.id.actions_extendedbolus).setOnClickListener(this); + view.findViewById(R.id.actions_settempbasal).setOnClickListener(this); return view; } @@ -41,17 +44,22 @@ public class ActionsFragment extends Fragment implements FragmentBase, View.OnCl @Override public void onClick(View view) { FragmentManager manager = getFragmentManager(); - NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); switch (view.getId()) { case R.id.actions_profileswitch: + NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, false, false, false, true, false); profileswitch.executeProfileSwitch = true; newDialog.setOptions(profileswitch); + newDialog.show(manager, "NewNSTreatmentDialog"); break; - default: - newDialog = null; + case R.id.actions_extendedbolus: + NewExtendedBolusDialog newExtendedDialog = new NewExtendedBolusDialog(); + newExtendedDialog.show(manager, "NewExtendedDialog"); + break; + case R.id.actions_settempbasal: + NewTempBasalDialog newTempDialog = new NewTempBasalDialog(); + newTempDialog.show(manager, "NewTempDialog"); + break; } - if (newDialog != null) - newDialog.show(manager, "NewNSTreatmentDialog"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewExtendedBolusDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewExtendedBolusDialog.java rename to app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java index 8ca775e25f..56ffa69d5f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewExtendedBolusDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.Overview.Dialogs; +package info.nightscout.androidaps.plugins.Actions.dialogs; import android.content.Context; import android.content.DialogInterface; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTempBasalDialog.java rename to app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java index 3b27f869d7..e0dae0bcd8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTempBasalDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.Overview.Dialogs; +package info.nightscout.androidaps.plugins.Actions.dialogs; import android.content.Context; import android.content.DialogInterface; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java index aefcdd646d..aa90b5701a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java @@ -2,9 +2,7 @@ package info.nightscout.androidaps.plugins.Careportal.Dialogs; import android.app.Activity; -import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -40,20 +38,13 @@ import java.util.Calendar; import java.util.Date; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.Services.Intents; -import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.events.EventNewBasalProfile; import info.nightscout.androidaps.interfaces.PumpInterface; -import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; -import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog; -import info.nightscout.client.data.DbLogger; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DateUtil; import info.nightscout.utils.PlusMinusEditText; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index d052d80d02..f842ac9a5b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -43,7 +43,7 @@ import info.nightscout.androidaps.plugins.Loop.DeviceStatus; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResult; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; -import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog; +import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog; import info.nightscout.client.data.DbLogger; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DateUtil; 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 401c612c75..6efdfd0b0a 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 @@ -11,7 +11,6 @@ import android.os.Handler; import android.os.HandlerThread; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; -import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; @@ -60,8 +59,6 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; -import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog; -import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTempBasalDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog; import info.nightscout.androidaps.plugins.Overview.GraphSeriesExtension.PointsWithLabelGraphSeries; @@ -70,7 +67,6 @@ import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.Round; -import info.nightscout.utils.SafeParse; public class OverviewFragment extends Fragment { @@ -91,14 +87,11 @@ public class OverviewFragment extends Fragment { GraphView bgGraph; LinearLayout cancelTempLayout; - LinearLayout setTempLayout; LinearLayout acceptTempLayout; LinearLayout quickWizardLayout; Button cancelTempButton; Button treatmentButton; Button wizardButton; - Button setTempButton; - Button setExtenedButton; Button acceptTempButton; Button quickWizardButton; @@ -131,10 +124,7 @@ public class OverviewFragment extends Fragment { cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp); treatmentButton = (Button) view.findViewById(R.id.overview_treatment); wizardButton = (Button) view.findViewById(R.id.overview_wizard); - setExtenedButton = (Button) view.findViewById(R.id.overview_extendedbolus); - setTempButton = (Button) view.findViewById(R.id.overview_settempbasal); cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp); - setTempLayout = (LinearLayout) view.findViewById(R.id.overview_settemplayout); cancelTempLayout = (LinearLayout) view.findViewById(R.id.overview_canceltemplayout); acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton); acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout); @@ -183,23 +173,6 @@ public class OverviewFragment extends Fragment { } }); - setTempButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - FragmentManager manager = getFragmentManager(); - NewTempBasalDialog newTempDialog = new NewTempBasalDialog(); - newTempDialog.show(manager, "NewTempDialog"); - } - }); - - setExtenedButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - FragmentManager manager = getFragmentManager(); - NewExtendedBolusDialog newExtendedDialog = new NewExtendedBolusDialog(); - newExtendedDialog.show(manager, "NewExtendedDialog"); - } - }); acceptTempButton.setOnClickListener(new View.OnClickListener() { @Override @@ -465,26 +438,20 @@ public class OverviewFragment extends Fragment { if (pump.isTempBasalInProgress()) { TempBasal activeTemp = pump.getTempBasal(); cancelTempLayout.setVisibility(View.VISIBLE); - setTempLayout.setVisibility(View.GONE); cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + ": " + activeTemp.toString()); runningTempView.setText(activeTemp.toString()); } else { cancelTempLayout.setVisibility(View.GONE); - setTempLayout.setVisibility(View.VISIBLE); Double currentBasal = pump.getBaseBasalRate(); runningTempView.setText(DecimalFormatter.to2Decimal(currentBasal) + " U/h"); } if (profile == null) { // disable all treatment buttons because we are not able to check constraints without profile - setExtenedButton.setVisibility(View.INVISIBLE); - setTempLayout.setVisibility(View.INVISIBLE); wizardButton.setVisibility(View.INVISIBLE); treatmentButton.setVisibility(View.INVISIBLE); return; } else { - setExtenedButton.setVisibility(View.VISIBLE); - setTempLayout.setVisibility(View.VISIBLE); wizardButton.setVisibility(View.VISIBLE); treatmentButton.setVisibility(View.VISIBLE); } diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml index 5557a64e6e..daa2f52ecf 100644 --- a/app/src/main/res/layout/actions_fragment.xml +++ b/app/src/main/res/layout/actions_fragment.xml @@ -7,7 +7,7 @@ + android:orientation="vertical">