Merge pull request #1 from MilosKozak/master

Update from original repo
This commit is contained in:
ecorman 2016-09-08 00:04:02 +02:00 committed by GitHub
commit 96a0d25183
13 changed files with 80 additions and 55 deletions

View file

@ -5,7 +5,7 @@
<GradleProjectSettings> <GradleProjectSettings>
<option name="distributionType" value="LOCAL" /> <option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.10" /> <option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View file

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -23,8 +23,8 @@ android {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 23
versionCode 1010 versionCode 1011
versionName "1.0.10" versionName "1.0.11"
} }
buildTypes { buildTypes {
release { release {
@ -33,6 +33,11 @@ android {
} }
} }
productFlavors { productFlavors {
danarcontrol {
buildConfigField "boolean", "APS", "false"
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "CLOSEDLOOP", "false"
}
careportal { careportal {
buildConfigField "boolean", "APS", "false" buildConfigField "boolean", "APS", "false"
buildConfigField "boolean", "PUMPDRIVERS", "false" buildConfigField "boolean", "PUMPDRIVERS", "false"

View file

@ -32,10 +32,6 @@ import info.nightscout.utils.LocaleHelper;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private static Logger log = LoggerFactory.getLogger(MainActivity.class); private static Logger log = LoggerFactory.getLogger(MainActivity.class);
private Toolbar toolbar;
private SlidingTabLayout mTabs;
private ViewPager mPager;
private static TabPageAdapter pageAdapter;
private static KeepAliveReceiver keepAliveReceiver; private static KeepAliveReceiver keepAliveReceiver;
@Override @Override
@ -50,16 +46,15 @@ public class MainActivity extends AppCompatActivity {
// show version in toolbar // show version in toolbar
try { try {
setTitle(getString(R.string.app_name) + " v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName); setTitle(getString(R.string.app_name) + " " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
registerBus(); registerBus();
if (keepAliveReceiver == null) { if (keepAliveReceiver == null) {
keepAliveReceiver = new KeepAliveReceiver(); keepAliveReceiver = new KeepAliveReceiver();
startService(new Intent(this, ExecutionService.class)); startService(new Intent(this, ExecutionService.class));
keepAliveReceiver.setAlarm(this); keepAliveReceiver.setAlarm(this);
@ -76,17 +71,18 @@ public class MainActivity extends AppCompatActivity {
try { // activity may be destroyed try { // activity may be destroyed
setUpTabs(true); setUpTabs(true);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
e.printStackTrace();
} }
} }
private void setUpTabs(boolean switchToLast) { private void setUpTabs(boolean switchToLast) {
pageAdapter = new TabPageAdapter(getSupportFragmentManager(), this); TabPageAdapter pageAdapter = new TabPageAdapter(getSupportFragmentManager(), this);
for (PluginBase p : MainApp.getPluginsList()) { for (PluginBase p : MainApp.getPluginsList()) {
pageAdapter.registerNewFragment(p); pageAdapter.registerNewFragment(p);
} }
mPager = (ViewPager) findViewById(R.id.pager); ViewPager mPager = (ViewPager) findViewById(R.id.pager);
mPager.setAdapter(pageAdapter); mPager.setAdapter(pageAdapter);
mTabs = (SlidingTabLayout) findViewById(R.id.tabs); SlidingTabLayout mTabs = (SlidingTabLayout) findViewById(R.id.tabs);
mTabs.setViewPager(mPager); mTabs.setViewPager(mPager);
if (switchToLast) if (switchToLast)
mPager.setCurrentItem(pageAdapter.getCount() - 1, false); mPager.setCurrentItem(pageAdapter.getCount() - 1, false);

View file

@ -301,7 +301,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
@Override @Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
eventTime.setYear(year); eventTime.setYear(year - 1900);
eventTime.setMonth(monthOfYear); eventTime.setMonth(monthOfYear);
eventTime.setDate(dayOfMonth); eventTime.setDate(dayOfMonth);
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);

View file

@ -24,7 +24,8 @@ public class MsgSettingShippingInfo extends MessageBase {
DanaRPlugin.getDanaRPump().shippingCountry = asciiStringFromBuff(bytes, 13, 3); DanaRPlugin.getDanaRPump().shippingCountry = asciiStringFromBuff(bytes, 13, 3);
if (DanaRPlugin.getDanaRPump().shippingDate.getTime() > new Date(116, 4, 1).getTime()) { if (DanaRPlugin.getDanaRPump().shippingDate.getTime() > new Date(116, 4, 1).getTime()) {
DanaRPlugin.getDanaRPump().isNewPump = true; DanaRPlugin.getDanaRPump().isNewPump = true;
} } else
DanaRPlugin.getDanaRPump().isNewPump = false;
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Serial number: " + DanaRPlugin.getDanaRPump().serialNumber); log.debug("Serial number: " + DanaRPlugin.getDanaRPump().serialNumber);
log.debug("Shipping date: " + DanaRPlugin.getDanaRPump().shippingDate); log.debug("Shipping date: " + DanaRPlugin.getDanaRPump().shippingDate);

View file

@ -177,6 +177,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
DetermineBasalResult determineBasalResult = determineBasalAdapterJS.invoke(); DetermineBasalResult determineBasalResult = determineBasalAdapterJS.invoke();
// Fix bug determine basal // Fix bug determine basal
if (determineBasalResult.rate == 0d && determineBasalResult.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress()) determineBasalResult.changeRequested = false; if (determineBasalResult.rate == 0d && determineBasalResult.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress()) determineBasalResult.changeRequested = false;
// limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResult.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRate()) < 0.1)
determineBasalResult.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResult.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
determineBasalResult.changeRequested = false;
}
determineBasalResult.iob = iobTotal; determineBasalResult.iob = iobTotal;

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.Overview.Dialogs; package info.nightscout.androidaps.plugins.Overview.Dialogs;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -89,7 +90,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
final Double finalInsulin = insulin; final Double finalInsulin = insulin;
final int finalDurationInMinutes = durationInMinutes; final int finalDurationInMinutes = durationInMinutes;
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); final Context context = getContext();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(this.getContext().getString(R.string.confirmation)); builder.setTitle(this.getContext().getString(R.string.confirmation));
builder.setMessage(confirmMessage); builder.setMessage(confirmMessage);
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@ -100,7 +102,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
public void run() { public void run() {
PumpEnactResult result = pump.setExtendedBolus(finalInsulin, finalDurationInMinutes); PumpEnactResult result = pump.setExtendedBolus(finalInsulin, finalDurationInMinutes);
if (!result.success) { if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror)); builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
builder.setMessage(result.comment); builder.setMessage(result.comment);
builder.setPositiveButton(getContext().getString(R.string.ok), null); builder.setPositiveButton(getContext().getString(R.string.ok), null);

View file

@ -26,6 +26,8 @@ import android.widget.TextView;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -51,6 +53,7 @@ import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
public class WizardDialog extends DialogFragment implements OnClickListener { public class WizardDialog extends DialogFragment implements OnClickListener {
private static Logger log = LoggerFactory.getLogger(WizardDialog.class);
Button wizardDialogDeliverButton; Button wizardDialogDeliverButton;
TextView correctionInput; TextView correctionInput;
@ -208,40 +211,44 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
final Double finalInsulinAfterConstraints = insulinAfterConstraints; final Double finalInsulinAfterConstraints = insulinAfterConstraints;
final Integer finalCarbsAfterConstraints = carbsAfterConstraints; final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext); if (parentContext != null) {
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
builder.setMessage(confirmMessage); builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setMessage(confirmMessage);
public void onClick(DialogInterface dialog, int id) { builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) { public void onClick(DialogInterface dialog, int id) {
final ConfigBuilderPlugin pump = MainApp.getConfigBuilder(); if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
mHandler.post(new Runnable() { final ConfigBuilderPlugin pump = MainApp.getConfigBuilder();
@Override mHandler.post(new Runnable() {
public void run() { @Override
PumpEnactResult result = pump.deliverTreatmentFromBolusWizard( public void run() {
parentContext, PumpEnactResult result = pump.deliverTreatmentFromBolusWizard(
finalInsulinAfterConstraints, parentContext,
finalCarbsAfterConstraints, finalInsulinAfterConstraints,
SafeParse.stringToDouble(bgInput.getText().toString()), finalCarbsAfterConstraints,
"Manual", SafeParse.stringToDouble(bgInput.getText().toString()),
SafeParse.stringToInt(carbTimeEdit.getText().toString()), "Manual",
boluscalcJSON SafeParse.stringToInt(carbTimeEdit.getText().toString()),
); boluscalcJSON
if (!result.success) { );
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext); if (!result.success) {
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror)); AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
builder.setMessage(result.comment); builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null); builder.setMessage(result.comment);
builder.show(); builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
builder.show();
}
} }
} });
}); }
} }
} });
}); builder.setNegativeButton(getString(R.string.cancel), null);
builder.setNegativeButton(getString(R.string.cancel), null); builder.show();
builder.show(); dismiss();
dismiss(); } else {
log.error("parentContext == null");
}
} }
break; break;
} }

View file

@ -247,6 +247,7 @@ public class OverviewFragment extends Fragment {
} }
}; };
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L); sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
updateGUIIfVisible();
} }
@Subscribe @Subscribe

View file

@ -12,6 +12,7 @@ import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.text.Normalizer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -226,11 +227,16 @@ public class SmsCommunicatorPlugin implements PluginBase {
bolusWaitingForConfirmation = null; bolusWaitingForConfirmation = null;
newSms.processed = true; newSms.processed = true;
} }
smsManager.sendTextMessage(newSms.phoneNumber, null, newSms.text, null, null); smsManager.sendTextMessage(newSms.phoneNumber, null, stripAccents(newSms.text), null, null);
messages.add(newSms); messages.add(newSms);
} }
MainApp.bus().post(new EventSmsCommunicatorUpdateGui()); MainApp.bus().post(new EventSmsCommunicatorUpdateGui());
} }
public static String stripAccents(String s)
{
s = Normalizer.normalize(s, Normalizer.Form.NFD);
s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
return s;
}
} }

View file

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View file

@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015 #Thu Aug 18 17:59:31 CEST 2016
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip