Combo tab: show command queue if non-empty.

This commit is contained in:
Johannes Mockenhaupt 2017-12-06 17:10:57 +01:00
parent 1cbfefffb8
commit 86b63cb27d
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 30 additions and 0 deletions

View file

@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.PumpCombo;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -16,7 +17,9 @@ import com.squareup.otto.Subscribe;
import de.jotomo.ruffy.spi.PumpState;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI;
import info.nightscout.androidaps.queue.events.EventQueueChanged;
import info.nightscout.utils.DateUtil;
public class ComboFragment extends SubscriberFragment implements View.OnClickListener, View.OnLongClickListener {
@ -28,6 +31,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
private TextView lastBolusView;
private TextView tempBasalText;
private LinearLayout buttonsLayout;
private TextView queueView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -42,6 +47,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
//lastBolusView = (TextView) view.findViewById(R.id.combo_last_bolus);
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
buttonsLayout = (LinearLayout) view.findViewById(R.id.combo_buttons_layout);
queueView = (TextView) view.findViewById(R.id.combo_queue);
Button refresh = (Button) view.findViewById(R.id.combo_refresh);
refresh.setOnClickListener(this);
@ -89,6 +96,12 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventQueueChanged ignored) {
updateGUI();
}
public void updateGUI() {
Activity fragmentActivity = getActivity();
if (fragmentActivity != null)
@ -188,6 +201,16 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
}
}
tempBasalText.setText(tbrStr);
// TODO clean up & i18n or remove
// Queued activities
Spanned status = ConfigBuilderPlugin.getCommandQueue().spannedStatus();
if (status.toString().equals("")) {
queueView.setVisibility(View.GONE);
} else {
queueView.setVisibility(View.VISIBLE);
queueView.setText("Queued activities:\n" + status);
}
}
});
}

View file

@ -337,6 +337,13 @@
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<TextView
android:id="@+id/combo_queue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textAlignment="center" />
</LinearLayout>
</ScrollView>