Skip to content
Snippets Groups Projects
Commit f16d3df3 authored by Pogman's avatar Pogman Committed by GitHub
Browse files

Merge pull request #9 from jotomo/pazaan/develop-basal-rates

jotomo pr
parents 7cb1e585 f182e8e9
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ buildscript { ...@@ -7,7 +7,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'io.fabric.tools:gradle:1.21.6' classpath 'io.fabric.tools:gradle:1.22.2'
classpath 'io.realm:realm-gradle-plugin:3.4.0' classpath 'io.realm:realm-gradle-plugin:3.4.0'
classpath 'org.ajoberstar:grgit:1.5.0' classpath 'org.ajoberstar:grgit:1.5.0'
} }
...@@ -88,52 +88,56 @@ android { ...@@ -88,52 +88,56 @@ android {
} }
} }
task signRelease << { task signRelease {
def command = [ doLast {
'jarsigner', def command = [
'-verbose', 'jarsigner',
'-sigalg', '-verbose',
'SHA1withRSA', '-sigalg',
'-digestalg', 'SHA1withRSA',
'SHA1', '-digestalg',
'-keystore', 'SHA1',
'/Users/lennart/keystores/nightscout_android.jks', '-keystore',
'app/build/outputs/apk/app-release-unsigned.apk', '/Users/lennart/keystores/nightscout_android.jks',
'nightscoutandroidkey' 'app/build/outputs/apk/app-release-unsigned.apk',
] 'nightscoutandroidkey'
]
def proc = new ProcessBuilder(command)
.redirectOutput(ProcessBuilder.Redirect.INHERIT) def proc = new ProcessBuilder(command)
.redirectInput(ProcessBuilder.Redirect.INHERIT) .redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT) .redirectInput(ProcessBuilder.Redirect.INHERIT)
.start() .redirectError(ProcessBuilder.Redirect.INHERIT)
.start()
proc.waitFor()
proc.waitFor()
if (0 != proc.exitValue()) {
throw new RuntimeException("Could not sign APK.") if (0 != proc.exitValue()) {
throw new RuntimeException("Could not sign APK.")
}
} }
} }
task zipalignRelease << { task zipalignRelease {
def command = [ doLast {
'/Users/lennart/Library/Android/sdk/build-tools/25.0.2/zipalign', def command = [
'-v', '/Users/lennart/Library/Android/sdk/build-tools/25.0.2/zipalign',
'4', '-v',
'app/build/outputs/apk/app-release-unsigned.apk', '4',
'app/build/outputs/apk/600-series-uploader.apk' 'app/build/outputs/apk/app-release-unsigned.apk',
] 'app/build/outputs/apk/600-series-uploader.apk'
]
def proc = new ProcessBuilder(command)
.redirectOutput(ProcessBuilder.Redirect.INHERIT) def proc = new ProcessBuilder(command)
.redirectInput(ProcessBuilder.Redirect.INHERIT) .redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT) .redirectInput(ProcessBuilder.Redirect.INHERIT)
.start() .redirectError(ProcessBuilder.Redirect.INHERIT)
.start()
proc.waitFor()
proc.waitFor()
if (0 != proc.exitValue()) {
throw new RuntimeException("Could not align APK.") if (0 != proc.exitValue()) {
throw new RuntimeException("Could not align APK.")
}
} }
} }
...@@ -161,6 +165,10 @@ dependencies { ...@@ -161,6 +165,10 @@ dependencies {
compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
// The version of okhttp3 *must* be the same as the version in AppUpdater // The version of okhttp3 *must* be the same as the version in AppUpdater
compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0' compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
......
...@@ -70,7 +70,6 @@ import info.nightscout.android.USB.UsbHidDriver; ...@@ -70,7 +70,6 @@ import info.nightscout.android.USB.UsbHidDriver;
import info.nightscout.android.eula.Eula; import info.nightscout.android.eula.Eula;
import info.nightscout.android.eula.Eula.OnEulaAgreedTo; import info.nightscout.android.eula.Eula.OnEulaAgreedTo;
import info.nightscout.android.medtronic.service.MedtronicCnlAlarmManager; import info.nightscout.android.medtronic.service.MedtronicCnlAlarmManager;
import info.nightscout.android.medtronic.service.MedtronicCnlAlarmReceiver;
import info.nightscout.android.medtronic.service.MedtronicCnlIntentService; import info.nightscout.android.medtronic.service.MedtronicCnlIntentService;
import info.nightscout.android.model.medtronicNg.PumpInfo; import info.nightscout.android.model.medtronicNg.PumpInfo;
import info.nightscout.android.model.medtronicNg.PumpStatusEvent; import info.nightscout.android.model.medtronicNg.PumpStatusEvent;
...@@ -93,7 +92,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -93,7 +92,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private int chartZoom = 3; private int chartZoom = 3;
private boolean hasZoomedChart = false; private boolean hasZoomedChart = false;
private NumberFormat sgvFormatter;
private boolean mEnableCgmService = true; private boolean mEnableCgmService = true;
private SharedPreferences prefs = null; private SharedPreferences prefs = null;
...@@ -104,7 +102,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -104,7 +102,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private Runnable mUiRefreshRunnable = new RefreshDisplayRunnable(); private Runnable mUiRefreshRunnable = new RefreshDisplayRunnable();
private Realm mRealm; private Realm mRealm;
private StatusMessageReceiver statusMessageReceiver = new StatusMessageReceiver(); private StatusMessageReceiver statusMessageReceiver = new StatusMessageReceiver();
private MedtronicCnlAlarmReceiver medtronicCnlAlarmReceiver = new MedtronicCnlAlarmReceiver();
/** /**
* calculate the next poll timestamp based on last svg event * calculate the next poll timestamp based on last svg event
...@@ -167,15 +164,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -167,15 +164,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
configurationStore.setMmolxl(prefs.getBoolean("mmolxl", false)); configurationStore.setMmolxl(prefs.getBoolean("mmolxl", false));
configurationStore.setMmolxlDecimals(prefs.getBoolean("mmolDecimals", false)); configurationStore.setMmolxlDecimals(prefs.getBoolean("mmolDecimals", false));
if (configurationStore.isMmolxl()) {
if (configurationStore.isMmolxlDecimals())
sgvFormatter = new DecimalFormat("0.00");
else
sgvFormatter = new DecimalFormat("0.0");
} else {
sgvFormatter = new DecimalFormat("0");
}
// Disable battery optimization to avoid missing values on 6.0+ // Disable battery optimization to avoid missing values on 6.0+
// taken from https://github.com/NightscoutFoundation/xDrip/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Home.java#L277L298 // taken from https://github.com/NightscoutFoundation/xDrip/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Home.java#L277L298
...@@ -559,14 +547,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -559,14 +547,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
} else if (key.equals("mmolxl") || key.equals("mmolDecimals")) { } else if (key.equals("mmolxl") || key.equals("mmolDecimals")) {
configurationStore.setMmolxl(sharedPreferences.getBoolean("mmolxl", false)); configurationStore.setMmolxl(sharedPreferences.getBoolean("mmolxl", false));
configurationStore.setMmolxlDecimals(sharedPreferences.getBoolean("mmolDecimals", false)); configurationStore.setMmolxlDecimals(sharedPreferences.getBoolean("mmolDecimals", false));
if (configurationStore.isMmolxl()) {
if (configurationStore.isMmolxlDecimals())
sgvFormatter = new DecimalFormat("0.00");
else
sgvFormatter = new DecimalFormat("0.0");
} else {
sgvFormatter = new DecimalFormat("0");
}
refreshDisplay(); refreshDisplay();
} else if (key.equals("pollInterval")) { } else if (key.equals("pollInterval")) {
configurationStore.setPollInterval(Long.parseLong(sharedPreferences.getString("pollInterval", configurationStore.setPollInterval(Long.parseLong(sharedPreferences.getString("pollInterval",
...@@ -944,6 +924,9 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -944,6 +924,9 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private class UsbReceiver extends BroadcastReceiver { private class UsbReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
// TODO move this somewhere else ... wherever it belongs
// realm might be closed ... sometimes occurs when USB is disconnected and replugged ...
if (mRealm.isClosed()) mRealm = Realm.getDefaultInstance();
String action = intent.getAction(); String action = intent.getAction();
if (MedtronicCnlIntentService.Constants.ACTION_USB_PERMISSION.equals(action)) { if (MedtronicCnlIntentService.Constants.ACTION_USB_PERMISSION.equals(action)) {
boolean permissionGranted = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false); boolean permissionGranted = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false);
......
...@@ -16,11 +16,10 @@ import info.nightscout.android.utils.ConfigurationStore; ...@@ -16,11 +16,10 @@ import info.nightscout.android.utils.ConfigurationStore;
*/ */
public class MedtronicCnlAlarmManager { public class MedtronicCnlAlarmManager {
private static final String TAG = MedtronicCnlAlarmManager.class.getSimpleName(); private static final String TAG = MedtronicCnlAlarmManager.class.getSimpleName();
private static final int ALARM_ID = 102; // Alarm id private static final int ALARM_ID = 102;
private static PendingIntent pendingIntent = null; private static PendingIntent pendingIntent = null;
private static AlarmManager alarmManager = null; private static AlarmManager alarmManager = null;
private static long nextAlarm = Long.MAX_VALUE;
public static void setContext(Context context) { public static void setContext(Context context) {
cancelAlarm(); cancelAlarm();
...@@ -30,11 +29,6 @@ public class MedtronicCnlAlarmManager { ...@@ -30,11 +29,6 @@ public class MedtronicCnlAlarmManager {
pendingIntent = PendingIntent.getBroadcast(context, ALARM_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT); pendingIntent = PendingIntent.getBroadcast(context, ALARM_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
} }
// Setting the alarm in 15 seconds from now
public static void setAlarm() {
setAlarm(System.currentTimeMillis());
}
/** /**
* set the alarm in the future * set the alarm in the future
* *
...@@ -44,7 +38,7 @@ public class MedtronicCnlAlarmManager { ...@@ -44,7 +38,7 @@ public class MedtronicCnlAlarmManager {
setAlarm(System.currentTimeMillis() + inFuture); setAlarm(System.currentTimeMillis() + inFuture);
} }
// Setting the alarm to call onRecieve // Setting the alarm to call onReceive
public static void setAlarm(long millis) { public static void setAlarm(long millis) {
if (alarmManager == null || pendingIntent == null) if (alarmManager == null || pendingIntent == null)
return; return;
...@@ -56,21 +50,14 @@ public class MedtronicCnlAlarmManager { ...@@ -56,21 +50,14 @@ public class MedtronicCnlAlarmManager {
if (millis < now) if (millis < now)
millis = now; millis = now;
// only accept alarm nearer than the last one
//if (nextAlarm < millis && nextAlarm > now) {
// return;
//}
cancelAlarm(); cancelAlarm();
nextAlarm = millis;
Log.d(TAG, "Alarm set to fire at " + new Date(millis)); Log.d(TAG, "Alarm set to fire at " + new Date(millis));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(millis, null), pendingIntent); alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(millis, null), pendingIntent);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// Android 5.0.0 + 5.0.1 (e.g. Galaxy S4) has a bug. // Android 5.0.0 + 5.0.1 (e.g. Galaxy S4) has a bug.
// Alarms are not exact. Fixed in 5.0.2 oder CM12 // Alarms are not exact. Fixed in 5.0.2 and CM12
alarmManager.setExact(AlarmManager.RTC_WAKEUP, millis, pendingIntent); alarmManager.setExact(AlarmManager.RTC_WAKEUP, millis, pendingIntent);
} else { } else {
alarmManager.set(AlarmManager.RTC_WAKEUP, millis, pendingIntent); alarmManager.set(AlarmManager.RTC_WAKEUP, millis, pendingIntent);
......
...@@ -71,6 +71,8 @@ public class EntriesSerializer implements JsonSerializer<PumpStatusEvent> { ...@@ -71,6 +71,8 @@ public class EntriesSerializer implements JsonSerializer<PumpStatusEvent> {
} }
} }
// TODO currentnly unused, see info.nightscout.android.xdrip_plus.XDripPlusUploadIntentService.addSgvEntry()
// TODO also, proper method name
@Override @Override
public JsonElement serialize(PumpStatusEvent src, Type typeOfSrc, JsonSerializationContext context) { public JsonElement serialize(PumpStatusEvent src, Type typeOfSrc, JsonSerializationContext context) {
final JsonObject jsonObject = new JsonObject(); final JsonObject jsonObject = new JsonObject();
...@@ -78,8 +80,8 @@ public class EntriesSerializer implements JsonSerializer<PumpStatusEvent> { ...@@ -78,8 +80,8 @@ public class EntriesSerializer implements JsonSerializer<PumpStatusEvent> {
jsonObject.addProperty("direction", getDirectionString(src.getCgmTrend())); jsonObject.addProperty("direction", getDirectionString(src.getCgmTrend()));
jsonObject.addProperty("device", src.getDeviceName()); jsonObject.addProperty("device", src.getDeviceName());
jsonObject.addProperty("type", "sgv"); jsonObject.addProperty("type", "sgv");
jsonObject.addProperty("date", src.getEventDate().getTime()); jsonObject.addProperty("date", src.getSgvDate().getTime());
jsonObject.addProperty("dateString", String.valueOf(src.getEventDate())); jsonObject.addProperty("dateString", String.valueOf(src.getSgvDate()));
return jsonObject; return jsonObject;
} }
......
...@@ -26,6 +26,7 @@ public class DataStore { ...@@ -26,6 +26,7 @@ public class DataStore {
// set some initial dummy values // set some initial dummy values
PumpStatusEvent dummyStatus = new PumpStatusEvent(); PumpStatusEvent dummyStatus = new PumpStatusEvent();
dummyStatus.setSgvDate(new Date());
// bypass setter to avoid dealing with a real Realm object // bypass setter to avoid dealing with a real Realm object
instance.lastPumpStatus = dummyStatus; instance.lastPumpStatus = dummyStatus;
......
...@@ -145,8 +145,8 @@ public class XDripPlusUploadIntentService extends IntentService { ...@@ -145,8 +145,8 @@ public class XDripPlusUploadIntentService extends IntentService {
json.put("direction", EntriesSerializer.getDirectionString(pumpRecord.getCgmTrend())); json.put("direction", EntriesSerializer.getDirectionString(pumpRecord.getCgmTrend()));
json.put("device", pumpRecord.getDeviceName()); json.put("device", pumpRecord.getDeviceName());
json.put("type", "sgv"); json.put("type", "sgv");
json.put("date", pumpRecord.getEventDate().getTime()); json.put("date", pumpRecord.getSgvDate().getTime());
json.put("dateString", pumpRecord.getEventDate()); json.put("dateString", pumpRecord.getSgvDate());
entriesArray.put(json); entriesArray.put(json);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment