better layout for nsclient mode

This commit is contained in:
Milos Kozak 2018-08-21 23:19:04 +02:00
parent 5114335005
commit 653a98fd5b
5 changed files with 35 additions and 99 deletions

View file

@ -15,6 +15,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
@ -174,10 +175,14 @@ public class NSDeviceStatus {
public Spanned getPumpStatus() {
//String[] ALL_STATUS_FIELDS = {"reservoir", "battery", "clock", "status", "device"};
StringBuilder string = new StringBuilder();
string.append("<span style=\"color:" + MainApp.gs(R.color.defaulttext).replace("#ff", "#") + "\">");
string.append(MainApp.gs(R.string.pump));
string.append(": </span>");
if (deviceStatusPumpData == null)
return Html.fromHtml("");
StringBuilder string = new StringBuilder();
// test warning level
int level = Levels.INFO;
long now = System.currentTimeMillis();
@ -329,6 +334,10 @@ public class NSDeviceStatus {
public Spanned getOpenApsStatus() {
StringBuilder string = new StringBuilder();
string.append("<span style=\"color:" + MainApp.gs(R.color.defaulttext).replace("#ff", "#") + "\">");
string.append(MainApp.gs(R.string.openaps_short));
string.append(": </span>");
// test warning level
int level = Levels.INFO;
long now = System.currentTimeMillis();
@ -426,6 +435,26 @@ public class NSDeviceStatus {
return minBattery + "%";
}
public Spanned getUploaderStatusSpanned() {
StringBuilder string = new StringBuilder();
string.append("<span style=\"color:" + MainApp.gs(R.color.defaulttext).replace("#ff", "#") + "\">");
string.append(MainApp.gs(R.string.uploader_short));
string.append(": </span>");
Iterator iter = uploaders.entrySet().iterator();
int minBattery = 100;
while (iter.hasNext()) {
Map.Entry pair = (Map.Entry) iter.next();
Uploader uploader = (Uploader) pair.getValue();
if (minBattery > uploader.battery)
minBattery = uploader.battery;
}
string.append(minBattery);
string.append("%");
return Html.fromHtml(string.toString());
}
public Spanned getExtendedUploaderStatus() {
StringBuilder string = new StringBuilder();

View file

@ -1358,7 +1358,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// Uploader status from ns
if (uploaderDeviceStatusView != null) {
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatus());
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatusSpanned());
uploaderDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null));
}

View file

@ -350,19 +350,6 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="2dp"
android:text="@string/pump"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_pump"
android:layout_width="wrap_content"
@ -388,18 +375,6 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/openaps_short"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_openaps"
android:layout_width="wrap_content"
@ -425,18 +400,6 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/uploader_short"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_uploader"
android:layout_width="wrap_content"

View file

@ -400,25 +400,6 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/pump"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_pump"
android:layout_width="match_parent"
@ -426,7 +407,7 @@
android:layout_weight="0.5"
android:gravity="start"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingLeft="20dp"
android:text=""
android:textColor="@android:color/white"
android:textSize="14sp" />
@ -448,25 +429,6 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/openaps"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_openaps"
android:layout_width="match_parent"
@ -474,7 +436,7 @@
android:layout_weight="0.5"
android:gravity="start"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingLeft="20dp"
android:text=""
android:textColor="@android:color/white"
android:textSize="14sp" />
@ -495,25 +457,6 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/uploader"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_uploader"
android:layout_width="match_parent"
@ -521,7 +464,7 @@
android:layout_weight="0.5"
android:gravity="start"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingLeft="20dp"
android:text=""
android:textColor="@android:color/white"
android:textSize="14sp" />

View file

@ -27,6 +27,7 @@
<color name="warning">#ff1a1a</color>
<color name="defaultbackground">#424242</color>
<color name="defaulttext">#BBBBBB</color>
<color name="tempTargetBackground">#77dd77</color>
<color name="tempTargetConfirmation">#77dd77</color>