disable careportal buttons until profile is set

This commit is contained in:
Milos Kozak 2017-08-27 11:44:39 +02:00
parent e4c98e6cd1
commit ba967df2e3
2 changed files with 360 additions and 323 deletions

View file

@ -9,6 +9,7 @@ import android.text.Layout;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
@ -16,10 +17,13 @@ import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; 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.db.CareportalEvent;
import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment; import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener { public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
@ -32,6 +36,8 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
TextView pbage; TextView pbage;
View statsLayout; View statsLayout;
LinearLayout butonsLayout;
View noProfileView;
static public CareportalPlugin getPlugin() { static public CareportalPlugin getPlugin() {
if (careportalPlugin == null) { if (careportalPlugin == null) {
@ -95,6 +101,18 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
statsLayout = (View) view.findViewById(R.id.careportal_stats); 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) if (BuildConfig.NSCLIENTOLNY)
statsLayout.setVisibility(View.GONE); // visible on overview statsLayout.setVisibility(View.GONE); // visible on overview

View file

@ -21,6 +21,23 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView
android:id="@+id/profileview_noprofile"
android:layout_width="match_parent"
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" />
<LinearLayout
android:id="@+id/careportal_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -369,6 +386,8 @@
app:layout_row="6" /> app:layout_row="6" />
</android.support.v7.widget.GridLayout> </android.support.v7.widget.GridLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>