DanaRUserOptionsActivity refactor

This commit is contained in:
Milos Kozak 2019-12-21 18:21:32 +01:00
parent 33d1d3e82d
commit a928c48ae0
6 changed files with 495 additions and 623 deletions

View file

@ -1,213 +0,0 @@
package info.nightscout.androidaps.plugins.pump.danaR.activities;
import android.os.Bundle;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Switch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.NumberPicker;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
/**
* Created by Rumen Georgiev on 5/31/2018.
*/
public class DanaRUserOptionsActivity extends NoSplashAppCompatActivity {
private static Logger log = LoggerFactory.getLogger(L.PUMP);
private CompositeDisposable disposable = new CompositeDisposable();
Switch timeFormat;
Switch buttonScroll;
Switch beep;
RadioGroup pumpAlarm;
RadioButton pumpAlarmSound;
RadioButton pumpAlarmVibrate;
RadioButton pumpAlarmBoth;
Switch pumpUnits;
NumberPicker screenTimeout;
NumberPicker backlightTimeout;
NumberPicker shutdown;
NumberPicker lowReservoir;
Button saveToPumpButton;
// This is for Dana pumps only
boolean isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP);
boolean isDanaR = DanaRPlugin.getPlugin().isEnabled(PluginType.PUMP);
boolean isDanaRv2 = DanaRv2Plugin.getPlugin().isEnabled(PluginType.PUMP);
@Override
protected synchronized void onResume() {
super.onResume();
disposable.add(RxBus.INSTANCE
.toObservable(EventInitializationChanged.class)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(event -> setData(), FabricPrivacy::logException)
);
}
@Override
protected synchronized void onPause() {
disposable.clear();
super.onPause();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.danar_user_options);
timeFormat = (Switch) findViewById(R.id.danar_timeformat);
buttonScroll = (Switch) findViewById(R.id.danar_buttonscroll);
beep = (Switch) findViewById(R.id.danar_beep);
pumpAlarm = (RadioGroup) findViewById(R.id.danar_pumpalarm);
pumpAlarmSound = (RadioButton) findViewById(R.id.danar_pumpalarm_sound);
pumpAlarmVibrate = (RadioButton) findViewById(R.id.danar_pumpalarm_vibrate);
pumpAlarmBoth = (RadioButton) findViewById(R.id.danar_pumpalarm_both);
screenTimeout = (NumberPicker) findViewById(R.id.danar_screentimeout);
backlightTimeout = (NumberPicker) findViewById(R.id.danar_backlight);
pumpUnits = (Switch) findViewById(R.id.danar_units);
shutdown = (NumberPicker) findViewById(R.id.danar_shutdown);
lowReservoir = (NumberPicker) findViewById(R.id.danar_lowreservoir);
saveToPumpButton = (Button) findViewById(R.id.save_user_options);
saveToPumpButton.setOnClickListener(v -> onSaveClick());
DanaRPump pump = DanaRPump.getInstance();
//used for debugging
if (L.isEnabled(L.PUMP))
log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nbuttonScroll:" + pump.buttonScrollOnOff
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
+ "\nbacklight:" + pump.backlightOnTimeSec
+ "\npumpUnits:" + pump.units
+ "\nlowReservoir:" + pump.lowReservoirRate);
screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false, findViewById(R.id.ok));
backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false, findViewById(R.id.ok));
shutdown.setParams((double) pump.shutdownHour, 0d, 24d, 1d, new DecimalFormat("1"), true, findViewById(R.id.ok));
lowReservoir.setParams((double) pump.lowReservoirRate, 10d, 60d, 10d, new DecimalFormat("10"), false, findViewById(R.id.ok));
switch (pump.beepAndAlarm) {
case 0x01:
pumpAlarmSound.setChecked(true);
break;
case 0x02:
pumpAlarmVibrate.setChecked(true);
break;
case 0x11:
pumpAlarmBoth.setChecked(true);
break;
case 0x101:
pumpAlarmSound.setChecked(true);
beep.setChecked(true);
break;
case 0x110:
pumpAlarmVibrate.setChecked(true);
beep.setChecked(true);
break;
case 0x111:
pumpAlarmBoth.setChecked(true);
beep.setChecked(true);
break;
}
if (pump.lastSettingsRead == 0)
log.error("No settings loaded from pump!");
else
setData();
}
public void setData() {
DanaRPump pump = DanaRPump.getInstance();
// in DanaRS timeDisplay values are reversed
timeFormat.setChecked((!isRS && pump.timeDisplayType != 0) || (isRS && pump.timeDisplayType == 0));
buttonScroll.setChecked(pump.buttonScrollOnOff != 0);
beep.setChecked(pump.beepAndAlarm > 4);
screenTimeout.setValue((double) pump.lcdOnTimeSec);
backlightTimeout.setValue((double) pump.backlightOnTimeSec);
pumpUnits.setChecked(pump.getUnits() != null && pump.getUnits().equals(Constants.MMOL));
shutdown.setValue((double) pump.shutdownHour);
lowReservoir.setValue((double) pump.lowReservoirRate);
}
public void onSaveClick() {
if (!isRS && !isDanaR && !isDanaRv2) {
//exit if pump is not DanaRS, Dana!, or DanaR with upgraded firmware
return;
}
DanaRPump pump = DanaRPump.getInstance();
if (timeFormat.isChecked())
pump.timeDisplayType = 1;
else
pump.timeDisplayType = 0;
// displayTime on RS is reversed
if (isRS) {
if (timeFormat.isChecked())
pump.timeDisplayType = 0;
else
pump.timeDisplayType = 1;
}
if (buttonScroll.isChecked())
pump.buttonScrollOnOff = 1;
else
pump.buttonScrollOnOff = 0;
pump.beepAndAlarm = 1; // default
if (pumpAlarmSound.isChecked()) pump.beepAndAlarm = 1;
else if (pumpAlarmVibrate.isChecked()) pump.beepAndAlarm = 2;
else if (pumpAlarmBoth.isChecked()) pump.beepAndAlarm = 3;
if (beep.isChecked()) pump.beepAndAlarm += 4;
// step is 5 seconds
int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5 : 5;
if (screenTimeoutValue > 4 && screenTimeoutValue < 241) {
pump.lcdOnTimeSec = screenTimeoutValue;
} else {
pump.lcdOnTimeSec = 5;
}
int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()) : 1;
if (backlightTimeoutValue > 0 && backlightTimeoutValue < 61) {
pump.backlightOnTimeSec = backlightTimeoutValue;
}
if (pumpUnits.isChecked()) {
pump.units = 1;
} else {
pump.units = 0;
}
int shutDownValue = !shutdown.getText().isEmpty() ? Integer.parseInt(shutdown.getText().toString()) : 0;
if (shutDownValue > -1 && shutDownValue < 25) {
pump.shutdownHour = shutDownValue;
} else {
pump.shutdownHour = 0;
}
int lowReservoirValue = !lowReservoir.getText().isEmpty() ? (Integer.parseInt(lowReservoir.getText().toString()) * 10) / 10 : 10;
if (lowReservoirValue > 9 && lowReservoirValue < 51) {
pump.lowReservoirRate = lowReservoirValue;
} else
pump.lowReservoirRate = 10;
ConfigBuilderPlugin.getPlugin().getCommandQueue().setUserOptions(null);
finish();
}
}

