Skip to content

Commit

Permalink
UIBased: improve non changing value handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Aug 26, 2023
1 parent c680a19 commit 379a670
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.eveningoutpost.dexdrip.services;

import static com.eveningoutpost.dexdrip.models.JoH.msSince;
import static com.eveningoutpost.dexdrip.cgm.dex.ClassifierAction.lastReadingTimestamp;
import static com.eveningoutpost.dexdrip.models.JoH.msSince;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.UiBased;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getDexCollectionType;
import static com.eveningoutpost.dexdrip.xdrip.gs;
Expand All @@ -26,22 +26,20 @@
import androidx.annotation.VisibleForTesting;

import com.eveningoutpost.dexdrip.BestGlucose;
import com.eveningoutpost.dexdrip.R;
import com.eveningoutpost.dexdrip.alert.Persist;
import com.eveningoutpost.dexdrip.cgm.dex.BlueTails;
import com.eveningoutpost.dexdrip.models.BgReading;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.Sensor;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.R;
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
import com.eveningoutpost.dexdrip.utilitymodels.Unitized;
import com.eveningoutpost.dexdrip.cgm.dex.BlueTails;
import com.eveningoutpost.dexdrip.utils.DexCollectionType;
import com.eveningoutpost.dexdrip.xdrip;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -334,7 +332,14 @@ private boolean isJammed(final int mgdl) {
}
val lastRepeat = PersistentStore.getLong(UI_BASED_STORE_LAST_REPEAT);
UserError.Log.d(TAG, "Last repeat: " + lastRepeat);
return lastRepeat > 3;
return lastRepeat > jamThreshold();
}

private int jamThreshold() {
if (lastPackage != null) {
if (lastPackage.startsWith("com.medtronic")) return 9;
}
return 4;
}

private void getTextViews(final List<TextView> output, final ViewGroup parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ public void filterStringTest() {
val spec2p = "5.123";
val spec3 = "≥100.123";
val spec3p = "100.123";
val spec4 = "\u0038\u002c\u0039\u00a0\u006d\u006d\u006f\u006c\u2060\u002f\u2060\u006c\u0020";
val spec4p = "8,9";
val spec5 = "\u0038\u002c\u0039\u00a0\u006d\u006d\u006f\u006c\u2060\u002f\u2060\u2191\u2b06\u006c\u0020";
val spec5p = "8,9";
assertWithMessage("null test pass through 1").that(i.filterString(spec1)).isEqualTo(spec1);
assertWithMessage("null test pass through 2").that(i.filterString(spec2)).isEqualTo(spec2);
assertWithMessage("null test pass through 3").that(i.filterString(spec3)).isEqualTo(spec3);
i.lastPackage = "hello world";
assertWithMessage("non 1").that(i.filterString(spec1)).isEqualTo(spec1);
assertWithMessage("gte 1").that(i.filterString(spec2)).isEqualTo(spec2p);
assertWithMessage("lte 1").that(i.filterString(spec3)).isEqualTo(spec3p);
assertWithMessage("gc1 1").that(i.filterString(spec4)).isEqualTo(spec4p);
assertWithMessage("gc1 2").that(i.filterString(spec5)).isEqualTo(spec5p);
}

@Test
Expand Down

0 comments on commit 379a670

Please sign in to comment.