Skip to content

Commit

Permalink
Merge branch 'NightscoutFoundation:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gruoner committed Aug 10, 2024
2 parents 4f90377 + f96d4e5 commit 17230bf
Show file tree
Hide file tree
Showing 50 changed files with 728 additions and 180 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,12 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation 'androidx.test.ext:junit:1.1.1', {
androidTestImplementation 'androidx.test.ext:junit:1.1.5', {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
// add this for intent mocking support
//androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.1'
Expand Down
15 changes: 15 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@
-keep class android.support.v7.widget.SearchView { *; }
-keep class kotlinx.serialization.Serializable { *; }

# As long as we only deserialize (from a JSON string into an `NSDeviceStatus`
# object in the class `AAPSStatusHandler`) we can simply ignore warnings related
# to kotlinx serialization.
# These rule should not cause problems: if a project actually relies on
# serialization, then much more than just this class will be required,
# so telling Proguard not to worry if this is missing will not prevent it
# from emitting errors for code that does use serialization but somehow forgot
# to depend on it.
-dontwarn kotlinx.serialization.Serializable

# The lib net.sf.kxml:kxml2:2.3.0 is referenced in same required libraries used for
# Android testing. R8 is showing missing classes warnings which can be safely ignored.
-dontwarn org.kxml2.io.KXmlParser
-dontwarn org.kxml2.io.KXmlSerializer

-dontwarn java.util.concurrent.**

-keep class rx.schedulers.Schedulers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@
*/


import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.schibsted.spain.barista.BaristaClickActions.click;
import static com.schibsted.spain.barista.BaristaScrollActions.scrollTo;
import static com.schibsted.spain.barista.custom.NestedEnabledScrollToAction.scrollTo;
import static org.hamcrest.core.AllOf.allOf;

import android.app.Activity;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
import android.support.test.espresso.ViewInteraction;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.view.WindowManager;

import androidx.test.InstrumentationRegistry;
import androidx.test.annotation.UiThreadTest;
import androidx.test.espresso.ViewInteraction;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import com.schibsted.spain.barista.flakyespresso.AllowFlaky;

import org.junit.After;
Expand All @@ -26,18 +39,6 @@

import java.io.File;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static com.schibsted.spain.barista.BaristaClickActions.click;
import static com.schibsted.spain.barista.BaristaScrollActions.scrollTo;
import static com.schibsted.spain.barista.custom.NestedEnabledScrollToAction.scrollTo;
import static org.hamcrest.core.AllOf.allOf;

@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class HomeEspressoTest {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,12 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".utilitymodels.SaveLogs"
android:configChanges="orientation|screenSize"
android:label="@string/title_activity_save_logs"
android:noHistory="true">
</activity>
<activity android:name=".deposit.DepositActivity" />
<activity android:name=".utils.AndroidBarcode" />
<activity
Expand Down
27 changes: 20 additions & 7 deletions app/src/main/java/com/eveningoutpost/dexdrip/EventLogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.eveningoutpost.dexdrip.utilitymodels.Inevitable;
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utilitymodels.SaveLogs;
import com.eveningoutpost.dexdrip.utilitymodels.SendFeedBack;
import com.eveningoutpost.dexdrip.databinding.ActivityEventLogBinding;
import com.eveningoutpost.dexdrip.ui.helpers.BitmapUtil;
Expand All @@ -50,6 +51,7 @@
import me.tatarka.bindingcollectionadapter2.collections.MergeObservableList;

import static com.eveningoutpost.dexdrip.Home.startWatchUpdaterService;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getBestCollectorHardwareName;

/*
* New style event log viewer
Expand All @@ -65,6 +67,7 @@ public class EventLogActivity extends BaseAppCompatActivity {
private static final String TAG = EventLogActivity.class.getSimpleName();
private static final String PREF_SEVERITY_SELECTION = "event-log-severity-enabled-";
private static final String PREF_LAST_SEARCH = "event-log-last-search-";
private static int MAX_LOG_PACKAGE_SIZE = 200000;

static {
severitiesList.add(1);
Expand Down Expand Up @@ -291,20 +294,32 @@ private void updateToTopButtonVisibility(boolean force) {
}
}

// prepare current visible logs for upload
public synchronized void uploadEventLogs(View v) {
public synchronized void uploadEventLogs(View v) { // Send events log to JamOrHam
startActivity(new Intent(getApplicationContext(), SendFeedBack.class).putExtra("generic_text", packLogs()));
}

public synchronized void saveEventLog(View v) { // Save events log in mobile storage
startActivity(new Intent(getApplicationContext(), SaveLogs.class).putExtra("generic_text", packLogs()));
}

private String packLogs() { // Prepare current visible logs for upload or local save
final StringBuilder builder = new StringBuilder(50000);
builder.append("The following logs will be sent to the developers: \n\nPlease also include your email address or we will not know who they are from!\n\nFilter: "
builder.append("\n"
+ (model.allSeveritiesEnabled() ? "ALL" : model.whichSeveritiesEnabled()) + (model.getCurrentFilter() != "" ? " Search: " + model.getCurrentFilter() : "") + "\n\n");
for (UserError item : model.visible) {
builder.append(item.toString());
builder.append("\n");
if (builder.length() > 200000) {
if (builder.length() > MAX_LOG_PACKAGE_SIZE) {
JoH.static_toast_long(this, "Could not package up all logs, using most recent");
builder.append("\n\nOnly the most recent logs have been included to limit the file size.\n");
break;
}
}
startActivity(new Intent(getApplicationContext(), SendFeedBack.class).putExtra("generic_text", builder.toString()));

builder.insert(0, JoH.getDeviceDetails() + "\n" + JoH.getVersionDetails() + "\n" + getBestCollectorHardwareName() + "\n===\n" + "\nLog data:\n"); // Adds device, version and collector details before the log.
builder.append("\n\nCaptured: " + JoH.dateTimeText(JoH.tsl())); // Adds date and time of capture after the log.

return builder.toString();
}

// View model container - accessible binding methods must be declared public
Expand Down Expand Up @@ -636,5 +651,3 @@ public void onBindBinding(ViewDataBinding binding, int bindingVariable, @LayoutR
}
}



13 changes: 8 additions & 5 deletions app/src/main/java/com/eveningoutpost/dexdrip/GcmActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import android.widget.Toast;

import com.eveningoutpost.dexdrip.cloud.jamcm.JamCm;
import com.eveningoutpost.dexdrip.models.BgReading;
import com.eveningoutpost.dexdrip.models.BloodTest;
import com.eveningoutpost.dexdrip.models.Calibration;
Expand Down Expand Up @@ -216,7 +217,8 @@ private static void queueCheckOld(Context context, boolean recursive) {
try {
Log.i(TAG, "Resending unacknowledged queue item: " + datum.bundle.getString("action") + datum.bundle.getString("payload"));
datum.resent++;
GoogleCloudMessaging.getInstance(context).send(senderid + "@gcm.googleapis.com", Integer.toString(msgId.incrementAndGet()), datum.bundle);
// GoogleCloudMessaging.getInstance(context).send(senderid + "@gcm.googleapis.com", Integer.toString(msgId.incrementAndGet()), datum.bundle);
JamCm.sendMessage(datum.bundle);
} catch (Exception e) {
Log.e(TAG, "Got exception during resend: " + e.toString());
}
Expand Down Expand Up @@ -650,7 +652,7 @@ public static void push_external_status_update(long timestamp, String statusLine
}
}

static String myIdentity() {
public static String myIdentity() {
// TODO prefs override possible
return GoogleDriveInterface.getDriveIdentityString();
}
Expand Down Expand Up @@ -762,19 +764,20 @@ private static synchronized String sendMessageNow(String identity, String action
Log.e(TAG, "Queue size exceeded");
Home.toaststaticnext("Maximum Sync Queue size Exceeded!");
}
final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(xdrip.getAppContext());
// final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(xdrip.getAppContext());
if (token == null) {
Log.e(TAG, "GCM token is null - cannot sendMessage");
return "";
}
String messageid = Integer.toString(msgId.incrementAndGet());
gcm.send(senderid + "@gcm.googleapis.com", messageid, data);
// gcm.send(senderid + "@gcm.googleapis.com", messageid, data);
if (last_ack == -1) last_ack = JoH.tsl();
last_send_previous = last_send;
last_send = JoH.tsl();
JamCm.sendMessage(data);
msg = "Sent message OK " + messageid;
DesertSync.fromGCM(data);
} catch (IOException ex) {
} catch (Exception ex) {
msg = "Error :" + ex.getMessage();
}
Log.d(TAG, "Return msg in SendMessage: " + msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.os.PowerManager;
import android.util.Base64;

import com.eveningoutpost.dexdrip.cloud.jamcm.JamCm;
import com.eveningoutpost.dexdrip.models.BgReading;
import com.eveningoutpost.dexdrip.models.BloodTest;
import com.eveningoutpost.dexdrip.models.Calibration;
Expand Down Expand Up @@ -167,8 +168,7 @@ public void onMessageReceived(RemoteMessage rmessage) {
String xfrom = data.getString("xfrom");
String payload = data.getString("datum", data.getString("payload"));
String action = data.getString("action");

if ((xfrom != null) && (xfrom.equals(GcmActivity.token))) {
if ((xfrom != null) && (xfrom.equals(GcmActivity.token) || xfrom.equals(JamCm.getId()))) {
GcmActivity.queueAction(action + payload);
return;
}
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.eveningoutpost.dexdrip.g5model.DexSyncKeeper;
import com.eveningoutpost.dexdrip.g5model.DexTimeKeeper;
import com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine;
import com.eveningoutpost.dexdrip.g5model.SensorDays;
Expand Down Expand Up @@ -645,7 +646,7 @@ private boolean checkBatteryOptimization() {
Log.d(TAG, "Requesting ignore battery optimization");

if (((dialog == null) || (!dialog.isShowing()))
&& (PersistentStore.incrementLong("asked_battery_optimization") < 40)) {
&& (PersistentStore.incrementLong("asked_battery_optimization") < 40000)) {
JoH.show_ok_dialog(this, gs(R.string.please_allow_permission), gs(R.string.xdrip_needs_whitelisting_for_proper_performance), new Runnable() {

@RequiresApi(api = Build.VERSION_CODES.M)
Expand Down Expand Up @@ -1912,7 +1913,7 @@ public void onReceive(Context ctx, Intent intent) {
NFControl.initNFC(this, false);

if (get_follower() || get_master()) {
GcmActivity.checkSync(this);
// GcmActivity.checkSync(this);
}

checkWifiSleepPolicy();
Expand Down Expand Up @@ -2630,11 +2631,11 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not
}

if (!isSensorActive) {
// Define a variable (notConnectedToG6Yet) that is only true if Native G6 is chosen, but, transmitter days is unknown.
boolean notConnectedToG6Yet = DexCollectionType.getDexCollectionType() == DexcomG5 && Pref.getBooleanDefaultFalse("ob1_g5_use_transmitter_alg") && Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1;
if (notConnectedToG6Yet || shortTxId()) { // Only if G6 has been selected and transmitter days is unknown, or if G7 has been selected.
// Define a variable (notConnectedToG6Yet) that is only true if Native G6 is chosen, but, transmitter days is unknown or not synced yet.
boolean notConnectedToG6Yet = DexCollectionType.getDexCollectionType() == DexcomG5 && Pref.getBooleanDefaultFalse("ob1_g5_use_transmitter_alg") && Pref.getBooleanDefaultFalse("using_g6") && (DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1 || !DexSyncKeeper.isReady(getTransmitterID()));
if (notConnectedToG6Yet || shortTxId()) { // Only if G6 has been selected and transmitter is not synced yet, or if G7 has been selected.
notificationText.setText(R.string.wait_to_connect);
} else { // Only if G6 is not selected or G6 transmitter days is known.
} else { // Only if G6 is not selected or G6 transmitter is synced.
notificationText.setText(R.string.now_start_your_sensor);
}

Expand All @@ -2653,7 +2654,7 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not
dialog.show();
} else {
if (!Experience.gotData() && !QuickSettingsDialogs.isDialogShowing() && !notConnectedToG6Yet && JoH.ratelimit("start-sensor_prompt", 20)) {
// Show the dialog only if there is no data, and there is no dialog, and G6 is not selected or G6 is connected, and the rate limit is satisfied.
// Show the start sensor prompt only if G6 is not selected or the G6 transmitter is synchronized.
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final Context context = this;
builder.setTitle(getString(R.string.start_sensor) + "?");
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/eveningoutpost/dexdrip/MegaStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void addAsection(String section, String title) {
}

private static final String G4_STATUS = "BT Device";
public static final String G5_STATUS = "G5/G6/G7 Status";
public static final String G5_STATUS = "Dex Status";
private static final String MEDTRUM_STATUS = "Medtrum Status";
private static final String IP_COLLECTOR = "IP Collector";
private static final String XDRIP_PLUS_SYNC = "Followers";
Expand Down Expand Up @@ -168,7 +168,7 @@ private void populateSectionList() {
}
if (dexCollectionType.equals(DexcomG5)) {
if (Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
addAsection(G5_STATUS, "OB1 G5/G6/G7 Collector and Transmitter Status");
addAsection(G5_STATUS, "G6/Dex1/G7/1+ Collector/Transmitter Status");
} else {
addAsection(G5_STATUS, "G5 Collector and Transmitter Status");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter;
import com.eveningoutpost.dexdrip.utilitymodels.Experience;
import com.eveningoutpost.dexdrip.stats.StatsActivity;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utils.DexCollectionType;
import com.eveningoutpost.dexdrip.utils.Preferences;

Expand Down Expand Up @@ -103,7 +102,7 @@ public NavDrawerBuilder(final Context context) {
}
}
}
if (!getBestCollectorHardwareName().equals("G7") || Pref.getBooleanDefaultFalse("engineering_mode")) { // If we are using G7, offer the stop sensor option in engineering mode only
if (!getBestCollectorHardwareName().equals("G7")) { // If we are using G7, there will be no stop sensor option in the menu.
this.nav_drawer_options.add(context.getString(R.string.stop_sensor));
this.nav_drawer_intents.add(new Intent(context, StopSensor.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SensorExpiry() {

@Override
public boolean activate() {
val expiry = niceTimeScalarNatural(SensorDays.get().getRemainingSensorPeriodInMs());
val expiry = niceTimeScalarNatural(SensorDays.get().getRemainingSensorPeriodInMs(), 1);
val notificationId = SENSORY_EXPIRY_NOTIFICATION_ID;
cancelNotification(notificationId);
val expireMsg = String.format("Sensor will expire in %s", expiry); // TODO i18n and format string
Expand Down
Loading

0 comments on commit 17230bf

Please sign in to comment.