From daaf1cbd16168a600b91456e09c0da9f6e07482d Mon Sep 17 00:00:00 2001 From: Tyler Rhodes Date: Mon, 26 Jan 2015 16:44:29 -0800 Subject: [PATCH 1/4] Update version name in activity settings. Bump versions. --- app/src/main/AndroidManifest.xml | 4 ++-- app/src/main/res/values-it/strings_activity_settings.xml | 2 +- app/src/main/res/values/strings_activity_settings.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d71bf416..9c4b19ab 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="21" + android:versionName="0.1.12"> diff --git a/app/src/main/res/values-it/strings_activity_settings.xml b/app/src/main/res/values-it/strings_activity_settings.xml index 094a2054..afe44b75 100644 --- a/app/src/main/res/values-it/strings_activity_settings.xml +++ b/app/src/main/res/values-it/strings_activity_settings.xml @@ -94,7 +94,7 @@ A proposito Nome della versione - Cookie Monster + Dreamsicle Numero della versione diff --git a/app/src/main/res/values/strings_activity_settings.xml b/app/src/main/res/values/strings_activity_settings.xml index fa80b52a..e71fbc0e 100644 --- a/app/src/main/res/values/strings_activity_settings.xml +++ b/app/src/main/res/values/strings_activity_settings.xml @@ -94,7 +94,7 @@ About Release name - Cookie Monster + Dreamsicle Version number From c512c77ffd891d796796372c744fb99846158e40 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sun, 8 Mar 2015 18:00:51 -0500 Subject: [PATCH 2/4] DST fix Crash on close fix Fix occasional Pebble NPEs Move version information to app/build.gradle Settings now displays version information and device ID for easy searching in Crash reporting tools Updated ACRA to version 4.6.1 and moved to Tracepot backend --- app/build.gradle | 22 +++++----- app/src/main/AndroidManifest.xml | 7 ++-- .../com/nightscout/android/MainActivity.java | 11 +++-- .../com/nightscout/android/Nightscout.java | 15 +++---- .../drivers/AndroidUploaderDevice.java | 7 +--- .../android/settings/SettingsActivity.java | 32 +++++++-------- .../nightscout/android/upload/Uploader.java | 6 --- .../nightscout/android/wearables/Pebble.java | 37 +++++++++-------- app/src/main/res/values-it/strings.xml | 9 +++-- .../values-it/strings_activity_settings.xml | 1 + app/src/main/res/values/strings.xml | 7 ++-- .../res/values/strings_activity_settings.xml | 1 + app/src/main/res/xml/pref_main.xml | 40 +++++++++++-------- core/build.gradle | 2 +- .../com/nightscout/core/dexcom/Utils.java | 9 ++++- .../records/GenericTimestampRecord.java | 4 ++ 16 files changed, 112 insertions(+), 98 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 40b93a2a..4a0b5d63 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,16 +11,23 @@ buildscript { apply plugin: 'com.android.application' apply plugin: 'robolectric' +def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim() +def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")) +def codeName = "Dreamsicle" + android { compileSdkVersion 21 buildToolsVersion '21.1.1' - defaultConfig { applicationId "com.nightscout.android" minSdkVersion 12 targetSdkVersion 18 + versionCode 22 + versionName "0.1.13" + buildConfigField "String", "GIT_SHA", "\"${gitSha}\"" + buildConfigField "String", "BUILD_TIME", "\"${buildTime}\"" + buildConfigField "String", "VERSION_CODENAME", "\"${codeName}\"" } - lintOptions { quiet false checkAllWarnings true @@ -33,7 +40,6 @@ android { checkReleaseBuilds true warning 'ProtectedPermissions', 'InvalidPackage' } - packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' @@ -42,7 +48,6 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } - sourceSets { androidTest { setRoot('src/test') @@ -68,22 +73,19 @@ dependencies { exclude group: 'org.apache.httpcomponents' exclude group: 'joda-time', module: 'joda-time' } - compile files('libs/acra-4.5.0.jar') + compile 'ch.acra:acra:4.6.1' compile 'com.android.support:appcompat-v7:20.0.0' compile 'com.android.support:support-v4:20.0.0' compile 'com.google.android.gms:play-services-base:6.5.87' compile 'org.mongodb:mongo-java-driver:2.10.1' - compile 'net.danlew:android.joda:2.6.0' + compile 'net.danlew:android.joda:2.7.1' compile 'com.google.guava:guava:18.0' -// compile 'com.noveogroup.android:android-logger:1.3.4' - + compile 'com.noveogroup.android:android-logger:1.3.4' compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar' compile 'com.embarkmobile:zxing-android-legacy:2.0.0@aar' compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar' compile 'com.google.zxing:core:3.0.1' - compile 'com.getpebble:pebblekit:2.6.0@aar' - androidTestCompile 'org.hamcrest:hamcrest-library:1.3' androidTestCompile 'org.mockito:mockito-core:1.9.5' androidTestCompile('junit:junit:4.11') { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9c4b19ab..5e4d0936 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,9 +1,7 @@ + package="com.nightscout.android"> @@ -25,7 +23,8 @@ android:allowBackup="true"> - mg/dL conversions Log.d(TAG, "display_options_units: " + preferences.getPreferredUnits().name()); - pebble.config(preferences.getPwdName(), preferences.getPreferredUnits()); + pebble.config(preferences.getPwdName(), preferences.getPreferredUnits(), getApplicationContext()); int sgv = (Integer) mTextSGV.getTag(R.string.display_sgv); int direction = (Integer) mTextSGV.getTag(R.string.display_trend); @@ -319,7 +319,12 @@ protected void onDestroy() { unregisterReceiver(mCGMStatusReceiver); unregisterReceiver(mDeviceStatusReceiver); unregisterReceiver(toastReceiver); - uploaderDevice.close(); + if (pebble != null) { + pebble.close(); + } + if (uploaderDevice != null) { + uploaderDevice.close(); + } } @Override @@ -380,7 +385,7 @@ public void onReceive(Context context, Intent intent) { String json = intent.getStringExtra(SyncingService.RESPONSE_JSON); if (responseSGV != -1) { - pebble.sendDownload(reading, trend, responseSGVTimestamp); + pebble.sendDownload(reading, trend, responseSGVTimestamp, getApplicationContext()); } // Reload d3 chart with new data if (json != null) { diff --git a/app/src/main/java/com/nightscout/android/Nightscout.java b/app/src/main/java/com/nightscout/android/Nightscout.java index a94bf549..6e7fcdd6 100644 --- a/app/src/main/java/com/nightscout/android/Nightscout.java +++ b/app/src/main/java/com/nightscout/android/Nightscout.java @@ -14,21 +14,16 @@ import org.acra.annotation.ReportsCrashes; @ReportsCrashes( - formKey = "", - formUri = "http://nightscout.cloudant.com/acra-nightscout/_design/acra-storage/_update/report", - reportType = org.acra.sender.HttpSender.Type.JSON, - httpMethod = org.acra.sender.HttpSender.Method.PUT, - formUriBasicAuthLogin="whisphisheiringliketfurg", - formUriBasicAuthPassword="8CgjF6r2u4i8EhPHoPJjnk8f", + formUri = "https://collector.tracepot.com/a64e4a51", resToastText = R.string.crash_toast_text, resDialogText = R.string.feebback_dialog_text, resDialogIcon = R.drawable.ic_launcher, resDialogTitle = R.string.feedback_dialog_title, resDialogCommentPrompt = R.string.feedback_dialog_comment_prompt, resDialogOkToast = R.string.feedback_dialog_ok_toast, - excludeMatchingSharedPreferencesKeys= {"cloud_storage_mongodb_uri", "cloud_storage_api_base"}, + excludeMatchingSharedPreferencesKeys = {"cloud_storage_mongodb_uri", "cloud_storage_api_base"}, mode = ReportingInteractionMode.TOAST, - logcatArguments = { "-t", "250", "-v", "time" } + logcatArguments = {"-t", "500", "-v", "time"} ) public class Nightscout extends Application { private final String TAG = MainActivity.class.getSimpleName(); @@ -44,12 +39,12 @@ public void onCreate() { synchronized public Tracker getTracker() { Log.d(TAG, "getTracker called"); if (tracker == null) { - Log.d(TAG,"tracker was null - returning new tracker"); + Log.d(TAG, "tracker was null - returning new tracker"); GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setDryRun(false); analytics.getLogger().setLogLevel(Logger.LogLevel.WARNING); analytics.setLocalDispatchPeriod(7200); - tracker = analytics.newTracker(R.xml.app_tracker); + tracker = analytics.newTracker(R.xml.app_tracker); return tracker; } return tracker; diff --git a/app/src/main/java/com/nightscout/android/drivers/AndroidUploaderDevice.java b/app/src/main/java/com/nightscout/android/drivers/AndroidUploaderDevice.java index 7e93f4dc..0821c654 100644 --- a/app/src/main/java/com/nightscout/android/drivers/AndroidUploaderDevice.java +++ b/app/src/main/java/com/nightscout/android/drivers/AndroidUploaderDevice.java @@ -9,7 +9,6 @@ public class AndroidUploaderDevice extends AbstractUploaderDevice { private int uploaderBattery; - private static AndroidUploaderDevice uploaderDevice; private Context context; private AndroidUploaderDevice(Context context) { @@ -23,11 +22,9 @@ public int getBatteryLevel() { return uploaderBattery; } + // TODO: This registers everytime. Need to fix public static AndroidUploaderDevice getUploaderDevice(Context context) { - if (uploaderDevice == null) { - uploaderDevice = new AndroidUploaderDevice(context); - } - return uploaderDevice; + return new AndroidUploaderDevice(context); } public void close() { diff --git a/app/src/main/java/com/nightscout/android/settings/SettingsActivity.java b/app/src/main/java/com/nightscout/android/settings/SettingsActivity.java index d6cae467..4d76cc60 100644 --- a/app/src/main/java/com/nightscout/android/settings/SettingsActivity.java +++ b/app/src/main/java/com/nightscout/android/settings/SettingsActivity.java @@ -1,21 +1,20 @@ package com.nightscout.android.settings; -import com.google.common.base.Optional; -import com.google.zxing.integration.android.IntentIntegrator; -import com.google.zxing.integration.android.IntentResult; - import android.app.AlertDialog; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; +import android.provider.Settings; import android.support.v4.app.FragmentActivity; import android.support.v4.app.NavUtils; import android.view.MenuItem; +import com.google.common.base.Optional; +import com.google.zxing.integration.android.IntentIntegrator; +import com.google.zxing.integration.android.IntentResult; +import com.nightscout.android.BuildConfig; import com.nightscout.android.R; import com.nightscout.android.barcode.AndroidBarcode; import com.nightscout.android.preferences.AndroidPreferences; @@ -39,9 +38,9 @@ protected void onCreate(Bundle savedInstanceState) { } private void refreshFragments() { - mainPreferenceFragment = new MainPreferenceFragment(); - getFragmentManager().beginTransaction().replace(android.R.id.content, - mainPreferenceFragment).commit(); + mainPreferenceFragment = new MainPreferenceFragment(); + getFragmentManager().beginTransaction().replace(android.R.id.content, + mainPreferenceFragment).commit(); } private void setupActionBar() { @@ -80,7 +79,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { prefs.setMongoClientUri(barcode.getMongoUri().get()); prefs.setMongoCollection(barcode.getMongoCollection().orNull()); prefs.setMongoDeviceStatusCollection( - barcode.getMongoDeviceStatusCollection().orNull()); + barcode.getMongoDeviceStatusCollection().orNull()); } } else { prefs.setMongoUploadEnabled(false); @@ -106,14 +105,11 @@ public void onCreate(Bundle savedInstanceState) { } private void setupVersionNumbers() { - try { - PackageInfo pInfo; - pInfo = getActivity().getPackageManager().getPackageInfo( - getActivity().getPackageName(), 0); - findPreference("about_version_number").setSummary(pInfo.versionName); - } catch (PackageManager.NameNotFoundException e) { - // nom - } + findPreference("about_version_number").setSummary(BuildConfig.VERSION_CODENAME); + findPreference("about_version_number").setSummary(BuildConfig.VERSION_NAME); + findPreference("about_build_hash").setSummary(BuildConfig.GIT_SHA); + findPreference("about_device_id").setSummary(Settings.Secure.getString(getActivity().getContentResolver(), + Settings.Secure.ANDROID_ID)); } private void setupBarcodeScanner() { diff --git a/app/src/main/java/com/nightscout/android/upload/Uploader.java b/app/src/main/java/com/nightscout/android/upload/Uploader.java index dd130ccb..d5867cf0 100644 --- a/app/src/main/java/com/nightscout/android/upload/Uploader.java +++ b/app/src/main/java/com/nightscout/android/upload/Uploader.java @@ -102,12 +102,6 @@ private boolean initializeRestUploaders(Context context, NightscoutPreferences p return allInitialized; } -// public boolean upload(GlucoseDataSet glucoseDataSet, MeterRecord meterRecord, -// CalRecord calRecord) { -// return upload(Lists.newArrayList(glucoseDataSet), Lists.newArrayList(meterRecord), -// Lists.newArrayList(calRecord)); -// } - public boolean upload(DownloadResults downloadResults, int numRecords) { G4Download download = downloadResults.getDownload(); List sgvList = filterRecords(numRecords, download.sgv); diff --git a/app/src/main/java/com/nightscout/android/wearables/Pebble.java b/app/src/main/java/com/nightscout/android/wearables/Pebble.java index 1383eb50..5a9d334f 100644 --- a/app/src/main/java/com/nightscout/android/wearables/Pebble.java +++ b/app/src/main/java/com/nightscout/android/wearables/Pebble.java @@ -40,6 +40,14 @@ public class Pebble { private GlucoseReading lastDelta; private TrendArrow lastTrend = TrendArrow.NONE; private long lastRecordTime = 0; + private PebbleKit.PebbleDataReceiver dataReceiver = new PebbleKit.PebbleDataReceiver(PEBBLEAPP_UUID) { + @Override + public void receiveData(final Context mContext, final int transactionId, final PebbleDictionary data) { + Log.d(TAG, "Received query. data: " + data.size()); + PebbleKit.sendAckToPebble(mContext, transactionId); + sendDownload(currentReading); + } + }; public Pebble(Context context) { this.context = context; @@ -47,6 +55,10 @@ public Pebble(Context context) { init(); } + public void close() { + context.unregisterReceiver(dataReceiver); + } + public PebbleDictionary buildDictionary(TrendArrow trend, String bgValue, int recordTime, int uploaderTimeSec, String delta, String uploaderBattery, String name) { PebbleDictionary dictionary = new PebbleDictionary(); @@ -61,11 +73,11 @@ public PebbleDictionary buildDictionary(TrendArrow trend, String bgValue, int re return dictionary; } - public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime) { - sendDownload(reading, trend, recordTime, false); + public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime, Context cntx) { + sendDownload(reading, trend, recordTime, cntx, false); } - public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime, boolean resend) { + public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime, Context cntx, boolean resend) { GlucoseReading delta = new GlucoseReading(0, GlucoseUnit.MGDL); if (currentReading != null) { @@ -87,7 +99,7 @@ public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTi lastTrend = trend; lastDelta = delta; recordTime = DateTimeZone.getDefault().convertUTCToLocal(recordTime); - int batLevel = AndroidUploaderDevice.getUploaderDevice(context).getBatteryLevel(); + int batLevel = AndroidUploaderDevice.getUploaderDevice(cntx).getBatteryLevel(); PebbleDictionary dictionary = buildDictionary(trend, bgStr, (int) (recordTime / 1000), (int) (DateTimeZone.getDefault().convertUTCToLocal(new DateTime().getMillis()) / 1000), deltaStr, String.valueOf(batLevel), pwdName); @@ -95,9 +107,9 @@ public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTi sendDownload(dictionary); } - public void resendDownload() { + public void resendDownload(Context cntx) { if (currentReading != null) { - sendDownload(lastReading, lastTrend, lastRecordTime, true); + sendDownload(lastReading, lastTrend, lastRecordTime, cntx, true); } } @@ -111,22 +123,15 @@ public void sendDownload(PebbleDictionary dictionary) { } private void init() { - PebbleKit.registerReceivedDataHandler(context, new PebbleKit.PebbleDataReceiver(PEBBLEAPP_UUID) { - @Override - public void receiveData(final Context mContext, final int transactionId, final PebbleDictionary data) { - Log.d(TAG, "Received query. data: " + data.size()); - PebbleKit.sendAckToPebble(mContext, transactionId); - sendDownload(currentReading); - } - }); + PebbleKit.registerReceivedDataHandler(context, dataReceiver); } - public void config(String pwdName, GlucoseUnit units) { + public void config(String pwdName, GlucoseUnit units, Context cntx) { boolean changed = !this.pwdName.equals(pwdName) || this.units != units; if (changed) { setPwdName(pwdName); setUnits(units); - resendDownload(); + resendDownload(cntx); } } diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index c111c5c0..c118e2aa 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -11,15 +11,15 @@ Per favore facci sapere cosa ne pensi Aggiungi i tuoi commenti qui sotto: Grazie! - + La lettura dal device è disabilitata finchè non leggi e accetti \"HO CAPITO\" nelle preferenze Forza invio dati ultimi 2 giorni Crash reporting is enabled Crash reporting is disabled Email This is the email address included in bug reports and automatic crash reports. This field is optional - - + + Esci Feedback @@ -36,7 +36,7 @@ Error resolving Mongo host. Double check mongo url. Could not create API uploader. Check your settings. Auto configure - + Batteria Dex Ora Trovata modifica temporale @@ -48,4 +48,5 @@ Impossibile connettersi a %s, si prega di verificare che si è connessi a Internet, e che l\'URL sia corretto. Versione sconosciuta Camping + Git hash diff --git a/app/src/main/res/values-it/strings_activity_settings.xml b/app/src/main/res/values-it/strings_activity_settings.xml index afe44b75..aaf5f223 100644 --- a/app/src/main/res/values-it/strings_activity_settings.xml +++ b/app/src/main/res/values-it/strings_activity_settings.xml @@ -115,4 +115,5 @@ Abilita il reporting dei crash PWD Display name This is the name of the pwd that will be displayed on other monitors e.g. pebble + Device ID diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d06a1c9a..96734b43 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,15 +11,15 @@ Please let us know what you think. Please add your comments below: Thank you! - + Reading from device is disabled until you review and accept “I understand” in preferences Force sync Crash reporting is enabled Crash reporting is disabled Email This is the email address included in bug reports and automatic crash reports. This field is optional - - + + Close Feedback @@ -47,4 +47,5 @@ OK Unknown version Camping + Git hash diff --git a/app/src/main/res/values/strings_activity_settings.xml b/app/src/main/res/values/strings_activity_settings.xml index e71fbc0e..e31cc19f 100644 --- a/app/src/main/res/values/strings_activity_settings.xml +++ b/app/src/main/res/values/strings_activity_settings.xml @@ -116,4 +116,5 @@ Auto configure using a barcode. See http://nightscout.github.io/pages/configure/ for more details PWD Display name This is the name of the pwd that will be displayed on other monitors e.g. pebble + Device ID diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index 40d4630e..24acbe5f 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -1,8 +1,7 @@ - + - + - + android:positiveButtonText="@null"> - + + + + - - + + android:defaultValue="true" /> + android:dialogMessage="@string/acra_user_email_dialog_message" /> - + - + android:summary="@string/pref_summary_root"> \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 8d49c96d..25d7ad67 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -6,7 +6,7 @@ targetCompatibility = JavaVersion.VERSION_1_7 dependencies { compile 'joda-time:joda-time:2.5' compile 'com.google.guava:guava:18.0' - compile 'org.slf4j:slf4j-simple:1.7.7' + compile 'org.slf4j:slf4j-api:1.7.7' compile 'org.mongodb:mongo-java-driver:2.10.1' /** Android-provided **/ // this is an old version of JSON, but it is the most compatible with the android version. diff --git a/core/src/main/java/com/nightscout/core/dexcom/Utils.java b/core/src/main/java/com/nightscout/core/dexcom/Utils.java index cde22445..57973a77 100644 --- a/core/src/main/java/com/nightscout/core/dexcom/Utils.java +++ b/core/src/main/java/com/nightscout/core/dexcom/Utils.java @@ -8,9 +8,12 @@ import org.joda.time.DateTime; import org.joda.time.DateTimeZone; +import org.joda.time.Instant; import org.joda.time.Period; import org.joda.time.format.PeriodFormatter; import org.joda.time.format.PeriodFormatterBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Date; @@ -20,6 +23,8 @@ import static org.joda.time.Duration.standardSeconds; public final class Utils { + protected static final Logger log = LoggerFactory.getLogger(Utils.class); + public static final DateTime DEXCOM_EPOCH = new DateTime(2009, 1, 1, 0, 0, 0, 0); private static final String PRIMARY_SEPARATOR = ", "; @@ -35,8 +40,10 @@ public final class Utils { .printZeroNever() .toFormatter(); + // TODO: probably not the right way to do this but it seems to do the trick. Need to revisit this to fully understand what is going on during DST change public static DateTime receiverTimeToDateTime(long deltaInSeconds) { - return DEXCOM_EPOCH.plus(standardSeconds(deltaInSeconds)).withZone(DateTimeZone.getDefault()); + int offset = DateTimeZone.getDefault().getOffset(DEXCOM_EPOCH) - DateTimeZone.getDefault().getOffset(Instant.now()); + return DEXCOM_EPOCH.plus(offset).plus(standardSeconds(deltaInSeconds)).withZone(DateTimeZone.UTC); } public static Date receiverTimeToDate(long delta) { diff --git a/core/src/main/java/com/nightscout/core/dexcom/records/GenericTimestampRecord.java b/core/src/main/java/com/nightscout/core/dexcom/records/GenericTimestampRecord.java index 735c2235..f463aaae 100644 --- a/core/src/main/java/com/nightscout/core/dexcom/records/GenericTimestampRecord.java +++ b/core/src/main/java/com/nightscout/core/dexcom/records/GenericTimestampRecord.java @@ -3,6 +3,9 @@ import com.nightscout.core.dexcom.Utils; import com.squareup.wire.Message; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; @@ -10,6 +13,7 @@ import java.util.List; abstract public class GenericTimestampRecord { + protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected final int OFFSET_SYS_TIME = 0; protected final int OFFSET_DISPLAY_TIME = 4; protected Date systemTime; From 8fe6d75b3d190cacd658f7f7fae0dfff0e99fe46 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sun, 8 Mar 2015 19:24:18 -0500 Subject: [PATCH 3/4] Fixing broken tests --- app/build.gradle | 4 ++-- .../test/java/com/nightscout/android/MainActivityTest.java | 3 ++- core/build.gradle | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4a0b5d63..16259ec2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,9 +78,9 @@ dependencies { compile 'com.android.support:support-v4:20.0.0' compile 'com.google.android.gms:play-services-base:6.5.87' compile 'org.mongodb:mongo-java-driver:2.10.1' - compile 'net.danlew:android.joda:2.7.1' + compile 'net.danlew:android.joda:2.6.0' compile 'com.google.guava:guava:18.0' - compile 'com.noveogroup.android:android-logger:1.3.4' +// compile 'com.noveogroup.android:android-logger:1.3.4' compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar' compile 'com.embarkmobile:zxing-android-legacy:2.0.0@aar' compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar' diff --git a/app/src/test/java/com/nightscout/android/MainActivityTest.java b/app/src/test/java/com/nightscout/android/MainActivityTest.java index 61ad48d3..d1ad321b 100644 --- a/app/src/test/java/com/nightscout/android/MainActivityTest.java +++ b/app/src/test/java/com/nightscout/android/MainActivityTest.java @@ -1,6 +1,7 @@ package com.nightscout.android; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.widget.TextView; @@ -122,7 +123,7 @@ public void testOnResume_ShouldCallPebbleConfig() { Pebble pebble = mock(Pebble.class); ((MainActivity) activity).setPebble(pebble); activityController.stop().resume(); - verify(pebble, times(1)).config(anyString(), (GlucoseUnit) anyObject()); + verify(pebble, times(1)).config(anyString(), (GlucoseUnit) anyObject(), (Context) anyObject()); } @Test diff --git a/core/build.gradle b/core/build.gradle index 25d7ad67..8d49c96d 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -6,7 +6,7 @@ targetCompatibility = JavaVersion.VERSION_1_7 dependencies { compile 'joda-time:joda-time:2.5' compile 'com.google.guava:guava:18.0' - compile 'org.slf4j:slf4j-api:1.7.7' + compile 'org.slf4j:slf4j-simple:1.7.7' compile 'org.mongodb:mongo-java-driver:2.10.1' /** Android-provided **/ // this is an old version of JSON, but it is the most compatible with the android version. From 780206f361e44e0ce5712466d5bded42b14f872c Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sun, 8 Mar 2015 19:31:23 -0500 Subject: [PATCH 4/4] Another attempt to fix broken tests --- core/src/main/java/com/nightscout/core/dexcom/Utils.java | 2 +- .../src/test/java/com/nightscout/core/dexcom/UtilsTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/nightscout/core/dexcom/Utils.java b/core/src/main/java/com/nightscout/core/dexcom/Utils.java index 57973a77..1de11cec 100644 --- a/core/src/main/java/com/nightscout/core/dexcom/Utils.java +++ b/core/src/main/java/com/nightscout/core/dexcom/Utils.java @@ -25,7 +25,7 @@ public final class Utils { protected static final Logger log = LoggerFactory.getLogger(Utils.class); - public static final DateTime DEXCOM_EPOCH = new DateTime(2009, 1, 1, 0, 0, 0, 0); + public static final DateTime DEXCOM_EPOCH = new DateTime(2009, 1, 1, 0, 0, 0, 0).withZone(DateTimeZone.UTC); private static final String PRIMARY_SEPARATOR = ", "; private static final String SECONDARY_SEPARATOR = ", and "; diff --git a/core/src/test/java/com/nightscout/core/dexcom/UtilsTest.java b/core/src/test/java/com/nightscout/core/dexcom/UtilsTest.java index 3fb9af52..e0d2783f 100644 --- a/core/src/test/java/com/nightscout/core/dexcom/UtilsTest.java +++ b/core/src/test/java/com/nightscout/core/dexcom/UtilsTest.java @@ -15,21 +15,21 @@ public class UtilsTest { @Test public void testReceiverTimeToDateTime_epoch() { assertThat(Utils.receiverTimeToDateTime(0), - is(Utils.DEXCOM_EPOCH.withZone(DateTimeZone.getDefault()))); + is(Utils.DEXCOM_EPOCH.withZone(DateTimeZone.UTC))); } @Test public void testReceiverTimeToDateTime_positiveDelta() { int secondsDelta = 10; assertThat(Utils.receiverTimeToDateTime(secondsDelta), - is(Utils.DEXCOM_EPOCH.plusSeconds(secondsDelta).withZone(DateTimeZone.getDefault()))); + is(Utils.DEXCOM_EPOCH.plusSeconds(secondsDelta).withZone(DateTimeZone.UTC))); } @Test public void testReceiverTimeToDateTime_negativeDelta() { int secondsDelta = -10; assertThat(Utils.receiverTimeToDateTime(secondsDelta), - is(Utils.DEXCOM_EPOCH.minusSeconds(10).withZone(DateTimeZone.getDefault()))); + is(Utils.DEXCOM_EPOCH.minusSeconds(10).withZone(DateTimeZone.UTC))); } @Test