Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into pumpstatus2

This commit is contained in:
AdrianLxM 2017-02-13 02:18:32 +01:00
commit 665f662f3a
82 changed files with 1274 additions and 648 deletions

6
.gitignore vendored
View file

@ -1,9 +1,9 @@
*.iml
wear/wear.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
*.apk
build/
.idea/

View file

@ -1 +0,0 @@
AndroidAPS

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View file

@ -1,3 +0,0 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View file

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/wear" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

View file

@ -1,13 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintLabelFor" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintRtlHardcoded" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintUselessParent" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintValidFragment" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
</profile>
</component>

View file

@ -1,7 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<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" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/AndroidAPS.iml" filepath="$PROJECT_DIR$/AndroidAPS.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/wear/wear.iml" filepath="$PROJECT_DIR$/wear/wear.iml" />
</modules>
</component>
</project>

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View file

@ -44,7 +44,7 @@ android {
minSdkVersion 21
targetSdkVersion 23
versionCode 1100
versionName "1.1d"
versionName "1.1e"
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
lintOptions {
@ -105,17 +105,29 @@ android {
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
dependencies {
wearWearApp project(path: ':wear', configuration: 'fullRelease')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile "com.android.support:design:23.4.0"
compile "com.android.support:percent:23.4.0"
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.squareup:otto:1.3.7'
compile 'com.j256.ormlite:ormlite-core:4.46'
@ -134,4 +146,6 @@ dependencies {
androidTestCompile 'org.mockito:mockito-core:2.+'
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
compile(name:'android-edittext-validator-v1.3.4-mod', ext:'aar')
}

Binary file not shown.

View file

@ -25,19 +25,8 @@ public class Constants {
public static final long keepAliveMsecs = 5 * 60 * 1000L;
// SMS COMMUNICATOR
public static final long remoteBolusMinDistance = 15 * 60 * 1000L;
// AMA
public static final int MAX_DAILY_SAFETY_MULTIPLIER = 3;
public static final int CURRENT_BASAL_SAFETY_MULTIPLIER = 4;
public static final int BOLUSSNOOZE_DIA_ADVISOR = 2;
public static final double AUTOSENS_MAX = 1.2d;
public static final double AUTOSENS_MIN = 0.7d;
public static final double MIN_5M_CARBIMPACT = 3d;
// Circadian Percentage Profile
public static final int CPP_MIN_PERCENTAGE = 50;
public static final int CPP_MAX_PERCENTAGE = 200;

View file

@ -1,15 +1,16 @@
package info.nightscout.androidaps;
import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
@ -17,6 +18,10 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeModule;
@ -29,10 +34,9 @@ import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
import info.nightscout.androidaps.tabs.SlidingTabLayout;
import info.nightscout.androidaps.tabs.TabPageAdapter;
import info.nightscout.utils.LogDialog;
import info.nightscout.utils.ImportExportPrefs;
import info.nightscout.utils.LocaleHelper;
@ -145,6 +149,9 @@ public class MainActivity extends AppCompatActivity {
ImportExportPrefs.verifyStoragePermissions(this);
ImportExportPrefs.importSharedPreferences(this);
break;
case R.id.nav_show_logcat:
LogDialog.showLogcat(this);
break;
// case R.id.nav_test_alarm:
// final int REQUEST_CODE_ASK_PERMISSIONS = 2355;
// int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.SYSTEM_ALERT_WINDOW);
@ -258,4 +265,21 @@ public class MainActivity extends AppCompatActivity {
}
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if ( v instanceof EditText) {
Rect outRect = new Rect();
v.getGlobalVisibleRect(outRect);
if (!outRect.contains((int)event.getRawX(), (int)event.getRawY())) {
v.clearFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
}
return super.dispatchTouchEvent(event);
}
}

View file

@ -90,7 +90,7 @@ public class MainApp extends Application {
pluginsList.add(SimpleProfileFragment.getPlugin());
pluginsList.add(LocalProfileFragment.getPlugin());
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
pluginsList.add(TempTargetRangeFragment.getPlugin());
if (Config.APS) pluginsList.add(TempTargetRangeFragment.getPlugin());
pluginsList.add(TreatmentsFragment.getPlugin());
pluginsList.add(TempBasalsFragment.getPlugin());
pluginsList.add(SafetyFragment.getPlugin());

View file

@ -11,6 +11,7 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase;
@ -53,10 +54,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
if (pref instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getTitle().toString().toLowerCase().contains("password"))
{
if (pref.getKey().contains("danar_password")) {
pref.setSummary("******");
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
pref.setSummary(editTextPref.getText());
}
}
@ -90,7 +91,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_closedmode);
if (Config.OPENAPSENABLED)
addPreferencesFromResource(R.xml.pref_openapsma);
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS))
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS))
addPreferencesFromResource(R.xml.pref_openapsama);
addPreferencesFromResource(R.xml.pref_profile);
if (Config.DANAR) {

View file

@ -31,4 +31,6 @@ public interface Intents {
String ACTION_NEW_BG_ESTIMATE_NO_DATA = "com.eveningoutpost.dexdrip.BgEstimateNoData";
String NS_EMULATOR = "com.eveningoutpost.dexdrip.NS_EMULATOR";
String ACTION_REMOTE_CALIBRATION = "com.eveningoutpost.dexdrip.NewCalibration";
}

View file

@ -6,6 +6,14 @@ import android.support.annotation.Nullable;
import android.text.Html;
import android.text.Spanned;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -21,6 +29,7 @@ import info.nightscout.utils.Round;
*/
public class GlucoseStatus {
private static Logger log = LoggerFactory.getLogger(GlucoseStatus.class);
public double glucose = 0d;
public double delta = 0d;
public double avgdelta = 0d;
@ -81,9 +90,9 @@ public class GlucoseStatus {
BgReading then = data.get(i);
long then_date = then.timeIndex;
double avgdelta = 0;
int minutesago;
long minutesago;
minutesago = Math.round((now_date - then_date) / (1000 * 60));
minutesago = Math.round((now_date - then_date) / (1000d * 60));
// multiply by 5 to get the same units as delta, i.e. mg/dL/5m
change = now.value - then.value;
avgdelta = change / minutesago * 5;
@ -124,6 +133,48 @@ public class GlucoseStatus {
return status.round();
}
/*
* Return last BgReading from database or null if db is empty
*/
@Nullable
public static BgReading lastBg() {
List<BgReading> bgList = null;
try {
Dao<BgReading, Long> daoBgReadings = MainApp.getDbHelper().getDaoBgReadings();
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
queryBuilder.orderBy("timeIndex", false);
queryBuilder.limit(1L);
queryBuilder.where().gt("value", 38);
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
bgList = daoBgReadings.query(preparedQuery);
} catch (SQLException e) {
log.debug(e.getMessage(), e);
}
if (bgList != null && bgList.size() > 0)
return bgList.get(0);
else
return null;
}
/*
* Return bg reading if not old ( <9 min )
* or null if older
*/
@Nullable
public static BgReading actualBg() {
BgReading lastBg = lastBg();
if (lastBg == null)
return null;
if (lastBg.timeIndex > new Date().getTime() - 9 * 60 * 1000)
return lastBg;
return null;
}
public static double average(ArrayList<Double> array) {
double sum = 0d;

View file

@ -18,14 +18,13 @@ import info.nightscout.client.data.NSProfile;
public class MealData {
public double boluses = 0d;
public double carbs = 0d;
public double mealCOB = 0.0d; // TODO: add calculation for AMA
public double mealCOB = 0.0d;
public void addTreatment(Treatment treatment) {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
if (profile == null) return;
// TODO: not sure how much data do i need for AMA
List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime((long) (new Date().getTime() - 60 * 60 * 1000L * profile.getDia() * 2), false);
long now = new Date().getTime();

View file

@ -172,48 +172,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return getDao(DanaRHistoryRecord.class);
}
/*
* Return last BgReading from database or null if db is empty
*/
@Nullable
public BgReading lastBg() {
List<BgReading> bgList = null;
try {
Dao<BgReading, Long> daoBgReadings = getDaoBgReadings();
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
queryBuilder.orderBy("timeIndex", false);
queryBuilder.limit(1L);
queryBuilder.where().gt("value", 38);
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
bgList = daoBgReadings.query(preparedQuery);
} catch (SQLException e) {
log.debug(e.getMessage(), e);
}
if (bgList != null && bgList.size() > 0)
return bgList.get(0);
else
return null;
}
/*
* Return bg reading if not old ( <9 min )
* or null if older
*/
@Nullable
public BgReading actualBg() {
BgReading lastBg = lastBg();
if (lastBg == null)
return null;
if (lastBg.timeIndex > new Date().getTime() - 9 * 60 * 1000)
return lastBg;
return null;
}
public List<BgReading> getBgreadingsDataFromTime(long mills, boolean ascending) {
try {
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
@ -299,7 +257,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
Where where = queryBuilder.where();
where.eq("_id", _id);
queryBuilder.limit(10);
queryBuilder.limit(10L);
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
List<Treatment> trList = daoTreatments.query(preparedQuery);
if (trList.size() != 1) {
@ -323,7 +281,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
Where where = queryBuilder.where();
where.eq("timeIndex", timeIndex);
queryBuilder.limit(10);
queryBuilder.limit(10L);
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
List<Treatment> trList = daoTreatments.query(preparedQuery);
if (trList.size() != 1) {

View file

@ -17,6 +17,8 @@ import info.nightscout.client.data.NSProfile;
public interface PumpInterface {
boolean isInitialized();
boolean isSuspended();
boolean isBusy();
boolean isTempBasalInProgress();
boolean isExtendedBoluslInProgress();

View file

@ -94,19 +94,19 @@ public class ActionsFragment extends Fragment implements FragmentBase, View.OnCl
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized())
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
profileSwitch.setVisibility(View.GONE);
else
profileSwitch.setVisibility(View.VISIBLE);
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized())
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
extendedBolus.setVisibility(View.GONE);
else
extendedBolus.setVisibility(View.VISIBLE);
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized())
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
tempBasal.setVisibility(View.GONE);
else
tempBasal.setVisibility(View.VISIBLE);
if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized())
if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
fill.setVisibility(View.GONE);
else
fill.setVisibility(View.VISIBLE);

View file

@ -151,7 +151,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
}
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
builder.setTitle(MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
builder.setMessage(result.comment);
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
builder.show();

View file

@ -4,22 +4,27 @@ package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.andreabaccega.widget.FormEditText;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
@ -34,24 +39,24 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;
public class CircadianPercentageProfileFragment extends Fragment implements FragmentBase {
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class);
private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin();
private Object snackbarCaller;
public static CircadianPercentageProfilePlugin getPlugin() {
return circadianPercentageProfilePlugin;
}
EditText diaView;
FormEditText diaView;
RadioButton mgdlView;
RadioButton mmolView;
EditText targetlowView;
EditText targethighView;
EditText percentageView;
EditText timeshiftView;
FormEditText targetlowView;
FormEditText targethighView;
FormEditText percentageView;
FormEditText timeshiftView;
TextView profileView;
TextView baseprofileIC;
TextView baseprofileBasal;
@ -64,19 +69,25 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
ImageView iceditIcon;
ImageView isfeditIcon;
BasalEditDialog basalEditDialog;
FrameLayout fl;
Snackbar mSnackBar;
static Boolean percentageViewHint = true;
static Boolean timeshiftViewHint = true;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.circadianpercentageprofile_fragment, container, false);
diaView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_dia);
fl = (FrameLayout) layout.findViewById(R.id.circadianpercentageprofile_framelayout);
fl.requestFocusFromTouch();
diaView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_dia);
mgdlView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mgdl);
mmolView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mmol);
targetlowView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_targetlow);
targethighView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_targethigh);
percentageView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_percentage);
timeshiftView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
targetlowView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_targetlow);
targethighView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_targethigh);
percentageView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_percentage);
timeshiftView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
profileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_profileview);
baseprofileBasal = (TextView) layout.findViewById(R.id.circadianpercentageprofile_baseprofilebasal);
baseprofileBasalLayout = (LinearLayout) layout.findViewById(R.id.circadianpercentageprofile_baseprofilebasal_layout);
@ -137,23 +148,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
}
});
timeshiftView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if (b)
ToastUtils.showToastInUiThread(getContext(), getString(R.string.timeshift_hint));
}
});
percentageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if (b)
ToastUtils.showToastInUiThread(getContext(), getString(R.string.percentagefactor_hint));
}
});
timeIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -201,6 +195,76 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
}
});
timeshiftView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) {
if(mSnackBar!=null && snackbarCaller == timeshiftView){
mSnackBar.dismiss();
}
timeshiftView.clearFocus();
fl.requestFocusFromTouch();
}
else {
if (timeshiftViewHint) {
customSnackbar(view, getString(R.string.timeshift_hint), timeshiftView);
}
}
}
});
percentageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) {
if(mSnackBar!=null && snackbarCaller == percentageView){
mSnackBar.dismiss();
}
percentageView.clearFocus();
fl.requestFocusFromTouch();
}
else {
if (percentageViewHint) {
customSnackbar(view, getString(R.string.percentagefactor_hint), percentageView);
}
}
}
});
diaView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) {
diaView.clearFocus();
fl.requestFocusFromTouch();
}
}
});
targethighView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) {
targethighView.clearFocus();
fl.requestFocusFromTouch();
}
}
});
targetlowView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) {
targetlowView.clearFocus();
fl.requestFocusFromTouch();
}
}
});
TextWatcher textWatch = new TextWatcher() {
@ -217,15 +281,30 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
public void onTextChanged(CharSequence s, int start,
int before, int count) {
if (percentageView.testValidity()) {
if (SafeParse.stringToInt(percentageView.getText().toString()) == 0) {
circadianPercentageProfilePlugin.percentage = 100;
} else {
circadianPercentageProfilePlugin.percentage = SafeParse.stringToInt(percentageView.getText().toString());
}
circadianPercentageProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
circadianPercentageProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
circadianPercentageProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
updateProfileInfo();
}
if (timeshiftView.testValidity()) {
circadianPercentageProfilePlugin.timeshift = SafeParse.stringToInt(timeshiftView.getText().toString());
updateProfileInfo();
}
if (diaView.testValidity()) {
circadianPercentageProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
updateProfileInfo();
}
if (targethighView.testValidity()) {
circadianPercentageProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
updateProfileInfo();
}
if (targetlowView.testValidity()) {
circadianPercentageProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
updateProfileInfo();
}
circadianPercentageProfilePlugin.storeSettings();
updateProfileInfo();
}
@ -242,6 +321,35 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
return layout;
}
private void customSnackbar(View view, final String Msg, Object snackbarCaller) {
if(mSnackBar!= null) mSnackBar.dismiss();
this.snackbarCaller = snackbarCaller;
if (timeshiftViewHint || percentageViewHint) {
//noinspection WrongConstant
mSnackBar = Snackbar.make(view, Msg, 7000)
.setActionTextColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo))
.setAction(getString(R.string.dont_show_again), new View.OnClickListener() {
@Override
public void onClick(View v) {
if (Msg.equals(getString(R.string.percentagefactor_hint))) {
percentageViewHint = false;
} else if (Msg.equals(getString(R.string.timeshift_hint))) {
timeshiftViewHint = false;
}
}
});
view = mSnackBar.getView();
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams();
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
view.setLayoutParams(params);
view.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardview_dark_background));
TextView mainTextView = (TextView) (view).findViewById(android.support.design.R.id.snackbar_text);
mainTextView.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.mdtp_white));
mSnackBar.show();
}
}
private void updateProfileInfo() {
StringBuilder sb = new StringBuilder();
sb.append("<h3>");
@ -274,6 +382,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
basalEditDialog.dismiss();
}
basalEditDialog = null;
fl.requestFocusFromTouch();
}
public static class BasalEditDialog extends DialogFragment {
@ -354,6 +463,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
basalEditDialog = null;
MainApp.bus().unregister(this);
fl.requestFocusFromTouch();
}
@Override
@ -361,6 +471,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
super.onResume();
MainApp.bus().register(this);
onStatusEvent(null);
fl.requestFocusFromTouch();
}
@Subscribe
@ -370,7 +481,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!MainApp.getConfigBuilder().isInitialized() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
profileswitchButton.setVisibility(View.GONE);
} else {
profileswitchButton.setVisibility(View.VISIBLE);

View file

@ -64,7 +64,6 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
// TODO: sorting
// TODO: Toast and sound when command failed
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,

View file

@ -18,6 +18,10 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
@ -73,7 +77,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
static ArrayList<PluginBase> pluginList;
static Date lastDeviceStatusUpload = new Date(0);
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledPost = null;
PowerManager.WakeLock mWakeLock;
@ -334,6 +339,16 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
return activePump.isInitialized();
}
@Override
public boolean isSuspended() {
return activePump.isSuspended();
}
@Override
public boolean isBusy() {
return activePump.isBusy();
}
@Override
public boolean isTempBasalInProgress() {
return activePump.isTempBasalInProgress();
@ -596,6 +611,17 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
result.comment = MainApp.sResources.getString(R.string.pumpNotInitialized);
result.enacted = false;
result.success = false;
log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized));
return result;
}
if (isSuspended()) {
result = new PumpEnactResult();
result.comment = MainApp.sResources.getString(R.string.pumpsuspended);
result.enacted = false;
result.success = false;
log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpsuspended));
return result;
}
if (Config.logCongigBuilderActions)
@ -789,22 +815,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
@Subscribe
public void onStatusEvent(final EventNewBG ev) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
// Give some time to Loop
try {
Thread.sleep(120 * 1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
// if status not uploaded, upload pump status only
if (new Date().getTime() - lastDeviceStatusUpload.getTime() > 120 * 1000L) {
uploadDeviceStatus();
}
}
});
t.start();
uploadDeviceStatus(120);
}
public void uploadTempBasalStartAbsolute(Double absolute, double durationInMinutes) {
@ -910,7 +921,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
}
public void uploadDeviceStatus() {
public void doUploadDeviceStatus() {
DeviceStatus deviceStatus = new DeviceStatus();
try {
LoopPlugin.LastRun lastRun = LoopPlugin.lastRun;
@ -951,13 +962,28 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
deviceStatus.created_at = DateUtil.toISOString(new Date());
deviceStatus.sendToNSClient();
lastDeviceStatusUpload = new Date();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
static public void uploadDeviceStatus(int sec) {
class PostRunnable implements Runnable {
public void run() {
MainApp.getConfigBuilder().doUploadDeviceStatus();
scheduledPost = null;
}
}
// prepare task for execution
// cancel waiting task to prevent sending multiple posts
if (scheduledPost != null)
scheduledPost.cancel(false);
Runnable task = new PostRunnable();
scheduledPost = worker.schedule(task, sec, TimeUnit.SECONDS);
log.debug("Scheduling devicestatus upload in " + sec + " sec");
}
public void uploadBolusWizardRecord(Treatment t, double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
JSONObject data = new JSONObject();
try {

View file

@ -219,7 +219,7 @@ public class DanaRFragment extends Fragment implements FragmentBase {
Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime();
double agoHours = agoMsec / 60d / 60d / 1000d;
if (agoHours < 6) // max 6h back
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(getPlugin().getDanaRPump().lastBolusAmount) + " U");
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(getPlugin().getDanaRPump().lastBolusAmount) + " U");
else lastBolusView.setText("");
}
@ -242,7 +242,7 @@ public class DanaRFragment extends Fragment implements FragmentBase {
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
iobView.setText(pump.iob + " U");
if (pump.isNewPump) {
firmwareView.setText(String.format(getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
} else {
firmwareView.setText("OLD");
}

View file

@ -85,7 +85,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
pumpDescription.bolusStep = 0.05d;
pumpDescription.isExtendedBolusCapable = true;
pumpDescription.extendedBolusStep = 0.1d;
pumpDescription.extendedBolusStep = 0.05d;
pumpDescription.isTempBasalCapable = true;
pumpDescription.lowTempBasalStyle = PumpDescription.PERCENT;
@ -211,6 +211,17 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return getDanaRPump().lastConnection.getTime() > 0 && getDanaRPump().isExtendedBolusEnabled;
}
@Override
public boolean isSuspended() {
return getDanaRPump().pumpSuspended;
}
@Override
public boolean isBusy() {
if (sExecutionService == null) return false;
return sExecutionService.isConnected() || sExecutionService.isConnecting();
}
// Pump interface
@Override
public boolean isTempBasalInProgress() {
@ -258,6 +269,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (!isInitialized())
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
DanaRPump pump = getDanaRPump();
if (pump.pumpProfiles == null)
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
int basalValues = pump.basal48Enable ? 48 : 24;
int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60;
for (int h = 0; h < basalValues; h++) {
@ -290,17 +303,19 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override
public double getTempBasalAbsoluteRate() {
if (isRealTempBasalInProgress()) {
if (getRealTempBasal().isAbsolute) {
return getRealTempBasal().absolute;
TempBasal tb = getRealTempBasal();
if (tb != null) {
if (tb.isAbsolute) {
return tb.absolute;
} else {
Double baseRate = getBaseBasalRate();
Double tempRate = baseRate * (getRealTempBasal().percent / 100d);
Double tempRate = baseRate * (tb.percent / 100d);
return tempRate;
}
}
if (isExtendedBoluslInProgress() && useExtendedBoluses) {
return getBaseBasalRate() + getExtendedBolus().absolute;
TempBasal eb = getExtendedBolus();
if (eb != null && useExtendedBoluses) {
return getBaseBasalRate() + eb.absolute;
}
return 0;
}
@ -492,7 +507,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
// Compare with extended rate in progress
if (Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < 0.02D) { // Allow some rounding diff
if (isExtendedBoluslInProgress() && Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
// correct extended already set
result.success = true;
result.absolute = getDanaRPump().extendedBolusAbsoluteRate;
@ -701,17 +716,18 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
JSONObject extended = new JSONObject();
try {
battery.put("percent", getDanaRPump().batteryRemaining);
status.put("status", "normal");
status.put("status", getDanaRPump().pumpSuspended ? "suspended" : "normal");
status.put("timestamp", DateUtil.toISOString(getDanaRPump().lastConnection));
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
extended.put("PumpIOB", getDanaRPump().iob);
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
if (isTempBasalInProgress()) {
TempBasal tb = getTempBasal();
if (tb != null) {
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
extended.put("TempBasalStart", getTempBasal().timeStart.toLocaleString());
extended.put("TempBasalRemaining", getTempBasal().getPlannedRemainingMinutes());
extended.put("IsExtended", getTempBasal().isExtended);
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
extended.put("IsExtended", tb.isExtended);
}
extended.put("BaseBasalRate", getBaseBasalRate());
try {

View file

@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;
public class DanaRStatsActivity extends Activity {
@ -185,7 +186,7 @@ public class DanaRStatsActivity extends Activity {
TableRow tr_head = new TableRow(this);
tr_head.setBackgroundColor(Color.DKGRAY);
tr_head.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_date = new TextView(this);
@ -215,7 +216,7 @@ public class DanaRStatsActivity extends Activity {
// add stats headers to tables
tl.addView(tr_head, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// cumulative table
@ -223,7 +224,7 @@ public class DanaRStatsActivity extends Activity {
TableRow ctr_head = new TableRow(this);
ctr_head.setBackgroundColor(Color.DKGRAY);
ctr_head.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_cum_amount_days = new TextView(this);
@ -243,7 +244,7 @@ public class DanaRStatsActivity extends Activity {
// add cummulative headers to tables
ctl.addView(ctr_head, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// expontial table
@ -251,7 +252,7 @@ public class DanaRStatsActivity extends Activity {
TableRow etr_head = new TableRow(this);
etr_head.setBackgroundColor(Color.DKGRAY);
etr_head.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_exp_weight = new TextView(this);
@ -271,7 +272,7 @@ public class DanaRStatsActivity extends Activity {
// add expontial headers to tables
etl.addView(etr_head, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
reloadButton.setOnClickListener(new View.OnClickListener() {
@ -366,7 +367,7 @@ public class DanaRStatsActivity extends Activity {
return;
}
else {
magicNumber = Double.parseDouble(TBB);
magicNumber = SafeParse.stringToDouble(TBB);
}
magicNumber *=2;
@ -386,7 +387,7 @@ public class DanaRStatsActivity extends Activity {
if(i%2!=0) tr.setBackgroundColor(Color.DKGRAY);
tr.setId(100+i);
tr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// Here create the TextView dynamically
@ -422,7 +423,7 @@ public class DanaRStatsActivity extends Activity {
// add stats rows to tables
tl.addView(tr, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
sum = sum + tdd;
@ -433,7 +434,7 @@ public class DanaRStatsActivity extends Activity {
if(i%2==0) ctr.setBackgroundColor(Color.DKGRAY);
ctr.setId(700+i);
ctr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// Here create the TextView dynamically
@ -457,7 +458,7 @@ public class DanaRStatsActivity extends Activity {
// add cummulative rows to tables
ctl.addView(ctr, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
}
@ -493,7 +494,7 @@ public class DanaRStatsActivity extends Activity {
if(i%2!=0) etr.setBackgroundColor(Color.DKGRAY);
etr.setId(1100+i);
etr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// Here create the TextView dynamically
@ -521,7 +522,7 @@ public class DanaRStatsActivity extends Activity {
// add exponentail rows to tables
etl.addView(etr, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
}
});

View file

@ -276,6 +276,7 @@ public class ExecutionService extends Service {
private boolean getPumpStatus() {
try {
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.gettingpumpstatus)));
MsgStatus statusMsg = new MsgStatus();
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
@ -336,6 +337,7 @@ public class ExecutionService extends Service {
danaRPump.lastConnection = now;
MainApp.bus().post(new EventDanaRNewStatus());
MainApp.bus().post(new EventInitializationChanged());
MainApp.getConfigBuilder().uploadDeviceStatus(60);
} catch (Exception e) {
e.printStackTrace();
}
@ -345,30 +347,37 @@ public class ExecutionService extends Service {
public boolean tempBasal(int percent, int durationInHours) {
connect("tempBasal");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}
public boolean tempBasalStop() {
connect("tempBasalStop");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}
public boolean extendedBolus(double insulin, int durationInHalfHours) {
connect("extendedBolus");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}
public boolean extendedBolusStop() {
connect("extendedBolusStop");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
return true;
@ -482,6 +491,7 @@ public class ExecutionService extends Service {
public boolean updateBasalsInPump(final NSProfile profile) {
connect("updateBasalsInPump");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.updatingbasalrates)));
double[] basal = buildDanaRProfileRecord(profile);
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
mSerialIOThread.sendMessage(msgSet);
@ -489,6 +499,7 @@ public class ExecutionService extends Service {
mSerialIOThread.sendMessage(msgActivate);
danaRPump.lastSettingsRead = new Date(0); // force read full settings
getPumpStatus();
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}

View file

@ -4,12 +4,20 @@ public class EventDanaRConnectionStatus {
public static final int CONNECTING = 0;
public static final int CONNECTED = 1;
public static final int DISCONNECTED = 2;
public static final int PERFORMING = 3;
public int sStatus = DISCONNECTED;
public int sSecondsElapsed = 0;
public String sAction = "";
public EventDanaRConnectionStatus(int status, int secondsElapsed) {
sStatus = status;
sSecondsElapsed = secondsElapsed;
}
public EventDanaRConnectionStatus(int status, int secondsElapsed, String action) {
sStatus = status;
sSecondsElapsed = secondsElapsed;
sAction = action;
}
}

View file

@ -240,7 +240,7 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
iobView.setText(pump.iob + " U");
if (pump.isNewPump) {
firmwareView.setText(String.format(getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
} else {
firmwareView.setText("OLD");
}

View file

@ -85,7 +85,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
pumpDescription.bolusStep = 0.1d;
pumpDescription.isExtendedBolusCapable = true;
pumpDescription.extendedBolusStep = 0.1d;
pumpDescription.extendedBolusStep = 0.05d;
pumpDescription.isTempBasalCapable = true;
pumpDescription.lowTempBasalStyle = PumpDescription.PERCENT;
@ -211,6 +211,17 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
return getDanaRPump().lastConnection.getTime() > 0 && !getDanaRPump().isConfigUD && !getDanaRPump().isEasyModeEnabled && getDanaRPump().isExtendedBolusEnabled;
}
@Override
public boolean isSuspended() {
return false;
}
@Override
public boolean isBusy() {
if (sExecutionService == null) return false;
return sExecutionService.isConnected() || sExecutionService.isConnecting();
}
// Pump interface
@Override
public boolean isTempBasalInProgress() {
@ -258,6 +269,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
if (!isInitialized())
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
DanaRKoreanPump pump = getDanaRPump();
if (pump.pumpProfiles == null)
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
int basalValues = pump.basal48Enable ? 48 : 24;
int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60;
for (int h = 0; h < basalValues; h++) {
@ -290,17 +303,19 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override
public double getTempBasalAbsoluteRate() {
if (isRealTempBasalInProgress()) {
if (getRealTempBasal().isAbsolute) {
return getRealTempBasal().absolute;
TempBasal tb = getRealTempBasal();
if (tb != null) {
if (tb.isAbsolute) {
return tb.absolute;
} else {
Double baseRate = getBaseBasalRate();
Double tempRate = baseRate * (getRealTempBasal().percent / 100d);
Double tempRate = baseRate * (tb.percent / 100d);
return tempRate;
}
}
if (isExtendedBoluslInProgress() && useExtendedBoluses) {
return getBaseBasalRate() + getExtendedBolus().absolute;
TempBasal eb = getExtendedBolus();
if (eb != null && useExtendedBoluses) {
return getBaseBasalRate() + eb.absolute;
}
return 0;
}
@ -492,7 +507,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
}
// Compare with extended rate in progress
if (Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < 0.02D) { // Allow some rounding diff
if (isExtendedBoluslInProgress() && Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
// correct extended already set
result.success = true;
result.absolute = getDanaRPump().extendedBolusAbsoluteRate;
@ -707,11 +722,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
extended.put("PumpIOB", getDanaRPump().iob);
// extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
// extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
if (isTempBasalInProgress()) {
TempBasal tb = getTempBasal();
if (tb != null) {
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
extended.put("TempBasalStart", getTempBasal().timeStart.toLocaleString());
extended.put("TempBasalRemaining", getTempBasal().getPlannedRemainingMinutes());
extended.put("IsExtended", getTempBasal().isExtended);
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
extended.put("IsExtended", tb.isExtended);
}
extended.put("BaseBasalRate", getBaseBasalRate());
try {

View file

@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatu
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;
public class DanaRStatsActivity extends Activity {
@ -185,7 +186,7 @@ public class DanaRStatsActivity extends Activity {
TableRow tr_head = new TableRow(this);
tr_head.setBackgroundColor(Color.DKGRAY);
tr_head.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_date = new TextView(this);
@ -215,7 +216,7 @@ public class DanaRStatsActivity extends Activity {
// add stats headers to tables
tl.addView(tr_head, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// cumulative table
@ -223,7 +224,7 @@ public class DanaRStatsActivity extends Activity {
TableRow ctr_head = new TableRow(this);
ctr_head.setBackgroundColor(Color.DKGRAY);
ctr_head.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_cum_amount_days = new TextView(this);
@ -243,7 +244,7 @@ public class DanaRStatsActivity extends Activity {
// add cummulative headers to tables
ctl.addView(ctr_head, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// expontial table
@ -251,7 +252,7 @@ public class DanaRStatsActivity extends Activity {
TableRow etr_head = new TableRow(this);
etr_head.setBackgroundColor(Color.DKGRAY);
etr_head.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_exp_weight = new TextView(this);
@ -271,7 +272,7 @@ public class DanaRStatsActivity extends Activity {
// add expontial headers to tables
etl.addView(etr_head, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
reloadButton.setOnClickListener(new View.OnClickListener() {
@ -366,7 +367,7 @@ public class DanaRStatsActivity extends Activity {
return;
}
else {
magicNumber = Double.parseDouble(TBB);
magicNumber = SafeParse.stringToDouble(TBB);
}
magicNumber *=2;
@ -386,7 +387,7 @@ public class DanaRStatsActivity extends Activity {
if(i%2!=0) tr.setBackgroundColor(Color.DKGRAY);
tr.setId(100+i);
tr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// Here create the TextView dynamically
@ -422,7 +423,7 @@ public class DanaRStatsActivity extends Activity {
// add stats rows to tables
tl.addView(tr, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
sum = sum + tdd;
@ -433,7 +434,7 @@ public class DanaRStatsActivity extends Activity {
if(i%2==0) ctr.setBackgroundColor(Color.DKGRAY);
ctr.setId(700+i);
ctr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// Here create the TextView dynamically
@ -457,7 +458,7 @@ public class DanaRStatsActivity extends Activity {
// add cummulative rows to tables
ctl.addView(ctr, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
}
@ -493,7 +494,7 @@ public class DanaRStatsActivity extends Activity {
if(i%2!=0) etr.setBackgroundColor(Color.DKGRAY);
etr.setId(1100+i);
etr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
// Here create the TextView dynamically
@ -521,7 +522,7 @@ public class DanaRStatsActivity extends Activity {
// add exponentail rows to tables
etl.addView(etr, new TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
}
});

View file

@ -272,6 +272,7 @@ public class ExecutionService extends Service {
private boolean getPumpStatus() {
try {
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.gettingpumpstatus)));
//MsgStatus statusMsg = new MsgStatus();
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
@ -330,6 +331,7 @@ public class ExecutionService extends Service {
danaRKoreanPump.lastConnection = now;
MainApp.bus().post(new EventDanaRNewStatus());
MainApp.bus().post(new EventInitializationChanged());
MainApp.getConfigBuilder().uploadDeviceStatus(60);
} catch (Exception e) {
e.printStackTrace();
}
@ -339,32 +341,40 @@ public class ExecutionService extends Service {
public boolean tempBasal(int percent, int durationInHours) {
connect("tempBasal");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}
public boolean tempBasalStop() {
connect("tempBasalStop");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}
public boolean extendedBolus(double insulin, int durationInHalfHours) {
connect("extendedBolus");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}
public boolean extendedBolusStop() {
connect("extendedBolusStop");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}
@ -476,11 +486,13 @@ public class ExecutionService extends Service {
public boolean updateBasalsInPump(final NSProfile profile) {
connect("updateBasalsInPump");
if (!isConnected()) return false;
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.updatingbasalrates)));
double[] basal = buildDanaRProfileRecord(profile);
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
mSerialIOThread.sendMessage(msgSet);
danaRKoreanPump.lastSettingsRead = new Date(0); // force read full settings
getPumpStatus();
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
return true;
}

View file

@ -156,7 +156,7 @@ public class LocalProfileFragment extends Fragment implements FragmentBase {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!MainApp.getConfigBuilder().isInitialized() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
profileswitchButton.setVisibility(View.GONE);
} else {
profileswitchButton.setVisibility(View.VISIBLE);

View file

@ -76,7 +76,14 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Frag
public void onClick(View view) {
switch (view.getId()) {
case R.id.loop_run:
lastRunView.setText(MainApp.sResources.getString(R.string.executing));
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
getPlugin().invoke("Loop button", true);
}
});
thread.start();
break;
}

View file

@ -228,7 +228,7 @@ public class LoopPlugin implements PluginBase {
}
MainApp.bus().post(new EventLoopUpdateGui());
MainApp.getConfigBuilder().uploadDeviceStatus();
MainApp.getConfigBuilder().uploadDeviceStatus(15);
} finally {
if (Config.logFunctionCalls)
log.debug("invoke end");

View file

@ -115,6 +115,16 @@ public class MDIPlugin implements PluginBase, PumpInterface {
return true;
}
@Override
public boolean isSuspended() {
return false;
}
@Override
public boolean isBusy() {
return false;
}
@Override
public boolean isTempBasalInProgress() {
return false;

View file

@ -1,5 +1,8 @@
package info.nightscout.androidaps.plugins.OpenAPSAMA;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,13 +17,14 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.Round;
import info.nightscout.utils.SafeParse;
public class Autosens {
private static Logger log = LoggerFactory.getLogger(Autosens.class);
public static AutosensResult detectSensitivityandCarbAbsorption(List<BgReading> glucose_data, Long mealTime) {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
//console.error(mealTime);
@ -128,7 +132,7 @@ public class Autosens {
if (mealTime != null && bgTime > mealTime) {
// figure out how many carbs that represents
// but always assume at least 3mg/dL/5m (default) absorption
double ci = Math.max(deviation, Constants.MIN_5M_CARBIMPACT);
double ci = Math.max(deviation, SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0")));
double absorbed = ci * profile.getIc(secondsFromMidnight) / sens;
// and add that to the running total carbsAbsorbed
carbsAbsorbed += absorbed;
@ -178,8 +182,8 @@ public class Autosens {
// don't adjust more than 1.5x
double rawRatio = ratio;
ratio = Math.max(ratio, Constants.AUTOSENS_MIN);
ratio = Math.min(ratio, Constants.AUTOSENS_MAX);
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2")));
if (ratio != rawRatio) {
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.SafeParse;
public class DetermineBasalAdapterAMAJS {
private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterAMAJS.class);
@ -209,7 +210,6 @@ public class DetermineBasalAdapterAMAJS {
String units = profile.getUnits();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
boolean autosensAdustTargets = preferences.getBoolean("openapsama_autosens_adjusttargets", false);
mProfile = new V8Object(mV8rt);
mProfile.add("max_iob", maxIob);
@ -222,13 +222,13 @@ public class DetermineBasalAdapterAMAJS {
mProfile.add("target_bg", targetBg);
mProfile.add("carb_ratio", profile.getIc(profile.secondsFromMidnight()));
mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units));
mProfile.add("max_daily_safety_multiplier", Constants.MAX_DAILY_SAFETY_MULTIPLIER);
mProfile.add("current_basal_safety_multiplier", Constants.CURRENT_BASAL_SAFETY_MULTIPLIER);
mProfile.add("max_daily_safety_multiplier", SafeParse.stringToInt(preferences.getString("openapsama_max_daily_safety_multiplier", "3")));
mProfile.add("current_basal_safety_multiplier", SafeParse.stringToInt(preferences.getString("openapsama_max_basal_safety_multiplier", "4")));
mProfile.add("skip_neutral_temps", true);
mProfile.add("current_basal", pump.getBaseBasalRate());
mProfile.add("temptargetSet", tempTargetSet);
mProfile.add("autosens_adjust_targets", autosensAdustTargets);
mProfile.add("min_5m_carbimpact", min_5m_carbimpact);
mProfile.add("autosens_adjust_targets", preferences.getBoolean("openapsama_autosens_adjusttargets", true));
mProfile.add("min_5m_carbimpact", SafeParse.stringToDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0")));
mV8rt.add(PARAM_profile, mProfile);
mCurrentTemp = new V8Object(mV8rt);

View file

@ -235,7 +235,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
lastAutosensResult.ratio, //autosensDataRatio
isTempTarget,
Constants.MIN_5M_CARBIMPACT //min_5m_carbimpact
SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
);

View file

@ -124,7 +124,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Override
public void run() {
if (c.sStatus == c.CONNECTING) {
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
statusView.setText(String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
} else if (c.sStatus == c.CONNECTED) {
statusView.setText(MainApp.sResources.getString(R.string.connected));
} else {

View file

@ -0,0 +1,79 @@
package info.nightscout.androidaps.plugins.Overview.Dialogs;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.XdripCalibrations;
public class CalibrationDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(CalibrationDialog.class);
Button okButton;
PlusMinusEditText bgText;
TextView unitsView;
Context parentContext;
public CalibrationDialog() {
// Required empty public constructor
}
public void setContext(Context context) {
parentContext = context;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.overview_calibration_dialog, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
okButton = (Button) view.findViewById(R.id.overview_calibration_okbutton);
okButton.setOnClickListener(this);
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
Double bg = NSProfile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile.getUnits());
if (profile.getUnits().equals(Constants.MMOL))
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
else
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
unitsView.setText(profile.getUnits());
return view;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.overview_calibration_okbutton:
final Double bg = bgText.getValue();
XdripCalibrations.confirmAndSendCalibration(bg, parentContext);
dismiss();
break;
}
}
}

View file

@ -36,6 +36,7 @@ import java.util.Date;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
@ -278,7 +279,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
else editBg.setStep(0.1d);
// Set BG if not old
BgReading lastBg = MainApp.getDbHelper().actualBg();
BgReading lastBg = GlucoseStatus.actualBg();
if (lastBg != null) {
Double lastBgValue = lastBg.valueToUnits(units);

View file

@ -21,6 +21,7 @@ public class Notification {
public static final int FAILED_UDPATE_PROFILE = 6;
public static final int BASAL_VALUE_BELOW_MINIMUM = 7;
public static final int OLD_NSCLIENT = 8;
public static final int INVALID_PHONE_NUMBER = 9;
public int id;
public Date date;

View file

@ -13,6 +13,7 @@ import android.os.HandlerThread;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
@ -70,17 +71,20 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
import info.nightscout.client.data.NSProfile;
@ -113,7 +117,7 @@ public class OverviewFragment extends Fragment {
TextView iobView;
TextView apsModeView;
TextView tempTargetView;
TextView initializingView;
TextView pumpStatusView;
GraphView bgGraph;
CheckBox showPredictionView;
@ -125,6 +129,7 @@ public class OverviewFragment extends Fragment {
Button cancelTempButton;
Button treatmentButton;
Button wizardButton;
Button calibrationButton;
Button acceptTempButton;
Button quickWizardButton;
@ -158,7 +163,7 @@ public class OverviewFragment extends Fragment {
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
initializingView = (TextView) view.findViewById(R.id.overview_initializing);
pumpStatusView = (TextView) view.findViewById(R.id.overview_initializing);
iobView = (TextView) view.findViewById(R.id.overview_iob);
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
@ -172,6 +177,7 @@ public class OverviewFragment extends Fragment {
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard);
calibrationButton = (Button) view.findViewById(R.id.overview_calibration);
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
@ -233,11 +239,20 @@ public class OverviewFragment extends Fragment {
}
});
calibrationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentManager manager = getFragmentManager();
CalibrationDialog calibrationDialog = new CalibrationDialog();
calibrationDialog.setContext(getContext());
calibrationDialog.show(manager, "CalibrationDialog");
}
});
acceptTempButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MainApp.getConfigBuilder().getActiveLoop().invoke("Accept temp button", false);
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
@ -254,7 +269,7 @@ public class OverviewFragment extends Fragment {
finalLastRun.setByPump = applyResult;
finalLastRun.lastEnact = new Date();
finalLastRun.lastOpenModeAccept = new Date();
MainApp.getConfigBuilder().uploadDeviceStatus();
MainApp.getConfigBuilder().uploadDeviceStatus(15);
ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
if (objectivesPlugin != null) {
objectivesPlugin.manualEnacts++;
@ -273,12 +288,25 @@ public class OverviewFragment extends Fragment {
}
});
pumpStatusView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.getConfigBuilder().updateStatus("RefreshClicked");
}
});
}
});
updateGUI();
return view;
}
void processQuickWizard() {
final BgReading lastBG = MainApp.getDbHelper().lastBg();
final BgReading lastBG = GlucoseStatus.lastBg();
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
return;
final NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
@ -429,16 +457,41 @@ public class OverviewFragment extends Fragment {
}
@Subscribe
public void onStatusEvent(final EventNewBasalProfile ev) { updateGUIIfVisible(); }
public void onStatusEvent(final EventNewBasalProfile ev) {
updateGUIIfVisible();
}
@Subscribe
public void onStatusEvent(final EventTempTargetRangeChange ev) {updateGUIIfVisible();}
public void onStatusEvent(final EventTempTargetRangeChange ev) {
updateGUIIfVisible();
}
@Subscribe
public void onStatusEvent(final EventNewNotification n) { updateNotifications(); }
public void onStatusEvent(final EventNewNotification n) {
updateNotifications();
}
@Subscribe
public void onStatusEvent(final EventDismissNotification n) { updateNotifications(); }
public void onStatusEvent(final EventDismissNotification n) {
updateNotifications();
}
@Subscribe
public void onStatusEvent(final EventDanaRConnectionStatus s) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (s.sStatus == EventDanaRConnectionStatus.CONNECTING)
updatePumpStatus(String.format(getString(R.string.danar_history_connectingfor), s.sSecondsElapsed));
else if (s.sStatus == EventDanaRConnectionStatus.PERFORMING)
updatePumpStatus(s.sAction);
else if (s.sStatus == EventDanaRConnectionStatus.DISCONNECTED)
updatePumpStatus(null);
}
});
}
private void hideTempRecommendation() {
Activity activity = getActivity();
@ -462,18 +515,47 @@ public class OverviewFragment extends Fragment {
});
}
private void updatePumpStatus(String status) {
PumpInterface pump = MainApp.getConfigBuilder();
if (status != null) {
pumpStatusView.setText(status);
pumpStatusView.setVisibility(View.VISIBLE);
} else if (pump.isBusy()) {
pumpStatusView.setText(R.string.pumpbusy);
pumpStatusView.setVisibility(View.VISIBLE);
} else if (pump.isSuspended()) {
// disable all treatment buttons because we are not able to check constraints without profile
wizardButton.setVisibility(View.INVISIBLE);
treatmentButton.setVisibility(View.INVISIBLE);
quickWizardButton.setVisibility(View.INVISIBLE);
pumpStatusView.setText(R.string.pumpsuspendedclicktorefresh);
pumpStatusView.setVisibility(View.VISIBLE);
} else if (!pump.isInitialized()) {
// disable all treatment buttons because we are not able to check constraints without profile
wizardButton.setVisibility(View.INVISIBLE);
treatmentButton.setVisibility(View.INVISIBLE);
quickWizardButton.setVisibility(View.INVISIBLE);
pumpStatusView.setText(R.string.waitingforpump);
pumpStatusView.setVisibility(View.VISIBLE);
} else {
wizardButton.setVisibility(View.VISIBLE);
treatmentButton.setVisibility(View.VISIBLE);
pumpStatusView.setVisibility(View.GONE);
}
}
@SuppressLint("SetTextI18n")
public void updateGUI() {
updateNotifications();
BgReading actualBG = MainApp.getDbHelper().actualBg();
BgReading lastBG = MainApp.getDbHelper().lastBg();
BgReading actualBG = GlucoseStatus.actualBg();
BgReading lastBG = GlucoseStatus.lastBg();
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
initializingView.setText(R.string.noprofileset);
initializingView.setVisibility(View.VISIBLE);
pumpStatusView.setText(R.string.noprofileset);
pumpStatusView.setVisibility(View.VISIBLE);
return;
} else {
initializingView.setVisibility(View.GONE);
pumpStatusView.setVisibility(View.GONE);
}
// Skip if not initialized yet
@ -532,7 +614,7 @@ public class OverviewFragment extends Fragment {
// temp target
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class);
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
if (Config.APS && tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
if (tempTarget != null) {
tempTargetView.setTextColor(Color.BLACK);
@ -564,13 +646,20 @@ public class OverviewFragment extends Fragment {
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested
if (showAcceptButton && pump.isInitialized()) {
if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && ConfigBuilderPlugin.getActiveLoop() != null) {
acceptTempLayout.setVisibility(View.VISIBLE);
acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
} else {
acceptTempLayout.setVisibility(View.GONE);
}
// **** Calibration button ****
if (MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE) && profile != null && GlucoseStatus.actualBg() != null) {
calibrationButton.setVisibility(View.VISIBLE);
} else {
calibrationButton.setVisibility(View.GONE);
}
TempBasal activeTemp = pump.getTempBasal();
if (pump.isTempBasalInProgress()) {
cancelTempLayout.setVisibility(View.VISIBLE);
@ -623,7 +712,7 @@ public class OverviewFragment extends Fragment {
// QuickWizard button
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && lastBG != null && pump.isInitialized()) {
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
quickWizardButton.setVisibility(View.VISIBLE);
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
BolusWizard wizard = new BolusWizard();
@ -911,23 +1000,10 @@ public class OverviewFragment extends Fragment {
bgGraph.getSecondScale().addSeries(basalsLineSeries);
bgGraph.getSecondScale().setMinY(0);
bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide
}
// Pump not initialized message
if (!pump.isInitialized()) {
// disable all treatment buttons because we are not able to check constraints without profile
wizardButton.setVisibility(View.INVISIBLE);
treatmentButton.setVisibility(View.INVISIBLE);
quickWizardButton.setVisibility(View.INVISIBLE);
initializingView.setText(R.string.waitingforpump);
initializingView.setVisibility(View.VISIBLE);
} else {
wizardButton.setVisibility(View.VISIBLE);
treatmentButton.setVisibility(View.VISIBLE);
initializingView.setVisibility(View.GONE);
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(ContextCompat.getColor(MainApp.instance(), R.color.background_material_dark)); // same color as backround = hide
}
updatePumpStatus(null);
}
//Notifications
@ -953,13 +1029,13 @@ public class OverviewFragment extends Fragment {
holder.text.setText(notification.text);
holder.time.setText(DateUtil.timeString(notification.date));
if (notification.level == Notification.URGENT)
holder.cv.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.notificationUrgent));
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationUrgent));
else if (notification.level == Notification.NORMAL)
holder.cv.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.notificationNormal));
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationNormal));
else if (notification.level == Notification.LOW)
holder.cv.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.notificationLow));
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationLow));
else if (notification.level == Notification.INFO)
holder.cv.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.notificationInfo));
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo));
}
@Override
@ -1019,5 +1095,4 @@ public class OverviewFragment extends Fragment {
}
}

View file

@ -103,8 +103,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
if (profile == null) return absoluteRate;
if (absoluteRate < 0) absoluteRate = 0d;
Integer maxBasalMult = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER;
Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER;
Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
Integer maxBasalFromDaily = SafeParse.stringToInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
// Check percentRate but absolute rate too, because we know real current basal in pump
Double origRate = absoluteRate;
if (absoluteRate > maxBasal) {
@ -142,8 +142,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
if (absoluteRate < 0) absoluteRate = 0d;
Integer maxBasalMult = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER;
Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER;
Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
Integer maxBasalFromDaily = SafeParse.stringToInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
// Check percentRate but absolute rate too, because we know real current basal in pump
Double origRate = absoluteRate;
if (absoluteRate > maxBasal) {
@ -191,7 +191,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
public Integer applyCarbsConstraints(Integer carbs) {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
try {
Integer maxCarbs = Integer.parseInt(SP.getString("treatmentssafety_maxcarbs", "48"));
Integer maxCarbs = SafeParse.stringToInt(SP.getString("treatmentssafety_maxcarbs", "48"));
if (carbs < 0) carbs = 0;
if (carbs > maxCarbs) carbs = maxCarbs;

View file

@ -170,7 +170,7 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!MainApp.getConfigBuilder().isInitialized() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
profileswitchButton.setVisibility(View.GONE);
} else {
profileswitchButton.setVisibility(View.VISIBLE);

View file

@ -31,11 +31,14 @@ import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.XdripCalibrations;
/**
* Created by mike on 05.08.2016.
@ -61,6 +64,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
String confirmCode;
double bolusRequested = 0d;
double tempBasal = 0d;
double calibrationRequested = 0d;
public Sms(SmsMessage message) {
phoneNumber = message.getOriginatingAddress();
@ -92,6 +96,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
Sms cancelTempBasalWaitingForConfirmation = null;
Sms tempBasalWaitingForConfirmation = null;
Sms bolusWaitingForConfirmation = null;
Sms calibrationWaitingForConfirmation = null;
Date lastRemoteBolusTime = new Date(0);
ArrayList<Sms> messages = new ArrayList<>();
@ -210,8 +215,8 @@ public class SmsCommunicatorPlugin implements PluginBase {
if (splited.length > 0) {
switch (splited[0].toUpperCase()) {
case "BG":
BgReading actualBG = MainApp.getDbHelper().actualBg();
BgReading lastBG = MainApp.getDbHelper().lastBg();
BgReading actualBG = GlucoseStatus.actualBg();
BgReading lastBG = GlucoseStatus.lastBg();
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
String units = profile.getUnits();
@ -364,6 +369,23 @@ public class SmsCommunicatorPlugin implements PluginBase {
}
}
break;
case "CAL":
if (splited.length > 1) {
amount = SafeParse.stringToDouble(splited[1]);
boolean remoteCommandsAllowed = sharedPreferences.getBoolean("smscommunicator_remotecommandsallowed", false);
if (amount > 0d && remoteCommandsAllowed) {
passCode = generatePasscode();
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
receivedSms.processed = true;
resetWaitingMessages();
sendSMS(calibrationWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
calibrationWaitingForConfirmation.calibrationRequested = amount;
} else {
reply = MainApp.sResources.getString(R.string.smscommunicator_remotecalibrationnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
}
break;
default: // expect passCode here
if (bolusWaitingForConfirmation != null && !bolusWaitingForConfirmation.processed &&
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - bolusWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
@ -417,6 +439,17 @@ public class SmsCommunicatorPlugin implements PluginBase {
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
}
} else if (calibrationWaitingForConfirmation != null && !calibrationWaitingForConfirmation.processed &&
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - calibrationWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
calibrationWaitingForConfirmation.processed = true;
boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested);
if (result) {
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationsent));
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
reply = MainApp.sResources.getString(R.string.smscommunicator_calibrationfailed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
} else {
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));
}
@ -446,8 +479,13 @@ public class SmsCommunicatorPlugin implements PluginBase {
SmsManager smsManager = SmsManager.getDefault();
sms.text = stripAccents(sms.text);
if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139);
try {
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
messages.add(sms);
} catch (IllegalArgumentException e) {
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.sResources.getString(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
}
}
private String generatePasscode() {
@ -464,6 +502,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
tempBasalWaitingForConfirmation = null;
cancelTempBasalWaitingForConfirmation = null;
bolusWaitingForConfirmation = null;
calibrationWaitingForConfirmation = null;
}
public static String stripAccents(String s) {

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.TempBasals;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@ -82,13 +83,13 @@ public class TempBasalsFragment extends Fragment implements FragmentBase {
holder.netRatio.setText(DecimalFormatter.to2Decimal(iob.netRatio) + " U/h");
holder.extendedFlag.setVisibility(tempBasal.isExtended ? View.VISIBLE : View.GONE);
if (tempBasal.isInProgress())
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorInProgress));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorInProgress));
else if (tempBasal.timeEnd == null)
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorNotEnded));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorNotEnded));
else if (tempBasal.iobCalc(new Date()).basaliob != 0)
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorAffectingIOB));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorAffectingIOB));
else
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardColorBackground));
}
@Override

View file

@ -9,6 +9,7 @@ import android.graphics.Paint;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
@ -92,9 +93,9 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
holder.reasonColon.setText("");
}
if (tempTarget.isInProgress())
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorInProgress));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorInProgress));
else
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardColorBackground));
holder.remove.setTag(tempTarget);
}

View file

@ -7,6 +7,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
@ -84,9 +85,9 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
holder.mealOrCorrection.setText(treatments.get(position).mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
if (iob.iobContrib != 0)
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorAffectingIOB));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorAffectingIOB));
else
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardColorBackground));
}
@Override

View file

@ -1,5 +1,8 @@
package info.nightscout.androidaps.plugins.Treatments;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
@ -26,6 +29,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.SafeParse;
/**
* Created by mike on 05.08.2016.
@ -121,6 +125,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public IobTotal getCalculationToTime(long time) {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
IobTotal total = new IobTotal(time);
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
@ -138,7 +143,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
Iob tIOB = t.iobCalc(now, dia);
total.iob += tIOB.iobContrib;
total.activity += tIOB.activityContrib;
Iob bIOB = t.iobCalc(now, dia / Constants.BOLUSSNOOZE_DIA_ADVISOR);
Iob bIOB = t.iobCalc(now, dia / SafeParse.stringToInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2")));
total.bolussnooze += bIOB.iobContrib;
}
return total;

View file

@ -124,6 +124,16 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
return true;
}
@Override
public boolean isSuspended() {
return false;
}
@Override
public boolean isBusy() {
return false;
}
@Override
public boolean isTempBasalInProgress() {
return getTempBasal() != null;

View file

@ -142,7 +142,7 @@ public class WatchUpdaterService extends WearableListenerService implements
private void sendData() {
BgReading lastBG = MainApp.getDbHelper().lastBg();
BgReading lastBG = GlucoseStatus.lastBg();
if (lastBG != null) {
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
@ -250,7 +250,7 @@ public class WatchUpdaterService extends WearableListenerService implements
private void resendData() {
if(googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { googleApiConnect(); }
long startTime = System.currentTimeMillis() - (long)(60000 * 60 * 5.5);
BgReading last_bg = MainApp.getDbHelper().lastBg();
BgReading last_bg = GlucoseStatus.lastBg();
if (last_bg == null) return;

View file

@ -108,12 +108,11 @@ public class PersistentNotificationPlugin implements PluginBase{
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
BgReading lastBG = MainApp.getDbHelper().lastBg();
BgReading lastBG = GlucoseStatus.lastBg();
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
if(profile != null && lastBG != null) {
line1 = lastBG.valueToUnitsToString(profile.getUnits());
}
if (glucoseStatus != null) {
line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits())
+ " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits());
@ -122,6 +121,7 @@ public class PersistentNotificationPlugin implements PluginBase{
ctx.getString(R.string.old_data) +
" ";
}
}
PumpInterface pump = MainApp.getConfigBuilder();

View file

@ -58,7 +58,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
}
});
t.start();
} else if (isStatusOutdated) {
} else if (isStatusOutdated && !pump.isBusy()) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
@ -66,7 +66,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
}
});
t.start();
} else if (isBasalOutdated) {
} else if (isBasalOutdated && !pump.isBusy()) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {

View file

@ -0,0 +1,68 @@
package info.nightscout.utils;
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.Context;
import android.content.DialogInterface;
import android.content.ClipboardManager;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
/**
* Created by mike on 09.02.2017.
*/
public class LogDialog {
public static void showLogcat(Context context) {
String logCat = "no logs";
final String processId = Integer.toString(android.os.Process.myPid());
try {
Process process = Runtime.getRuntime().exec("logcat -d " + MainApp.sResources.getString(R.string.app_name) + ":D");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder log = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains(processId)) log.append(line + "\n");
}
logCat = log.toString();
} catch (IOException e) {
logCat = e.getLocalizedMessage();
} finally {
showAlertText(logCat, context);
}
}
public static void showAlertText(final String msg, final Context context) {
try {
AlertDialog alertDialog = new AlertDialog.Builder(context)
.setMessage(msg)
.setPositiveButton(MainApp.sResources.getString(R.string.copy_to_clipboard), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setPrimaryClip(ClipData.newPlainText(null, msg));
ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.copied_to_clipboard));
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
if (msg.length() > 100) {
TextView textView = (TextView) alertDialog.findViewById(android.R.id.message);
textView.setTextSize(10);
}
} catch (Exception e) {
// crashing on screen rotation
}
}
}

View file

@ -2,6 +2,8 @@ package info.nightscout.utils;
import android.content.Context;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.TextViewCompat;
import android.text.Editable;
import android.text.Layout;
import android.text.TextWatcher;
@ -73,11 +75,8 @@ public class TimeListEdit {
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
llp.setMargins(10, 0, 0, 0); // llp.setMargins(left, top, right, bottom);
textlabel.setLayoutParams(llp);
textlabel.setBackgroundColor(MainApp.sResources.getColor(R.color.linearBlockBackground));
if (Build.VERSION.SDK_INT < 23)
textlabel.setTextAppearance(context, android.R.style.TextAppearance_Medium);
else
textlabel.setTextAppearance(android.R.style.TextAppearance_Medium);
textlabel.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.linearBlockBackground));
TextViewCompat.setTextAppearance(textlabel, android.R.style.TextAppearance_Medium);
layout.addView(textlabel);
for (int i = 0; i < itemsCount(); i++) {

View file

@ -0,0 +1,69 @@
package info.nightscout.utils;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.client.data.NSProfile;
/**
* Created by mike on 10.02.2017.
*/
public class XdripCalibrations {
private static Logger log = LoggerFactory.getLogger(XdripCalibrations.class);
public static void confirmAndSendCalibration(final Double bg, Context parentContext) {
if (parentContext != null) {
String confirmMessage = String.format(MainApp.sResources.getString(R.string.send_calibration), bg);
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
builder.setMessage(confirmMessage);
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
sendIntent(bg);
}
});
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
builder.show();
}
}
public static boolean sendIntent(Double bg) {
final NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putDouble("glucose_number", bg);
bundle.putString("units", profile.getUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
bundle.putLong("timestamp", new Date().getTime());
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
if (q.size() < 1) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.xdripnotinstalled));
log.debug(MainApp.sResources.getString(R.string.xdripnotinstalled));
return false;
} else {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.calibrationsent));
log.debug(MainApp.sResources.getString(R.string.calibrationsent));
return true;
}
}
}

View file

@ -1,7 +1,12 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/circadianpercentageprofile_framelayout"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
tools:context=".plugins.CircadianPercentageProfile.CircadianPercentageProfileFragment">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
@ -33,9 +38,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/pillborder"
android:orientation="horizontal"
android:padding="5dp">
android:padding="5dp"
android:backgroundTint="@color/mdtp_transparent_black"
android:background="@drawable/pillborder"
android:backgroundTintMode="src_over">
<ImageView
android:id="@+id/circadianpercentageprofile_percentageicon"
@ -44,23 +51,34 @@
android:src="@mipmap/ic_percentage"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<EditText
<com.andreabaccega.widget.FormEditText
validate:testType="numericRange"
validate:minNumber="50"
validate:maxNumber="200"
android:digits="0123456789.,"
android:id="@+id/circadianpercentageprofile_percentage"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:hint="@string/percentagefactor_hint"
android:inputType="number"/>
android:inputType="number"
android:selectAllOnFocus="true"
android:textAlignment="center" />
</LinearLayout>
<Space
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/pillborder"
android:orientation="horizontal"
android:padding="5dp">
android:padding="5dp"
android:backgroundTint="@color/mdtp_transparent_black"
android:background="@drawable/pillborder"
android:backgroundTintMode="src_over">
<ImageView
android:id="@+id/circadianpercentageprofile_timeicon"
@ -69,12 +87,17 @@
android:src="@mipmap/ic_time"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<EditText
<com.andreabaccega.widget.FormEditText
validate:testType="numericRange"
validate:minNumber="0"
validate:maxNumber="24"
android:digits="0123456789.,"
android:id="@+id/circadianpercentageprofile_timeshift"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:hint="@string/timeshift_hint"
android:inputType="number"/>
android:inputType="number"
android:selectAllOnFocus="true"
android:textAlignment="center" />
</LinearLayout>
</LinearLayout>
@ -231,7 +254,12 @@
android:text="@string/dia"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
<com.andreabaccega.widget.FormEditText
validate:testType="floatNumericRange"
validate:floatminNumber="1.0"
validate:floatmaxNumber="10.0"
android:digits="0123456789.,"
android:selectAllOnFocus="true"
android:id="@+id/circadianpercentageprofile_dia"
android:layout_width="100dp"
android:layout_height="wrap_content"
@ -249,14 +277,24 @@
android:text="@string/target_range"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
<com.andreabaccega.widget.FormEditText
validate:testType="floatNumericRange"
validate:floatminNumber="4.0"
validate:floatmaxNumber="180.0"
android:digits="0123456789.,"
android:selectAllOnFocus="true"
android:id="@+id/circadianpercentageprofile_targetlow"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:inputType="numberDecimal" />
<EditText
<com.andreabaccega.widget.FormEditText
validate:testType="floatNumericRange"
validate:floatminNumber="4.0"
validate:floatmaxNumber="270.0"
android:digits="0123456789.,"
android:selectAllOnFocus="true"
android:id="@+id/circadianpercentageprofile_targethigh"
android:layout_width="100dp"
android:layout_height="wrap_content"

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:text="@string/overview_calibration_bg_label"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:id="@+id/overview_calibration_units"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="@+id/overview_calibration_bg_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
android:id="@+id/overview_calibration_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/overview_calibration_bg_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
</LinearLayout>
<Button
android:id="@+id/overview_calibration_okbutton"
style="?android:attr/buttonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="OK"
android:textSize="20sp"
android:layout_marginTop="30dp" />
</LinearLayout>
</LinearLayout>

View file

@ -4,7 +4,6 @@
android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog">
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"

View file

@ -217,8 +217,8 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="Accept new temp\n0.25U/h"
@ -237,8 +237,8 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="Cancel temp basal"
@ -257,8 +257,8 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="@string/overview_bolus_label"
@ -270,12 +270,25 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="@string/overview_calculator_label"
android:textColor="@color/colorWizardButton" />
<Button
android:id="@+id/overview_calibration"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="@string/overview_calibration"
android:textColor="@color/colorCalibrationButton" />
</LinearLayout>
<LinearLayout
@ -289,8 +302,8 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:drawableLeft="@drawable/bread"

View file

@ -14,8 +14,8 @@
android:id="@+id/nav_import"
android:title="@string/nav_import" />
<item
android:id="@+id/nav_test_alarm"
android:title="@string/nav_test_alert" />
android:id="@+id/nav_show_logcat"
android:title="@string/nav_show_logcat" />
<item
android:id="@+id/nav_exit"
android:title="@string/nav_exit" />

View file

@ -246,7 +246,7 @@
<string name="overview_bolusprogress_stoppressed">НАТИСНАТ СТОП</string>
<string name="openapsma_target_bg">КЗ цел за изчисления</string>
<string name="pumpbusy">Помпата е заета</string>
<string name="waitingforpump">Изчаква за помпа</string>
<string name="waitingforpump">Изчаква за помпа. Click to refresh.</string>
<string name="wrongpumppassword">Грешна парола за помпата!</string>
<string name="youareonallowedlimit">Достигнахте лимита</string>
<string name="danar_alarm">аларма</string>
@ -410,7 +410,6 @@
<string name="long_avgdelta">Дългоср. изменение</string>
<string name="mdi">Писалки</string>
<string name="openapsama">OpenAPS AMA</string>
<string name="openapsama_autosens_adjusttargets">Позволи autosens да променя целите</string>
<string name="openapsama_useautosens">Разреши AMA autosens</string>
<string name="openapsma_autosensdata_label">Autosens данни</string>
<string name="old_data">СТАРИ ДАННИ</string>

View file

@ -191,8 +191,6 @@
<string name="de_lang">German</string>
<string name="openapsma_high_summary">Maximální hodnota glykémie ještě v rozsahu</string>
<string name="openapsma_low_summary">Minimální hodnota glykémie ještě v rozsahu</string>
<string name="openapsma_maxbasal_summary">Maximální povolený bazál [U/h]</string>
<string name="openapsma_maxiob_summary">Maximální bazální IOB [U]</string>
<string name="bg_lang">Bulgarian</string>
<string name="dismiss">POTVRDIT</string>
<string name="language">Jazyk</string>
@ -240,7 +238,6 @@
<string name="manual">Jiný</string>
<string name="glucosetype_sensor">Senzor</string>
<string name="danarprofile">DanaR profil</string>
<string name="danarprofile_dia">Celková doba aktivity inzulínu[h]</string>
<string name="failedupdatebasalprofile">Chyba při nastavení dočasného bazálu</string>
<string name="danar_alarm">alarm</string>
<string name="danar_basalhour">hodinový bazál</string>
@ -252,7 +249,7 @@
<string name="danar_glucose">glykémie</string>
<string name="danar_history">Historie</string>
<string name="danar_history_alarm">Alarmy</string>
<string name="danar_history_basalhours">Hodinvé bazály</string>
<string name="danar_history_basalhours">Hodinové bazály</string>
<string name="danar_history_bolus">Bolusy</string>
<string name="danar_history_carbohydrates">Sacharidy</string>
<string name="danar_history_connectingfor" formatted="false">Připojování %d sec</string>
@ -274,7 +271,7 @@
<string name="overview_bolusprogress_stop">Stop</string>
<string name="overview_bolusprogress_stoped">Zastaveno</string>
<string name="overview_bolusprogress_stoppressed">STISKNUTO STOP</string>
<string name="waitingforpump">Čekání na pumpu</string>
<string name="waitingforpump">Čekání na pumpu. Klik pro připojení.</string>
<string name="overview_bolusprogress_goingtodeliver" formatted="false">Podávání %.2fU inzulínu</string>
<string name="objectives_0_gate">Zkontrolovat, zda jsou glykémie a údaje z pumpy viditelné v Nightscoutu</string>
<string name="objectives_0_objective">Nastavit vizualizaci a monitoring, analyzovat bazály a koeficienty</string>
@ -434,9 +431,43 @@
<string name="danar_stats_tdd">TDD</string>
<string name="danar_stats_warning_Message">Pravděpodobně nepřesné při používání bolusů k doplňování</string>
<string name="danar_stats_weight">Váha</string>
<string name="openapsama_autosens_adjusttargets">Povolit funkci Autosens měnit cílový rozsah</string>
<string name="prefs_delta_title">Nastavení parametru delta BG</string>
<string name="profile">Profil</string>
<string name="short_tabtitles">Krátké názvy modulů</string>
<string name="virtualpump_firmware_label">Firmware:</string>
<string name="smscommunicator_invalidphonennumber">Špatné telefonní číslo</string>
<string name="tempbasaldeliveryerror">Chyba nastavování dočasného bazálu</string>
<string name="copied_to_clipboard">Nakopírováno do schránky</string>
<string name="copy_to_clipboard">Kopírovat do schránky</string>
<string name="danarprofile_dia_summary">Celková doba aktivity inzulínu</string>
<string name="danarprofile_dia">DIA [h]</string>
<string name="error_field_must_not_be_empty">Toto pole nesmí být prázdné</string>
<string name="nav_show_logcat">Zobrazit log</string>
<string name="openapsma_maxbasal_title">Maximální povolený bazál [U/h]</string>
<string name="openapsma_maxiob_title">Maximální bazální IOB [U]</string>
<string name="openapsma_maxbasal_summary">Tato hodnota je v kontextu OpenAPS nazývána max basal</string>
<string name="openapsma_maxiob_summary">Tato hodnota je v kontextu OpenAPS nazývána max IOB</string>
<string name="error_only_numeric_digits_allowed">Povoleny pouze číslice</string>
<string name="error_only_numeric_digits_range_allowed">Povoleny pouze čísla v rozsahu %1$s - %2$s</string>
<string name="error_phone_not_valid">Neplatné telefonní číslo</string>
<string name="calibrationsent">Kalibrace odeslána do xDripu</string>
<string name="overview_calibration">Kalibrace</string>
<string name="overview_calibration_bg_label">Kalibrační glykémie</string>
<string name="send_calibration">Poslat do xDripu kalibraci %.1f ?</string>
<string name="xdripnotinstalled">xDrip+ není nainstalován</string>
<string name="smscommunicator_calibrationfailed">xDrip nepřijímá kalibrace</string>
<string name="smscommunicator_calibrationreplywithcode" formatted="false">Odeslání kalibrace %.2f potvrďte kódem %s</string>
<string name="smscommunicator_calibrationsent">Kalibrace odeslána. Příjem musí být v xDripu povolený.</string>
<string name="smscommunicator_remotecalibrationnotallowed">Vzdálené kalibrace nejsou povoleny</string>
<string name="disconnecting">Odpojuji</string>
<string name="dont_show_again">Nezobrazovat znovu</string>
<string name="executing">Provádím</string>
<string name="gettingpumpstatus">Načítám stav pumpy</string>
<string name="pumpsuspended">Pumpa vypnuta</string>
<string name="pumpsuspendedclicktorefresh">Pumpa vypnuta. Klik pro obnovení stavu</string>
<string name="settingextendedbolus">Nastavuji extended bolus</string>
<string name="settingtempbasal">Nastavuji dočasný bazál</string>
<string name="stoppingextendedbolus">Zastavuji extended bolus</string>
<string name="stoppingtempbasal">Zastavuji dočasný bazál</string>
<string name="updatingbasalrates">Aktualizuji bazály</string>
</resources>

View file

@ -242,7 +242,7 @@
<string name="ko_lang">Korean</string>
<string name="youareonallowedlimit">Limit erreicht</string>
<string name="wrongpumppassword">Falsches Pumpen-Passwort!</string>
<string name="waitingforpump">Warte auf Pumpe</string>
<string name="waitingforpump">Warte auf Pumpe. Click to refresh.</string>
<string name="correctionbous">Korr</string>
<string name="bolusdelivering">Abgabe %.2fU</string>
<string name="bolusdelivered">%.2fU Bolus erfolgreich abgegeben</string>
@ -328,4 +328,8 @@
<string name="configbuilder_shortname">"CONF"</string>
<string name="circadian_percentage_profile_shortname">"CPP"</string>
<string name="careportal_shortname">"CP"</string>
<string name="error_only_numeric_digits_allowed">Bitte verwenden Sie nur Ziffern.</string>
<string name="error_field_must_not_be_empty">Pflichtfeld</string>
<string name="error_phone_not_valid">Telefonnummer ist nicht gültig.</string>
<string name="error_only_numeric_digits_range_allowed">Bitte verwenden Sie nur Ziffern von %1$s - %2$s</string>
</resources>

View file

@ -283,7 +283,7 @@
<string name="occlusion">Oclusión</string>
<string name="overview_bolusprogress_stop">Detener</string>
<string name="overview_bolusprogress_stoppressed">Parar pulsado</string>
<string name="waitingforpump">Esperando bomba</string>
<string name="waitingforpump">Esperando bomba. Click to refresh.</string>
<string formatted="false" name="overview_bolusprogress_goingtodeliver">Va a entregar% .2fU</string>
<string name="objectives_0_objective">Configuración de visualización y monitoreo, y el análisis de los basales y ratios</string>
<string name="objectives_0_gate">Comprobar que los datos de BG están disponibles en Nightscout, y que los datos de la bomba de insulina se están subiendo</string>
@ -401,6 +401,8 @@
<string name="temptargetrange_refreshfromnightscout">Actualizar objetivo temporal desde NS</string>
<string name="timeshift_hint"></string>
<string name="units">Unidades:</string>
<string name="openapsama_autosens_adjusttargets">Reajuste objetivos por autosens</string>
<string name="error_only_numeric_digits_allowed">Sólo se permiten caracteres numéricos</string>
<string name="error_only_numeric_digits_range_allowed">Sólo se permiten dígitos en el rango %1$s - %2$s</string>
<string name="error_field_must_not_be_empty">Este campo no puede estar vacío</string>
<string name="error_phone_not_valid">Número de teléfono inválido</string>
</resources>

View file

@ -286,7 +286,7 @@
<string name="occlusion">막힘</string>
<string name="overview_bolusprogress_stop">정지</string>
<string name="overview_bolusprogress_stoppressed">정지 누름</string>
<string name="waitingforpump">펌프를 기다리고 있습니다.</string>
<string name="waitingforpump">펌프를 기다리고 있습니다. Click to refresh.</string>
<string name="overview_bolusprogress_goingtodeliver" formatted="false">%.2fU을 주입합니다</string>
<string name="objectives_0_objective">나이트스카우트를 세팅하고, 기초주입과 비율을 분석한다.</string>
<string name="objectives_0_gate">나이트스카우트에서 혈당 데이터가 잘 들어오는지, 펌프데이터가 업로드 되는지 확인한다.</string>
@ -398,4 +398,8 @@
<string name="configbuilder_shortname">" "</string>
<string name="circadian_percentage_profile_shortname">" "</string>
<string name="careportal_shortname">" "</string>
<string name="error_field_must_not_be_empty">필수 입력 항목입니다.</string>
<string name="error_only_numeric_digits_allowed">숫자만 입력가능합니다.</string>
<string name="error_only_numeric_digits_range_allowed">이 범위(%1$s - %2$s)안에 해당하는 숫자만 입력가능합니다.</string>
<string name="error_phone_not_valid">유효한 도메인 이름이 아닙니다.</string>
</resources>

View file

@ -18,6 +18,7 @@
<color name="colorSetExtendedButton">#FFDD7792</color>
<color name="colorProfileSwitchButton">#ca77dd</color>
<color name="colorTempTargetButton">#d43429</color>
<color name="colorCalibrationButton">#ceb812</color>
<color name="colorInProgress">#c45026</color>
<color name="colorAffectingIOB">#830400</color>

View file

@ -116,6 +116,7 @@
<string name="openapsma_disabled">Plugin is disabled</string>
<string name="constraints_violation">Constraints violation</string>
<string name="treatmentdeliveryerror">Bolus delivery error</string>
<string name="tempbasaldeliveryerror">Tempbasal delivery error</string>
<string name="overview_newtempbasal_basal_label">Basal value</string>
<string name="overview_newtempbasal_percent_label">% (100% = current)</string>
<string name="setbasalquestion">Accept new temp basal:</string>
@ -210,8 +211,10 @@
<string name="el_lang">Greek</string>
<string name="openapsma_low_summary">The minimum BG value to be in range.</string>
<string name="openapsma_high_summary">The maximum BG value to be in range.</string>
<string name="openapsma_maxbasal_summary">Max U/hr a Temp Basal can be set to</string>
<string name="openapsma_maxiob_summary">Maximum basal IOB OpenAPS can deliver [U]</string>
<string name="openapsma_maxbasal_title">Max U/hr a Temp Basal can be set to</string>
<string name="openapsma_maxbasal_summary">This value is called max basal in OpenAPS context</string>
<string name="openapsma_maxiob_title">Maximum basal IOB OpenAPS can deliver [U]</string>
<string name="openapsma_maxiob_summary">This value is called Max IOB in OpenAPS context\nThis will default to zero. After several days or weeks, depending on your comfort level, you may choose to adjust this number.</string>
<string name="bg_lang">Bulgarian</string>
<string name="dismiss">DISMISS</string>
<string name="language">Language</string>
@ -250,6 +253,7 @@
<string name="smscommunicator_allowednumbers">Allowed phone numbers</string>
<string name="smscommunicator_allowednumbers_summary">+XXXXXXXXXX;+YYYYYYYYYY</string>
<string name="smscommunicator_bolusreplywithcode" formatted="false">To deliver bolus %.2fU reply with code %s</string>
<string name="smscommunicator_calibrationreplywithcode" formatted="false">To send calibration %.2f reply with code %s</string>
<string name="smscommunicator_bolusfailed">Bolus failed</string>
<string name="bolusdelivered" formatted="false">Bolus %.2fU delivered successfully</string>
<string name="smscommunicator_bolusdelivered" formatted="false">Bolus %.2fU delivered successfully</string>
@ -263,6 +267,7 @@
<string name="careportal_temporarytargetcancel">Temporary Target Cancel</string>
<string name="danarprofile">DanaR profile settings</string>
<string name="danarprofile_dia">DIA [h]</string>
<string name="danarprofile_dia_summary">Duration of Insulin Activity</string>
<string name="failedupdatebasalprofile">Failed to update basal profile</string>
<string name="danar_history">History</string>
<string name="danar_historyreload">Reload</string>
@ -296,7 +301,7 @@
<string name="occlusion">Occlusion</string>
<string name="overview_bolusprogress_stop">Stop</string>
<string name="overview_bolusprogress_stoppressed">STOP PRESSED</string>
<string name="waitingforpump">Waiting for pump</string>
<string name="waitingforpump">Waiting for pump. Click to refresh.</string>
<string name="overview_bolusprogress_goingtodeliver" formatted="false">Going to deliver %.2fU</string>
<string name="objectives_0_objective">Setting up visualization and monitoring, and analyzing basals and ratios</string>
<string name="objectives_0_gate">Verify that BG is available in Nightscout, and pump insulin data is being uploaded</string>
@ -425,7 +430,6 @@
<string name="danar_stats_tbb">Total Base Basal</string>
<string name="danar_stats_tbb2">TBB * 2</string>
<string name="initializing">Initializing ...</string>
<string name="openapsama_autosens_adjusttargets">Allow autosens to adjust targets</string>
<string name="actions_shortname">ACT</string>
<string name="configbuilder_shortname">CONF</string>
<string name="loop_shortname">LOOP</string>
@ -450,6 +454,49 @@
<string name="always_use_shortavg_summary">Useful when data from unfiltered sources like xDrip gets noisy.</string>
<string name="advancedsettings_title">Advanced Settings</string>
<string name="virtualpump_firmware_label">Firmware:</string>
<string formatted="false" name="danar_model">Model: %02X Protocol: %02X Code: %02X</string>
<string name="danar_model" formatted="false">Model: %02X Protocol: %02X Code: %02X</string>
<string name="profile">Profile</string>
<string name="openapsama_max_daily_safety_multiplier" translatable="false">max_daily_safety_multiplier</string>
<string name="openapsama_max_daily_safety_multiplier_summary">Default value: 3\nThis is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware thats what is discussed about “3x max daily; 4x current” for safety caps.</string>
<string name="openapsama_current_basal_safety_multiplier" translatable="false">current_basal_safety_multiplier</string>
<string name="openapsama_current_basal_safety_multiplier_summary">Default value: 4\nThis is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap.</string>
<string name="openapsama_autosens_max" translatable="false">autosens_max</string>
<string name="openapsama_autosens_max_summary">Default value: 1.2\nThis is a multiplier cap for autosens (and soon autotune) to set a 20% max limit on how high the autosens ratio can be, which in turn determines how high autosens can adjust basals, how low it can adjust ISF, and how low it can set the BG target.</string>
<string name="openapsama_autosens_min" translatable="false">autosens_min</string>
<string name="openapsama_autosens_min_summary">Default value: 0.7\nThe other side of the autosens safety limits, putting a cap on how low autosens can adjust basals, and how high it can adjust ISF and BG targets.</string>
<string name="openapsama_autosens_adjusttargets" translatable="false">autosens_adjust_targets</string>
<string name="openapsama_autosens_adjusttargets_summary">Default value: true\nThis is used to allow autosens to adjust BG targets, in addition to ISF and basals.</string>
<string name="openapsama_bolussnooze_dia_divisor" translatable="false">bolussnooze_dia_divisor</string>
<string name="openapsama_bolussnooze_dia_divisor_summary">Default value: 2\nBolus snooze is enacted after you do a meal bolus, so the loop wont counteract with low temps when youve just eaten. The example here and default is 2; so a 3 hour DIA means that bolus snooze will be gradually phased out over 1.5 hours (3DIA/2).</string>
<string name="openapsama_min_5m_carbimpact" translatable="false">min_5m_carbimpact</string>
<string name="openapsama_min_5m_carbimpact_summary">Default value: 3.0\nThis is a setting for default carb absorption impact per 5 minutes. The default is an expected 3mg/dl/5min. This affects how fast COB are decayed, and how much carb absorption is assumed in calculating future predicted BG, when BG is falling more than expected, or not rising as much as expected.</string>
<string name="openapsama_link_to_preferncejson_doc_txt">Attention!\nNormally you do not have to change these values below. Please CLICK HERE and READ the text and make sure you UNDERSTAND it before change any of these values.</string>
<string name="openapsama_link_to_preferncejson_doc">http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html</string>
<string name="error_only_numeric_digits_allowed">Only numeric digits are allowed.</string>
<string name="error_only_numeric_digits_range_allowed">Only numeric digits within the range %1$s - %2$s are allowed.</string>
<string name="error_field_must_not_be_empty">The field must not be empty</string>
<string name="error_phone_not_valid">Phone number not valid</string>
<string name="smscommunicator_invalidphonennumber">Invalid SMS phone number</string>
<string name="copy_to_clipboard">Copy To Clipboard</string>
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="nav_show_logcat">Show log</string>
<string name="overview_calibration">Calibration</string>
<string name="overview_calibration_bg_label">Calibration BG</string>
<string name="send_calibration" formatted="false">Send calibration %.1f to xDrip?</string>
<string name="xdripnotinstalled">xDrip+ not installed</string>
<string name="calibrationsent">Calibration sent to xDrip</string>
<string name="smscommunicator_remotecalibrationnotallowed">Remote calibration not allowed</string>
<string name="smscommunicator_calibrationsent">Calibration sent. Receiving must be enabled in xDrip.</string>
<string name="smscommunicator_calibrationfailed">xDrip is not receiving calibrations</string>
<string name="dont_show_again">Don\'t show again</string>
<string name="pumpsuspendedclicktorefresh">Pump suspended. Click to refresh state</string>
<string name="pumpsuspended">Pump suspended</string>
<string name="gettingpumpstatus">Getting pump status</string>
<string name="settingtempbasal">Setting temp basal</string>
<string name="stoppingtempbasal">Stopping temp basal</string>
<string name="settingextendedbolus">Setting extended bolus</string>
<string name="stoppingextendedbolus">Stopping extended bolus</string>
<string name="updatingbasalrates">Updating basal rates</string>
<string name="disconnecting">Disconnecting</string>
<string name="executing">Executing</string>
</resources>

View file

@ -8,7 +8,9 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.base" parent="Theme.AppCompat.NoActionBar"></style>
<style name="AppTheme.base" parent="Theme.AppCompat.NoActionBar">
<item name="android:textColorSecondary">@color/mdtp_white</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="advanced"
android:title="@string/advancedsettings_title">
@ -25,6 +26,95 @@
android:title="@string/always_use_shortavg"
android:summary="@string/always_use_shortavg_summary"/>
</PreferenceCategory>
<PreferenceCategory
android:title="OpenAPS preferences.json">
<Preference
android:summary="@string/openapsama_link_to_preferncejson_doc_txt" >
<intent
android:action="android.intent.action.VIEW"
android:data="@string/openapsama_link_to_preferncejson_doc" />
</Preference>
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="1"
validate:maxNumber="10"
android:digits="0123456789.,"
android:defaultValue="3"
android:selectAllOnFocus="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/openapsama_max_daily_safety_multiplier"
android:dialogMessage="@string/openapsama_max_daily_safety_multiplier_summary"
android:key="openapsama_max_daily_safety_multiplier" />
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="1"
validate:maxNumber="10"
android:digits="0123456789.,"
android:defaultValue="4"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/openapsama_current_basal_safety_multiplier"
android:dialogMessage="@string/openapsama_current_basal_safety_multiplier_summary"
android:key="openapsama_current_basal_safety_multiplier" />
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="floatNumericRange"
validate:floatminNumber="0.5"
validate:floatmaxNumber="3"
android:digits="0123456789.,"
android:defaultValue="1.2"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberDecimal"
android:maxLines="20"
android:title="@string/openapsama_autosens_max"
android:dialogMessage="@string/openapsama_autosens_max_summary"
android:key="openapsama_autosens_max" />
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="floatNumericRange"
validate:floatminNumber="0.1"
validate:floatmaxNumber="1.0"
android:defaultValue="0.7"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberDecimal"
android:maxLines="20"
android:title="@string/openapsama_autosens_min"
android:dialogMessage="@string/openapsama_autosens_min_summary"
android:key="openapsama_autosens_min" />
<SwitchPreference
android:defaultValue="true"
android:key="openapsama_autosens_adjusttargets"
android:title="@string/openapsama_autosens_adjusttargets"
android:summary="@string/openapsama_autosens_adjusttargets_summary"/>
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="1"
validate:maxNumber="5"
android:digits="0123456789.,"
android:defaultValue="2"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/openapsama_bolussnooze_dia_divisor"
android:dialogMessage="@string/openapsama_bolussnooze_dia_divisor_summary"
android:key="openapsama_bolussnooze_dia_divisor" />
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="floatNumericRange"
validate:floatminNumber="0.1"
validate:floatmaxNumber="5.0"
android:defaultValue="3.0"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberDecimal"
android:maxLines="20"
android:title="@string/openapsama_min_5m_carbimpact"
android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary"
android:key="openapsama_min_5m_carbimpact" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -7,6 +7,7 @@
android:defaultValue=""
android:key="danarprofile_dia"
android:numeric="decimal"
android:dialogMessage="@string/danarprofile_dia_summary"
android:title="@string/danarprofile_dia" />
</PreferenceCategory>

View file

@ -9,13 +9,6 @@
android:key="openapsama_useautosens"
android:title="@string/openapsama_useautosens" />
<SwitchPreference
android:defaultValue="false"
android:key="openapsama_autosens_adjusttargets"
android:dependency="openapsama_useautosens"
android:title="@string/openapsama_autosens_adjusttargets"/>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -24,11 +24,13 @@
android:defaultValue="1"
android:key="openapsma_max_basal"
android:numeric="decimal"
android:title="@string/openapsma_maxbasal_summary" />
android:dialogMessage="@string/openapsma_maxbasal_summary"
android:title="@string/openapsma_maxbasal_title" />
<EditTextPreference
android:defaultValue="1.5"
android:key="openapsma_max_iob"
android:numeric="decimal"
android:title="@string/openapsma_maxiob_summary" />
android:dialogMessage="@string/openapsma_maxiob_summary"
android:title="@string/openapsma_maxiob_title" />
</PreferenceCategory>
</PreferenceScreen>

5
wear/.gitignore vendored
View file

@ -1 +1,6 @@
*.iml
.gradle
/build
*.apk
build/
.idea/

View file

@ -1,156 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":wear" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":wear" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="fullDebug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleFullDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileFullDebugSources" />
<afterSyncTasks>
<task>generateFullDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/full/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/full/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/full/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/full/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/7.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.support/wearable/1.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.denley.wearpreferenceactivity/wearpreferenceactivity/0.5.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/ustwo-clockwise-debug/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="ustwo-clockwise-debug-" level="project" />
<orderEntry type="library" exported="" name="hellocharts-library-1.5.5" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-7.3.0" level="project" />
<orderEntry type="library" exported="" name="wearpreferenceactivity-0.5.0" level="project" />
<orderEntry type="library" exported="" name="wearable-1.4.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="play-services-base-7.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
</component>
</module>