code cleanup

This commit is contained in:
Milos Kozak 2022-11-30 19:30:46 +01:00
parent 59a2c7dbc7
commit 2b5e51c857
45 changed files with 99 additions and 140 deletions

View file

@ -6,5 +6,4 @@ import dagger.Module
includes = [ includes = [
] ]
) )
open class SharedModule { open class SharedModule
}

View file

@ -97,9 +97,7 @@ public class GraphView extends View {
lastDown = 0; lastDown = 0;
} }
} else if (event.getAction() == MotionEvent.ACTION_UP) { } else if (event.getAction() == MotionEvent.ACTION_UP) {
if (System.currentTimeMillis() - lastDown < 400) { return System.currentTimeMillis() - lastDown < 400;
return true;
}
} }
return false; return false;
} }

View file

@ -37,7 +37,7 @@ public interface LabelFormatter {
* false if it is a value for the y axis * false if it is a value for the y axis
* @return the formatted number as string * @return the formatted number as string
*/ */
public String formatLabel(double value, boolean isValueX); String formatLabel(double value, boolean isValueX);
/** /**
* will be called in order to have a * will be called in order to have a
@ -50,5 +50,5 @@ public interface LabelFormatter {
* *
* @param viewport the used viewport * @param viewport the used viewport
*/ */
public void setViewport(Viewport viewport); void setViewport(Viewport viewport);
} }

View file

@ -78,7 +78,7 @@ public class LegendRenderer {
/** /**
* wrapped styles * wrapped styles
*/ */
private Styles mStyles; private final Styles mStyles;
/** /**
* reference to the graphview * reference to the graphview
@ -94,7 +94,7 @@ public class LegendRenderer {
/** /**
* paint for the drawing * paint for the drawing
*/ */
private Paint mPaint; private final Paint mPaint;
/** /**
* cached legend width * cached legend width

View file

@ -53,7 +53,7 @@ public class SecondScale {
* For the current version this is always * For the current version this is always
* true. * true.
*/ */
private boolean mYAxisBoundsManual = true; private final boolean mYAxisBoundsManual = true;
/** /**
* min y value for the y axis bounds * min y value for the y axis bounds

View file

@ -37,5 +37,5 @@ public interface ValueDependentColor<T extends DataPointInterface> {
* @return the color that the bar should be drawn with * @return the color that the bar should be drawn with
* Generate the int via the android.graphics.Color class. * Generate the int via the android.graphics.Color class.
*/ */
public int get(T data); int get(T data);
} }

View file

