Skip to content

Commit

Permalink
Merge pull request #31 from Rig22/dev
Browse files Browse the repository at this point in the history
Dev Stand 07.01.2021
  • Loading branch information
Rig22 committed Jan 7, 2021
2 parents f43ccf9 + 07fa17e commit 50661e0
Show file tree
Hide file tree
Showing 34 changed files with 236 additions and 128 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/info/nightscout/androidaps/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ class MainActivity : NoSplashAppCompatActivity() {
}

private fun setPluginPreferenceMenuName() {
val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem)
this.menu?.findItem(R.id.nav_plugin_preferences)?.title = resourceHelper.gs(R.string.nav_preferences_plugin, plugin.name)
if (main_pager.currentItem > 0) {
val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem)
this.menu?.findItem(R.id.nav_plugin_preferences)?.title = resourceHelper.gs(R.string.nav_preferences_plugin, plugin.name)
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,21 @@ class LoopDialog : DaggerDialogFragment() {
val profile = profileFunction.getProfile() ?: return true
when (v.id) {
R.id.overview_closeloop -> {
aapsLogger.debug("USER ENTRY: CLOSED LOOP MODE")
sp.putString(R.string.key_aps_mode, "closed")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop)))
return true
}

R.id.overview_lgsloop -> {
aapsLogger.debug("USER ENTRY: LGS LOOP MODE")
sp.putString(R.string.key_aps_mode, "lgs")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true
}

R.id.overview_openloop -> {
aapsLogger.debug("USER ENTRY: OPEN LOOP MODE")
sp.putString(R.string.key_aps_mode, "open")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TempTargetDialog().show(childFragmentManager, "Overview") })

R.id.overview_activeprofile -> {
val args = Bundle()
args.putLong("time", DateUtil.now())
args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
val pvd = ProfileViewerDialog()
pvd.arguments = args
pvd.show(childFragmentManager, "ProfileViewDialog")
ProfileViewerDialog().also { pvd ->
pvd.arguments = Bundle().also {
it.putLong("time", DateUtil.now())
it.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
}
}.show(childFragmentManager, "ProfileViewDialog")
}

R.id.overview_cgmbutton -> {
Expand Down Expand Up @@ -329,24 +329,26 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
val lastRun = loopPlugin.lastRun
loopPlugin.invoke("Accept temp button", false)
if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed?.isChangeRequested == true) {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned()
?: "".toSpanned(), {
aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL")
overview_accepttempbutton?.visibility = View.GONE
(context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID)
actionStringHandler.handleInitiate("cancelChangeRequest")
loopPlugin.acceptChangeRequest()
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned()
?: "".toSpanned(), {
aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL")
overview_accepttempbutton?.visibility = View.GONE
(context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID)
actionStringHandler.handleInitiate("cancelChangeRequest")
loopPlugin.acceptChangeRequest()
})
})
}
}
}

R.id.overview_apsmode -> {
val args = Bundle()
args.putInt("showOkCancel", 1) // 1-> true
val pvd = LoopDialog()
pvd.arguments = args
pvd.show(childFragmentManager, "Overview")
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
LoopDialog().also { dialog ->
dialog.arguments = Bundle().also { it.putInt("showOkCancel", 1) }
}.show(childFragmentManager, "Overview")
})
}
}
}
Expand Down Expand Up @@ -374,11 +376,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}

R.id.overview_apsmode -> {
val args = Bundle()
args.putInt("showOkCancel", 0) // 0-> false
val pvd = LoopDialog()
pvd.arguments = args
pvd.show(childFragmentManager, "Overview")
activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
LoopDialog().also { dialog ->
dialog.arguments = Bundle().also { it.putInt("showOkCancel", 0) }
}.show(childFragmentManager, "Overview")
})
}
}

R.id.overview_temptarget -> v.performClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class TimeDateOrTZChangeReceiver : DaggerBroadcastReceiver() {

Intent.ACTION_TIMEZONE_CHANGED == action -> {
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.")
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange)
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChanged)
}

