From ba967df2e386517954a8e25f955b3526d5f9ca3f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 27 Aug 2017 11:44:39 +0200 Subject: [PATCH] disable careportal buttons until profile is set --- .../Careportal/CareportalFragment.java | 18 + .../main/res/layout/careportal_fragment.xml | 665 +++++++++--------- 2 files changed, 360 insertions(+), 323 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java index 6ddda8cd68..2353fa6645 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java @@ -9,6 +9,7 @@ import android.text.Layout; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; import com.squareup.otto.Subscribe; @@ -16,10 +17,13 @@ import com.squareup.otto.Subscribe; import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewFragment; public class CareportalFragment extends SubscriberFragment implements View.OnClickListener { @@ -32,6 +36,8 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli TextView pbage; View statsLayout; + LinearLayout butonsLayout; + View noProfileView; static public CareportalPlugin getPlugin() { if (careportalPlugin == null) { @@ -95,6 +101,18 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli statsLayout = (View) view.findViewById(R.id.careportal_stats); + noProfileView = (View) view.findViewById(R.id.profileview_noprofile); + butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons); + + ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile(); + if (profileStore == null) { + noProfileView.setVisibility(View.VISIBLE); + butonsLayout.setVisibility(View.GONE); + } else { + noProfileView.setVisibility(View.GONE); + butonsLayout.setVisibility(View.VISIBLE); + } + if (BuildConfig.NSCLIENTOLNY) statsLayout.setVisibility(View.GONE); // visible on overview diff --git a/app/src/main/res/layout/careportal_fragment.xml b/app/src/main/res/layout/careportal_fragment.xml index 9c7d34d6a1..4f21471075 100644 --- a/app/src/main/res/layout/careportal_fragment.xml +++ b/app/src/main/res/layout/careportal_fragment.xml @@ -22,353 +22,372 @@ android:layout_height="wrap_content" /> + android:gravity="center_horizontal" + android:text="@string/noprofileset" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textColor="@android:color/holo_red_light" + android:textStyle="bold" + android:visibility="gone" /> - - -