View file

@ -0,0 +1,159 @@
package info.nightscout.androidaps.plugins.pump.danaR.activities
import android.content.Intent
import android.os.Bundle
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.events.EventInitializationChanged
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.plugins.bus.RxBus.toObservable
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.danar_user_options_activity.*
import org.slf4j.LoggerFactory
import java.text.DecimalFormat
import kotlin.math.max
import kotlin.math.min
class DanaRUserOptionsActivity : NoSplashAppCompatActivity() {
private val log = LoggerFactory.getLogger(L.PUMP)
private val disposable = CompositeDisposable()
// This is for Dana pumps only
private var isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP)
private var isDanaR = DanaRPlugin.getPlugin().isEnabled(PluginType.PUMP)
private var isDanaRv2 = DanaRv2Plugin.getPlugin().isEnabled(PluginType.PUMP)
@Synchronized
override fun onResume() {
super.onResume()
disposable.add(toObservable(EventInitializationChanged::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ setData() }) { FabricPrivacy.logException(it) }
)
}
@Synchronized
override fun onPause() {
disposable.clear()
super.onPause()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.danar_user_options_activity)
save_user_options.setOnClickListener { onSaveClick() }
val pump = DanaRPump.getInstance()
if (L.isEnabled(L.PUMP))
log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nbuttonScroll:" + pump.buttonScrollOnOff
+ "\ntimeDisplayType:" + pump.timeDisplayType
+ "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
+ "\nbackLight:" + pump.backlightOnTimeSec
+ "\npumpUnits:" + pump.units
+ "\nlowReservoir:" + pump.lowReservoirRate)
danar_screentimeout.setParams(pump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, save_user_options)
danar_backlight.setParams(pump.backlightOnTimeSec.toDouble(), 1.0, 60.0, 1.0, DecimalFormat("1"), false, save_user_options)
danar_shutdown.setParams(pump.shutdownHour.toDouble(), 0.0, 24.0, 1.0, DecimalFormat("1"), true, save_user_options)
danar_lowreservoir.setParams(pump.lowReservoirRate.toDouble(), 10.0, 60.0, 10.0, DecimalFormat("10"), false, save_user_options)
when (pump.beepAndAlarm) {
0x01 -> danar_pumpalarm_sound.isChecked = true
0x02 -> danar_pumpalarm_vibrate.isChecked = true
0x11 -> danar_pumpalarm_both.isChecked = true
0x101 -> {
danar_pumpalarm_sound.isChecked = true
danar_beep.isChecked = true
}
0x110 -> {
danar_pumpalarm_vibrate.isChecked = true
danar_beep.isChecked = true
}
0x111 -> {
danar_pumpalarm_both.isChecked = true
danar_beep.isChecked = true
}
}
if (pump.lastSettingsRead == 0L)
log.error("No settings loaded from pump!") else setData()
}
fun setData() {
val pump = DanaRPump.getInstance()
// in DanaRS timeDisplay values are reversed
danar_timeformat.isChecked = !isRS && pump.timeDisplayType != 0 || isRS && pump.timeDisplayType == 0
danar_buttonscroll.isChecked = pump.buttonScrollOnOff != 0
danar_beep.isChecked = pump.beepAndAlarm > 4
danar_screentimeout.value = pump.lcdOnTimeSec.toDouble()
danar_backlight.value = pump.backlightOnTimeSec.toDouble()
danar_units.isChecked = pump.getUnits() == Constants.MMOL
danar_shutdown.value = pump.shutdownHour.toDouble()
danar_lowreservoir.value = pump.lowReservoirRate.toDouble()
}
private fun onSaveClick() {
//exit if pump is not DanaRS, DanaR, or DanaR with upgraded firmware
if (!isRS && !isDanaR && !isDanaRv2) return
val pump = DanaRPump.getInstance()
if (isRS) // displayTime on RS is reversed
pump.timeDisplayType = if (danar_timeformat.isChecked) 0 else 1
else
pump.timeDisplayType = if (danar_timeformat.isChecked) 1 else 0
pump.buttonScrollOnOff = if (danar_buttonscroll.isChecked) 1 else 0
pump.beepAndAlarm = when {
danar_pumpalarm_sound.isChecked -> 1
danar_pumpalarm_vibrate.isChecked -> 2
danar_pumpalarm_both.isChecked -> 3
else -> 1
}
if (danar_beep.isChecked) pump.beepAndAlarm += 4
// step is 5 seconds, 5 to 240
pump.lcdOnTimeSec = min(max(danar_screentimeout.value.toInt() / 5 * 5, 5), 240)
// 1 to 60
pump.backlightOnTimeSec = min(max(danar_backlight.value.toInt(), 1), 60)
pump.units = if (danar_units.isChecked) 1 else 0
pump.shutdownHour = min(danar_shutdown.value.toInt(),24)
// 10 to 50
pump.lowReservoirRate = min(max(danar_lowreservoir.value.toInt() * 10 / 10, 10), 50)
ConfigBuilderPlugin.getPlugin().commandQueue.setUserOptions(object : Callback() {
override fun run() {
if (!result.success) {
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", MainApp.gs(R.string.pumperror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
MainApp.instance().startActivity(i)
}
}
})
finish()
}
}