@ -44,7 +44,7 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
/** /**
* paint to do drawing on canvas * paint to do drawing on canvas
*/ */
private Paint mPaint; private final Paint mPaint;
/** /**
* spacing between the bars in percentage. * spacing between the bars in percentage.
@ -83,7 +83,7 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
* stores the coordinates of the bars to * stores the coordinates of the bars to
* trigger tap on series events. * trigger tap on series events.
*/ */
private Map<RectF, E> mDataPoints = new HashMap<RectF, E>(); private final Map<RectF, E> mDataPoints = new HashMap<RectF, E>();
/** /**
* creates bar series without any data * creates bar series without any data

View file

@ -25,6 +25,7 @@ import android.util.Log;
import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.GraphView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -61,7 +62,7 @@ public abstract class BaseSeries<E extends DataPointInterface> implements Series
* *
* will be filled while drawing via {@link #registerDataPoint(float, float, DataPointInterface)} * will be filled while drawing via {@link #registerDataPoint(float, float, DataPointInterface)}
*/ */
private Map<PointF, E> mDataPoints = new HashMap<PointF, E>(); private final Map<PointF, E> mDataPoints = new HashMap<PointF, E>();
/** /**
* title for this series that can be displayed * title for this series that can be displayed
@ -84,7 +85,7 @@ public abstract class BaseSeries<E extends DataPointInterface> implements Series
* stores the graphviews where this series is used. * stores the graphviews where this series is used.
* Can be more than one. * Can be more than one.
*/ */
private List<GraphView> mGraphViews; private final List<GraphView> mGraphViews;
/** /**
* creates series without data * creates series without data
@ -101,9 +102,7 @@ public abstract class BaseSeries<E extends DataPointInterface> implements Series
*/ */
public BaseSeries(E[] data) { public BaseSeries(E[] data) {
mGraphViews = new ArrayList<GraphView>(); mGraphViews = new ArrayList<GraphView>();
for (E d : data) { Collections.addAll(mData, data);
mData.add(d);
}
} }
/** /**
@ -168,7 +167,7 @@ public abstract class BaseSeries<E extends DataPointInterface> implements Series
return mData.iterator(); return mData.iterator();
} else { } else {
return new Iterator<E>() { return new Iterator<E>() {
Iterator<E> org = mData.iterator(); final Iterator<E> org = mData.iterator();
E nextValue = null; E nextValue = null;
E nextNextValue = null; E nextNextValue = null;
boolean plusOne = true; boolean plusOne = true;
@ -350,9 +349,7 @@ public abstract class BaseSeries<E extends DataPointInterface> implements Series
*/ */
public void resetData(E[] data) { public void resetData(E[] data) {
mData.clear(); mData.clear();
for (E d : data) { Collections.addAll(mData, data);
mData.add(d);
}
checkValueOrder(null); checkValueOrder(null);
// update graphview // update graphview

View file

@ -33,8 +33,8 @@ import java.util.Date;
public class DataPoint implements DataPointInterface, Serializable { public class DataPoint implements DataPointInterface, Serializable {
private static final long serialVersionUID=1428263322645L; private static final long serialVersionUID=1428263322645L;
private double x; private final double x;
private double y; private final double y;
public DataPoint(double x, double y) { public DataPoint(double x, double y) {
this.x=x; this.x=x;

View file

@ -32,10 +32,10 @@ public interface DataPointInterface {
/** /**
* @return the x value * @return the x value
*/ */
public double getX(); double getX();
/** /**
* @return the y value * @return the y value
*/ */
public double getY(); double getY();
} }

View file

@ -41,7 +41,7 @@ public class PointsGraphSeries<E extends DataPointInterface> extends BaseSeries<
* interface to implement a custom * interface to implement a custom
* drawing for the data points. * drawing for the data points.
*/ */
public static interface CustomShape { public interface CustomShape {
/** /**
* called when drawing a single data point. * called when drawing a single data point.
* use the x and y coordinates to render your * use the x and y coordinates to render your
@ -201,10 +201,8 @@ public class PointsGraphSeries<E extends DataPointInterface> extends BaseSeries<
double orgY = y; double orgY = y;
// overdraw // overdraw
boolean overdraw = false; boolean overdraw = x > graphWidth;
if (x > graphWidth) { // end right // end right
overdraw = true;
}
if (y < 0) { // end bottom if (y < 0) { // end bottom
overdraw = true; overdraw = true;
} }

View file

@ -42,22 +42,22 @@ public interface Series<E extends DataPointInterface> {
/** /**
* @return the lowest x-value of the data * @return the lowest x-value of the data
*/ */
public double getLowestValueX(); double getLowestValueX();
/** /**
* @return the highest x-value of the data * @return the highest x-value of the data
*/ */
public double getHighestValueX(); double getHighestValueX();
/** /**
* @return the lowest y-value of the data * @return the lowest y-value of the data
*/ */
public double getLowestValueY(); double getLowestValueY();
/** /**
* @return the highest y-value of the data * @return the highest y-value of the data
*/ */
public double getHighestValueY(); double getHighestValueY();
/** /**
* get the values for a specific range. It is * get the values for a specific range. It is
@ -69,7 +69,7 @@ public interface Series<E extends DataPointInterface> {
* @return all datapoints between the from and until x-value * @return all datapoints between the from and until x-value
* including the from and until data points. * including the from and until data points.
*/ */
public Iterator<E> getValues(double from, double until); Iterator<E> getValues(double from, double until);
/** /**
* Plots the series to the viewport. * Plots the series to the viewport.
@ -82,25 +82,25 @@ public interface Series<E extends DataPointInterface> {
* @param canvas canvas to draw on * @param canvas canvas to draw on
* @param isSecondScale true if the drawing is for the second scale * @param isSecondScale true if the drawing is for the second scale
*/ */
public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale); void draw(GraphView graphView, Canvas canvas, boolean isSecondScale);
/** /**
* @return the title of the series. Used in the legend * @return the title of the series. Used in the legend
*/ */
public String getTitle(); String getTitle();
/** /**
* @return the color of the series. Used in the legend and should * @return the color of the series. Used in the legend and should
* be used for the plotted points or lines. * be used for the plotted points or lines.
*/ */
public int getColor(); int getColor();
/** /**
* set a listener for tap on a data point. * set a listener for tap on a data point.
* *
* @param l listener * @param l listener
*/ */
public void setOnDataPointTapListener(OnDataPointTapListener l); void setOnDataPointTapListener(OnDataPointTapListener l);
/** /**
* called by the tap detector in order to trigger * called by the tap detector in order to trigger

View file

@ -1,4 +1,3 @@
package info.nightscout.interfaces.source package info.nightscout.interfaces.source
interface DoingOwnUploadSource { interface DoingOwnUploadSource
}

View file

@ -68,7 +68,8 @@ public class InsightPairingActivity extends DaggerAppCompatActivity implements I
@Override @Override
public void onServiceConnected(ComponentName name, IBinder binder) { public void onServiceConnected(ComponentName name, IBinder binder) {
service = ((InsightConnectionService.LocalBinder) binder).getService(); service = ((InsightConnectionService.LocalBinder) binder).getService();
if (service.isPaired()) return; if (service.isPaired()) {
}
else { else {
service.requestConnection(InsightPairingActivity.this); service.requestConnection(InsightPairingActivity.this);
service.registerStateCallback(InsightPairingActivity.this); service.registerStateCallback(InsightPairingActivity.this);

View file

@ -29,7 +29,7 @@ abstract class SourceModule {
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment @ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
@ContributesAndroidInjector abstract fun contributesNSProfileWorker(): ProfilePlugin.NSProfileWorker @ContributesAndroidInjector abstract fun contributesNSProfileWorker(): ProfilePlugin.NSProfileWorker
@ContributesAndroidInjector abstract fun contributesNSClientSourceWorker(): info.nightscout.plugins.source.NSClientSourcePlugin.NSClientSourceWorker @ContributesAndroidInjector abstract fun contributesNSClientSourceWorker(): NSClientSourcePlugin.NSClientSourceWorker
@ContributesAndroidInjector abstract fun contributesXdripWorker(): XdripPlugin.XdripWorker @ContributesAndroidInjector abstract fun contributesXdripWorker(): XdripPlugin.XdripWorker
@ContributesAndroidInjector abstract fun contributesDexcomWorker(): DexcomPlugin.DexcomWorker @ContributesAndroidInjector abstract fun contributesDexcomWorker(): DexcomPlugin.DexcomWorker
@ContributesAndroidInjector abstract fun contributesMM640gWorker(): MM640gPlugin.MM640gWorker @ContributesAndroidInjector abstract fun contributesMM640gWorker(): MM640gPlugin.MM640gWorker
@ -43,6 +43,6 @@ abstract class SourceModule {
@Module @Module
interface Bindings { interface Bindings {
@Binds fun bindNSClientSource(nsClientSourcePlugin: info.nightscout.plugins.source.NSClientSourcePlugin): NSClientSource @Binds fun bindNSClientSource(nsClientSourcePlugin: NSClientSourcePlugin): NSClientSource
} }
} }

View file

@ -34,7 +34,7 @@ class ProfileElement(ps: EffectiveProfileSwitch, serialNumber: String, dateUtil:
init { init {
type = "pumpSettings" type = "pumpSettings"
val profile: Profile? = ProfileSealed.EPS(ps) val profile: Profile = ProfileSealed.EPS(ps)
checkNotNull(profile) checkNotNull(profile)
for (br in profile.getBasalValues()) for (br in profile.getBasalValues())
basalSchedules.Normal.add(BasalRate(br.timeAsSeconds * 1000, br.value)) basalSchedules.Normal.add(BasalRate(br.timeAsSeconds * 1000, br.value))

View file

@ -1,6 +1,7 @@
package info.nightscout.pump.combo.ruffyscripter.history; package info.nightscout.pump.combo.ruffyscripter.history;
import java.util.Date; import java.util.Date;
import java.util.Objects;
public class PumpAlert extends HistoryRecord { public class PumpAlert extends HistoryRecord {
public final Integer warningCode; public final Integer warningCode;
@ -23,11 +24,11 @@ public class PumpAlert extends HistoryRecord {
PumpAlert pumpAlert = (PumpAlert) o; PumpAlert pumpAlert = (PumpAlert) o;
if (timestamp != pumpAlert.timestamp) return false; if (timestamp != pumpAlert.timestamp) return false;
if (warningCode != null ? !warningCode.equals(pumpAlert.warningCode) : pumpAlert.warningCode != null) if (!Objects.equals(warningCode, pumpAlert.warningCode))
return false; return false;
if (errorCode != null ? !errorCode.equals(pumpAlert.errorCode) : pumpAlert.errorCode != null) if (!Objects.equals(errorCode, pumpAlert.errorCode))
return false; return false;
return message != null ? message.equals(pumpAlert.message) : pumpAlert.message == null; return Objects.equals(message, pumpAlert.message);
} }
@Override @Override

View file

@ -719,8 +719,7 @@ object ApplicationLayer {
command = extractAppLayerPacketCommand(tpLayerPacket), command = extractAppLayerPacketCommand(tpLayerPacket),
version = tpLayerPacket.payload[VERSION_BYTE_OFFSET], version = tpLayerPacket.payload[VERSION_BYTE_OFFSET],
payload = ArrayList<Byte>(tpLayerPacket.payload.subList(PAYLOAD_BYTES_OFFSET, tpLayerPacket.payload.size)) payload = ArrayList<Byte>(tpLayerPacket.payload.subList(PAYLOAD_BYTES_OFFSET, tpLayerPacket.payload.size))
) { )
}
/** /**
* Produces transport layer DATA packet info containing this application layer * Produces transport layer DATA packet info containing this application layer
@ -1680,10 +1679,10 @@ object ApplicationLayer {
* This is preferred over directly using the [Packet] constructor. * This is preferred over directly using the [Packet] constructor.
*/ */
fun checkAndParseTransportLayerDataPacket(tpLayerPacket: TransportLayer.Packet): fun checkAndParseTransportLayerDataPacket(tpLayerPacket: TransportLayer.Packet):
ApplicationLayer.Packet { Packet {
try { try {
logger(LogLevel.VERBOSE) { "Parsing DATA packet as application layer packet" } logger(LogLevel.VERBOSE) { "Parsing DATA packet as application layer packet" }
val appLayerPacket = ApplicationLayer.Packet(tpLayerPacket) val appLayerPacket = Packet(tpLayerPacket)
logger(LogLevel.VERBOSE) { logger(LogLevel.VERBOSE) {
"This is an application layer packet with command ${appLayerPacket.command} and payload ${appLayerPacket.payload.toHexString()}" "This is an application layer packet with command ${appLayerPacket.command} and payload ${appLayerPacket.payload.toHexString()}"
} }
@ -1709,7 +1708,7 @@ object ApplicationLayer {
} }
return appLayerPacket return appLayerPacket
} catch (e: ApplicationLayer.InvalidCommandIDException) { } catch (e: InvalidCommandIDException) {
logger(LogLevel.WARN) { logger(LogLevel.WARN) {
"Got an application layer packet with invalid/unknown command ID 0x${e.commandID.toString(16)} " + "Got an application layer packet with invalid/unknown command ID 0x${e.commandID.toString(16)} " +
"service ID ${e.serviceID.name} and payload (with ${e.payload.size} byte(s)) ${e.payload.toHexString()}" + "service ID ${e.serviceID.name} and payload (with ${e.payload.size} byte(s)) ${e.payload.toHexString()}" +
@ -1719,7 +1718,7 @@ object ApplicationLayer {
} catch (e: ErrorCodeException) { } catch (e: ErrorCodeException) {
// We already logged the error code, so just pass through the exception // We already logged the error code, so just pass through the exception
throw e throw e
} catch (e: ApplicationLayer.ExceptionBase) { } catch (e: ExceptionBase) {
logger(LogLevel.ERROR) { "Could not parse DATA packet as application layer packet: $e" } logger(LogLevel.ERROR) { "Could not parse DATA packet as application layer packet: $e" }
throw e throw e
} }

View file

@ -134,7 +134,7 @@ class PumpIO(
// and [List<Byte>.toComboFrame] for details). // and [List<Byte>.toComboFrame] for details).
private val framedComboIO = FramedComboIO(bluetoothDevice) private val framedComboIO = FramedComboIO(bluetoothDevice)
private var initialMode: PumpIO.Mode? = null private var initialMode: Mode? = null
private var transportLayerIO = TransportLayer.IO( private var transportLayerIO = TransportLayer.IO(
pumpStateStore, bluetoothDevice.address, framedComboIO pumpStateStore, bluetoothDevice.address, framedComboIO

View file

@ -159,8 +159,8 @@ object TransportLayer {
// Utility function to be able to throw an exception in case of // Utility function to be able to throw an exception in case of
// an invalid command ID in the Packet constructor below. // an invalid command ID in the Packet constructor below.
private fun checkedGetCommand(value: Int, bytes: List<Byte>): TransportLayer.Command = private fun checkedGetCommand(value: Int, bytes: List<Byte>): Command =
TransportLayer.Command.fromInt(value) ?: throw TransportLayer.InvalidCommandIDException(value, bytes) Command.fromInt(value) ?: throw InvalidCommandIDException(value, bytes)
/** /**
* Class containing Combo transport layer packet data. * Class containing Combo transport layer packet data.
@ -835,7 +835,7 @@ object TransportLayer {
* @throws IncorrectPacketException if expectedCommand is non-null and * @throws IncorrectPacketException if expectedCommand is non-null and
* the received packet's command does not match expectedCommand. * the received packet's command does not match expectedCommand.
*/ */
suspend fun receive(expectedCommand: Command? = null): TransportLayer.Packet { suspend fun receive(expectedCommand: Command? = null): Packet {
// In here, we mainly listen to the packetReceiverChannel // In here, we mainly listen to the packetReceiverChannel
// for incoming packets from the packet receiver coroutine. // for incoming packets from the packet receiver coroutine.
// The actual reception takes place there. startInternal() // The actual reception takes place there. startInternal()

View file

@ -953,7 +953,7 @@ suspend fun navigateToRTScreen(
null null
} }
if (path?.isEmpty() ?: false) if (path?.isEmpty() == true)
return currentParsedScreen return currentParsedScreen
if (path == null) { if (path == null) {

View file

@ -37,18 +37,14 @@ import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchConfig;
import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchLifecycleEvent; import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchLifecycleEvent;
import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchState; import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchState;
import info.nightscout.androidaps.plugins.pump.eopatch.vo.TempBasal; import info.nightscout.androidaps.plugins.pump.eopatch.vo.TempBasal;
import info.nightscout.interfaces.plugin.ActivePlugin;
import info.nightscout.interfaces.profile.ProfileFunction;
import info.nightscout.interfaces.pump.DetailedBolusInfo; import info.nightscout.interfaces.pump.DetailedBolusInfo;
import info.nightscout.interfaces.pump.PumpSync; import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.defs.PumpType; import info.nightscout.interfaces.pump.defs.PumpType;
import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.rx.AapsSchedulers; import info.nightscout.rx.AapsSchedulers;
import info.nightscout.rx.bus.RxBus; import info.nightscout.rx.bus.RxBus;
import info.nightscout.rx.events.EventCustomActionsChanged; import info.nightscout.rx.events.EventCustomActionsChanged;
import info.nightscout.rx.events.EventPumpStatusChanged; import info.nightscout.rx.events.EventPumpStatusChanged;
import info.nightscout.rx.events.EventRefreshOverview; import info.nightscout.rx.events.EventRefreshOverview;
import info.nightscout.rx.logging.AAPSLogger;
import info.nightscout.shared.interfaces.ResourceHelper; import info.nightscout.shared.interfaces.ResourceHelper;
import info.nightscout.shared.sharedPreferences.SP; import info.nightscout.shared.sharedPreferences.SP;
import info.nightscout.shared.utils.DateUtil; import info.nightscout.shared.utils.DateUtil;
@ -63,10 +59,6 @@ public class PatchManager implements IPatchManager {
@Inject PatchManagerImpl patchManager; @Inject PatchManagerImpl patchManager;
@Inject IPreferenceManager pm; @Inject IPreferenceManager pm;
@Inject ProfileFunction profileFunction;
@Inject ActivePlugin activePlugin;
@Inject CommandQueue commandQueue;
@Inject AAPSLogger aapsLogger;
@Inject ResourceHelper resourceHelper; @Inject ResourceHelper resourceHelper;
@Inject RxBus rxBus; @Inject RxBus rxBus;
@Inject Context context; @Inject Context context;

View file

@ -80,10 +80,10 @@ public class PatchStateManager {
// Resume --> onBasalResume // Resume --> onBasalResume
onBasalResumeState(); onBasalResumeState();
} else if (oldState.isNormalBasalAct() == false) { } else if (!oldState.isNormalBasalAct()) {
// Start --> onBasalStarted // Start --> onBasalStarted
} }
} else if (oldState.isNormalBasalPaused() == false && newState.isNormalBasalPaused()) { } else if (!oldState.isNormalBasalPaused() && newState.isNormalBasalPaused()) {
if (newState.isTempBasalAct()) { if (newState.isTempBasalAct()) {
} else { } else {
// pause // pause
@ -93,25 +93,21 @@ public class PatchStateManager {
/* Temp Basal ------------------------------------------------------------------------------------------- */ /* Temp Basal ------------------------------------------------------------------------------------------- */
if (newState.isTempBasalAct()) { if (newState.isTempBasalAct()) {
if (oldState.isTempBasalAct() == false) { if (!oldState.isTempBasalAct()) {
// Start // Start
onTempBasalStartState(); onTempBasalStartState();
} }
} }
boolean tempBasalStopped = false; boolean tempBasalStopped = false;
boolean tempBasalFinished = false; boolean tempBasalFinished = newState.isTempBasalDone() && !newState.isPatchInternalSuspended();
if (newState.isTempBasalDone() && !newState.isPatchInternalSuspended()) { if (!oldState.isTempBasalDone()) {
tempBasalFinished = true;
}
if (oldState.isTempBasalDone() == false) {
if (newState.isTempBasalDone()) { if (newState.isTempBasalDone()) {
tempBasalStopped = true; tempBasalStopped = true;
onTempBasalDoneState(); onTempBasalDoneState();
} else if (oldState.isTempBasalAct() && newState.isTempBasalAct() == false) { } else if (oldState.isTempBasalAct() && !newState.isTempBasalAct()) {
tempBasalStopped = true; tempBasalStopped = true;
onTempBasalCancelState(); onTempBasalCancelState();
@ -126,15 +122,15 @@ public class PatchStateManager {
} }
} }
if (newState.isTempBasalAct() == false && pm.getTempBasalManager().getStartedBasal() != null) { if (!newState.isTempBasalAct() && pm.getTempBasalManager().getStartedBasal() != null) {
pm.getTempBasalManager().updateBasalStopped(); pm.getTempBasalManager().updateBasalStopped();
} }
/* Now Bolus -------------------------------------------------------------------------------------------- */ /* Now Bolus -------------------------------------------------------------------------------------------- */
if (oldState.isNowBolusRegAct() == false && newState.isNowBolusRegAct() == true) { if (!oldState.isNowBolusRegAct() && newState.isNowBolusRegAct()) {
// Start // Start
} else if (oldState.isNowBolusDone() == false) { } else if (!oldState.isNowBolusDone()) {
if (oldState.isNowBolusRegAct() && newState.isNowBolusRegAct() == false) { if (oldState.isNowBolusRegAct() && !newState.isNowBolusRegAct()) {
// Cancel // Cancel
} else if (newState.isNowBolusDone()) { } else if (newState.isNowBolusDone()) {
// Done // Done
@ -143,23 +139,23 @@ public class PatchStateManager {
BolusCurrent bolusCurrent = pm.getBolusCurrent(); BolusCurrent bolusCurrent = pm.getBolusCurrent();
if (newState.isNowBolusRegAct() == false && bolusCurrent.historyId(BolusType.NOW) > 0 if (!newState.isNowBolusRegAct() && bolusCurrent.historyId(BolusType.NOW) > 0
&& bolusCurrent.endTimeSynced(BolusType.NOW)) { && bolusCurrent.endTimeSynced(BolusType.NOW)) {
bolusCurrent.clearBolus(BolusType.NOW); bolusCurrent.clearBolus(BolusType.NOW);
} }
/* Extended Bolus --------------------------------------------------------------------------------------- */ /* Extended Bolus --------------------------------------------------------------------------------------- */
if (oldState.isExtBolusRegAct() == false && newState.isExtBolusRegAct() == true) { if (!oldState.isExtBolusRegAct() && newState.isExtBolusRegAct()) {
// Start // Start
} else if (oldState.isExtBolusDone() == false) { } else if (!oldState.isExtBolusDone()) {
if (oldState.isExtBolusRegAct() && newState.isExtBolusRegAct() == false) { if (oldState.isExtBolusRegAct() && !newState.isExtBolusRegAct()) {
// Cancel // Cancel
} else if (newState.isExtBolusDone()) { } else if (newState.isExtBolusDone()) {
// Done // Done
} }
} }
if (newState.isExtBolusRegAct() == false && bolusCurrent.historyId(BolusType.EXT) > 0 if (!newState.isExtBolusRegAct() && bolusCurrent.historyId(BolusType.EXT) > 0
&& bolusCurrent.endTimeSynced(BolusType.EXT)) { && bolusCurrent.endTimeSynced(BolusType.EXT)) {
bolusCurrent.clearBolus(BolusType.EXT); bolusCurrent.clearBolus(BolusType.EXT);
} }
@ -243,7 +239,7 @@ public class PatchStateManager {
if (normalBasal != null) { if (normalBasal != null) {
pm.getNormalBasalManager().updateBasalStarted(); pm.getNormalBasalManager().updateBasalStarted();
normalBasal.updateNormalBasalIndex(); normalBasal.updateNormalBasalIndex();
pm.flushNormalBasalManager();; pm.flushNormalBasalManager();
} }
} }

View file

@ -101,7 +101,7 @@ public class SyncBasalHistoryTask extends TaskBase {
} }
public synchronized int updateInjected(float[] normal, float[] temp, int start, int end) { public synchronized int updateInjected(float[] normal, float[] temp, int start, int end) {
if (pm.getPatchState().isPatchInternalSuspended() && pm.getPatchConfig().isInBasalPausedTime() == false) { if (pm.getPatchState().isPatchInternalSuspended() && !pm.getPatchConfig().isInBasalPausedTime()) {
return -1; return -1;
} }

View file

@ -16,7 +16,7 @@ import io.reactivex.rxjava3.core.Single;
public class UpdateConnectionTask extends TaskBase { public class UpdateConnectionTask extends TaskBase {
@Inject PatchStateManager patchStateManager; @Inject PatchStateManager patchStateManager;
private UpdateConnection UPDATE_CONNECTION; private final UpdateConnection UPDATE_CONNECTION;
@Inject @Inject
public UpdateConnectionTask() { public UpdateConnectionTask() {

View file

@ -10,7 +10,7 @@ import kotlin.reflect.KClass
@MustBeDocumented @MustBeDocumented
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME) @Retention(AnnotationRetention.RUNTIME)
@MapKey @MapKey
internal annotation class ViewModelKey(val value: KClass<out ViewModel>) internal annotation class ViewModelKey(val value: KClass<out ViewModel>)

View file

@ -21,7 +21,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject
* BolusCurrent : 현재 패치에서 진행 중인 '볼루스의 정보' 표현한 클래스. * BolusCurrent : 현재 패치에서 진행 중인 '볼루스의 정보' 표현한 클래스.
*/ */
class BolusCurrent(): IPreference<BolusCurrent> { class BolusCurrent : IPreference<BolusCurrent> {
@Transient @Transient
private val subject: BehaviorSubject<BolusCurrent> = BehaviorSubject.create() private val subject: BehaviorSubject<BolusCurrent> = BehaviorSubject.create()

View file

@ -22,8 +22,7 @@ class PatchState: IPreference<PatchState> {
private val stateBytes: ByteArray private val stateBytes: ByteArray
var updatedTimestamp: Long = 0 var updatedTimestamp: Long = 0
constructor(): this(ByteArray(SIZE), 0) { constructor(): this(ByteArray(SIZE), 0)
}
constructor(stateBytes: ByteArray, updatedTimestamp: Long) { constructor(stateBytes: ByteArray, updatedTimestamp: Long) {
this.stateBytes = stateBytes this.stateBytes = stateBytes

View file

@ -79,10 +79,8 @@ class MedtronicUITask {
MedtronicCommandType.SetTemporaryBasal -> { MedtronicCommandType.SetTemporaryBasal -> {
val tbr = getTbrSettings() val tbr = getTbrSettings()
if (tbr != null) {
result = communicationManager.setTemporaryBasal(tbr) result = communicationManager.setTemporaryBasal(tbr)
} }
}
MedtronicCommandType.ReadTemporaryBasal -> { MedtronicCommandType.ReadTemporaryBasal -> {
result = communicationManager.getTemporaryBasal() result = communicationManager.getTemporaryBasal()
@ -128,7 +126,7 @@ class MedtronicUITask {
} }
} }
private fun getTbrSettings(): TempBasalPair? { private fun getTbrSettings(): TempBasalPair {
return TempBasalPair(getDoubleFromParameters(0)!!, // return TempBasalPair(getDoubleFromParameters(0)!!, //
false, // false, //
getIntegerFromParameters(1)) getIntegerFromParameters(1))

View file

@ -13,7 +13,7 @@ import kotlin.reflect.KClass
annotation class OmnipodPluginQualifier annotation class OmnipodPluginQualifier
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME) @Retention(AnnotationRetention.RUNTIME)
@MapKey @MapKey
annotation class ViewModelKey(val value: KClass<out ViewModel>) annotation class ViewModelKey(val value: KClass<out ViewModel>)

View file

@ -309,7 +309,7 @@ class OmnipodDashManagerImpl @Inject constructor(
.setUniqueId(podStateManager.uniqueId!!.toInt()) .setUniqueId(podStateManager.uniqueId!!.toInt())
.setSequenceNumber(podStateManager.messageSequenceNumber) .setSequenceNumber(podStateManager.messageSequenceNumber)
.setNonce(NONCE) .setNonce(NONCE)
.setNumberOfUnits(Round.roundTo(podStateManager.firstPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS, POD_PULSE_BOLUS_UNITS)) .setNumberOfUnits(Round.roundTo(podStateManager.firstPrimeBolusVolume!! * POD_PULSE_BOLUS_UNITS, POD_PULSE_BOLUS_UNITS))
.setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte()) .setDelayBetweenPulsesInEighthSeconds(podStateManager.primePulseRate!!.toByte())
.setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0)) .setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0))
.build(), .build(),
@ -412,7 +412,7 @@ class OmnipodDashManagerImpl @Inject constructor(
) )
observables.add( observables.add(
observeSendProgramBolusCommand( observeSendProgramBolusCommand(
Round.roundTo(podStateManager.secondPrimeBolusVolume!! * PodConstants.POD_PULSE_BOLUS_UNITS, PodConstants.POD_PULSE_BOLUS_UNITS), Round.roundTo(podStateManager.secondPrimeBolusVolume!! * POD_PULSE_BOLUS_UNITS, POD_PULSE_BOLUS_UNITS),
podStateManager.primePulseRate!!.toByte(), podStateManager.primePulseRate!!.toByte(),
confirmationBeeps = false, confirmationBeeps = false,
completionBeeps = false completionBeeps = false

View file

@ -75,7 +75,6 @@ abstract class PumpPluginAbstract protected constructor(
protected var displayConnectionMessages = false protected var displayConnectionMessages = false
var pumpType: PumpType = PumpType.GENERIC_AAPS var pumpType: PumpType = PumpType.GENERIC_AAPS
get() = field
set(value) { set(value) {
field = value field = value
pumpDescription.fillFor(value) pumpDescription.fillFor(value)

View file

@ -9,6 +9,5 @@ public enum BasalProfileStatus {
NotInitialized, // NotInitialized, //
ProfileOK, // ProfileOK, //
ProfileChanged, // ProfileChanged, //
;
} }

View file

@ -65,11 +65,11 @@ enum class PumpHistoryEntryGroup(val resourceId: Int, val pumpTypeGroupConfig: P
if (pumpTypeGroupConfig == PumpTypeGroupConfig.All) { if (pumpTypeGroupConfig == PumpTypeGroupConfig.All) {
outList = translatedList!!.stream() outList = translatedList!!.stream()
.filter { pre -> pre.pumpTypeGroupConfig == PumpTypeGroupConfig.All } .filter { pre -> pre.pumpTypeGroupConfig == PumpTypeGroupConfig.All }
.toList(); .toList()
} else { } else {
outList = translatedList!!.stream() outList = translatedList!!.stream()
.filter { pre -> (pre.pumpTypeGroupConfig == PumpTypeGroupConfig.All || pre.pumpTypeGroupConfig == pumpTypeGroupConfig) } .filter { pre -> (pre.pumpTypeGroupConfig == PumpTypeGroupConfig.All || pre.pumpTypeGroupConfig == pumpTypeGroupConfig) }
.toList(); .toList()
} }
return outList return outList

View file

@ -28,22 +28,21 @@ enum class PumpUpdateFragmentType {
Custom_8 Custom_8
; ;
final var children: List<PumpUpdateFragmentType>? = null var children: List<PumpUpdateFragmentType>? = null
constructor() { constructor()
}
constructor(children: List<PumpUpdateFragmentType>) { constructor(children: List<PumpUpdateFragmentType>) {
this.children = children; this.children = children
} }
fun isOptionIncluded(type: PumpUpdateFragmentType): Boolean { fun isOptionIncluded(type: PumpUpdateFragmentType): Boolean {
if (this == type) if (this == type)
return true return true
else if (this.children != null && this.children!!.contains(type)) else if (this.children != null && this.children!!.contains(type))
return true; return true
return false; return false
} }
} }

View file

@ -1,4 +1,3 @@
package info.nightscout.pump.common.driver.history package info.nightscout.pump.common.driver.history
interface PumpDataConverter { interface PumpDataConverter
}

View file

@ -7,7 +7,7 @@ import java.util.GregorianCalendar
abstract class PumpHistoryDataProviderAbstract : PumpHistoryDataProvider { abstract class PumpHistoryDataProviderAbstract : PumpHistoryDataProvider {
override fun getInitialData(): List<PumpHistoryEntry> { override fun getInitialData(): List<PumpHistoryEntry> {
return getData(getInitialPeriod()); return getData(getInitialPeriod())
} }
override fun getSpinnerWidthInPixels(): Int { override fun getSpinnerWidthInPixels(): Int {

View file

@ -4,5 +4,4 @@ import info.nightscout.rx.events.Event
class EventPumpChanged(var serialNumber: String, class EventPumpChanged(var serialNumber: String,
var connectionAddress: String, var connectionAddress: String,
var parameters: MutableMap<String, Any>? = null) : Event() { var parameters: MutableMap<String, Any>? = null) : Event()
}

View file

@ -2,5 +2,4 @@ package info.nightscout.pump.common.events
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event
class EventPumpConnectionParametersChanged : Event() { class EventPumpConnectionParametersChanged : Event()
}

View file

@ -77,7 +77,7 @@ data class PumpDbEntryCarbs(var date: Long,
var pumpId: Long? = null) { var pumpId: Long? = null) {
constructor(detailedBolusInfo: DetailedBolusInfo, constructor(detailedBolusInfo: DetailedBolusInfo,
creator: info.nightscout.pump.common.sync.PumpSyncEntriesCreator creator: PumpSyncEntriesCreator
) : this(detailedBolusInfo.timestamp, ) : this(detailedBolusInfo.timestamp,
detailedBolusInfo.carbs, detailedBolusInfo.carbs,
creator.model(), creator.model(),

View file

@ -110,7 +110,7 @@ class PumpSyncStorage @Inject constructor(
return pumpSyncStorageTBR return pumpSyncStorageTBR
} }
fun addBolusWithTempId(detailedBolusInfo: DetailedBolusInfo, writeToInternalHistory: Boolean, creator: info.nightscout.pump.common.sync.PumpSyncEntriesCreator): Boolean { fun addBolusWithTempId(detailedBolusInfo: DetailedBolusInfo, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator): Boolean {
val temporaryId = creator.generateTempId(detailedBolusInfo.timestamp) val temporaryId = creator.generateTempId(detailedBolusInfo.timestamp)
val result = pumpSync.addBolusWithTempId( val result = pumpSync.addBolusWithTempId(
detailedBolusInfo.timestamp, detailedBolusInfo.timestamp,
@ -157,7 +157,7 @@ class PumpSyncStorage @Inject constructor(
"carbs=${carbsDto.carbs}, pumpSerial=${carbsDto.serialNumber}] - Result: $result") "carbs=${carbsDto.carbs}, pumpSerial=${carbsDto.serialNumber}] - Result: $result")
} }
fun addTemporaryBasalRateWithTempId(temporaryBasal: PumpDbEntryTBR, writeToInternalHistory: Boolean, creator: info.nightscout.pump.common.sync.PumpSyncEntriesCreator): Boolean { fun addTemporaryBasalRateWithTempId(temporaryBasal: PumpDbEntryTBR, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator): Boolean {
val timeNow: Long = System.currentTimeMillis() val timeNow: Long = System.currentTimeMillis()
val temporaryId = creator.generateTempId(timeNow) val temporaryId = creator.generateTempId(timeNow)

View file

@ -72,14 +72,6 @@ class PumpHistoryActivity : DaggerAppCompatActivity() {
} }
override fun onResume() {
super.onResume()
//filterHistory(selectedGroup)
//setHistoryTypeSpinner()
//aapsLogger.info(LTag.PUMP, "onResume")
//binding.pumpHistoryRoot.requestLayout()
}
private fun setHistoryTypeSpinner() { private fun setHistoryTypeSpinner() {
manualChange = true manualChange = true
for (i in typeListFull!!.indices) { for (i in typeListFull!!.indices) {
@ -119,12 +111,12 @@ class PumpHistoryActivity : DaggerAppCompatActivity() {
binding.pumpHistoryText.text = historyDataProvider.getText(PumpHistoryText.PUMP_HISTORY) binding.pumpHistoryText.text = historyDataProvider.getText(PumpHistoryText.PUMP_HISTORY)
binding.pumpHistoryType.adapter = spinnerAdapter binding.pumpHistoryType.adapter = spinnerAdapter
binding.pumpHistoryType.getLayoutParams().width = fromDpToSize(historyDataProvider.getSpinnerWidthInPixels()) binding.pumpHistoryType.layoutParams.width = fromDpToSize(historyDataProvider.getSpinnerWidthInPixels())
binding.pumpHistoryType.requestLayout(); binding.pumpHistoryType.requestLayout()
binding.pumpHistoryType.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener { binding.pumpHistoryType.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) { override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
if (manualChange) return if (manualChange) return
val selected = binding.pumpHistoryType.getSelectedItem() as TypeList val selected = binding.pumpHistoryType.selectedItem as TypeList
showingType = selected showingType = selected
selectedGroup = selected.entryGroup selectedGroup = selected.entryGroup
filterHistory(selectedGroup) filterHistory(selectedGroup)
@ -138,7 +130,7 @@ class PumpHistoryActivity : DaggerAppCompatActivity() {
if (manualChange) return if (manualChange) return
filterHistory(PumpHistoryEntryGroup.All) filterHistory(PumpHistoryEntryGroup.All)
} }
}) }
binding.pumpHistoryTypeText.requestLayout() binding.pumpHistoryTypeText.requestLayout()
} }

View file

@ -32,7 +32,7 @@ object ProfileUtil {
return if (stringBuilder.length > 3) stringBuilder.substring(0, stringBuilder.length - 2) else stringBuilder.toString() return if (stringBuilder.length > 3) stringBuilder.substring(0, stringBuilder.length - 2) else stringBuilder.toString()
} }
fun getBasalProfilesDisplayableAsStringOfArray(profile: Profile, pumpType: PumpType): String? { fun getBasalProfilesDisplayableAsStringOfArray(profile: Profile, pumpType: PumpType): String {
val stringBuilder = java.lang.StringBuilder() val stringBuilder = java.lang.StringBuilder()
// for (basalValue in profiles) { // for (basalValue in profiles) {
// val basalValueValue = pumpType.determineCorrectBasalSize(basalValue.value) // val basalValueValue = pumpType.determineCorrectBasalSize(basalValue.value)

View file

@ -157,7 +157,7 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
// FIXME wakeUp successful !!!!!!!!!!!!!!!!!! // FIXME wakeUp successful !!!!!!!!!!!!!!!!!!
nextWakeUpRequired = System.currentTimeMillis() + (receiverDeviceAwakeForMinutes * 60 * 1000); nextWakeUpRequired = System.currentTimeMillis() + ((long) receiverDeviceAwakeForMinutes * 60 * 1000);
} else { } else {
aapsLogger.debug(LTag.PUMPBTCOMM, "Last pump communication was recent, not waking pump."); aapsLogger.debug(LTag.PUMPBTCOMM, "Last pump communication was recent, not waking pump.");
} }

View file

@ -58,10 +58,6 @@ class DataLayerListenerServiceWear : WearableListenerService() {
} }
} }
override fun onPeerConnected(p0: Node) {
super.onPeerConnected(p0)
}
override fun onCapabilityChanged(p0: CapabilityInfo) { override fun onCapabilityChanged(p0: CapabilityInfo) {
super.onCapabilityChanged(p0) super.onCapabilityChanged(p0)
handler.post { updateTranscriptionCapability() } handler.post { updateTranscriptionCapability() }