Intent.ACTION_TIME_CHANGED == action -> {
val currentDst = calculateDST()
if (currentDst == isDST) {
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.")
activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange)
activePump.timezoneOrDSTChanged(TimeChangeType.TimeChanged)
} else {
if (currentDst) {
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class BolusWizard @Inject constructor(
if (carbTime > 0) {
timeShift += " (+" + resourceHelper.gs(R.string.mins, carbTime) + ")"
} else if (carbTime < 0) {
timeShift += " (-" + resourceHelper.gs(R.string.mins, carbTime) + ")"
timeShift += " (" + resourceHelper.gs(R.string.mins, carbTime) + ")"
}
actions.add(resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, carbs).formatColor(resourceHelper, R.color.carbs) + timeShift)
}
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/res/layout/activity_profilehelper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:gravity="center_vertical">

<TextView
android:id="@+id/profilehelper_age_label"
Expand All @@ -105,7 +106,8 @@
<TableRow
android:id="@+id/profilehelper_tdd_row"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:gravity="center_vertical">

<TextView
android:id="@+id/profilehelper_tdd_label"
Expand All @@ -126,7 +128,8 @@
<TableRow
android:id="@+id/profilehelper_weight_row"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:gravity="center_vertical">

<TextView
android:id="@+id/profilehelper_weigth_label"
Expand All @@ -147,7 +150,8 @@
<TableRow
android:id="@+id/profilehelper_basalpctfromtdd_row"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:gravity="center_vertical">

<TextView
android:id="@+id/profilehelper_basalpctfromtdd_label"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/automation_event_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
android:layout_height="wrap_content"
android:contentDescription="@string/reorder_label"
android:orientation="horizontal"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@+id/iconLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iconTrash"
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/layout/datetime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:width="120dp"
android:padding="10dp"
android:paddingLeft="10dp"
android:paddingRight="4dp"
android:text="@string/event_time_label"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold" />
Expand All @@ -19,15 +20,15 @@
android:id="@+id/overview_eventdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:padding="10dp"
android:text="2017/05/05" />

<TextView
android:id="@+id/overview_eventtime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:padding="10dp"
android:text="08:20pm" />

Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout/overview_info_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,20 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="-4dp"
android:visibility="gone"
app:srcCompat="@drawable/ic_loop_closed" />

<TextView
android:id="@+id/overview_apsmode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:text="Open Loop"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textStyle="bold" />
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>

<LinearLayout
Expand All @@ -183,6 +185,7 @@
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/overview_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/overview_apsmode_llayout"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,17 @@
<string name="key_statuslights_sbat_critical" translatable="false">statuslights_sbat_critical</string>
<string name="statuslights_sbat_critical">Threshold critical sensor battery level [%]</string>
<string name="key_statuslights_bage_warning" translatable="false">statuslights_bage_warning</string>
<string name="statuslights_bage_warning">Threshold warning battery age [h]</string>
<string name="statuslights_bage_warning">Threshold warning pump battery age [h]</string>
<string name="key_statuslights_bage_critical" translatable="false">statuslights_bage_critical</string>
<string name="statuslights_bage_critical">Threshold critical battery age [h]</string>
<string name="statuslights_bage_critical">Threshold critical pump battery age [h]</string>
<string name="key_statuslights_res_warning" translatable="false">statuslights_res_warning</string>
<string name="statuslights_res_warning">Threshold warning reservoir level [U]</string>
<string name="key_statuslights_res_critical" translatable="false">statuslights_res_critical</string>
<string name="statuslights_res_critical">Threshold critical reservoir level [U]</string>
<string name="key_statuslights_bat_warning" translatable="false">statuslights_bat_warning</string>
<string name="statuslights_bat_warning">Threshold warning battery level [%]</string>
<string name="statuslights_bat_warning">Threshold warning pump battery level [%]</string>
<string name="key_statuslights_bat_critical" translatable="false">statuslights_bat_critical</string>
<string name="statuslights_bat_critical">Threshold critical battery level [%]</string>
<string name="statuslights_bat_critical">Threshold critical pump battery level [%]</string>
<string name="prediction_shortname">PRED</string>
<string name="iob">IOB</string>
<string name="cob">COB</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class Notification {
public static final int OMNIPOD_UNCERTAIN_SMB = 67;
public static final int OMNIPOD_UNKNOWN_TBR = 68;
public static final int OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69;
public static final int OMNIPOD_TIME_OUT_OF_SYNC = 70;

public static final int IMPORTANCE_HIGH = 2;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package info.nightscout.androidaps.utils;

public enum TimeChangeType {
TimezoneChange,
TimezoneChanged,
DST_Started,
DST_Ended,
ManualTimeChange
TimeChanged
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import info.nightscout.androidaps.utils.SafeParse;
import info.nightscout.androidaps.utils.ToastUtils;

/**
* Created by mike on 28.06.2016.
*/
public class NumberPicker extends LinearLayout implements View.OnKeyListener,
View.OnTouchListener, View.OnClickListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class DanaRSService : DaggerService() {
danaPump.bolusStopped = true
danaPump.bolusStopForced = true
aapsLogger.debug(LTag.PUMPCOMM, "Communication stopped")
bleComm.disconnect("Communication stopped")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,16 @@ public boolean isConnecting() {

@Override
public void getPumpStatus(String reason) {
boolean needRefresh = true;

if (firstRun) {
initializePump(!isRefresh);
needRefresh = initializePump(!isRefresh);
} else {
refreshAnyStatusThatNeedsToBeRefreshed();
}

rxBus.send(new EventMedtronicPumpValuesChanged());
if (needRefresh)
rxBus.send(new EventMedtronicPumpValuesChanged());
}


Expand Down Expand Up @@ -556,7 +558,10 @@ private void setRefreshButtonEnabled(boolean enabled) {
}


private void initializePump(boolean realInit) {
private boolean initializePump(boolean realInit) {

if (rileyLinkMedtronicService==null)
return false;

aapsLogger.info(LTag.PUMP, getLogPrefix() + "initializePump - start");

Expand All @@ -571,7 +576,7 @@ private void initializePump(boolean realInit) {

setRefreshButtonEnabled(true);

return;
return true;
}

medtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
Expand Down Expand Up @@ -614,7 +619,7 @@ private void initializePump(boolean realInit) {
aapsLogger.error("Number of error counts was 5 or more. Starting tunning.");
setRefreshButtonEnabled(true);
serviceTaskExecutor.startTask(new WakeAndTuneTask(getInjector()));
return;
return true;
}

medtronicPumpStatus.setLastCommunicationToNow();
Expand All @@ -628,6 +633,8 @@ private void initializePump(boolean realInit) {
// this.pumpState = PumpDriverState.Initialized;

this.firstRun = false;

return true;
}

private void getBasalProfiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,14 @@ private BatteryStatusDTO decodeBatteryStatus(byte[] rawData) {

if (rawData.length > 1) {

Double d = null;

// if response in 3 bytes then we add additional information
double d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
if (rawData.length == 2) {
d = (rawData[1] * 1.0d) / 100.0d;
} else {
d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
}

batteryStatus.voltage = d;
batteryStatus.extendedDataReceived = true;
Expand All @@ -171,7 +177,14 @@ private Float decodeRemainingInsulin(byte[] rawData) {
startIdx = 2;
}

float value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
int reqLength = startIdx+1;
float value = 0;

if (reqLength >= rawData.length) {
value = rawData[startIdx] / (1.0f * strokes);
} else {
value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
}

aapsLogger.debug(LTag.PUMPCOMM, "Remaining insulin: " + value);
return value;
Expand Down
Loading

0 comments on commit 50661e0

Please sign in to comment.