View file

@ -19,7 +19,7 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/carbs"
android:contentDescription="@string/danar_history"
android:src="@drawable/icon_danarhistory" />
<TextView

View file

@ -1,404 +0,0 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".plugins.pump.danaR.activities.DanaRUserOptionsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/danar_buttons"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:text="@string/danar_pump_settings"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<LinearLayout
android:id="@+id/overview_pumpstatuslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="2dp"
android:visibility="gone">
<TextView
android:id="@+id/overview_pumpstatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center_vertical|center_horizontal"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<Switch
android:id="@+id/danar_timeformat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:showText="true"
android:text="@string/danar_timedisplay"
android:textOff="12h"
android:textOn="24h" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<Switch
android:id="@+id/danar_buttonscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/danar_buttonscroll"
android:textOff="@string/option_off"
android:textOn="@string/option_on" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<Switch
android:id="@+id/danar_beep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/danar_beep"
android:textOff="@string/option_off"
android:textOn="@string/option_on" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingRight="5dp"
android:text="@string/danar_pumpalarm"
android:textSize="14sp" />
<RadioGroup
android:id="@+id/danar_pumpalarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkedButton="@+id/danar_pumpalarm_sound">
<RadioButton
android:id="@+id/danar_pumpalarm_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_sound" />
<RadioButton
android:id="@+id/danar_pumpalarm_vibrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_vibrate" />
<RadioButton
android:id="@+id/danar_pumpalarm_both"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_both" />
</RadioGroup>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top"
android:paddingRight="5dp"
android:text="@string/danar_screentimeout"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_screentimeout"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top"
android:paddingRight="5dp"
android:text="@string/danar_backlight"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_backlight"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<Switch
android:id="@+id/danar_units"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:showText="true"
android:splitTrack="false"
android:text="@string/danar_glucoseunits"
android:textOff="@string/mgdl"
android:textOn="@string/mmol" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingRight="5dp"
android:text="@string/danar_shutdown"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_shutdown"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingRight="5dp"
android:text="@string/danar_lowreservoir"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_lowreservoir"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<Button
android:id="@+id/save_user_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/danar_saveuseroptions" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
</FrameLayout>

View file

@ -0,0 +1,328 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".plugins.pump.danaR.activities.DanaRUserOptionsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/danar_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/cardColorBackground"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/danar_pump_settings"
android:src="@drawable/icon_danar_useropt" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="@string/danar_pump_settings"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<LinearLayout
android:id="@+id/spacer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" />
<Switch
android:id="@+id/danar_timeformat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:showText="true"
android:text="@string/danar_timedisplay"
android:textOff="@string/timeformat12h"
android:textOn="@string/timeformat24h" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<Switch
android:id="@+id/danar_buttonscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:text="@string/danar_buttonscroll"
android:textOff="@string/option_off"
android:textOn="@string/option_on" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<Switch
android:id="@+id/danar_beep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:text="@string/danar_beep"
android:textOff="@string/option_off"
android:textOn="@string/option_on" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/danar_pumpalarm"
android:textSize="14sp" />
<RadioGroup
android:id="@+id/danar_pumpalarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkedButton="@+id/danar_pumpalarm_sound"
android:orientation="horizontal">
<RadioButton
android:id="@+id/danar_pumpalarm_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_sound" />
<RadioButton
android:id="@+id/danar_pumpalarm_vibrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_vibrate" />
<RadioButton
android:id="@+id/danar_pumpalarm_both"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_both" />
</RadioGroup>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top"
android:text="@string/danar_screentimeout"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_screentimeout"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top"
android:text="@string/danar_backlight"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_backlight"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<Switch
android:id="@+id/danar_units"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:showText="true"
android:splitTrack="false"
android:text="@string/danar_glucoseunits"
android:textOff="@string/mgdl"
android:textOn="@string/mmol" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/danar_shutdown"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_shutdown"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/danar_lowreservoir"
android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker
android:id="@+id/danar_lowreservoir"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<Button
android:id="@+id/save_user_options"
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/icon_local_save"
android:text="@string/danar_saveuseroptions" />
</LinearLayout>
</ScrollView>

View file

@ -262,7 +262,7 @@
<string name="connecting">Connecting</string>
<string name="connected">Connected</string>
<string name="disconnected">Disconnected</string>
<string name="danar_pump_settings">DanaR pump settings</string>
<string name="danar_pump_settings">Dana pump settings</string>
<string name="end_user_license_agreement">End User License Agreement</string>
<string name="end_user_license_agreement_text">MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</string>
<string name="end_user_license_agreement_i_understand">I UNDERSTAND AND AGREE</string>
@ -1121,11 +1121,11 @@
<string name="danar_pumpalarm_sound">Sound</string>
<string name="danar_pumpalarm_vibrate">Vibrate</string>
<string name="danar_pumpalarm_both">Both</string>
<string name="danar_screentimeout">LCD on time [s]</string>
<string name="danar_backlight">Backlight on time [s]</string>
<string name="danar_screentimeout">LCD on time [seconds]</string>
<string name="danar_backlight">Backlight on time [seconds]</string>
<string name="danar_glucoseunits">Glucose units</string>
<string name="danar_shutdown">Shutdown(hours)</string>
<string name="danar_lowreservoir">Low reservoir (Units)</string>
<string name="danar_shutdown">Shutdown [hours]</string>
<string name="danar_lowreservoir">Low reservoir [Units]</string>
<string name="danar_saveuseroptions">Save options to pump</string>
<string name="option_on">On</string>
<string name="option_off">Off</string>
@ -1687,5 +1687,7 @@
<string name="tools">Tools</string>
<string name="show_calculation">Show calcuation</string>
<string name="error">Error</string>
<string name="timeformat12h">12h</string>
<string name="timeformat24h">24h</string>
</resources>