diff --git a/app/build.gradle b/app/build.gradle
index 16e3bfbe71..b885c36dcd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -209,7 +209,7 @@ dependencies {
implementation("com.google.android:flexbox:0.3.0") {
exclude group: "com.android.support"
}
- implementation("io.socket:socket.io-client:0.8.3") {
+ implementation("io.socket:socket.io-client:1.0.0") {
// excluding org.json which is provided by Android
exclude group: "org.json", module: "json"
}
diff --git a/app/libs/sightparser-release.aar b/app/libs/sightparser-release.aar
index 0d656738d2..302b9e836d 100644
Binary files a/app/libs/sightparser-release.aar and b/app/libs/sightparser-release.aar differ
diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
index 440024f853..9a80c61904 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
@@ -247,7 +247,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
log.debug("Requesting ignore battery optimization");
- OKDialog.show(this, getString(R.string.pleaseallowpermission), String.format(getString(R.string.needwhitelisting), getString(R.string.app_name)), new Runnable() {
+ OKDialog.show(this, MainApp.gs(R.string.pleaseallowpermission), String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name)), new Runnable() {
@Override
public void run() {
@@ -260,7 +260,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
startActivity(intent);
} catch (ActivityNotFoundException e) {
- final String msg = getString(R.string.batteryoptimalizationerror);
+ final String msg = MainApp.gs(R.string.batteryoptimalizationerror);
ToastUtils.showToastInUiThread(getApplicationContext(), msg);
log.error(msg);
}
@@ -399,21 +399,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
break;
case R.id.nav_about:
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
- builder.setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION);
+ builder.setTitle(MainApp.gs(R.string.app_name) + " " + BuildConfig.VERSION);
if (Config.NSCLIENT || Config.G5UPLOADER)
builder.setIcon(R.mipmap.yellowowl);
else
builder.setIcon(R.mipmap.blueowl);
String message = "Build: " + BuildConfig.BUILDVERSION + "\n";
message += "Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + "\n";
- message += getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName;
+ message += MainApp.gs(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName;
if (MainApp.engineeringMode)
message += "\n" + MainApp.gs(R.string.engineering_mode_enabled);
- message += getString(R.string.about_link_urls);
+ message += MainApp.gs(R.string.about_link_urls);
final SpannableString messageSpanned = new SpannableString(message);
Linkify.addLinks(messageSpanned, Linkify.WEB_URLS);
builder.setMessage(messageSpanned);
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
+ builder.setPositiveButton(MainApp.gs(R.string.ok), null);
AlertDialog alertDialog = builder.create();
alertDialog.show();
((TextView)alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java
index 5456da1805..45aff91654 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainApp.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java
@@ -245,12 +245,27 @@ public class MainApp extends Application {
}
}
-
public void stopKeepAliveService() {
if (keepAliveReceiver != null)
KeepAliveReceiver.cancelAlarm(this);
}
+ public static void subscribe(Object subscriber) {
+ try {
+ bus().register(subscriber);
+ } catch (IllegalArgumentException e) {
+ // already registered
+ }
+ }
+
+ public static void unsubscribe(Object subscriber) {
+ try {
+ bus().unregister(subscriber);
+ } catch (IllegalArgumentException e) {
+ // already unregistered
+ }
+ }
+
public static Bus bus() {
return sBus;
}
@@ -371,6 +386,10 @@ public class MainApp extends Application {
return engineeringMode || !devBranch;
}
+ public static boolean isDev() {
+ return devBranch;
+ }
+
public String getLogDirectory() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
return lc.getProperty("EXT_FILES_DIR");
diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
index 17dea50108..881f2e3bac 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
+++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
@@ -304,7 +304,7 @@ public class DataService extends IntentService {
log.debug("Got versions: NSClient: " + ConfigBuilderPlugin.nsClientVersionName + " Nightscout: " + ConfigBuilderPlugin.nightscoutVersionName);
try {
if (ConfigBuilderPlugin.nsClientVersionCode < MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode) {
- Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.sResources.getString(R.string.unsupportedclientver), Notification.URGENT);
+ Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.OLD_NSCLIENT));
@@ -313,13 +313,13 @@ public class DataService extends IntentService {
log.error("Unhandled exception", e);
}
if (ConfigBuilderPlugin.nightscoutVersionCode < Config.SUPPORTEDNSVERSION) {
- Notification notification = new Notification(Notification.OLD_NS, MainApp.sResources.getString(R.string.unsupportednsversion), Notification.NORMAL);
+ Notification notification = new Notification(Notification.OLD_NS, MainApp.gs(R.string.unsupportednsversion), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.OLD_NS));
}
} else {
- Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.sResources.getString(R.string.unsupportedclientver), Notification.URGENT);
+ Notification notification = new Notification(Notification.OLD_NSCLIENT, MainApp.gs(R.string.unsupportedclientver), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
if (bundles.containsKey("status")) {
diff --git a/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java b/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java
index 369b2f42b5..7bc3ee31c5 100644
--- a/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/TDDStatsActivity.java
@@ -141,27 +141,27 @@ public class TDDStatsActivity extends Activity {
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_date = new TextView(this);
- label_date.setText(getString(R.string.danar_stats_date));
+ label_date.setText(MainApp.gs(R.string.danar_stats_date));
label_date.setTextColor(Color.WHITE);
tr_head.addView(label_date);
TextView label_basalrate = new TextView(this);
- label_basalrate.setText(getString(R.string.danar_stats_basalrate));
+ label_basalrate.setText(MainApp.gs(R.string.danar_stats_basalrate));
label_basalrate.setTextColor(Color.WHITE);
tr_head.addView(label_basalrate);
TextView label_bolus = new TextView(this);
- label_bolus.setText(getString(R.string.danar_stats_bolus));
+ label_bolus.setText(MainApp.gs(R.string.danar_stats_bolus));
label_bolus.setTextColor(Color.WHITE);
tr_head.addView(label_bolus);
TextView label_tdd = new TextView(this);
- label_tdd.setText(getString(R.string.danar_stats_tdd));
+ label_tdd.setText(MainApp.gs(R.string.danar_stats_tdd));
label_tdd.setTextColor(Color.WHITE);
tr_head.addView(label_tdd);
TextView label_ratio = new TextView(this);
- label_ratio.setText(getString(R.string.danar_stats_ratio));
+ label_ratio.setText(MainApp.gs(R.string.danar_stats_ratio));
label_ratio.setTextColor(Color.WHITE);
tr_head.addView(label_ratio);
@@ -179,17 +179,17 @@ public class TDDStatsActivity extends Activity {
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_cum_amount_days = new TextView(this);
- label_cum_amount_days.setText(getString(R.string.danar_stats_amount_days));
+ label_cum_amount_days.setText(MainApp.gs(R.string.danar_stats_amount_days));
label_cum_amount_days.setTextColor(Color.WHITE);
ctr_head.addView(label_cum_amount_days);
TextView label_cum_tdd = new TextView(this);
- label_cum_tdd.setText(getString(R.string.danar_stats_tdd));
+ label_cum_tdd.setText(MainApp.gs(R.string.danar_stats_tdd));
label_cum_tdd.setTextColor(Color.WHITE);
ctr_head.addView(label_cum_tdd);
TextView label_cum_ratio = new TextView(this);
- label_cum_ratio.setText(getString(R.string.danar_stats_ratio));
+ label_cum_ratio.setText(MainApp.gs(R.string.danar_stats_ratio));
label_cum_ratio.setTextColor(Color.WHITE);
ctr_head.addView(label_cum_ratio);
@@ -207,17 +207,17 @@ public class TDDStatsActivity extends Activity {
TableLayout.LayoutParams.WRAP_CONTENT));
TextView label_exp_weight = new TextView(this);
- label_exp_weight.setText(getString(R.string.danar_stats_weight));
+ label_exp_weight.setText(MainApp.gs(R.string.danar_stats_weight));
label_exp_weight.setTextColor(Color.WHITE);
etr_head.addView(label_exp_weight);
TextView label_exp_tdd = new TextView(this);
- label_exp_tdd.setText(getString(R.string.danar_stats_tdd));
+ label_exp_tdd.setText(MainApp.gs(R.string.danar_stats_tdd));
label_exp_tdd.setTextColor(Color.WHITE);
etr_head.addView(label_exp_tdd);
TextView label_exp_ratio = new TextView(this);
- label_exp_ratio.setText(getString(R.string.danar_stats_ratio));
+ label_exp_ratio.setText(MainApp.gs(R.string.danar_stats_ratio));
label_exp_ratio.setTextColor(Color.WHITE);
etr_head.addView(label_exp_ratio);
@@ -235,7 +235,7 @@ public class TDDStatsActivity extends Activity {
reloadButton.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
statsMessage.setVisibility(View.VISIBLE);
- statsMessage.setText(getString(R.string.danar_stats_warning_Message));
+ statsMessage.setText(MainApp.gs(R.string.danar_stats_warning_Message));
}
});
ConfigBuilderPlugin.getCommandQueue().loadTDDs( new Callback() {
@@ -441,7 +441,7 @@ public class TDDStatsActivity extends Activity {
if (isOldData(historyList) && ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad) {
statsMessage.setVisibility(View.VISIBLE);
- statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
+ statsMessage.setText(MainApp.gs(R.string.danar_stats_olddata_Message));
} else {
tl.setBackgroundColor(Color.TRANSPARENT);
diff --git a/app/src/main/java/info/nightscout/androidaps/db/BgReading.java b/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
index 20b9040065..ef0277d170 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
@@ -1,5 +1,7 @@
package info.nightscout.androidaps.db;
+import android.content.res.Resources;
+
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
@@ -211,7 +213,7 @@ public class BgReading implements DataPointWithLabelInterface {
}
int color = MainApp.sResources.getColor(R.color.inrange);
if (isPrediction())
- color = MainApp.sResources.getColor(R.color.prediction);
+ return getPredectionColor();
else if (valueToUnits(units) < lowLine)
color = MainApp.sResources.getColor(R.color.low);
else if (valueToUnits(units) > highLine)
@@ -219,8 +221,7 @@ public class BgReading implements DataPointWithLabelInterface {
return color;
}
- @Override
- public int getSecondColor() {
+ public int getPredectionColor() {
if (isIOBPrediction)
return MainApp.sResources.getColor(R.color.iob);
if (isCOBPrediction)
diff --git a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java
index b0f69144c5..755005cdae 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java
@@ -95,7 +95,7 @@ public class CareportalEvent implements DataPointWithLabelInterface {
if (OverviewFragment.shorttextmode)
return diff.get(TimeUnit.DAYS) +"d" + diff.get(TimeUnit.HOURS) + "h";
else
- return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours);
+ return diff.get(TimeUnit.DAYS) + " " + MainApp.gs(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.gs(R.string.hours);
}
public boolean isOlderThan(double hours) {
@@ -263,9 +263,4 @@ public class CareportalEvent implements DataPointWithLabelInterface {
return Color.GRAY;
}
- @Override
- public int getSecondColor() {
- return 0;
- }
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java
index 418de86c6c..1123cb58df 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java
@@ -297,8 +297,4 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
return Color.CYAN;
}
- @Override
- public int getSecondColor() {
- return 0;
- }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java
index 9dca91c595..40c8e50c6d 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java
@@ -263,11 +263,6 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
return Color.CYAN;
}
- @Override
- public int getSecondColor() {
- return 0;
- }
-
public String toString() {
return "ProfileSwitch{" +
"date=" + date +
diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventChargingState.java b/app/src/main/java/info/nightscout/androidaps/events/EventChargingState.java
new file mode 100644
index 0000000000..bcd9061133
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/events/EventChargingState.java
@@ -0,0 +1,13 @@
+package info.nightscout.androidaps.events;
+
+public class EventChargingState {
+
+ public boolean isCharging = false;
+
+ public EventChargingState() {}
+
+ public EventChargingState(boolean isCharging) {
+ this.isCharging = isCharging;
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.java
index ed639d643d..03df71f31b 100644
--- a/app/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.java
+++ b/app/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.java
@@ -5,6 +5,10 @@ public class EventNetworkChange extends Event {
public boolean mobileConnected = false;
public boolean wifiConnected = false;
- public String ssid;
+ public String ssid = "";
public boolean roaming = false;
+
+ public String getSsid() {
+ return ssid.replace("SSID: ","").replaceAll("\"","");
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java
index f99cb54568..f23d4e802a 100644
--- a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java
+++ b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java
@@ -12,11 +12,11 @@ public class EventPreferenceChange extends Event {
}
public EventPreferenceChange(int resourceID) {
- changedKey = MainApp.sResources.getString(resourceID);
+ changedKey = MainApp.gs(resourceID);
}
public boolean isChanged(int id) {
- return changedKey.equals(MainApp.sResources.getString(id));
+ return changedKey.equals(MainApp.gs(id));
}
public boolean isChanged(String id) {
diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java
index 52c3183821..7d810702b9 100644
--- a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java
+++ b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java
@@ -46,13 +46,13 @@ public class EventPumpStatusChanged extends Event {
public String textStatus() {
if (sStatus == CONNECTING)
- return String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), sSecondsElapsed);
+ return String.format(MainApp.gs(R.string.danar_history_connectingfor), sSecondsElapsed);
else if (sStatus == CONNECTED)
- return MainApp.sResources.getString(R.string.connected);
+ return MainApp.gs(R.string.connected);
else if (sStatus == PERFORMING)
return sPerfomingAction;
else if (sStatus == DISCONNECTING)
- return MainApp.sResources.getString(R.string.disconnecting);
+ return MainApp.gs(R.string.disconnecting);
else if (sStatus == DISCONNECTED)
return "";
return "";
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java
index cc73571b9d..84086d6117 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java
@@ -158,7 +158,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
if (activeExtendedBolus != null) {
extendedBolus.setVisibility(View.GONE);
extendedBolusCancel.setVisibility(View.VISIBLE);
- extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeExtendedBolus.toString());
+ extendedBolusCancel.setText(MainApp.gs(R.string.cancel) + " " + activeExtendedBolus.toString());
} else {
extendedBolus.setVisibility(View.VISIBLE);
extendedBolusCancel.setVisibility(View.GONE);
@@ -174,7 +174,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
if (activeTemp != null) {
tempBasal.setVisibility(View.GONE);
tempBasalCancel.setVisibility(View.VISIBLE);
- tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeTemp.toStringShort());
+ tempBasalCancel.setText(MainApp.gs(R.string.cancel) + " " + activeTemp.toStringShort());
} else {
tempBasal.setVisibility(View.VISIBLE);
tempBasalCancel.setVisibility(View.GONE);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java
index 5e99a6ca17..828c7dbcc9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java
@@ -179,10 +179,10 @@ public class FillDialog extends DialogFragment implements OnClickListener {
}
if (pumpSiteChangeCheckbox.isChecked())
- confirmMessage.add("" + "" + getString(R.string.record_pump_site_change) + "");
+ confirmMessage.add("" + "" + MainApp.gs(R.string.record_pump_site_change) + "");
if (insulinCartridgeChangeCheckbox.isChecked())
- confirmMessage.add("" + "" + getString(R.string.record_insulin_cartridge_change) + "");
+ confirmMessage.add("" + "" + MainApp.gs(R.string.record_insulin_cartridge_change) + "");
final String notes = notesEdit.getText().toString();
if (!notes.isEmpty()) {
@@ -197,7 +197,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
builder.setTitle(MainApp.gs(R.string.confirmation));
if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) {
builder.setMessage(Html.fromHtml(Joiner.on("
").join(confirmMessage)));
- builder.setPositiveButton(getString(R.string.primefill), (dialog, id) -> {
+ builder.setPositiveButton(MainApp.gs(R.string.primefill), (dialog, id) -> {
if (finalInsulinAfterConstraints > 0) {
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
@@ -212,7 +212,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
- i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror));
+ i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
@@ -228,7 +228,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
} else {
builder.setMessage(MainApp.gs(R.string.no_action_selected));
}
- builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
dismiss();
} catch (RuntimeException e) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java
index 04dd783b04..45b6460392 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
import com.crashlytics.android.answers.CustomEvent;
+import org.mozilla.javascript.tools.jsc.Main;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +40,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- getDialog().setTitle(getString(R.string.overview_extendedbolus_button));
+ getDialog().setTitle(MainApp.gs(R.string.overview_extendedbolus_button));
View view = inflater.inflate(R.layout.overview_newextendedbolus_dialog, container, false);
@@ -68,13 +69,13 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
int durationInMinutes = SafeParse.stringToInt(editDuration.getText());
- String confirmMessage = getString(R.string.setextendedbolusquestion);
+ String confirmMessage = MainApp.gs(R.string.setextendedbolusquestion);
Double insulinAfterConstraint = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
confirmMessage += " " + insulinAfterConstraint + " U ";
- confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
+ confirmMessage += MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?";
if (insulinAfterConstraint - insulin != 0d)
- confirmMessage += "\n" + getString(R.string.constraintapllied);
+ confirmMessage += "\n" + MainApp.gs(R.string.constraintapllied);
insulin = insulinAfterConstraint;
final Double finalInsulin = insulin;
@@ -82,9 +83,9 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
final Context context = getContext();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(context.getString(R.string.confirmation));
+ builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(confirmMessage);
- builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
ConfigBuilderPlugin.getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() {
@Override
@@ -93,7 +94,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
- i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror));
+ i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
@@ -102,7 +103,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
FabricPrivacy.getInstance().logCustom(new CustomEvent("ExtendedBolus"));
}
});
- builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
dismiss();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
index fb00879ae4..7a03887cf6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
@@ -52,7 +52,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- getDialog().setTitle(getString(R.string.overview_tempbasal_button));
+ getDialog().setTitle(MainApp.gs(R.string.overview_tempbasal_button));
View view = inflater.inflate(R.layout.overview_newtempbasal_dialog, container, false);
@@ -122,21 +122,21 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
if (profile == null)
return;
- String confirmMessage = getString(R.string.setbasalquestion);
+ String confirmMessage = MainApp.gs(R.string.setbasalquestion);
if (setAsPercent) {
int basalPercentInput = SafeParse.stringToInt(basalPercent.getText());
percent = MainApp.getConstraintChecker().applyBasalPercentConstraints(new Constraint<>(basalPercentInput), profile).value();
confirmMessage += "\n" + percent + "% ";
- confirmMessage += "\n" + getString(R.string.duration) + " " + durationInMinutes + "min ?";
+ confirmMessage += "\n" + MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?";
if (percent != basalPercentInput)
- confirmMessage += "\n" + getString(R.string.constraintapllied);
+ confirmMessage += "\n" + MainApp.gs(R.string.constraintapllied);
} else {
Double basalAbsoluteInput = SafeParse.stringToDouble(basalAbsolute.getText());
absolute = MainApp.getConstraintChecker().applyBasalConstraints(new Constraint<>(basalAbsoluteInput), profile).value();
confirmMessage += "\n" + absolute + " U/h ";
- confirmMessage += "\n" + getString(R.string.duration) + " " + durationInMinutes + "min ?";
+ confirmMessage += "\n" + MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?";
if (absolute - basalAbsoluteInput != 0d)
- confirmMessage += "\n" + getString(R.string.constraintapllied);
+ confirmMessage += "\n" + MainApp.gs(R.string.constraintapllied);
}
final int finalBasalPercent = percent;
@@ -144,9 +144,9 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
final int finalDurationInMinutes = durationInMinutes;
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(this.getContext().getString(R.string.confirmation));
+ builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(confirmMessage);
- builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Callback callback = new Callback() {
@Override
@@ -155,7 +155,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
- i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
@@ -169,7 +169,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
FabricPrivacy.getInstance().logCustom(new CustomEvent("TempBasal"));
}
});
- builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
dismiss();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
index 4719ed525c..ac018e3101 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
@@ -225,7 +225,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 360);
double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 240);
- String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable);
+ String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.gs(R.string.notavailable);
if (sage != null) {
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
if (careportalEvent != null) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java
index 56aa0158cf..46c1e3666d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java
@@ -715,14 +715,26 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
FabricPrivacy.getInstance().logCustom(new CustomEvent("TempTarget"));
}
} else {
- NSUpload.uploadCareportalEntryToNS(data);
+ if (JsonHelper.safeGetString(data, "eventType").equals(CareportalEvent.PROFILESWITCH)) {
+ ProfileSwitch profileSwitch = prepareProfileSwitch(
+ profileStore,
+ JsonHelper.safeGetString(data, "profile"),
+ JsonHelper.safeGetInt(data, "duration"),
+ JsonHelper.safeGetInt(data, "percentage"),
+ JsonHelper.safeGetInt(data, "timeshift"),
+ eventTime.getTime()
+ );
+ NSUpload.uploadProfileSwitch(profileSwitch);
+ } else {
+ NSUpload.uploadCareportalEntryToNS(data);
+ }
FabricPrivacy.getInstance().logCustom(new CustomEvent("NSTreatment"));
}
}
- public static void doProfileSwitch(final ProfileStore profileStore, final String profileName, final int duration, final int percentage, final int timeshift) {
+ public static ProfileSwitch prepareProfileSwitch(final ProfileStore profileStore, final String profileName, final int duration, final int percentage, final int timeshift, long date) {
ProfileSwitch profileSwitch = new ProfileSwitch();
- profileSwitch.date = System.currentTimeMillis();
+ profileSwitch.date = date;
profileSwitch.source = Source.USER;
profileSwitch.profileName = profileName;
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
@@ -731,6 +743,11 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
profileSwitch.timeshift = timeshift;
profileSwitch.percentage = percentage;
+ return profileSwitch;
+ }
+
+ public static void doProfileSwitch(final ProfileStore profileStore, final String profileName, final int duration, final int percentage, final int timeshift) {
+ ProfileSwitch profileSwitch = prepareProfileSwitch(profileStore, profileName, duration, percentage, timeshift, System.currentTimeMillis());
TreatmentsPlugin.getPlugin().addToHistoryProfileSwitch(profileSwitch);
FabricPrivacy.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
index df5b727749..35130c5209 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
@@ -429,17 +429,17 @@ public class ConfigBuilderPlugin extends PluginBase {
request.rate = MainApp.getConstraintChecker().applyBasalConstraints(request.rateConstraint, profile).value();
if (!pump.isInitialized()) {
- log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized));
+ log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpNotInitialized));
if (callback != null) {
- callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
+ callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
}
return;
}
if (pump.isSuspended()) {
- log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpsuspended));
+ log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpsuspended));
if (callback != null) {
- callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpsuspended)).enacted(false).success(false)).run();
+ callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
}
return;
}
@@ -499,17 +499,17 @@ public class ConfigBuilderPlugin extends PluginBase {
PumpInterface pump = getActivePump();
if (!pump.isInitialized()) {
- log.debug("applySMBRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized));
+ log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpNotInitialized));
if (callback != null) {
- callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
+ callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
}
return;
}
if (pump.isSuspended()) {
- log.debug("applySMBRequest: " + MainApp.sResources.getString(R.string.pumpsuspended));
+ log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpsuspended));
if (callback != null) {
- callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpsuspended)).enacted(false).success(false)).run();
+ callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
}
return;
}
@@ -538,7 +538,7 @@ public class ConfigBuilderPlugin extends PluginBase {
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
- i.putExtra("title", MainApp.sResources.getString(R.string.failedupdatebasalprofile));
+ i.putExtra("title", MainApp.gs(R.string.failedupdatebasalprofile));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java
index abe3c75c73..7a4e99b584 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java
@@ -19,13 +19,13 @@ public class DetailedBolusInfoStorage {
private static Logger log = LoggerFactory.getLogger(DetailedBolusInfoStorage.class);
private static List store = new ArrayList<>();
- public static void add(DetailedBolusInfo detailedBolusInfo) {
+ public static synchronized void add(DetailedBolusInfo detailedBolusInfo) {
log.debug("Stored bolus info: " + detailedBolusInfo);
store.add(detailedBolusInfo);
}
@Nullable
- public static DetailedBolusInfo findDetailedBolusInfo(long bolustime) {
+ public static synchronized DetailedBolusInfo findDetailedBolusInfo(long bolustime) {
DetailedBolusInfo found = null;
for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(i).date;
@@ -38,7 +38,7 @@ public class DetailedBolusInfoStorage {
return found;
}
- public static void remove(long bolustime) {
+ public static synchronized void remove(long bolustime) {
for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(i).date;
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java
index 688c741329..1424013440 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java
@@ -26,6 +26,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.FabricPrivacy;
+import info.nightscout.utils.T;
public class ObjectivesFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
@@ -58,7 +59,7 @@ public class ObjectivesFragment extends SubscriberFragment {
holder.position.setText(String.valueOf(position + 1));
holder.objective.setText(o.objective);
holder.gate.setText(o.gate);
- holder.duration.setText(context.getString(R.string.objectives_minimalduration) + " " + o.durationInDays + " " + context.getString(R.string.days));
+ holder.duration.setText(MainApp.gs(R.string.objectives_minimalduration) + " " + o.durationInDays + " " + MainApp.gs(R.string.days));
holder.progress.setText(requirementsMet.comment);
holder.started.setText(o.started.toLocaleString());
holder.accomplished.setText(o.accomplished.toLocaleString());
@@ -204,7 +205,7 @@ public class ObjectivesFragment extends SubscriberFragment {
return 1;
} else if (objectiveStartedTime > 0 && !enableFakeValue
&& objectiveAccomplishedTime == 0
- && !(objectiveStartedTime + durationInDays * 24 * 60 * 60 * 1000 >= now && requirementsMet)) {
+ && !(objectiveStartedTime + T.days(durationInDays).msecs() < now && requirementsMet)) {
return 2;
} else if (objectiveAccomplishedTime == 0) {
return 3;
@@ -240,20 +241,20 @@ public class ObjectivesFragment extends SubscriberFragment {
});
// Add correct translations to array after app is initialized
- ObjectivesPlugin.objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective);
- ObjectivesPlugin.objectives.get(1).objective = MainApp.sResources.getString(R.string.objectives_1_objective);
- ObjectivesPlugin.objectives.get(2).objective = MainApp.sResources.getString(R.string.objectives_2_objective);
- ObjectivesPlugin.objectives.get(3).objective = MainApp.sResources.getString(R.string.objectives_3_objective);
- ObjectivesPlugin.objectives.get(4).objective = MainApp.sResources.getString(R.string.objectives_4_objective);
- ObjectivesPlugin.objectives.get(5).objective = MainApp.sResources.getString(R.string.objectives_5_objective);
- ObjectivesPlugin.objectives.get(6).objective = MainApp.sResources.getString(R.string.objectives_6_objective);
- ObjectivesPlugin.objectives.get(7).objective = MainApp.sResources.getString(R.string.objectives_7_objective);
- ObjectivesPlugin.objectives.get(0).gate = MainApp.sResources.getString(R.string.objectives_0_gate);
- ObjectivesPlugin.objectives.get(1).gate = MainApp.sResources.getString(R.string.objectives_1_gate);
- ObjectivesPlugin.objectives.get(2).gate = MainApp.sResources.getString(R.string.objectives_2_gate);
- ObjectivesPlugin.objectives.get(3).gate = MainApp.sResources.getString(R.string.objectives_3_gate);
- ObjectivesPlugin.objectives.get(4).gate = MainApp.sResources.getString(R.string.objectives_4_gate);
- ObjectivesPlugin.objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate);
+ ObjectivesPlugin.objectives.get(0).objective = MainApp.gs(R.string.objectives_0_objective);
+ ObjectivesPlugin.objectives.get(1).objective = MainApp.gs(R.string.objectives_1_objective);
+ ObjectivesPlugin.objectives.get(2).objective = MainApp.gs(R.string.objectives_2_objective);
+ ObjectivesPlugin.objectives.get(3).objective = MainApp.gs(R.string.objectives_3_objective);
+ ObjectivesPlugin.objectives.get(4).objective = MainApp.gs(R.string.objectives_4_objective);
+ ObjectivesPlugin.objectives.get(5).objective = MainApp.gs(R.string.objectives_5_objective);
+ ObjectivesPlugin.objectives.get(6).objective = MainApp.gs(R.string.objectives_6_objective);
+ ObjectivesPlugin.objectives.get(7).objective = MainApp.gs(R.string.objectives_7_objective);
+ ObjectivesPlugin.objectives.get(0).gate = MainApp.gs(R.string.objectives_0_gate);
+ ObjectivesPlugin.objectives.get(1).gate = MainApp.gs(R.string.objectives_1_gate);
+ ObjectivesPlugin.objectives.get(2).gate = MainApp.gs(R.string.objectives_2_gate);
+ ObjectivesPlugin.objectives.get(3).gate = MainApp.gs(R.string.objectives_3_gate);
+ ObjectivesPlugin.objectives.get(4).gate = MainApp.gs(R.string.objectives_4_gate);
+ ObjectivesPlugin.objectives.get(5).gate = MainApp.gs(R.string.objectives_5_gate);
updateGUI();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java
index 490146cc14..1acf6ea083 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java
@@ -54,7 +54,7 @@ public class FoodFragment extends SubscriberFragment {
ArrayList categories;
ArrayList subcategories;
- final String EMPTY = MainApp.sResources.getString(R.string.none);
+ final String EMPTY = MainApp.gs(R.string.none);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -158,7 +158,7 @@ public class FoodFragment extends SubscriberFragment {
// make it unique
categories = new ArrayList<>(catSet);
- categories.add(0, MainApp.sResources.getString(R.string.none));
+ categories.add(0, MainApp.gs(R.string.none));
ArrayAdapter adapterCategories = new ArrayAdapter<>(getContext(),
R.layout.spinner_centered, categories);
@@ -180,7 +180,7 @@ public class FoodFragment extends SubscriberFragment {
// make it unique
subcategories = new ArrayList<>(subCatSet);
- subcategories.add(0, MainApp.sResources.getString(R.string.none));
+ subcategories.add(0, MainApp.gs(R.string.none));
ArrayAdapter adapterSubcategories = new ArrayAdapter<>(getContext(),
R.layout.spinner_centered, subcategories);
@@ -242,14 +242,14 @@ public class FoodFragment extends SubscriberFragment {
holder.ns.setVisibility(food._id != null ? View.VISIBLE : View.GONE);
holder.name.setText(food.name);
holder.portion.setText(food.portion + food.units);
- holder.carbs.setText(food.carbs + MainApp.sResources.getString(R.string.shortgramm));
- holder.fat.setText(MainApp.sResources.getString(R.string.shortfat) + ": " + food.fat + MainApp.sResources.getString(R.string.shortgramm));
+ holder.carbs.setText(food.carbs + MainApp.gs(R.string.shortgramm));
+ holder.fat.setText(MainApp.gs(R.string.shortfat) + ": " + food.fat + MainApp.gs(R.string.shortgramm));
if (food.fat == 0)
holder.fat.setVisibility(View.INVISIBLE);
- holder.protein.setText(MainApp.sResources.getString(R.string.shortprotein) + ": " + food.protein + MainApp.sResources.getString(R.string.shortgramm));
+ holder.protein.setText(MainApp.gs(R.string.shortprotein) + ": " + food.protein + MainApp.gs(R.string.shortgramm));
if (food.protein == 0)
holder.protein.setVisibility(View.INVISIBLE);
- holder.energy.setText(MainApp.sResources.getString(R.string.shortenergy) + ": " + food.energy + MainApp.sResources.getString(R.string.shortkilojoul));
+ holder.energy.setText(MainApp.gs(R.string.shortenergy) + ": " + food.energy + MainApp.gs(R.string.shortkilojoul));
if (food.energy == 0)
holder.energy.setVisibility(View.INVISIBLE);
holder.remove.setTag(food);
@@ -291,9 +291,9 @@ public class FoodFragment extends SubscriberFragment {
case R.id.food_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + food.name);
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + food.name);
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = food._id;
if (_id != null && !_id.equals("")) {
@@ -302,7 +302,7 @@ public class FoodFragment extends SubscriberFragment {
MainApp.getSpecificPlugin(FoodPlugin.class).getService().delete(food);
}
});
- builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java
index 672c5cfeb6..2c46cd7bb6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefBasePlugin.java
@@ -56,7 +56,7 @@ public abstract class InsulinOrefBasePlugin extends PluginBase implements Insuli
}
public String getNotificationPattern() {
- return MainApp.sResources.getString(R.string.dia_too_short);
+ return MainApp.gs(R.string.dia_too_short);
}
public double getUserDefinedDia() {
@@ -98,7 +98,7 @@ public abstract class InsulinOrefBasePlugin extends PluginBase implements Insuli
String comment = commentStandardText();
double userDia = getUserDefinedDia();
if (userDia < MIN_DIA) {
- comment += "\n" + String.format(MainApp.sResources.getString(R.string.dia_too_short), userDia, MIN_DIA);
+ comment += "\n" + String.format(MainApp.gs(R.string.dia_too_short), userDia, MIN_DIA);
}
return comment;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java
index 3a19573d71..a710f742a7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefFreePeakPlugin.java
@@ -33,12 +33,12 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
}
public String getFriendlyName() {
- return MainApp.sResources.getString(R.string.free_peak_oref);
+ return MainApp.gs(R.string.free_peak_oref);
}
@Override
public String commentStandardText() {
- return MainApp.sResources.getString(R.string.insulin_peak_time) + ": " + getPeak();
+ return MainApp.gs(R.string.insulin_peak_time) + ": " + getPeak();
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java
index cd7769b55b..a8f9761771 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefRapidActingPlugin.java
@@ -32,12 +32,12 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
@Override
public String getFriendlyName() {
- return MainApp.sResources.getString(R.string.rapid_acting_oref);
+ return MainApp.gs(R.string.rapid_acting_oref);
}
@Override
public String commentStandardText() {
- return MainApp.sResources.getString(R.string.fastactinginsulincomment);
+ return MainApp.gs(R.string.fastactinginsulincomment);
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java
index 0e20f8dd42..ba5fc99011 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinOrefUltraRapidActingPlugin.java
@@ -32,17 +32,17 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
@Override
public String getName() {
- return MainApp.sResources.getString(R.string.ultrarapid_oref);
+ return MainApp.gs(R.string.ultrarapid_oref);
}
@Override
public String getFriendlyName() {
- return MainApp.sResources.getString(R.string.ultrarapid_oref);
+ return MainApp.gs(R.string.ultrarapid_oref);
}
@Override
public String commentStandardText() {
- return MainApp.sResources.getString(R.string.ultrafastactinginsulincomment);
+ return MainApp.gs(R.string.ultrafastactinginsulincomment);
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java
index 693a6fad55..79ab63e2ac 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java
@@ -164,9 +164,4 @@ public class AutosensData implements DataPointWithLabelInterface {
return MainApp.gc(R.color.cob);
}
- @Override
- public int getSecondColor() {
- return 0;
- }
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java
index 90b72132bd..d8b6d7674a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java
@@ -1,7 +1,10 @@
package info.nightscout.androidaps.plugins.IobCobCalculator;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import info.nightscout.utils.DecimalFormatter;
+
public class CobInfo {
/** All COB up to now, including carbs not yet processed by IobCob calculation. */
@Nullable
@@ -12,4 +15,17 @@ public class CobInfo {
this.displayCob = displayCob;
this.futureCarbs = futureCarbs;
}
+
+ @NonNull
+ public String generateCOBString() {
+ String cobStringResult = "--g";
+ if (displayCob != null) {
+ cobStringResult = DecimalFormatter.to0Decimal(displayCob);
+ if (futureCarbs > 0) {
+ cobStringResult += "(" + DecimalFormatter.to0Decimal(futureCarbs) + ")";
+ }
+ cobStringResult += "g";
+ }
+ return cobStringResult;
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java
index 2081e43929..89d66fd891 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java
@@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.IobCobCalculator;
import android.os.SystemClock;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;
@@ -325,7 +326,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
basalIobWithZeroTemp.plus(calc);
}
- basalIob.iobWithZeroTemp = basalIobWithZeroTemp;
+ basalIob.iobWithZeroTemp = IobTotal.combine(bolusIob, basalIobWithZeroTemp).round();
}
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();
@@ -404,6 +405,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
}
}
+
+ @NonNull
public CobInfo getCobInfo(boolean _synchronized, String reason) {
AutosensData autosensData = _synchronized ? getLastAutosensDataSynchronized(reason) : getLastAutosensData(reason);
Double displayCob = null;
@@ -414,6 +417,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
if (autosensData != null) {
displayCob = autosensData.cob;
for (Treatment treatment : treatments) {
+ if (!treatment.isValid) continue;
if (IobCobCalculatorPlugin.roundUpTime(treatment.date) > IobCobCalculatorPlugin.roundUpTime(autosensData.time)
&& treatment.date <= now && treatment.carbs > 0) {
displayCob += treatment.carbs;
@@ -421,6 +425,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
}
}
for (Treatment treatment : treatments) {
+ if (!treatment.isValid) continue;
if (treatment.date > now && treatment.carbs > 0) {
futureCarbs += treatment.carbs;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java
index c37730b227..9818ed17e4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java
@@ -98,7 +98,8 @@ public class IobCobThread extends Thread {
AutosensData previous = autosensDataTable.get(prevDataTime);
// start from oldest to be able sub cob
for (int i = bucketed_data.size() - 4; i >= 0; i--) {
- MainApp.bus().post(new EventIobCalculationProgress(i + "/" + bucketed_data.size()));
+ String progress = i + (MainApp.isDev() ? " (" + from + ")" : "");
+ MainApp.bus().post(new EventIobCalculationProgress(progress));
if (iobCobCalculatorPlugin.stopCalculationTrigger) {
iobCobCalculatorPlugin.stopCalculationTrigger = false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
index 7a9c4deae9..87e55c7dc6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
@@ -52,23 +52,23 @@ public class APSResult {
String ret;
// rate
if (rate == 0 && duration == 0)
- ret = MainApp.sResources.getString(R.string.canceltemp) + "\n";
+ ret = MainApp.gs(R.string.canceltemp) + "\n";
else if (rate == -1)
- ret = MainApp.sResources.getString(R.string.let_temp_basal_run) + "\n";
+ ret = MainApp.gs(R.string.let_temp_basal_run) + "\n";
else
- ret = MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " +
+ ret = MainApp.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " +
"(" + DecimalFormatter.to2Decimal(rate / pump.getBaseBasalRate() * 100) + "%) \n" +
- MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min\n";
+ MainApp.gs(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min\n";
// smb
if (smb != 0)
ret += ("SMB: " + DecimalFormatter.toPumpSupportedBolus(smb) + " U\n");
// reason
- ret += MainApp.sResources.getString(R.string.reason) + ": " + reason;
+ ret += MainApp.gs(R.string.reason) + ": " + reason;
return ret;
} else
- return MainApp.sResources.getString(R.string.nochangerequested);
+ return MainApp.gs(R.string.nochangerequested);
}
public Spanned toSpanned() {
@@ -77,23 +77,23 @@ public class APSResult {
String ret;
// rate
if (rate == 0 && duration == 0)
- ret = MainApp.sResources.getString(R.string.canceltemp) + "
";
+ ret = MainApp.gs(R.string.canceltemp) + "
";
else if (rate == -1)
- ret = MainApp.sResources.getString(R.string.let_temp_basal_run) + "
";
+ ret = MainApp.gs(R.string.let_temp_basal_run) + "
";
else
- ret = "" + MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " +
+ ret = "" + MainApp.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " +
"(" + DecimalFormatter.to2Decimal(rate / pump.getBaseBasalRate() * 100) + "%)
" +
- "" + MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min
";
+ "" + MainApp.gs(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min
";
// smb
if (smb != 0)
ret += ("" + "SMB" + ": " + DecimalFormatter.toPumpSupportedBolus(smb) + " U
");
// reason
- ret += "" + MainApp.sResources.getString(R.string.reason) + ": " + reason.replace("<", "<").replace(">", ">");
+ ret += "" + MainApp.gs(R.string.reason) + ": " + reason.replace("<", "<").replace(">", ">");
return Html.fromHtml(ret);
} else
- return Html.fromHtml(MainApp.sResources.getString(R.string.nochangerequested));
+ return Html.fromHtml(MainApp.gs(R.string.nochangerequested));
}
public APSResult() {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java
index 5285dc7831..4ad35c0d02 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java
@@ -65,7 +65,7 @@ public class LoopFragment extends SubscriberFragment {
@OnClick(R.id.loop_run)
void onRunClick() {
- lastRunView.setText(MainApp.sResources.getString(R.string.executing));
+ lastRunView.setText(MainApp.gs(R.string.executing));
new Thread(() -> LoopPlugin.getPlugin().invoke("Loop button", true)).start();
FabricPrivacy.getInstance().logCustom(new CustomEvent("Loop_Run"));
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
index 43d00b24af..f6ec0ff7ab 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
@@ -258,7 +258,7 @@ public class LoopPlugin extends PluginBase {
Constraint loopEnabled = MainApp.getConstraintChecker().isLoopInvokationAllowed();
if (!loopEnabled.value()) {
- String message = MainApp.sResources.getString(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
+ String message = MainApp.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
log.debug(message);
MainApp.bus().post(new EventLoopSetLastRunGui(message));
return;
@@ -272,8 +272,8 @@ public class LoopPlugin extends PluginBase {
Profile profile = MainApp.getConfigBuilder().getProfile();
if (!MainApp.getConfigBuilder().isProfileValid("Loop")) {
- log.debug(MainApp.sResources.getString(R.string.noprofileselected));
- MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected)));
+ log.debug(MainApp.gs(R.string.noprofileselected));
+ MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
return;
}
@@ -288,7 +288,7 @@ public class LoopPlugin extends PluginBase {
// Check if we have any result
if (result == null) {
- MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noapsselected)));
+ MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noapsselected)));
return;
}
@@ -317,14 +317,14 @@ public class LoopPlugin extends PluginBase {
NSUpload.uploadDeviceStatus();
if (isSuspended()) {
- log.debug(MainApp.sResources.getString(R.string.loopsuspended));
- MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopsuspended)));
+ log.debug(MainApp.gs(R.string.loopsuspended));
+ MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended)));
return;
}
if (pump.isSuspended()) {
- log.debug(MainApp.sResources.getString(R.string.pumpsuspended));
- MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.pumpsuspended)));
+ log.debug(MainApp.gs(R.string.pumpsuspended));
+ MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended)));
return;
}
@@ -376,7 +376,7 @@ public class LoopPlugin extends PluginBase {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(MainApp.instance().getApplicationContext(), CHANNEL_ID);
builder.setSmallIcon(R.drawable.notif_icon)
- .setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
+ .setContentTitle(MainApp.gs(R.string.openloop_newsuggestion))
.setContentText(resultAfterConstraints.toString())
.setAutoCancel(true)
.setPriority(Notification.PRIORITY_HIGH)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java
index 39e24f8b38..3bff1c9be3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientFragment.java
@@ -110,16 +110,16 @@ public class NSClientFragment extends SubscriberFragment implements View.OnClick
final Context context = getContext();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(this.getContext().getString(R.string.confirmation));
+ builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage("Clear queue? All data in queue will be lost!");
- builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
UploadQueue.clearQueue();
updateGUI();
FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientClearQueue"));
}
});
- builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
case R.id.nsclientinternal_showqueue:
@@ -165,7 +165,7 @@ public class NSClientFragment extends SubscriberFragment implements View.OnClick
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
}
urlTextView.setText(NSClientPlugin.getPlugin().url());
- Spanned queuetext = Html.fromHtml(MainApp.sResources.getString(R.string.queue) + " " + UploadQueue.size() + "");
+ Spanned queuetext = Html.fromHtml(MainApp.gs(R.string.queue) + " " + UploadQueue.size() + "");
queueTextView.setText(queuetext);
statusTextView.setText(NSClientPlugin.getPlugin().status);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java
index 0525a3a9dd..c43297ccf6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java
@@ -18,12 +18,12 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
-import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventAppExit;
+import info.nightscout.androidaps.events.EventChargingState;
import info.nightscout.androidaps.events.EventNetworkChange;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase;
@@ -33,7 +33,6 @@ import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientN
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
-import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
@@ -55,13 +54,14 @@ public class NSClientPlugin extends PluginBase {
Spanned textLog = Html.fromHtml("");
public boolean paused = false;
- public boolean allowed = true;
boolean autoscroll = true;
public String status = "";
public NSClientService nsClientService = null;
+ private NsClientReceiverDelegate nsClientReceiverDelegate;
+
private NSClientPlugin() {
super(new PluginDescription()
.mainType(PluginType.GENERAL)
@@ -82,8 +82,16 @@ public class NSClientPlugin extends PluginBase {
handlerThread.start();
handler = new Handler(handlerThread.getLooper());
}
+
+ nsClientReceiverDelegate =
+ new NsClientReceiverDelegate(MainApp.instance().getApplicationContext(), MainApp.bus());
}
+ public boolean isAllowed() {
+ return nsClientReceiverDelegate.allowed;
+ }
+
+
@Override
protected void onStart() {
MainApp.bus().register(this);
@@ -92,9 +100,7 @@ public class NSClientPlugin extends PluginBase {
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
super.onStart();
- EventNetworkChange event = NetworkChangeReceiver.grabNetworkStatus();
- if (event != null)
- MainApp.bus().post(event);
+ nsClientReceiverDelegate.registerReceivers();
}
@Override
@@ -102,8 +108,26 @@ public class NSClientPlugin extends PluginBase {
MainApp.bus().unregister(this);
Context context = MainApp.instance().getApplicationContext();
context.unbindService(mConnection);
+
+ nsClientReceiverDelegate.unregisterReceivers();
}
+ @Subscribe
+ public void onStatusEvent(EventPreferenceChange ev) {
+ nsClientReceiverDelegate.onStatusEvent(ev);
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventChargingState ev) {
+ nsClientReceiverDelegate.onStatusEvent(ev);
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventNetworkChange ev) {
+ nsClientReceiverDelegate.onStatusEvent(ev);
+ }
+
+
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
@@ -119,41 +143,12 @@ public class NSClientPlugin extends PluginBase {
}
};
- @Subscribe
- public void onStatusEvent(EventPreferenceChange ev) {
- if (ev.isChanged(R.string.key_ns_wifionly) ||
- ev.isChanged(R.string.key_ns_wifi_ssids) ||
- ev.isChanged(R.string.key_ns_allowroaming)
- ) {
- EventNetworkChange event = NetworkChangeReceiver.grabNetworkStatus();
- if (event != null)
- MainApp.bus().post(event);
- }
- }
-
- @Subscribe
- public void onStatusEvent(final EventNetworkChange ev) {
- boolean wifiOnly = SP.getBoolean(R.string.key_ns_wifionly, false);
- String allowedSSIDs = SP.getString(R.string.key_ns_wifi_ssids, "");
- boolean allowRoaming = SP.getBoolean(R.string.key_ns_allowroaming, true) && !wifiOnly;
-
- boolean newAllowedState = true;
-
- if (!ev.wifiConnected && wifiOnly) newAllowedState = false;
- if (ev.wifiConnected && !allowedSSIDs.isEmpty() && !allowedSSIDs.contains(ev.ssid))
- newAllowedState = false;
- if (!allowRoaming && ev.roaming) newAllowedState = false;
-
- if (newAllowedState != allowed) {
- allowed = newAllowedState;
- MainApp.bus().post(new EventPreferenceChange(R.string.key_nsclientinternal_paused));
- }
- }
-
@Subscribe
public void onStatusEvent(final EventAppExit ignored) {
- if (nsClientService != null)
+ if (nsClientService != null) {
MainApp.instance().getApplicationContext().unbindService(mConnection);
+ nsClientReceiverDelegate.unregisterReceivers();
+ }
}
@Subscribe
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NsClientReceiverDelegate.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NsClientReceiverDelegate.java
new file mode 100644
index 0000000000..04b587ca24
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NsClientReceiverDelegate.java
@@ -0,0 +1,138 @@
+package info.nightscout.androidaps.plugins.NSClientInternal;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.ConnectivityManager;
+import android.net.wifi.WifiManager;
+
+import com.squareup.otto.Bus;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.events.EventChargingState;
+import info.nightscout.androidaps.events.EventNetworkChange;
+import info.nightscout.androidaps.events.EventPreferenceChange;
+import info.nightscout.androidaps.receivers.ChargingStateReceiver;
+import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
+import info.nightscout.utils.SP;
+
+class NsClientReceiverDelegate {
+
+ private final Context context;
+ private final Bus bus;
+
+ private NetworkChangeReceiver networkChangeReceiver = new NetworkChangeReceiver();
+ private ChargingStateReceiver chargingStateReceiver = new ChargingStateReceiver();
+
+ private boolean allowedChargingState = true;
+ private boolean allowedNetworkState = true;
+ boolean allowed = true;
+
+ NsClientReceiverDelegate(Context context, Bus bus) {
+ this.context = context;
+ this.bus = bus;
+ }
+
+ void registerReceivers() {
+ Context context = MainApp.instance().getApplicationContext();
+ // register NetworkChangeReceiver --> https://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html
+ // Nougat is not providing Connectivity-Action anymore ;-(
+ context.registerReceiver(networkChangeReceiver,
+ new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
+ context.registerReceiver(networkChangeReceiver,
+ new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION));
+
+ EventNetworkChange event = networkChangeReceiver.grabNetworkStatus(context);
+ if (event != null)
+ bus.post(event);
+
+ context.registerReceiver(chargingStateReceiver,
+ new IntentFilter(Intent.ACTION_POWER_CONNECTED));
+ context.registerReceiver(chargingStateReceiver,
+ new IntentFilter(Intent.ACTION_POWER_DISCONNECTED));
+
+ EventChargingState eventChargingState = chargingStateReceiver.grabChargingState(context);
+ if (eventChargingState != null)
+ bus.post(eventChargingState);
+
+ }
+
+ void unregisterReceivers() {
+ context.unregisterReceiver(networkChangeReceiver);
+ context.unregisterReceiver(chargingStateReceiver);
+ }
+
+ void onStatusEvent(EventPreferenceChange ev) {
+ if (ev.isChanged(R.string.key_ns_wifionly) ||
+ ev.isChanged(R.string.key_ns_wifi_ssids) ||
+ ev.isChanged(R.string.key_ns_allowroaming)
+ ) {
+ EventNetworkChange event = networkChangeReceiver.grabNetworkStatus(MainApp.instance().getApplicationContext());
+ if (event != null)
+ bus.post(event);
+ } else if (ev.isChanged(R.string.key_ns_chargingonly)) {
+ EventChargingState event = chargingStateReceiver.grabChargingState(MainApp.instance().getApplicationContext());
+ if (event != null)
+ bus.post(event);
+ }
+ }
+
+ void onStatusEvent(final EventChargingState ev) {
+ boolean newChargingState = calculateStatus(ev);
+
+ if (newChargingState != allowedChargingState) {
+ allowedChargingState = newChargingState;
+ processStateChange();
+ }
+ }
+
+ void onStatusEvent(final EventNetworkChange ev) {
+ boolean newNetworkState = calculateStatus(ev);
+
+ if (newNetworkState != allowedNetworkState) {
+ allowedNetworkState = newNetworkState;
+ processStateChange();
+ }
+ }
+
+ void processStateChange() {
+ boolean newAllowedState = allowedChargingState && allowedNetworkState;
+ if (newAllowedState != allowed) {
+ allowed = newAllowedState;
+ bus.post(new EventPreferenceChange(R.string.key_nsclientinternal_paused));
+ }
+ }
+
+ boolean calculateStatus(final EventChargingState ev) {
+ boolean chargingOnly = SP.getBoolean(R.string.key_ns_chargingonly, false);
+
+ boolean newAllowedState = true;
+
+ if (!ev.isCharging && chargingOnly) newAllowedState = false;
+
+ return newAllowedState;
+ }
+
+ boolean calculateStatus(final EventNetworkChange ev) {
+ boolean wifiOnly = SP.getBoolean(R.string.key_ns_wifionly, false);
+ String allowedSSIDs = SP.getString(R.string.key_ns_wifi_ssids, "");
+ boolean allowRoaming = SP.getBoolean(R.string.key_ns_allowroaming, true);
+
+ boolean newAllowedState = true;
+
+ if (ev.wifiConnected) {
+ if (!allowedSSIDs.trim().isEmpty() && !allowedSSIDs.contains(ev.ssid)) {
+ newAllowedState = false;
+ }
+ } else {
+ if ((!allowRoaming && ev.roaming) || wifiOnly) {
+ newAllowedState = false;
+ }
+ }
+
+
+ return newAllowedState;
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java
index 79a66186fb..2723fc0748 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java
@@ -22,7 +22,7 @@ public class DbLogger {
public static void dbAdd(Intent intent, String data) {
List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
if (q.size() < 1) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.sResources.getString(R.string.nsclientnotinstalled));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.gs(R.string.nsclientnotinstalled));
log.error("DBADD No receivers");
} else if (Config.logNSUpload)
log.debug("DBADD dbAdd " + q.size() + " receivers " + data);
@@ -31,7 +31,7 @@ public class DbLogger {
public static void dbRemove(Intent intent, String data) {
List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
if (q.size() < 1) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.sResources.getString(R.string.nsclientnotinstalled));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.gs(R.string.nsclientnotinstalled));
log.error("DBREMOVE No receivers");
} else if (Config.logNSUpload)
log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java
index 445bef32fe..fab9a181c4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java
@@ -33,7 +33,6 @@ import info.nightscout.androidaps.db.DbRequest;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventPreferenceChange;
-import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
@@ -203,7 +202,7 @@ public class NSClientService extends Service {
nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString();
MainApp.bus().post(new EventNSClientStatus("Initializing"));
- if (!MainApp.getSpecificPlugin(NSClientPlugin.class).allowed) {
+ if (!MainApp.getSpecificPlugin(NSClientPlugin.class).isAllowed()) {
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "not allowed"));
MainApp.bus().post(new EventNSClientStatus("Not allowed"));
} else if (MainApp.getSpecificPlugin(NSClientPlugin.class).paused) {
@@ -251,6 +250,7 @@ public class NSClientService extends Service {
private Emitter.Listener onDisconnect = new Emitter.Listener() {
@Override
public void call(Object... args) {
+ log.debug("disconnect reason: {}", args);
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
}
};
@@ -309,7 +309,7 @@ public class NSClientService extends Service {
MainApp.bus().post(new EventNSClientNewLog("ERROR", "Write treatment permission not granted !!!!"));
}
if (!hasWriteAuth) {
- Notification noperm = new Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, MainApp.sResources.getString(R.string.nowritepermission), Notification.URGENT);
+ Notification noperm = new Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, MainApp.gs(R.string.nowritepermission), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(noperm));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.NSCLIENT_NO_WRITE_PERMISSION));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java
index 2e6bb277e6..f05b0ac696 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java
@@ -107,7 +107,7 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
try {
JSONArray iobArray = new JSONArray(determineBasalAdapterAMAJS.getIobDataParam());
- iobDataView.setText(String.format(MainApp.sResources.getString(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0)));
+ iobDataView.setText(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0)));
} catch (JSONException e) {
log.error("Unhandled exception", e);
iobDataView.setText("JSONException");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
index 17e1dd77e9..143456f6fc 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
@@ -104,23 +104,23 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (profile == null) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.noprofileselected));
+ log.debug(MainApp.gs(R.string.noprofileselected));
return;
}
if (!isEnabled(PluginType.APS)) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
+ log.debug(MainApp.gs(R.string.openapsma_disabled));
return;
}
if (glucoseStatus == null) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata));
+ log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
index 00f1888851..14dac65625 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
@@ -104,23 +104,23 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (profile == null) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.noprofileselected));
+ log.debug(MainApp.gs(R.string.noprofileselected));
return;
}
if (!isEnabled(PluginType.APS)) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
+ log.debug(MainApp.gs(R.string.openapsma_disabled));
return;
}
if (glucoseStatus == null) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata));
+ log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java
index 7780fcc9b4..724bfcf86c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java
@@ -99,7 +99,7 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
currentTempView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getCurrentTempParam()).toString().trim());
try {
JSONArray iobArray = new JSONArray(determineBasalAdapterSMBJS.getIobDataParam());
- iobDataView.setText((String.format(MainApp.sResources.getString(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))).trim());
+ iobDataView.setText((String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n" + JSONFormatter.format(iobArray.getString(0))).trim());
} catch (JSONException e) {
log.error("Unhandled exception", e);
iobDataView.setText("JSONException see log for details");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java
index cd7872ecb1..49a81ea612 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java
@@ -107,23 +107,23 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (profile == null) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.noprofileselected));
+ log.debug(MainApp.gs(R.string.noprofileselected));
return;
}
if (!isEnabled(PluginType.APS)) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
+ log.debug(MainApp.gs(R.string.openapsma_disabled));
return;
}
if (glucoseStatus == null) {
- MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata)));
+ MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
if (Config.logAPSResult)
- log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata));
+ log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
return;
}
@@ -255,9 +255,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
if (newvalue < lowLimit || newvalue > highLimit) {
newvalue = Math.max(newvalue, lowLimit);
newvalue = Math.min(newvalue, highLimit);
- String msg = String.format(MainApp.sResources.getString(R.string.valueoutofrange), valueName);
+ String msg = String.format(MainApp.gs(R.string.valueoutofrange), valueName);
msg += ".\n";
- msg += String.format(MainApp.sResources.getString(R.string.valuelimitedto), value, newvalue);
+ msg += String.format(MainApp.gs(R.string.valuelimitedto), value, newvalue);
log.error(msg);
NSUpload.uploadError(msg);
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java
index 35906187a6..8ef6ec2fc6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java
@@ -42,7 +42,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
}
public void setInsulin(double amount) {
- this.amount = amount;
+ BolusProgressDialog.amount = amount;
bolusEnded = false;
}
@@ -53,15 +53,15 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- getDialog().setTitle(String.format(MainApp.sResources.getString(R.string.overview_bolusprogress_goingtodeliver), amount));
+ getDialog().setTitle(String.format(MainApp.gs(R.string.overview_bolusprogress_goingtodeliver), amount));
View view = inflater.inflate(R.layout.overview_bolusprogress_dialog, container, false);
- stopButton = (Button) view.findViewById(R.id.overview_bolusprogress_stop);
- statusView = (TextView) view.findViewById(R.id.overview_bolusprogress_status);
- stopPressedView = (TextView) view.findViewById(R.id.overview_bolusprogress_stoppressed);
- progressBar = (ProgressBar) view.findViewById(R.id.overview_bolusprogress_progressbar);
+ stopButton = view.findViewById(R.id.overview_bolusprogress_stop);
+ statusView = view.findViewById(R.id.overview_bolusprogress_status);
+ stopPressedView = view.findViewById(R.id.overview_bolusprogress_stoppressed);
+ progressBar = view.findViewById(R.id.overview_bolusprogress_progressbar);
stopButton.setOnClickListener(this);
progressBar.setMax(100);
- statusView.setText(MainApp.sResources.getString(R.string.waitingforpump));
+ statusView.setText(MainApp.gs(R.string.waitingforpump));
setCancelable(false);
stopPressed = false;
return view;
@@ -70,16 +70,28 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Override
public void onResume() {
super.onResume();
- if (getDialog() != null)
- getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- MainApp.bus().register(this);
- running = true;
- if (bolusEnded) dismiss();
+ if(!ConfigBuilderPlugin.getCommandQueue().bolusInQueue()) {
+ bolusEnded = true;
+ }
+ if (bolusEnded) {
+ dismiss();
+ } else {
+ if (getDialog() != null)
+ getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ MainApp.subscribe(this);
+ running = true;
+ }
}
@Override
public void dismiss() {
- super.dismiss();
+ try {
+ super.dismiss();
+ } catch (IllegalStateException e) {
+ // dialog not running yet. onResume will try again. Set bolusEnded to make extra
+ // sure onResume will catch this
+ bolusEnded = true;
+ }
if (helperActivity != null) {
helperActivity.finish();
}
@@ -88,7 +100,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Override
public void onPause() {
super.onPause();
- MainApp.bus().unregister(this);
+ MainApp.unsubscribe(this);
running = false;
}
@@ -109,16 +121,13 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
public void onStatusEvent(final EventOverviewBolusProgress ev) {
Activity activity = getActivity();
if (activity != null) {
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- log.debug("Status: " + ev.status + " Percent: " + ev.percent);
- statusView.setText(ev.status);
- progressBar.setProgress(ev.percent);
- if (ev.percent == 100) {
- stopButton.setVisibility(View.INVISIBLE);
- scheduleDismiss();
- }
+ activity.runOnUiThread(() -> {
+ log.debug("Status: " + ev.status + " Percent: " + ev.percent);
+ statusView.setText(ev.status);
+ progressBar.setProgress(ev.percent);
+ if (ev.percent == 100) {
+ stopButton.setVisibility(View.INVISIBLE);
+ scheduleDismiss();
}
});
}
@@ -133,41 +142,25 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {
-
Activity activity = getActivity();
if (activity != null) {
- activity.runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- statusView.setText(c.textStatus());
- }
- }
- );
+ activity.runOnUiThread(() -> statusView.setText(c.textStatus()));
}
-
}
private void scheduleDismiss() {
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- SystemClock.sleep(5000);
- BolusProgressDialog.bolusEnded = true;
- Activity activity = getActivity();
- if (activity != null) {
- activity.runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- try {
- dismiss();
- } catch (Exception e) {
- log.error("Unhandled exception", e);
- }
- }
- });
- }
+ Thread t = new Thread(() -> {
+ SystemClock.sleep(5000);
+ BolusProgressDialog.bolusEnded = true;
+ Activity activity = getActivity();
+ if (activity != null) {
+ activity.runOnUiThread(() -> {
+ try {
+ dismiss();
+ } catch (Exception e) {
+ log.error("Unhandled exception", e);
+ }
+ });
}
});
t.start();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java
index 2751b800bc..50de25b656 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/EditQuickWizardDialog.java
@@ -149,13 +149,13 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
int getSelection(Spinner spinner) {
String value = spinner.getSelectedItem().toString();
- if (value.equals(MainApp.sResources.getString(R.string.yes)))
+ if (value.equals(MainApp.gs(R.string.yes)))
return QuickWizardEntry.YES;
- if (value.equals(MainApp.sResources.getString(R.string.no)))
+ if (value.equals(MainApp.gs(R.string.no)))
return QuickWizardEntry.NO;
- if (value.equals(MainApp.sResources.getString(R.string.positiveonly)))
+ if (value.equals(MainApp.gs(R.string.positiveonly)))
return QuickWizardEntry.POSITIVE_ONLY;
- if (value.equals(MainApp.sResources.getString(R.string.negativeonly)))
+ if (value.equals(MainApp.gs(R.string.negativeonly)))
return QuickWizardEntry.NEGATIVE_ONLY;
return QuickWizardEntry.NO;
}
@@ -164,19 +164,19 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
String selection;
switch (value) {
case QuickWizardEntry.YES:
- selection = MainApp.sResources.getString(R.string.yes);
+ selection = MainApp.gs(R.string.yes);
break;
case QuickWizardEntry.NO:
- selection = MainApp.sResources.getString(R.string.no);
+ selection = MainApp.gs(R.string.no);
break;
case QuickWizardEntry.POSITIVE_ONLY:
- selection = MainApp.sResources.getString(R.string.positiveonly);
+ selection = MainApp.gs(R.string.positiveonly);
break;
case QuickWizardEntry.NEGATIVE_ONLY:
- selection = MainApp.sResources.getString(R.string.negativeonly);
+ selection = MainApp.gs(R.string.negativeonly);
break;
default:
- selection = MainApp.sResources.getString(R.string.no);
+ selection = MainApp.gs(R.string.no);
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
index 5939ab5aa3..2ebab6caab 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
@@ -1,9 +1,7 @@
package info.nightscout.androidaps.plugins.Overview.Dialogs;
-import android.content.Intent;
import android.os.Bundle;
import android.os.HandlerThread;
-import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
@@ -33,15 +31,13 @@ import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.interfaces.Constraint;
-import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.Treatments.CarbsGenerator;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
-import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.DefaultValueHelper;
@@ -364,47 +360,40 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
}
accepted = true;
- if (startActivityTTCheckbox.isChecked()) {
- TempTarget tempTarget = new TempTarget()
- .date(System.currentTimeMillis())
- .duration(finalActivityTTDuration)
- .reason(MainApp.gs(R.string.activity))
- .source(Source.USER)
- .low(Profile.toMgdl(finalActivityTT, currentProfile.getUnits()))
- .high(Profile.toMgdl(finalActivityTT, currentProfile.getUnits()));
- TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
- } else if (startEatingSoonTTCheckbox.isChecked()) {
- TempTarget tempTarget = new TempTarget()
- .date(System.currentTimeMillis())
- .duration(finalEatingSoonTTDuration)
- .reason(MainApp.gs(R.string.eatingsoon))
- .source(Source.USER)
- .low(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()))
- .high(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()));
- TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
- } else if (startHypoTTCheckbox.isChecked()) {
- TempTarget tempTarget = new TempTarget()
- .date(System.currentTimeMillis())
- .duration(finalHypoTTDuration)
- .reason(MainApp.gs(R.string.hypo))
- .source(Source.USER)
- .low(Profile.toMgdl(finalHypoTT, currentProfile.getUnits()))
- .high(Profile.toMgdl(finalHypoTT, currentProfile.getUnits()));
- TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
- }
+ if (startActivityTTCheckbox.isChecked()) {
+ TempTarget tempTarget = new TempTarget()
+ .date(System.currentTimeMillis())
+ .duration(finalActivityTTDuration)
+ .reason(MainApp.gs(R.string.activity))
+ .source(Source.USER)
+ .low(Profile.toMgdl(finalActivityTT, currentProfile.getUnits()))
+ .high(Profile.toMgdl(finalActivityTT, currentProfile.getUnits()));
+ TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
+ } else if (startEatingSoonTTCheckbox.isChecked()) {
+ TempTarget tempTarget = new TempTarget()
+ .date(System.currentTimeMillis())
+ .duration(finalEatingSoonTTDuration)
+ .reason(MainApp.gs(R.string.eatingsoon))
+ .source(Source.USER)
+ .low(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()))
+ .high(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()));
+ TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
+ } else if (startHypoTTCheckbox.isChecked()) {
+ TempTarget tempTarget = new TempTarget()
+ .date(System.currentTimeMillis())
+ .duration(finalHypoTTDuration)
+ .reason(MainApp.gs(R.string.hypo))
+ .source(Source.USER)
+ .low(Profile.toMgdl(finalHypoTT, currentProfile.getUnits()))
+ .high(Profile.toMgdl(finalHypoTT, currentProfile.getUnits()));
+ TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
+ }
if (carbsAfterConstraints > 0) {
if (duration == 0) {
- createCarb(carbsAfterConstraints, time, notes);
+ CarbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes);
} else {
- long remainingCarbs = carbsAfterConstraints;
- int ticks = (duration * 4); //duration guaranteed to be integer greater zero
- for (int i = 0; i < ticks; i++){
- long carbTime = time + i * 15 * 60 * 1000;
- long smallCarbAmount = Math.round((1d * remainingCarbs) / (ticks-i)); //on last iteration (ticks-i) is 1 -> smallCarbAmount == remainingCarbs
- remainingCarbs -= smallCarbAmount;
- createCarb(smallCarbAmount, carbTime, notes);
- }
+ CarbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes);
}
}
}
@@ -419,31 +408,4 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
log.error("Unhandled exception", e);
}
}
-
- private void createCarb(long carbs, long time, @Nullable String notes) {
- DetailedBolusInfo carbInfo = new DetailedBolusInfo();
- carbInfo.date = time;
- carbInfo.eventType = CareportalEvent.CARBCORRECTION;
- carbInfo.carbs = carbs;
- carbInfo.context = getContext();
- carbInfo.source = Source.USER;
- carbInfo.notes = notes;
- if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo && carbInfo.date <= now()) {
- ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
- i.putExtra("soundid", R.raw.boluserror);
- i.putExtra("status", result.comment);
- i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
- i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- MainApp.instance().startActivity(i);
- }
- }
- });
- } else {
- TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo);
- }
- }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
index e15c34bac8..718b1c6bfa 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
@@ -270,13 +270,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
}
private void saveCheckedStates() {
- SP.putBoolean(getString(R.string.key_wizard_include_cob), cobCheckbox.isChecked());
- SP.putBoolean(getString(R.string.key_wizard_include_trend_bg), bgtrendCheckbox.isChecked());
+ SP.putBoolean(MainApp.gs(R.string.key_wizard_include_cob), cobCheckbox.isChecked());
+ SP.putBoolean(MainApp.gs(R.string.key_wizard_include_trend_bg), bgtrendCheckbox.isChecked());
}
private void loadCheckedStates() {
- bgtrendCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_trend_bg), false));
- cobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_cob), false));
+ bgtrendCheckbox.setChecked(SP.getBoolean(MainApp.gs(R.string.key_wizard_include_trend_bg), false));
+ cobCheckbox.setChecked(SP.getBoolean(MainApp.gs(R.string.key_wizard_include_cob), false));
}
@Override
@@ -287,7 +287,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
@Override
public void onNothingSelected(AdapterView> parent) {
- ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.noprofileselected));
+ ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.noprofileselected));
okButton.setVisibility(View.GONE);
}
@@ -306,20 +306,20 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
if (profile != null && (calculatedTotalInsulin > 0d || calculatedCarbs > 0d)) {
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
- String confirmMessage = getString(R.string.entertreatmentquestion);
+ String confirmMessage = MainApp.gs(R.string.entertreatmentquestion);
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(calculatedTotalInsulin)).value();
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(calculatedCarbs)).value();
- confirmMessage += "
" + getString(R.string.bolus) + ": " + "" + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U" + "";
- confirmMessage += "
" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
+ confirmMessage += "
" + MainApp.gs(R.string.bolus) + ": " + "" + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U" + "";
+ confirmMessage += "
" + MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g";
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
- builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
+ builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
+ builder.setMessage(MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
+ builder.setPositiveButton(MainApp.gs(R.string.ok), null);
builder.show();
return;
}
@@ -332,9 +332,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
final String finalNotes = notesEdit.getText().toString();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
+ builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(Html.fromHtml(confirmMessage));
- builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
synchronized (builder) {
if (accepted) {
@@ -356,7 +356,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
- i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
@@ -382,7 +382,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
- i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror));
+ i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
@@ -396,7 +396,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
}
}
});
- builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
dismiss();
}
@@ -412,14 +412,14 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
if (profile == null) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.noprofile));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile));
dismiss();
return;
}
ArrayList profileList;
profileList = profileStore.getProfileList();
- profileList.add(0, MainApp.sResources.getString(R.string.active));
+ profileList.add(0, MainApp.gs(R.string.active));
ArrayAdapter adapter = new ArrayAdapter<>(getContext(),
R.layout.spinner_centered, profileList);
@@ -458,7 +458,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
return; // not initialized yet
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
Profile specificProfile;
- if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active)))
+ if (selectedAlternativeProfile.equals(MainApp.gs(R.string.active)))
specificProfile = MainApp.getConfigBuilder().getProfile();
else
specificProfile = profileStore.getSpecificProfile(selectedAlternativeProfile);
@@ -472,13 +472,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
c_correction = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(c_correction)).value();
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
editCorr.setValue(0d);
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.bolusconstraintapplied));
return;
}
Integer carbsAfterConstraint = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(c_carbs)).value();
if (c_carbs - carbsAfterConstraint != 0) {
editCarbs.setValue(0d);
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.carbsconstraintapplied));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.carbsconstraintapplied));
return;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
index 2536e8bf5c..3d0970f8f4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
@@ -678,9 +678,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(getContext().getString(R.string.confirmation));
- builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
- builder.setPositiveButton(getContext().getString(R.string.ok), (dialog, id) -> {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
+ builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
hideTempRecommendation();
clearNotification();
MainApp.getConfigBuilder().applyTBRRequest(finalLastRun.constraintsProcessed, profile, new Callback() {
@@ -702,7 +702,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
});
FabricPrivacy.getInstance().logCustom(new CustomEvent("AcceptTemp"));
});
- builder.setNegativeButton(getContext().getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
}
}
@@ -742,18 +742,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
if (wizard.calculatedTotalInsulin > 0d && quickWizardEntry.carbs() > 0d) {
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
- String confirmMessage = getString(R.string.entertreatmentquestion);
+ String confirmMessage = MainApp.gs(R.string.entertreatmentquestion);
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(wizard.calculatedTotalInsulin)).value();
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(quickWizardEntry.carbs())).value();
- confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
- confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
+ confirmMessage += "\n" + MainApp.gs(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
+ confirmMessage += "\n" + MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g";
if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
- builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
+ builder.setMessage(MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
builder.setPositiveButton(MainApp.gs(R.string.ok), null);
builder.show();
return;
@@ -766,7 +766,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
accepted = false;
builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(confirmMessage);
- builder.setPositiveButton(getString(R.string.ok), (dialog, id) -> {
+ builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
synchronized (builder) {
if (accepted) {
log.debug("guarding: already accepted");
@@ -822,7 +822,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
}
});
- builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
}
}
@@ -1091,7 +1091,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) {
acceptTempLayout.setVisibility(View.VISIBLE);
- acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
+ acceptTempButton.setText(MainApp.gs(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
} else {
acceptTempLayout.setVisibility(View.GONE);
}
@@ -1269,14 +1269,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
iobView.setText(iobtext);
iobView.setOnClickListener(v -> {
String iobtext1 = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
- + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
- + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
+ + MainApp.gs(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
+ + MainApp.gs(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
OKDialog.show(getActivity(), MainApp.gs(R.string.iob), iobtext1, null);
});
} else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
- + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
- + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
+ + MainApp.gs(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
+ + MainApp.gs(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
iobView.setText(iobtext);
} else {
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
@@ -1359,7 +1359,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// **** BG ****
if (predictionsAvailable && SP.getBoolean("showprediction", false))
- graphData.addBgReadings(fromTime, toTime, lowLine, highLine, finalLastRun.constraintsProcessed);
+ graphData.addBgReadings(fromTime, toTime, lowLine, highLine,
+ finalLastRun.constraintsProcessed.getPredictions());
else
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java
index 25e7cb4af8..8023e86ac0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java
@@ -12,6 +12,7 @@ import com.jjoe64.graphview.series.LineGraphSeries;
import com.jjoe64.graphview.series.Series;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import info.nightscout.androidaps.Constants;
@@ -61,7 +62,7 @@ public class GraphData {
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
}
- public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, APSResult apsResult) {
+ public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, List predictions) {
double maxBgValue = 0d;
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
List bgListArray = new ArrayList<>();
@@ -74,9 +75,12 @@ public class GraphData {
if (bg.value > maxBgValue) maxBgValue = bg.value;
bgListArray.add(bg);
}
- if (apsResult != null) {
- List predArray = apsResult.getPredictions();
- bgListArray.addAll(predArray);
+ if (predictions != null) {
+ Collections.sort(predictions, (o1, o2) -> Double.compare(o1.getX(), o2.getX()));
+ for (BgReading prediction : predictions) {
+ if (prediction.value >= 40)
+ bgListArray.add(prediction);
+ }
}
maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
@@ -273,6 +277,7 @@ public class GraphData {
for (int tx = 0; tx < treatments.size(); tx++) {
Treatment t = treatments.get(tx);
if (t.getX() < fromTime || t.getX() > endTime) continue;
+ if (t.isSMB && !t.isValid) continue;
t.setY(getNearestBg((long) t.getX()));
filteredTreatments.add(t);
}
@@ -431,10 +436,10 @@ public class GraphData {
for (long time = fromTime; time <= toTime; time += 5 * 60 * 1000L) {
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getAutosensData(time);
if (autosensData != null) {
- int color = Color.BLACK; // "="
- if (autosensData.pastSensitivity.equals("C")) color = Color.GRAY;
- if (autosensData.pastSensitivity.equals("+")) color = Color.GREEN;
- if (autosensData.pastSensitivity.equals("-")) color = Color.RED;
+ int color = MainApp.gc(R.color.deviationblack); // "="
+ if (autosensData.pastSensitivity.equals("C")) color = MainApp.gc(R.color.deviationgrey);
+ if (autosensData.pastSensitivity.equals("+")) color = MainApp.gc(R.color.deviationgreen);
+ if (autosensData.pastSensitivity.equals("-")) color = MainApp.gc(R.color.deviationred);
devArray.add(new DeviationDataPoint(time, autosensData.deviation, color, devScale));
maxDevValueFound = Math.max(maxDevValueFound, Math.abs(autosensData.deviation));
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/DataPointWithLabelInterface.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/DataPointWithLabelInterface.java
index 3f6280431c..20d478692a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/DataPointWithLabelInterface.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/DataPointWithLabelInterface.java
@@ -55,5 +55,4 @@ public interface DataPointWithLabelInterface extends DataPointInterface{
PointsWithLabelGraphSeries.Shape getShape();
float getSize();
int getColor();
- int getSecondColor();
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java
index 8ac3be0ad8..5f39cedafe 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java
@@ -211,7 +211,6 @@ public class PointsWithLabelGraphSeries e
mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
- mPaint.setColor(value.getSecondColor());
mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, scaledPxSize / 3, mPaint);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java
index 6087ae0210..1b1487bbaa 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java
@@ -94,7 +94,7 @@ public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter store = new ArrayList();
public long snoozedUntil = 0L;
+ private boolean usesChannels;
public NotificationStore() {
createNotificationChannel();
@@ -60,8 +61,14 @@ public class NotificationStore {
}
store.add(n);
- if (SP.getBoolean(MainApp.sResources.getString(R.string.key_raise_notifications_as_android_notifications), false)) {
+ if (SP.getBoolean(MainApp.gs(R.string.key_raise_notifications_as_android_notifications), false)) {
raiseSystemNotification(n);
+ if (usesChannels && n.soundId != null) {
+ Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
+ alarm.putExtra("soundid", n.soundId);
+ MainApp.instance().startService(alarm);
+ }
+
} else {
if (n.soundId != null) {
Intent alarm = new Intent(MainApp.instance().getApplicationContext(), AlarmSoundService.class);
@@ -105,7 +112,7 @@ public class NotificationStore {
public void unSnooze() {
if (Notification.isAlarmForStaleData()) {
- Notification notification = new Notification(Notification.NSALARM, MainApp.sResources.getString(R.string.nsalarm_staledata), Notification.URGENT);
+ Notification notification = new Notification(Notification.NSALARM, MainApp.gs(R.string.nsalarm_staledata), Notification.URGENT);
SP.putLong("snoozedTo", System.currentTimeMillis());
add(notification);
log.debug("Snoozed to current time and added back notification!");
@@ -126,11 +133,11 @@ public class NotificationStore {
.setDeleteIntent(DismissNotificationService.deleteIntent(n.id));
if (n.level == Notification.URGENT) {
notificationBuilder.setVibrate(new long[]{1000, 1000, 1000, 1000})
- .setContentTitle(MainApp.sResources.getString(R.string.urgent_alarm))
+ .setContentTitle(MainApp.gs(R.string.urgent_alarm))
.setSound(sound, AudioAttributes.USAGE_ALARM);
} else {
notificationBuilder.setVibrate(new long[]{0, 100, 50, 100, 50})
- .setContentTitle(MainApp.sResources.getString(R.string.info))
+ .setContentTitle(MainApp.gs(R.string.info))
;
}
mgr.notify(n.id, notificationBuilder.build());
@@ -138,7 +145,7 @@ public class NotificationStore {
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-
+ usesChannels = true;
NotificationManager mNotificationManager =
(NotificationManager) MainApp.instance().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
@SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java
index 789c9df143..ed57652d1f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java
@@ -35,6 +35,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
+import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DecimalFormatter;
@@ -92,7 +94,7 @@ public class PersistentNotificationPlugin extends PluginBase {
return;
}
- String line1 = ctx.getString(R.string.noprofile);
+ String line1 = "";
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || !MainApp.getConfigBuilder().isProfileValid("Notificiation"))
return;
@@ -109,9 +111,11 @@ public class PersistentNotificationPlugin extends PluginBase {
+ " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units);
} else {
line1 += " " +
- ctx.getString(R.string.old_data) +
+ MainApp.gs(R.string.old_data) +
" ";
}
+ } else {
+ line1 = MainApp.gs(R.string.missed_bg_readings);
}
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
@@ -125,11 +129,9 @@ public class PersistentNotificationPlugin extends PluginBase {
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round();
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
- String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
- + ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
- + ctx.getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
-
+ String line2 = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + MainApp.gs(R.string.cob)+": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString();;
+
String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h";
@@ -138,6 +140,7 @@ public class PersistentNotificationPlugin extends PluginBase {
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
builder.setOngoing(true);
+ builder.setOnlyAlertOnce(true);
builder.setCategory(NotificationCompat.CATEGORY_STATUS);
builder.setSmallIcon(R.drawable.ic_notification);
Bitmap largeIcon = BitmapFactory.decodeResource(ctx.getResources(), R.mipmap.blueowl);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java
index a325f08ad2..6c22a2e9ce 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java
@@ -57,7 +57,7 @@ public class LocalProfileFragment extends SubscriberFragment {
Runnable save = () -> {
doEdit();
if (basalView != null) {
- basalView.updateLabel(MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel());
+ basalView.updateLabel(MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel());
}
};
@@ -91,10 +91,10 @@ public class LocalProfileFragment extends SubscriberFragment {
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
- icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
- isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
- basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
- targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
+ icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
+ isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
+ basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
+ targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
resetButton = (Button) layout.findViewById(R.id.localprofile_reset);
saveButton = (Button) layout.findViewById(R.id.localprofile_save);
@@ -144,10 +144,10 @@ public class LocalProfileFragment extends SubscriberFragment {
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
- icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
- isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
- basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
- targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
+ icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
+ isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
+ basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
+ targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
updateGUI();
});
@@ -199,22 +199,14 @@ public class LocalProfileFragment extends SubscriberFragment {
if (isValid) {
invalidProfile.setVisibility(View.GONE); //show invalid profile
- if (isEdited || !ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended()) {
+ if (isEdited) {
//edited profile -> save first
- //pump not initialized -> don't update profile yet
profileswitchButton.setVisibility(View.GONE);
- } else {
- profileswitchButton.setVisibility(View.VISIBLE);
- }
-
- if(isEdited){
saveButton.setVisibility(View.VISIBLE);
} else {
+ profileswitchButton.setVisibility(View.VISIBLE);
saveButton.setVisibility(View.GONE);
-
}
-
-
} else {
invalidProfile.setVisibility(View.VISIBLE);
profileswitchButton.setVisibility(View.GONE);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java
index 14fdd3c219..455f1f7015 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java
@@ -120,12 +120,18 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
// activity
String activity = plugin.getPump().activity;
- if (StringUtils.isNotEmpty(activity)) {
+ if (activity != null) {
+ activityView.setTextColor(Color.WHITE);
activityView.setTextSize(14);
activityView.setText(activity);
- } else {
+ } else if (plugin.isInitialized()){
+ activityView.setTextColor(Color.WHITE);
activityView.setTextSize(20);
activityView.setText("{fa-bed}");
+ } else {
+ activityView.setTextColor(Color.RED);
+ activityView.setTextSize(14);
+ activityView.setText(MainApp.gs(R.string.pump_unreachable));
}
if (plugin.isInitialized()) {
@@ -145,7 +151,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
// reservoir
int reservoirLevel = plugin.getPump().reservoirLevel;
if (reservoirLevel != -1) {
- reservoirView.setText(reservoirLevel + " " + MainApp.sResources.getString(R.string.insulin_unit_shortname));
+ reservoirView.setText(reservoirLevel + " " + MainApp.gs(R.string.insulin_unit_shortname));
} else if (ps.insulinState == PumpState.LOW) {
reservoirView.setText(MainApp.gs(R.string.combo_reservoir_low));
} else if (ps.insulinState == PumpState.EMPTY) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
index 68db1658f6..3cf4557e54 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
@@ -458,7 +458,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
log.error("deliverTreatment: Invalid input");
return new PumpEnactResult().success(false).enacted(false)
.bolusDelivered(0d).carbsDelivered(0d)
- .comment(MainApp.instance().getString(R.string.danar_invalidinput));
+ .comment(MainApp.gs(R.string.danar_invalidinput));
} else if (detailedBolusInfo.insulin > 0) {
// bolus needed, ask pump to deliver it
return deliverBolus(detailedBolusInfo);
@@ -474,7 +474,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
return new PumpEnactResult().success(true).enacted(true)
.bolusDelivered(0d).carbsDelivered(detailedBolusInfo.carbs)
- .comment(MainApp.instance().getString(R.string.virtualpump_resultok));
+ .comment(MainApp.gs(R.string.virtualpump_resultok));
}
} finally {
MainApp.bus().post(new EventComboPumpUpdateGUI());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
index ea83e6d4d6..903be558b9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java
@@ -95,22 +95,22 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
}
if (!isInitialized()) {
log.error("setNewBasalProfile not initialized");
- Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
+ Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
- result.comment = MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet);
+ result.comment = MainApp.gs(R.string.pumpNotInitializedProfileNotSet);
return result;
} else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
}
if (!sExecutionService.updateBasalsInPump(profile)) {
- Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
+ Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
- result.comment = MainApp.sResources.getString(R.string.failedupdatebasalprofile);
+ result.comment = MainApp.gs(R.string.failedupdatebasalprofile);
return result;
} else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
- Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
+ Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
result.success = true;
result.enacted = true;
@@ -166,7 +166,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.isTempCancel = false;
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
+ result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("setTempBasalPercent: Invalid input");
return result;
}
@@ -178,7 +178,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
result.enacted = false;
result.success = true;
result.isTempCancel = false;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
result.isPercent = true;
@@ -191,7 +191,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent;
@@ -202,7 +202,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
}
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.tempbasaldeliveryerror);
+ result.comment = MainApp.gs(R.string.tempbasaldeliveryerror);
log.error("setTempBasalPercent: Failed to set temp basal");
return result;
}
@@ -219,7 +219,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = false;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.extendedBolusRemainingMinutes;
result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false;
@@ -232,7 +232,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = true;
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false;
result.duration = pump.extendedBolusRemainingMinutes;
result.absolute = pump.extendedBolusAbsoluteRate;
@@ -245,7 +245,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
}
result.enacted = false;
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("setExtendedBolus: Failed to extended bolus");
return result;
}
@@ -261,13 +261,13 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
}
if (!pump.isExtendedInProgress) {
result.success = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions)
log.debug("cancelExtendedBolus: OK");
return result;
} else {
result.success = false;
- result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
+ result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("cancelExtendedBolus: Failed to cancel extended bolus");
return result;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java
index 7ef3d6a987..b8afdaf15a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java
@@ -206,7 +206,7 @@ public class DanaRFragment extends SubscriberFragment {
if (pump.lastConnection != 0) {
Long agoMsec = System.currentTimeMillis() - pump.lastConnection;
int agoMin = (int) (agoMsec / 60d / 1000d);
- lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
+ lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.gs(R.string.minago), agoMin) + ")");
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
}
if (pump.lastBolusTime.getTime() != 0) {
@@ -247,7 +247,7 @@ public class DanaRFragment extends SubscriberFragment {
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
iobView.setText(pump.iob + " U");
if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) {
- firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
+ firmwareView.setText(String.format(MainApp.gs(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
} else {
firmwareView.setText("OLD");
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
index 7a91437f17..279a93340f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
@@ -159,7 +159,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
+ result.success = connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
if (!result.success)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java
index 7f90fb190b..97c5569b4b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java
@@ -122,20 +122,20 @@ public class DanaRHistoryActivity extends Activity {
// Types
ArrayList typeList = new ArrayList<>();
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ALARM, getString(R.string.danar_history_alarm)));
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, getString(R.string.danar_history_basalhours)));
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BOLUS, getString(R.string.danar_history_bolus)));
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, getString(R.string.danar_history_carbohydrates)));
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, getString(R.string.danar_history_dailyinsulin)));
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, getString(R.string.danar_history_glucose)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ALARM, MainApp.gs(R.string.danar_history_alarm)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, MainApp.gs(R.string.danar_history_basalhours)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BOLUS, MainApp.gs(R.string.danar_history_bolus)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, MainApp.gs(R.string.danar_history_carbohydrates)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, MainApp.gs(R.string.danar_history_dailyinsulin)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, MainApp.gs(R.string.danar_history_glucose)));
if (!isKorean && !isRS) {
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, getString(R.string.danar_history_errors)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, MainApp.gs(R.string.danar_history_errors)));
}
if (isRS)
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_PRIME, getString(R.string.danar_history_prime)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_PRIME, MainApp.gs(R.string.danar_history_prime)));
if (!isKorean) {
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, getString(R.string.danar_history_refill)));
- typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, getString(R.string.danar_history_syspend)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, MainApp.gs(R.string.danar_history_refill)));
+ typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, MainApp.gs(R.string.danar_history_syspend)));
}
ArrayAdapter spinnerAdapter = new ArrayAdapter<>(this,
R.layout.spinner_centered, typeList);
@@ -215,7 +215,7 @@ public class DanaRHistoryActivity extends Activity {
});
profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.noprofile));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile));
finish();
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java
index e7813fac10..d505443c1d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java
@@ -57,7 +57,7 @@ public class DanaRNSHistorySync {
if (record._id != null) continue;
//log.debug(record.bytes);
JSONObject nsrec = new JSONObject();
- ev.message = MainApp.sResources.getString(R.string.uploading) + " " + processing + "/" + records + " "; // TODO: translations
+ ev.message = MainApp.gs(R.string.uploading) + " " + processing + "/" + records + " "; // TODO: translations
switch (record.recordCode) {
case RecordTypes.RECORD_TYPE_BOLUS:
if ((what & SYNC_BOLUS) == 0) break;
@@ -68,10 +68,10 @@ public class DanaRNSHistorySync {
nsrec.put("eventType", "Meal Bolus");
nsrec.put("insulin", record.recordValue);
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_sbolus);
+ ev.message += MainApp.gs(R.string.danar_sbolus);
break;
case "E":
if (record.recordDuration > 0) {
@@ -86,10 +86,10 @@ public class DanaRNSHistorySync {
cal.setTimeInMillis(record.recordDate);
cal.add(Calendar.MINUTE, -1 * record.recordDuration);
nsrec.put("created_at", DateUtil.toISOString(cal.getTime()));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_ebolus);
+ ev.message += MainApp.gs(R.string.danar_ebolus);
} else {
log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration");
}
@@ -102,10 +102,10 @@ public class DanaRNSHistorySync {
nsrec.put("splitNow", 100);
nsrec.put("splitExt", 0);
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_dsbolus);
+ ev.message += MainApp.gs(R.string.danar_dsbolus);
break;
case "DE":
log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
@@ -118,10 +118,10 @@ public class DanaRNSHistorySync {
cal.setTimeInMillis(record.recordDate);
cal.add(Calendar.MINUTE, -1 * record.recordDuration);
nsrec.put("created_at", DateUtil.toISOString(cal.getTime()));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_debolus);
+ ev.message += MainApp.gs(R.string.danar_debolus);
break;
default:
log.debug("Unknown bolus record");
@@ -135,10 +135,10 @@ public class DanaRNSHistorySync {
nsrec.put("eventType", "Note");
nsrec.put("notes", "Error");
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_error);
+ ev.message += MainApp.gs(R.string.danar_error);
break;
case RecordTypes.RECORD_TYPE_REFILL:
if ((what & SYNC_REFILL) == 0) break;
@@ -147,10 +147,10 @@ public class DanaRNSHistorySync {
nsrec.put("eventType", "Insulin Change");
nsrec.put("notes", "Refill " + record.recordValue + "U");
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_refill);
+ ev.message += MainApp.gs(R.string.danar_refill);
break;
case RecordTypes.RECORD_TYPE_BASALHOUR:
if ((what & SYNC_BASALHOURS) == 0) break;
@@ -160,10 +160,10 @@ public class DanaRNSHistorySync {
nsrec.put("absolute", record.recordValue);
nsrec.put("duration", 60);
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_basalhour);
+ ev.message += MainApp.gs(R.string.danar_basalhour);
break;
case RecordTypes.RECORD_TYPE_TB:
//log.debug("Ignoring TB record " + record.bytes + " " + DateUtil.toISOString(record.recordDate));
@@ -176,10 +176,10 @@ public class DanaRNSHistorySync {
nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, MainApp.getConfigBuilder().getProfileUnits()));
nsrec.put("glucoseType", "Finger");
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_glucose);
+ ev.message += MainApp.gs(R.string.danar_glucose);
break;
case RecordTypes.RECORD_TYPE_CARBO:
if ((what & SYNC_CARBO) == 0) break;
@@ -188,10 +188,10 @@ public class DanaRNSHistorySync {
nsrec.put("eventType", "Meal Bolus");
nsrec.put("carbs", record.recordValue);
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_carbohydrate);
+ ev.message += MainApp.gs(R.string.danar_carbohydrate);
break;
case RecordTypes.RECORD_TYPE_ALARM:
if ((what & SYNC_ALARM) == 0) break;
@@ -200,10 +200,10 @@ public class DanaRNSHistorySync {
nsrec.put("eventType", "Note");
nsrec.put("notes", "Alarm: " + record.recordAlarm);
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
- nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
+ nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
NSUpload.uploadCareportalEntryToNS(nsrec);
uploaded++;
- ev.message += MainApp.sResources.getString(R.string.danar_alarm);
+ ev.message += MainApp.gs(R.string.danar_alarm);
break;
case RecordTypes.RECORD_TYPE_SUSPEND: // TODO: this too
case RecordTypes.RECORD_TYPE_DAILY:
@@ -216,7 +216,7 @@ public class DanaRNSHistorySync {
}
MainApp.bus().post(ev);
}
- ev.message = String.format(MainApp.sResources.getString(R.string.danar_totaluploaded), uploaded);
+ ev.message = String.format(MainApp.gs(R.string.danar_totaluploaded), uploaded);
MainApp.bus().post(ev);
} catch (JSONException e) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java
index 79358526fa..cb01a7d901 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java
@@ -36,7 +36,7 @@ public class MsgBolusProgress extends MessageBase {
Double done = (amount * 100 - progress) / 100d;
t.insulin = done;
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), done);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), done);
bolusingEvent.t = t;
bolusingEvent.percent = Math.min((int) (done / amount * 100), 100);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java
index 6718d76194..5c677b813e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java
@@ -34,10 +34,10 @@ public class MsgBolusStop extends MessageBase {
stopped = true;
if (!forced) {
t.insulin = amount;
- bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_delivered);
+ bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_delivered);
bolusingEvent.percent = 100;
} else {
- bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_stoped);
+ bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_stoped);
}
MainApp.bus().post(bolusingEvent);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java
index b180d4107b..e42327c3b0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java
@@ -25,19 +25,19 @@ public class MsgError extends MessageBase {
case 1:
case 2:
case 3: // Pump error
- errorString = MainApp.sResources.getString(R.string.pumperror) + " " + errorCode;
+ errorString = MainApp.gs(R.string.pumperror) + " " + errorCode;
break;
case 4: // Shutdown
- errorString = MainApp.sResources.getString(R.string.pumpshutdown);
+ errorString = MainApp.gs(R.string.pumpshutdown);
break;
case 5: // Occlusion
- errorString = MainApp.sResources.getString(R.string.occlusion);
+ errorString = MainApp.gs(R.string.occlusion);
break;
case 7: // Low Battery
- errorString = MainApp.sResources.getString(R.string.lowbattery);
+ errorString = MainApp.gs(R.string.lowbattery);
break;
case 8: // Battery 0%
- errorString = MainApp.sResources.getString(R.string.batterydischarged);
+ errorString = MainApp.gs(R.string.batterydischarged);
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java
index 83bd9dc77d..4fc9844b0d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java
@@ -41,7 +41,7 @@ public class MsgInitConnStatusBolus extends MessageBase {
}
if (!pump.isExtendedBolusEnabled) {
- Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
+ Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java
index 642f539f6c..84d9c413bf 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java
@@ -27,7 +27,7 @@ public class MsgInitConnStatusTime extends MessageBase {
@Override
public void handleMessage(byte[] bytes) {
if (bytes.length - 10 > 7) {
- Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL);
+ Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
log.debug("Wrong model selected. Switching to Korean DanaR");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java
index 01c80bc255..9f945e8b26 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java
@@ -33,12 +33,12 @@ public class MsgSetBasalProfile extends MessageBase {
if (result != 1) {
failed = true;
log.debug("Set basal profile result: " + result + " FAILED!!!");
- Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT);
+ Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
} else {
if (Config.logDanaMessageDetail)
log.debug("Set basal profile result: " + result);
- Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
+ Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(reportOK));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java
index 1c79080093..7dd9ca522b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java
@@ -32,12 +32,12 @@ public class MsgSetSingleBasalProfile extends MessageBase {
if (result != 1) {
failed = true;
log.debug("Set basal profile result: " + result + " FAILED!!!");
- Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT);
+ Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
} else {
if (Config.logDanaMessageDetail)
log.debug("Set basal profile result: " + result);
- Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
+ Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(reportOK));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java
index 6f87803868..8d94a1784d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java
@@ -48,14 +48,14 @@ public class MsgSettingMeal extends MessageBase {
}
if (pump.basalStep != 0.01d) {
- Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.sResources.getString(R.string.danar_setbasalstep001), Notification.URGENT);
+ Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.gs(R.string.danar_setbasalstep001), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.WRONGBASALSTEP));
}
if (pump.isConfigUD) {
- Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.sResources.getString(R.string.danar_switchtouhmode), Notification.URGENT);
+ Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.gs(R.string.danar_switchtouhmode), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.UD_MODE_ENABLED));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java
index 5524cf5c5c..b7201c1163 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java
@@ -134,7 +134,7 @@ public abstract class AbstractDanaRExecutionService extends Service {
}
protected void getBTSocketForSelectedPump() {
- mDevName = SP.getString(MainApp.sResources.getString(R.string.key_danar_bt_name), "");
+ mDevName = SP.getString(MainApp.gs(R.string.key_danar_bt_name), "");
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter != null) {
@@ -152,10 +152,10 @@ public abstract class AbstractDanaRExecutionService extends Service {
}
}
} else {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.nobtadapter));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nobtadapter));
}
if (mBTDevice == null) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.devicenotfound));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.devicenotfound));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
index 944931569b..65a5d22d36 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
@@ -97,7 +97,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.wrongpumppassword), R.raw.error);
return;
}
@@ -138,7 +138,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public void getPumpStatus() {
try {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
MsgStatus statusMsg = new MsgStatus();
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
@@ -154,15 +154,15 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
mSerialIOThread.sendMessage(statusMsg);
mSerialIOThread.sendMessage(statusBasicMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
mSerialIOThread.sendMessage(tempStatusMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
mSerialIOThread.sendMessage(exStatusMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
long now = System.currentTimeMillis();
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRPlugin.class).isInitialized()) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpsettings)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
mSerialIOThread.sendMessage(new MsgSettingMeal());
@@ -173,7 +173,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumptime)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
log.debug("Pump time difference: " + timeDiff + " seconds");
@@ -192,9 +192,9 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
- Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
+ Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
- NSUpload.uploadError(MainApp.sResources.getString(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
+ NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
}
} catch (Exception e) {
log.error("Unhandled exception", e);
@@ -204,11 +204,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public boolean tempBasal(int percent, int durationInHours) {
if (!isConnected()) return false;
if (mDanaRPump.isTempBasalInProgress) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
SystemClock.sleep(500);
}
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -217,7 +217,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public boolean tempBasalStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -226,7 +226,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public boolean extendedBolus(double insulin, int durationInHalfHours) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -235,7 +235,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public boolean extendedBolusStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -310,7 +310,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
while (System.currentTimeMillis() < expectedEnd) {
long waitTime = expectedEnd - System.currentTimeMillis();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.waitingforestimatedbolusend), waitTime / 1000);
MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000);
}
@@ -363,7 +363,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
mSerialIOThread.sendMessage(msgSet);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
index 03d60ad605..092febec61 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
@@ -160,7 +160,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
+ result.success = connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
if (!result.success)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java
index 82beecc5e9..fa28e664ed 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java
@@ -39,7 +39,7 @@ public class MsgInitConnStatusBasic_k extends MessageBase {
}
if (pump.isEasyModeEnabled) {
- Notification notification = new Notification(Notification.EASYMODE_ENABLED, MainApp.sResources.getString(R.string.danar_disableeasymode), Notification.URGENT);
+ Notification notification = new Notification(Notification.EASYMODE_ENABLED, MainApp.gs(R.string.danar_disableeasymode), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.EASYMODE_ENABLED));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java
index bf105b8db0..552511cf7c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java
@@ -44,7 +44,7 @@ public class MsgInitConnStatusBolus_k extends MessageBase {
}
if (!pump.isExtendedBolusEnabled) {
- Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
+ Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java
index 2028411791..7553b0cc37 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java
@@ -29,7 +29,7 @@ public class MsgInitConnStatusTime_k extends MessageBase {
public void handleMessage(byte[] bytes) {
if (bytes.length - 10 < 10) {
- Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL);
+ Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
log.debug("Wrong model selected. Switching to export DanaR");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
index 106074ca3c..b9cc704aba 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
@@ -105,7 +105,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.wrongpumppassword), R.raw.error);
return;
}
@@ -146,7 +146,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public void getPumpStatus() {
try {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
//MsgStatus_k statusMsg = new MsgStatus_k();
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k();
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
@@ -162,15 +162,15 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
//mSerialIOThread.sendMessage(statusMsg);
mSerialIOThread.sendMessage(statusBasicMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
mSerialIOThread.sendMessage(tempStatusMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
mSerialIOThread.sendMessage(exStatusMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
long now = System.currentTimeMillis();
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isInitialized()) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpsettings)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
mSerialIOThread.sendMessage(new MsgSettingMeal());
mSerialIOThread.sendMessage(new MsgSettingBasal_k());
@@ -178,7 +178,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
mSerialIOThread.sendMessage(new MsgSettingGlucose());
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumptime)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
log.debug("Pump time difference: " + timeDiff + " seconds");
@@ -197,9 +197,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
- Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
+ Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
- NSUpload.uploadError(MainApp.sResources.getString(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
+ NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
}
} catch (Exception e) {
log.error("Unhandled exception", e);
@@ -209,11 +209,11 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean tempBasal(int percent, int durationInHours) {
if (!isConnected()) return false;
if (mDanaRPump.isTempBasalInProgress) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
SystemClock.sleep(500);
}
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -222,7 +222,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean tempBasalStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -231,7 +231,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean extendedBolus(double insulin, int durationInHalfHours) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -240,7 +240,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean extendedBolusStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
@@ -310,7 +310,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
mSerialIOThread.sendMessage(msgSet);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
index a2ec13d184..1cbb256c1e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
@@ -297,22 +297,22 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
if (!isInitialized()) {
log.error("setNewBasalProfile not initialized");
- Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
+ Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
- result.comment = MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet);
+ result.comment = MainApp.gs(R.string.pumpNotInitializedProfileNotSet);
return result;
} else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
}
if (!danaRSService.updateBasalsInPump(profile)) {
- Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
+ Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
- result.comment = MainApp.sResources.getString(R.string.failedupdatebasalprofile);
+ result.comment = MainApp.gs(R.string.failedupdatebasalprofile);
return result;
} else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
- Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
+ Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
result.success = true;
result.enacted = true;
@@ -386,7 +386,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = danaRSService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
+ result.success = connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
if (!result.success)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java
index a663d14245..9f72e1d08f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/activities/PairingProgressDialog.java
@@ -51,14 +51,14 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.danars_pairingprogressdialog, container, false);
- getDialog().setTitle(MainApp.sResources.getString(R.string.pairing));
+ getDialog().setTitle(MainApp.gs(R.string.pairing));
statusView = (TextView) view.findViewById(R.id.danars_paringprogress_status);
progressBar = (ProgressBar) view.findViewById(R.id.danars_paringprogress_progressbar);
button = (Button) view.findViewById(R.id.ok);
progressBar.setMax(100);
progressBar.setProgress(0);
- statusView.setText(MainApp.sResources.getString(R.string.waitingforpairing));
+ statusView.setText(MainApp.gs(R.string.waitingforpairing));
button.setVisibility(View.GONE);
button.setOnClickListener(this);
setCancelable(false);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java
index a707c5e0cc..181584df8e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java
@@ -200,7 +200,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
if (datetime.getTime() > lastEventTimeLoaded)
lastEventTimeLoaded = datetime.getTime();
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.processinghistory) + ": " + status));
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java
index 048912a23d..f3fef0d49d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java
@@ -53,7 +53,7 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet {
}
if (pump.basalStep != 0.01d) {
- Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.sResources.getString(R.string.danar_setbasalstep001), Notification.URGENT);
+ Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.gs(R.string.danar_setbasalstep001), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.WRONGBASALSTEP));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java
index eb4af6b25f..69c2f75ba6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java
@@ -102,7 +102,7 @@ public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet {
int missedBolus04EndMin = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (!pump.isExtendedBolusEnabled) {
- Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
+ Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
index f90dd77b74..44e5d308dc 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java
@@ -53,9 +53,10 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
public void handleMessage(byte[] data) {
errorCode = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) {
- if (errorCode == 0)
+ if (errorCode == 0) {
log.debug("Result OK");
- else {
+ failed = false;
+ } else {
failed = true;
log.error("Result Error: " + errorCode);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java
index 83e84e28cc..78548ecab3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java
@@ -47,10 +47,10 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet {
stopped = true;
if (!forced) {
t.insulin = amount;
- bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_delivered);
+ bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_delivered);
bolusingEvent.percent = 100;
} else {
- bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_stoped);
+ bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_stoped);
}
MainApp.bus().post(bolusingEvent);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java
index a9bb7157af..bdc5ab8d9b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java
@@ -43,7 +43,7 @@ public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet {
}
if (pump.productCode < 2) {
- MainApp.bus().post(new EventNewNotification(new Notification(Notification.UNSUPPORTED_FIRMWARE, MainApp.sResources.getString(R.string.unsupportedfirmware), Notification.URGENT)));
+ MainApp.bus().post(new EventNewNotification(new Notification(Notification.UNSUPPORTED_FIRMWARE, MainApp.gs(R.string.unsupportedfirmware), Notification.URGENT)));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java
index 88edd13a63..04737f0bdc 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java
@@ -30,23 +30,23 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet {
switch (alarmCode) {
case 0x01:
// Battery 0% Alarm
- errorString = MainApp.sResources.getString(R.string.batterydischarged);
+ errorString = MainApp.gs(R.string.batterydischarged);
break;
case 0x02:
// Pump Error
- errorString = MainApp.sResources.getString(R.string.pumperror) + " " + alarmCode;
+ errorString = MainApp.gs(R.string.pumperror) + " " + alarmCode;
break;
case 0x03:
// Occlusion
- errorString = MainApp.sResources.getString(R.string.occlusion);
+ errorString = MainApp.gs(R.string.occlusion);
break;
case 0x04:
// LOW BATTERY
- errorString = MainApp.sResources.getString(R.string.lowbattery);
+ errorString = MainApp.gs(R.string.lowbattery);
break;
case 0x05:
// Shutdown
- errorString = MainApp.sResources.getString(R.string.lowbattery);
+ errorString = MainApp.gs(R.string.lowbattery);
break;
case 0x06:
// Basal Compare
@@ -54,20 +54,20 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet {
break;
case 0x09:
// Empty Reservoir
- errorString = MainApp.sResources.getString(R.string.emptyreservoir);
+ errorString = MainApp.gs(R.string.emptyreservoir);
break;
// BT
case 0x07:
case 0xFF:
// Blood sugar measurement alert
- errorString = MainApp.sResources.getString(R.string.bloodsugarmeasurementalert);
+ errorString = MainApp.gs(R.string.bloodsugarmeasurementalert);
break;
case 0x08:
case 0xFE:
// Remaining insulin level
- errorString = MainApp.sResources.getString(R.string.remaininsulinalert);
+ errorString = MainApp.gs(R.string.remaininsulinalert);
break;
case 0xFD:
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java
index fb5793995c..2598c5efc9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java
@@ -39,7 +39,7 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet {
if (t != null) {
t.insulin = deliveredInsulin;
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), deliveredInsulin);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), deliveredInsulin);
bolusingEvent.t = t;
bolusingEvent.percent = Math.min((int) (deliveredInsulin / amount * 100), 100);
done = true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java
index 5354836375..34621d07ee 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java
@@ -39,7 +39,7 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
lastReceive = System.currentTimeMillis();
t.insulin = deliveredInsulin;
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), deliveredInsulin);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), deliveredInsulin);
bolusingEvent.t = t;
bolusingEvent.percent = Math.min((int) (deliveredInsulin / amount * 100), 100);
MainApp.bus().post(bolusingEvent);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java
index 2901c4b863..b552026279 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java
@@ -433,7 +433,7 @@ public class BLEComm {
if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') {
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer));
// Grab pairing key from preferences if exists
- String pairingKey = SP.getString(MainApp.sResources.getString(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null);
+ String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null);
log.debug("Using stored pairing key: " + pairingKey);
if (pairingKey != null) {
byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey);
@@ -448,11 +448,11 @@ public class BLEComm {
} else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') {
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear();
- MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.sResources.getString(R.string.pumpbusy)));
+ MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumpbusy)));
} else {
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear();
- MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.sResources.getString(R.string.connectionerror)));
+ MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.connectionerror)));
}
break;
// 2nd packet, pairing key
@@ -480,7 +480,7 @@ public class BLEComm {
SendTimeInfo();
byte[] pairingKey = {inputBuffer[2], inputBuffer[3]};
// store pairing key to preferences
- SP.putString(MainApp.sResources.getString(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey));
+ SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey));
log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey));
break;
// time and user password information. last packet in handshake
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
index 91859c759a..a6afd0aeb0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
@@ -123,19 +123,19 @@ public class DanaRSService extends Service {
public void getPumpStatus() {
try {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
bleComm.sendMessage(new DanaRS_Packet_General_Initial_Screen_Information());
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
long now = System.currentTimeMillis();
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpsettings)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); // serial no
bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check()); // firmware
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number());
@@ -143,7 +143,7 @@ public class DanaRSService extends Service {
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information()); // target
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array());
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumptime)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
log.debug("Pump time difference: " + timeDiff + " seconds");
@@ -165,9 +165,9 @@ public class DanaRSService extends Service {
NSUpload.uploadDeviceStatus();
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
- Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
+ Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
- NSUpload.uploadError(MainApp.sResources.getString(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
+ NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
}
} catch (Exception e) {
log.error("Unhandled exception", e);
@@ -202,7 +202,7 @@ public class DanaRSService extends Service {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus)));
bolusingTreatment = t;
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed);
@@ -258,7 +258,7 @@ public class DanaRSService extends Service {
long expectedEnd = bolusStart + bolusDurationInMSec + 2000;
while (System.currentTimeMillis() < expectedEnd) {
long waitTime = expectedEnd - System.currentTimeMillis();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.waitingforestimatedbolusend), waitTime / 1000);
MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000);
}
@@ -267,10 +267,10 @@ public class DanaRSService extends Service {
@Override
public void run() {
// reread bolus status
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus
bolusingEvent.percent = 100;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting)));
}
});
return !start.failed;
@@ -295,11 +295,11 @@ public class DanaRSService extends Service {
public boolean tempBasal(Integer percent, int durationInHours) {
if (!isConnected()) return false;
if (danaRPump.isTempBasalInProgress) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
SystemClock.sleep(500);
}
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(percent, durationInHours));
SystemClock.sleep(200);
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
@@ -310,11 +310,11 @@ public class DanaRSService extends Service {
public boolean highTempBasal(Integer percent) {
if (danaRPump.isTempBasalInProgress) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
SystemClock.sleep(500);
}
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent));
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
loadEvents();
@@ -343,7 +343,7 @@ public class DanaRSService extends Service {
public boolean tempBasalStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
loadEvents();
@@ -353,7 +353,7 @@ public class DanaRSService extends Service {
public boolean extendedBolus(Double insulin, int durationInHalfHours) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus(insulin, durationInHalfHours));
SystemClock.sleep(200);
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
@@ -364,7 +364,7 @@ public class DanaRSService extends Service {
public boolean extendedBolusStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel());
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
loadEvents();
@@ -374,7 +374,7 @@ public class DanaRSService extends Service {
public boolean updateBasalsInPump(Profile profile) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal);
bleComm.sendMessage(msgSet);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
index 0ea6f192e4..7c13707949 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
@@ -174,7 +174,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
PumpEnactResult result = new PumpEnactResult();
- result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
+ result.success = connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep;
result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
if (!result.success)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java
index 9117ad1c98..0869844a1c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java
@@ -39,7 +39,7 @@ public class MsgCheckValue_v2 extends MessageBase {
pump.productCode = intFromBuff(bytes, 2, 1);
if (pump.model != DanaRPump.EXPORT_MODEL) {
pump.lastConnection = 0;
- Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL);
+ Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
log.debug("Wrong model selected. Switching to Korean DanaR");
@@ -64,7 +64,7 @@ public class MsgCheckValue_v2 extends MessageBase {
if (pump.protocol != 2) {
pump.lastConnection = 0;
- Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.sResources.getString(R.string.pumpdrivercorrected), Notification.NORMAL);
+ Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
log.debug("Wrong model selected. Switching to non APS DanaR");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java
index ac31d2df92..05c4087dcb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java
@@ -170,6 +170,6 @@ public class MsgHistoryEvents_v2 extends MessageBase {
if (datetime.getTime() > lastEventTimeLoaded)
lastEventTimeLoaded = datetime.getTime();
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.processinghistory) + ": " + status));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
index 25cac9da1c..b9eb8ae655 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
@@ -120,7 +120,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.wrongpumppassword), R.raw.error);
return;
}
@@ -161,7 +161,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public void getPumpStatus() {
try {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
MsgStatus statusMsg = new MsgStatus();
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2();
@@ -175,17 +175,17 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
}
}
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
mSerialIOThread.sendMessage(statusMsg);
mSerialIOThread.sendMessage(statusBasicMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
mSerialIOThread.sendMessage(tempStatusMsg);
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
mSerialIOThread.sendMessage(exStatusMsg);
long now = System.currentTimeMillis();
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpsettings)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
mSerialIOThread.sendMessage(new MsgSettingMeal());
@@ -196,7 +196,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumptime)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
log.debug("Pump time difference: " + timeDiff + " seconds");
@@ -218,9 +218,9 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
NSUpload.uploadDeviceStatus();
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
- Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
+ Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
- NSUpload.uploadError(MainApp.sResources.getString(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
+ NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
}
} catch (Exception e) {
log.error("Unhandled exception", e);
@@ -231,11 +231,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean tempBasal(int percent, int durationInHours) {
if (!isConnected()) return false;
if (mDanaRPump.isTempBasalInProgress) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
SystemClock.sleep(500);
}
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
loadEvents();
@@ -246,11 +246,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean highTempBasal(int percent) {
if (!isConnected()) return false;
if (mDanaRPump.isTempBasalInProgress) {
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
SystemClock.sleep(500);
}
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent));
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
loadEvents();
@@ -280,7 +280,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean tempBasalStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
loadEvents();
@@ -290,7 +290,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean extendedBolus(double insulin, int durationInHalfHours) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2());
loadEvents();
@@ -300,7 +300,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean extendedBolusStop() {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2());
loadEvents();
@@ -312,7 +312,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus)));
mBolusingTreatment = t;
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
MessageBase start;
@@ -371,7 +371,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
long expectedEnd = bolusStart + bolusDurationInMSec + 2000;
while (System.currentTimeMillis() < expectedEnd) {
long waitTime = expectedEnd - System.currentTimeMillis();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.waitingforestimatedbolusend), waitTime / 1000);
MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000);
}
@@ -380,10 +380,10 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
@Override
public void run() {
// load last bolus status
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
mSerialIOThread.sendMessage(new MsgStatus());
bolusingEvent.percent = 100;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting)));
}
});
return !start.failed;
@@ -442,7 +442,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
double[] basal = DanaRPump.buildDanaRProfileRecord(profile);
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
mSerialIOThread.sendMessage(msgSet);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java
index c0e53ddaac..824a449f38 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java
@@ -320,9 +320,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
PumpEnactResult result = new PumpEnactResult();
if (!isInitialized()) {
log.error("setNewBasalProfile not initialized");
- Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
+ Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
- result.comment = MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet);
+ result.comment = MainApp.gs(R.string.pumpNotInitializedProfileNotSet);
return result;
}
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
@@ -339,16 +339,16 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
final Mstatus ms = async.busyWaitForCommandResult(uuid, BUSY_WAIT_TIME);
if (ms.success()) {
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
- Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
+ Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
result.success = true;
result.enacted = true;
result.comment = "OK";
this.profileBlocks = profileBlocks;
} else {
- Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
+ Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
- result.comment = MainApp.sResources.getString(R.string.failedupdatebasalprofile);
+ result.comment = MainApp.gs(R.string.failedupdatebasalprofile);
}
return result;
}
@@ -395,7 +395,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
result.bolusDelivered = detailedBolusInfo.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
result.enacted = result.bolusDelivered > 0 || result.carbsDelivered > 0;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.percent = 100;
@@ -425,7 +425,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
t.isSMB = detailedBolusInfo.isSMB;
final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = t;
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), 0F);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), 0F);
bolusingEvent.bolusId = bolusId;
bolusingEvent.percent = 0;
MainApp.bus().post(bolusingEvent);
@@ -464,7 +464,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
if (activeBolus == null) break;
else {
bolusingEvent.percent = (int) (100D / activeBolus.getInitialAmount() * (activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount()));
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount());
+ bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount());
MainApp.bus().post(bolusingEvent);
}
} else break;
@@ -796,7 +796,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
}
private String gs(int id) {
- return MainApp.instance().getString(id);
+ return MainApp.gs(id);
}
private boolean isPumpRunning() {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java
index a96c98a39a..82b6cc3cc8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java
@@ -62,7 +62,7 @@ public class Connector {
private int serviceReconnects = 0;
private StatusCallback statusCallback = new StatusCallback() {
@Override
- public synchronized void onStatusChange(Status status) {
+ public synchronized void onStatusChange(Status status, long statusTime, long waitTime) {
if ((status != lastStatus) || (Helpers.msSince(lastStatusTime) > 2000)) {
log("Status change: " + status);
@@ -94,15 +94,15 @@ public class Connector {
serviceConnector.connect();
} else {
log("PROTOCOL VERSION MISMATCH! local: " + COMPATIBILITY_VERSION + " remote: " + remoteVersion);
- statusCallback.onStatusChange(Status.INCOMPATIBLE);
- compatabilityMessage = gs(R.string.insight_incompatible_compantion_app_we_need_version) + " " + getLocalVersion();
+ statusCallback.onStatusChange(Status.INCOMPATIBLE, 0, 0);
+ compatabilityMessage = MainApp.gs(R.string.insight_incompatible_compantion_app_we_need_version) + " " + getLocalVersion();
serviceConnector.disconnectFromService();
}
} catch (NullPointerException e) {
log("ERROR: null pointer when trying to connect to pump");
}
- statusCallback.onStatusChange(safeGetStatus());
+ statusCallback.onStatusChange(safeGetStatus(), 0, 0);
}
@Override
@@ -179,33 +179,29 @@ public class Connector {
switch (status) {
case EXCHANGING_KEYS:
- return gs(R.string.connecting).toUpperCase();
+ return MainApp.gs(R.string.connecting).toUpperCase();
case WAITING_FOR_CODE_CONFIRMATION:
- return gs(R.string.insight_waiting_for_code).toUpperCase();
+ return MainApp.gs(R.string.insight_waiting_for_code).toUpperCase();
case CODE_REJECTED:
- return gs(R.string.insight_code_rejected).toUpperCase();
+ return MainApp.gs(R.string.insight_code_rejected).toUpperCase();
case APP_BINDING:
- return gs(R.string.insight_app_binding).toUpperCase();
+ return MainApp.gs(R.string.insight_app_binding).toUpperCase();
case CONNECTING:
- return gs(R.string.connecting).toUpperCase();
+ return MainApp.gs(R.string.connecting).toUpperCase();
case CONNECTED:
- return gs(R.string.connected).toUpperCase();
+ return MainApp.gs(R.string.connected).toUpperCase();
case DISCONNECTED:
- return gs(R.string.disconnected).toUpperCase();
+ return MainApp.gs(R.string.disconnected).toUpperCase();
case NOT_AUTHORIZED:
- return gs(R.string.insight_not_authorized).toUpperCase();
+ return MainApp.gs(R.string.insight_not_authorized).toUpperCase();
case INCOMPATIBLE:
- return gs(R.string.insight_incompatible).toUpperCase();
+ return MainApp.gs(R.string.insight_incompatible).toUpperCase();
default:
return status.toString();
}
}
- private static String gs(int id) {
- return MainApp.instance().getString(id);
- }
-
private static synchronized void extendKeepAliveIfActive() {
if (keepAliveActive()) {
if (Helpers.ratelimit("extend-insight-keepalive", 10)) {
@@ -221,7 +217,7 @@ public class Connector {
public static String getKeepAliveString() {
if (keepAliveActive()) {
- return MainApp.instance().getString(R.string.insight_keepalive_format_string,
+ return MainApp.gs(R.string.insight_keepalive_format_string,
stayConnectedTime / 1000, Helpers.hourMinuteSecondString(stayConnectedTill));
} else {
@@ -384,7 +380,7 @@ public class Connector {
public String getLastStatusMessage() {
if (!companionAppInstalled) {
- return gs(R.string.insight_companion_app_not_installed);
+ return MainApp.gs(R.string.insight_companion_app_not_installed);
}
if (!isConnected()) {
@@ -398,13 +394,13 @@ public class Connector {
// if disconnected but previous state was incompatible
return compatabilityMessage;
} else {
- return gs(R.string.insight_not_connected_to_companion_app);
+ return MainApp.gs(R.string.insight_not_connected_to_companion_app);
}
}
}
if (lastStatus == null) {
- return gs(R.string.insight_unknown);
+ return MainApp.gs(R.string.insight_unknown);
}
switch (lastStatus) {
@@ -414,16 +410,16 @@ public class Connector {
}
break;
case INCOMPATIBLE:
- return statusToString(lastStatus) + " " + gs(R.string.insight_needs) + " " + getLocalVersion();
+ return statusToString(lastStatus) + " " + MainApp.gs(R.string.insight_needs) + " " + getLocalVersion();
}
return statusToString(lastStatus);
}
public String getNiceLastStatusTime() {
if (lastStatusTime < 1) {
- return gs(R.string.insight_startup_uppercase);
+ return MainApp.gs(R.string.insight_startup_uppercase);
} else {
- return Helpers.niceTimeScalar(Helpers.msSince(lastStatusTime)) + " " + gs(R.string.ago);
+ return Helpers.niceTimeScalar(Helpers.msSince(lastStatusTime)) + " " + MainApp.gs(R.string.ago);
}
}
@@ -516,7 +512,7 @@ public class Connector {
}
for (Map.Entry entry : statistics.entrySet()) {
if ((long) entry.getValue() > 1000) {
- l.add(new StatusItem(gs(R.string.statistics) + " " + Helpers.capitalize(entry.getKey().toString()),
+ l.add(new StatusItem(MainApp.gs(R.string.statistics) + " " + Helpers.capitalize(entry.getKey().toString()),
new Formatter().format("%4s %12s",
percentage(getEntryTime(entry), total) + "%",
Helpers.niceTimeScalar(getEntryTime(entry))).toString()));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
index 244537af3e..e7784287b7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java
@@ -161,7 +161,7 @@ class HistoryIntentAdapter {
Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE);
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
- logNote(date, MainApp.instance().getString(getAlertText(alertType)));
+ logNote(date, MainApp.gs(getAlertText(alertType)));
}
}
@@ -171,13 +171,13 @@ class HistoryIntentAdapter {
String newStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_NEW_STATUS);
switch (newStatus) {
case "STARTED":
- logNote(newStatusTime, MainApp.instance().getString(R.string.pump_started));
+ logNote(newStatusTime, MainApp.gs(R.string.pump_started));
break;
case "STOPPED":
- logNote(newStatusTime, MainApp.instance().getString(R.string.pump_stopped));
+ logNote(newStatusTime, MainApp.gs(R.string.pump_stopped));
break;
case "PAUSED":
- logNote(newStatusTime, MainApp.instance().getString(R.string.pump_paused));
+ logNote(newStatusTime, MainApp.gs(R.string.pump_paused));
break;
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java
index efce8d7a40..ca68a389c8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryReceiver.java
@@ -131,7 +131,7 @@ public class HistoryReceiver {
@Override
public String toString() {
- return MainApp.instance().getString(string_id);
+ return MainApp.gs(string_id);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java
index ca3848e113..46af6bda98 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/LiveHistory.java
@@ -17,7 +17,7 @@ public class LiveHistory {
public static String getStatus() {
if (status.equals("")) return status;
- return status + " " + Helpers.niceTimeScalar(Helpers.msSince(status_time)) + " " + gs(R.string.ago);
+ return status + " " + Helpers.niceTimeScalar(Helpers.msSince(status_time)) + " " + MainApp.gs(R.string.ago);
}
public static long getStatusTime() {
@@ -30,8 +30,4 @@ public class LiveHistory {
status = mystatus;
}
}
-
- private static String gs(int id) {
- return MainApp.instance().getString(id);
- }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java
index a2abda40d7..344bf638b2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/utils/Helpers.java
@@ -96,32 +96,28 @@ public class Helpers {
}
public static String niceTimeScalar(long t) {
- String unit = gs(R.string.second);
+ String unit = MainApp.gs(R.string.second);
t = t / 1000;
if (t > 59) {
- unit = gs(R.string.minute);
+ unit = MainApp.gs(R.string.minute);
t = t / 60;
if (t > 59) {
- unit = gs(R.string.hour);
+ unit = MainApp.gs(R.string.hour);
t = t / 60;
if (t > 24) {
- unit = gs(R.string.day);
+ unit = MainApp.gs(R.string.day);
t = t / 24;
if (t > 28) {
- unit = gs(R.string.week);
+ unit = MainApp.gs(R.string.week);
t = t / 7;
}
}
}
}
- if (t != 1) unit = unit + gs(R.string.time_plural);
+ if (t != 1) unit = unit + MainApp.gs(R.string.time_plural);
return qs((double) t, 0) + " " + unit;
}
- private static String gs(int id) {
- return MainApp.instance().getString(id);
- }
-
public static String qs(double x, int digits) {
if (digits == -1) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
index 9c19a383ae..fed0c01c64 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
@@ -134,7 +134,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
result.success = true;
result.bolusDelivered = detailedBolusInfo.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
return result;
}
@@ -147,7 +147,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
- result.comment = MainApp.instance().getString(R.string.pumperror);
+ result.comment = MainApp.gs(R.string.pumperror);
if (Config.logPumpComm)
log.debug("Setting temp basal absolute: " + result);
return result;
@@ -157,7 +157,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
- result.comment = MainApp.instance().getString(R.string.pumperror);
+ result.comment = MainApp.gs(R.string.pumperror);
if (Config.logPumpComm)
log.debug("Settings temp basal percent: " + result);
return result;
@@ -167,7 +167,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
- result.comment = MainApp.instance().getString(R.string.pumperror);
+ result.comment = MainApp.gs(R.string.pumperror);
if (Config.logPumpComm)
log.debug("Setting extended bolus: " + result);
return result;
@@ -177,7 +177,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
public PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
- result.comment = MainApp.instance().getString(R.string.pumperror);
+ result.comment = MainApp.gs(R.string.pumperror);
if (Config.logPumpComm)
log.debug("Cancel temp basal: " + result);
return result;
@@ -187,7 +187,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
- result.comment = MainApp.instance().getString(R.string.pumperror);
+ result.comment = MainApp.gs(R.string.pumperror);
if (Config.logPumpComm)
log.debug("Canceling extended basal: " + result);
return result;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
index 95f27d1707..4a85b5d462 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
@@ -176,7 +176,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
PumpEnactResult result = new PumpEnactResult();
result.success = true;
- Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
+ Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
return result;
}
@@ -207,21 +207,21 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.bolusDelivered = detailedBolusInfo.insulin;
result.carbsDelivered = detailedBolusInfo.carbs;
result.enacted = result.bolusDelivered > 0 || result.carbsDelivered > 0;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
Double delivering = 0d;
while (delivering < detailedBolusInfo.insulin) {
SystemClock.sleep(200);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), delivering);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), delivering);
bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100);
MainApp.bus().post(bolusingEvent);
delivering += 0.1d;
}
SystemClock.sleep(200);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
- bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivered), detailedBolusInfo.insulin);
+ bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivered), detailedBolusInfo.insulin);
bolusingEvent.percent = 100;
MainApp.bus().post(bolusingEvent);
SystemClock.sleep(1000);
@@ -251,7 +251,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.isTempCancel = false;
result.absolute = absoluteRate;
result.duration = durationInMinutes;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
if (Config.logPumpComm)
log.debug("Setting temp basal absolute: " + result);
@@ -279,7 +279,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.isPercent = true;
result.isTempCancel = false;
result.duration = durationInMinutes;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
if (Config.logPumpComm)
log.debug("Settings temp basal percent: " + result);
@@ -303,7 +303,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.bolusDelivered = insulin;
result.isTempCancel = false;
result.duration = durationInMinutes;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
if (Config.logPumpComm)
log.debug("Setting extended bolus: " + result);
@@ -317,7 +317,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
PumpEnactResult result = new PumpEnactResult();
result.success = true;
result.isTempCancel = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
result.enacted = true;
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
@@ -342,7 +342,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
result.success = true;
result.enacted = true;
result.isTempCancel = true;
- result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
+ result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpComm)
log.debug("Canceling extended basal: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java
index 28c4192f99..75b1ea9675 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java
@@ -56,9 +56,9 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
String age = SP.getString(R.string.key_age, "");
int defaultHours = 24;
- if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
- if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 4;
- if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
+ if (age.equals(MainApp.gs(R.string.key_adult))) defaultHours = 24;
+ if (age.equals(MainApp.gs(R.string.key_teenage))) defaultHours = 4;
+ if (age.equals(MainApp.gs(R.string.key_child))) defaultHours = 4;
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
Profile profile = MainApp.getConfigBuilder().getProfile();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java
index 2f59769f55..58f59701d9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java
@@ -52,9 +52,9 @@ public class SensitivityWeightedAveragePlugin extends PluginBase implements Sens
String age = SP.getString(R.string.key_age, "");
int defaultHours = 24;
- if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
- if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 4;
- if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
+ if (age.equals(MainApp.gs(R.string.key_adult))) defaultHours = 24;
+ if (age.equals(MainApp.gs(R.string.key_teenage))) defaultHours = 4;
+ if (age.equals(MainApp.gs(R.string.key_child))) defaultHours = 4;
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
if (autosensDataTable == null || autosensDataTable.size() < 4) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
index a0192a528c..9de6cc6ad6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
@@ -206,24 +206,24 @@ public class SmsCommunicatorPlugin extends PluginBase {
String units = MainApp.getConfigBuilder().getProfileUnits();
if (actualBG != null) {
- reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
+ reply = MainApp.gs(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
} else if (lastBG != null) {
Long agoMsec = System.currentTimeMillis() - lastBG.date;
int agoMin = (int) (agoMsec / 60d / 1000d);
- reply = MainApp.sResources.getString(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.sResources.getString(R.string.sms_minago), agoMin) + ", ";
+ reply = MainApp.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.gs(R.string.sms_minago), agoMin) + ", ";
}
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
if (glucoseStatus != null)
- reply += MainApp.sResources.getString(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
+ reply += MainApp.gs(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round();
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
- reply += MainApp.sResources.getString(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
- + MainApp.sResources.getString(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
- + MainApp.sResources.getString(R.string.sms_basal) + " " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
+ reply += MainApp.gs(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
+ + MainApp.gs(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
+ + MainApp.gs(R.string.sms_basal) + " " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
receivedSms.processed = true;
@@ -241,8 +241,8 @@ public class SmsCommunicatorPlugin extends PluginBase {
@Override
public void run() {
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
- String reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled) + " " +
- MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
+ String reply = MainApp.gs(R.string.smscommunicator_loophasbeendisabled) + " " +
+ MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
});
@@ -255,7 +255,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
- reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled);
+ reply = MainApp.gs(R.string.smscommunicator_loophasbeenenabled);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
}
@@ -267,11 +267,11 @@ public class SmsCommunicatorPlugin extends PluginBase {
if (loopPlugin != null) {
if (loopPlugin.isEnabled(PluginType.LOOP)) {
if (loopPlugin.isSuspended())
- reply = String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend());
+ reply = String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend());
else
- reply = MainApp.sResources.getString(R.string.smscommunicator_loopisenabled);
+ reply = MainApp.gs(R.string.smscommunicator_loopisenabled);
} else {
- reply = MainApp.sResources.getString(R.string.smscommunicator_loopisdisabled);
+ reply = MainApp.gs(R.string.smscommunicator_loopisdisabled);
}
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
@@ -282,7 +282,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
LoopPlugin.getPlugin().suspendTo(0);
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_RESUME"));
NSUpload.uploadOpenAPSOffline(0);
- reply = MainApp.sResources.getString(R.string.smscommunicator_loopresumed);
+ reply = MainApp.gs(R.string.smscommunicator_loopresumed);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Resume"));
break;
@@ -292,18 +292,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
duration = Math.max(0, duration);
duration = Math.min(180, duration);
if (duration == 0) {
- reply = MainApp.sResources.getString(R.string.smscommunicator_wrongduration);
+ reply = MainApp.gs(R.string.smscommunicator_wrongduration);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else if (remoteCommandsAllowed) {
passCode = generatePasscode();
- reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_suspendreplywithcode), duration, passCode);
+ reply = String.format(MainApp.gs(R.string.smscommunicator_suspendreplywithcode), duration, passCode);
receivedSms.processed = true;
resetWaitingMessages();
sendSMS(suspendWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
suspendWaitingForConfirmation.duration = duration;
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Suspend"));
} else {
- reply = MainApp.sResources.getString(R.string.smscommunicator_remotecommandnotallowed);
+ reply = MainApp.gs(R.string.smscommunicator_remotecommandnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
break;
@@ -350,7 +350,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
} else {
- String reply = MainApp.sResources.getString(R.string.readstatusfailed);
+ String reply = MainApp.gs(R.string.readstatusfailed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
}
@@ -363,33 +363,33 @@ public class SmsCommunicatorPlugin extends PluginBase {
if (splited[1].toUpperCase().equals("CANCEL") || splited[1].toUpperCase().equals("STOP")) {
if (remoteCommandsAllowed) {
passCode = generatePasscode();
- reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_basalstopreplywithcode), passCode);
+ reply = String.format(MainApp.gs(R.string.smscommunicator_basalstopreplywithcode), passCode);
receivedSms.processed = true;
resetWaitingMessages();
sendSMS(cancelTempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal"));
} else {
- reply = MainApp.sResources.getString(R.string.smscommunicator_remotebasalnotallowed);
+ reply = MainApp.gs(R.string.smscommunicator_remotebasalnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
} else {
tempBasal = SafeParse.stringToDouble(splited[1]);
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
- reply = MainApp.sResources.getString(R.string.noprofile);
+ reply = MainApp.gs(R.string.noprofile);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
tempBasal = MainApp.getConstraintChecker().applyBasalConstraints(new Constraint<>(tempBasal), profile).value();
if (remoteCommandsAllowed) {
passCode = generatePasscode();
- reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_basalreplywithcode), tempBasal, passCode);
+ reply = String.format(MainApp.gs(R.string.smscommunicator_basalreplywithcode), tempBasal, passCode);
receivedSms.processed = true;
resetWaitingMessages();
sendSMS(tempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
tempBasalWaitingForConfirmation.tempBasal = tempBasal;
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal"));
} else {
- reply = MainApp.sResources.getString(R.string.smscommunicator_remotebasalnotallowed);
+ reply = MainApp.gs(R.string.smscommunicator_remotebasalnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
}
@@ -398,24 +398,24 @@ public class SmsCommunicatorPlugin extends PluginBase {
break;
case "BOLUS":
if (System.currentTimeMillis() - lastRemoteBolusTime.getTime() < Constants.remoteBolusMinDistance) {
- reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed);
+ reply = MainApp.gs(R.string.smscommunicator_remotebolusnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else if (ConfigBuilderPlugin.getActivePump().isSuspended()) {
- reply = MainApp.sResources.getString(R.string.pumpsuspended);
+ reply = MainApp.gs(R.string.pumpsuspended);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else if (splited.length > 1) {
amount = SafeParse.stringToDouble(splited[1]);
amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
if (amount > 0d && remoteCommandsAllowed) {
passCode = generatePasscode();
- reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusreplywithcode), amount, passCode);
+ reply = String.format(MainApp.gs(R.string.smscommunicator_bolusreplywithcode), amount, passCode);
receivedSms.processed = true;
resetWaitingMessages();
sendSMS(bolusWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
bolusWaitingForConfirmation.bolusRequested = amount;
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Bolus"));
} else {
- reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed);
+ reply = MainApp.gs(R.string.smscommunicator_remotebolusnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
}
@@ -425,14 +425,14 @@ public class SmsCommunicatorPlugin extends PluginBase {
amount = SafeParse.stringToDouble(splited[1]);
if (amount > 0d && remoteCommandsAllowed) {
passCode = generatePasscode();
- reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
+ reply = String.format(MainApp.gs(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
receivedSms.processed = true;
resetWaitingMessages();
sendSMS(calibrationWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
calibrationWaitingForConfirmation.calibrationRequested = amount;
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Cal"));
} else {
- reply = MainApp.sResources.getString(R.string.smscommunicator_remotecalibrationnotallowed);
+ reply = MainApp.gs(R.string.smscommunicator_remotecalibrationnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
}
@@ -449,13 +449,13 @@ public class SmsCommunicatorPlugin extends PluginBase {
public void run() {
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
if (result.success) {
- String reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
+ String reply = String.format(MainApp.gs(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
if (pump != null)
reply += "\n" + pump.shortStatus(true);
lastRemoteBolusTime = new Date();
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
- String reply = MainApp.sResources.getString(R.string.smscommunicator_bolusfailed);
+ String reply = MainApp.gs(R.string.smscommunicator_bolusfailed);
if (pump != null)
reply += "\n" + pump.shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
@@ -471,11 +471,11 @@ public class SmsCommunicatorPlugin extends PluginBase {
@Override
public void run() {
if (result.success) {
- String reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
+ String reply = String.format(MainApp.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
- String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalfailed);
+ String reply = MainApp.gs(R.string.smscommunicator_tempbasalfailed);
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
@@ -488,11 +488,11 @@ public class SmsCommunicatorPlugin extends PluginBase {
@Override
public void run() {
if (result.success) {
- String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
+ String reply = MainApp.gs(R.string.smscommunicator_tempbasalcanceled);
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
- String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
+ String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed);
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
@@ -503,10 +503,10 @@ public class SmsCommunicatorPlugin extends PluginBase {
calibrationWaitingForConfirmation.processed = true;
boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested);
if (result) {
- reply = MainApp.sResources.getString(R.string.smscommunicator_calibrationsent);
+ reply = MainApp.gs(R.string.smscommunicator_calibrationsent);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
- reply = MainApp.sResources.getString(R.string.smscommunicator_calibrationfailed);
+ reply = MainApp.gs(R.string.smscommunicator_calibrationfailed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
} else if (suspendWaitingForConfirmation != null && !suspendWaitingForConfirmation.processed &&
@@ -519,18 +519,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
- String reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
- MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
+ String reply = MainApp.gs(R.string.smscommunicator_loopsuspended) + " " +
+ MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
- String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
+ String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed);
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
}
});
} else {
- sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));
+ sendSMS(new Sms(receivedSms.phoneNumber, MainApp.gs(R.string.smscommunicator_unknowncommand), new Date()));
}
resetWaitingMessages();
break;
@@ -563,10 +563,10 @@ public class SmsCommunicatorPlugin extends PluginBase {
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);
+ Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.gs(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
} catch (java.lang.SecurityException e) {
- Notification notification = new Notification(Notification.MISSING_SMS_PERMISSION, MainApp.sResources.getString(R.string.smscommunicator_missingsmspermission), Notification.NORMAL);
+ Notification notification = new Notification(Notification.MISSING_SMS_PERMISSION, MainApp.gs(R.string.smscommunicator_missingsmspermission), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java
index 7e959b78d4..3e9a79d459 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/BGSourceFragment.java
@@ -143,9 +143,9 @@ public class BGSourceFragment extends SubscriberFragment {
case R.id.bgsource_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profile.getUnits()));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profile.getUnits()));
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
/* final String _id = bgReading._id;
if (NSUpload.isIdValid(_id)) {
@@ -159,7 +159,7 @@ public class BGSourceFragment extends SubscriberFragment {
updateGUI();
}
});
- builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/CarbsGenerator.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/CarbsGenerator.java
new file mode 100644
index 0000000000..99168a2776
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/CarbsGenerator.java
@@ -0,0 +1,56 @@
+package info.nightscout.androidaps.plugins.Treatments;
+
+import android.content.Intent;
+import android.support.annotation.Nullable;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.data.DetailedBolusInfo;
+import info.nightscout.androidaps.db.CareportalEvent;
+import info.nightscout.androidaps.db.Source;
+import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
+import info.nightscout.androidaps.queue.Callback;
+
+import static info.nightscout.utils.DateUtil.now;
+
+public class CarbsGenerator {
+ public static void generateCarbs(int amount, long startTime, int duration, @Nullable String notes) {
+ long remainingCarbs = amount;
+ int ticks = (duration * 4); //duration guaranteed to be integer greater zero
+ for (int i = 0; i < ticks; i++){
+ long carbTime = startTime + i * 15 * 60 * 1000;
+ int smallCarbAmount = (int) Math.round((1d * remainingCarbs) / (ticks-i)); //on last iteration (ticks-i) is 1 -> smallCarbAmount == remainingCarbs
+ remainingCarbs -= smallCarbAmount;
+ if (smallCarbAmount > 0)
+ createCarb(smallCarbAmount, carbTime, CareportalEvent.MEALBOLUS, notes);
+ }
+ }
+
+ public static void createCarb(int carbs, long time, String eventType, @Nullable String notes) {
+ DetailedBolusInfo carbInfo = new DetailedBolusInfo();
+ carbInfo.date = time;
+ carbInfo.eventType = eventType;
+ carbInfo.carbs = carbs;
+ carbInfo.context = MainApp.instance();
+ carbInfo.source = Source.USER;
+ carbInfo.notes = notes;
+ if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo && carbInfo.date <= now()) {
+ ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() {
+ @Override
+ public void run() {
+ if (!result.success) {
+ Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
+ i.putExtra("soundid", R.raw.boluserror);
+ i.putExtra("status", result.comment);
+ i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
+ i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ MainApp.instance().startActivity(i);
+ }
+ }
+ });
+ } else {
+ TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo);
+ }
+ }
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java
index 31d44a3e30..1983c38242 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/Treatment.java
@@ -193,11 +193,6 @@ public class Treatment implements DataPointWithLabelInterface {
return MainApp.instance().getResources().getColor(android.R.color.holo_red_light);
}
- @Override
- public int getSecondColor() {
- return 0;
- }
-
@Override
public void setY(double y) {
yValue = y;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
index 55129cdc7b..8ae2e6d7b1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
@@ -284,6 +284,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
long last = 0;
synchronized (treatments) {
for (Treatment t : treatments) {
+ if (!t.isValid)
+ continue;
if (t.date > last && t.insulin > 0 && t.isValid && t.date <= now)
last = t.date;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java
index ae977d4024..57ad6833a9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java
@@ -81,7 +81,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia());
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U");
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
- holder.mealOrCorrection.setText(t.isSMB ? "SMB" : t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
+ holder.mealOrCorrection.setText(t.isSMB ? "SMB" : t.mealBolus ? MainApp.gs(R.string.mealbolus) : MainApp.gs(R.string.correctionbous));
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
holder.ns.setVisibility(NSUpload.isIdValid(t._id) ? View.VISIBLE : View.GONE);
holder.invalid.setVisibility(t.isValid ? View.GONE : View.VISIBLE);
@@ -142,9 +142,9 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
switch (v.getId()) {
case R.id.treatments_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date));
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = treatment._id;
if (treatment.source == Source.PUMP) {
@@ -162,7 +162,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
}
});
- builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
@@ -204,16 +204,16 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
switch (view.getId()) {
case R.id.treatments_reshreshfromnightscout:
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
- builder.setTitle(this.getContext().getString(R.string.confirmation));
- builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?");
- builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + "?");
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
TreatmentsPlugin.getPlugin().getService().resetTreatments();
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
}
});
- builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java
index 7218198b43..97c3a05274 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsCareportalFragment.java
@@ -105,9 +105,9 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
switch (v.getId()) {
case R.id.careportal_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(careportalEvent.date));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(careportalEvent.date));
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = careportalEvent._id;
if (NSUpload.isIdValid(_id)) {
@@ -118,7 +118,7 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
MainApp.getDbHelper().delete(careportalEvent);
}
});
- builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
@@ -157,16 +157,16 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
switch (view.getId()) {
case R.id.careportal_refreshfromnightscout:
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
- builder.setTitle(this.getContext().getString(R.string.confirmation));
- builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + " ?");
- builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + " ?");
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MainApp.getDbHelper().resetCareportalEvents();
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
}
});
- builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java
index c8fc539d02..05e18bfdc3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java
@@ -67,7 +67,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
holder.ns.setVisibility(NSUpload.isIdValid(extendedBolus._id) ? View.VISIBLE : View.GONE);
if (extendedBolus.isEndingEvent()) {
holder.date.setText(DateUtil.dateAndTimeString(extendedBolus.date));
- holder.duration.setText(MainApp.sResources.getString(R.string.cancel));
+ holder.duration.setText(MainApp.gs(R.string.cancel));
holder.insulin.setText("");
holder.realDuration.setText("");
holder.iob.setText("");
@@ -144,9 +144,9 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
switch (v.getId()) {
case R.id.extendedboluses_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(extendedBolus.date));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(extendedBolus.date));
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = extendedBolus._id;
if (NSUpload.isIdValid(_id)) {
@@ -158,7 +158,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveExtendedBolus"));
}
});
- builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java
index 8a6b0456f5..307f9c8ee6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java
@@ -131,9 +131,9 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
switch (v.getId()) {
case R.id.profileswitch_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(profileSwitch.date));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(profileSwitch.date));
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = profileSwitch._id;
if (NSUpload.isIdValid(_id)) {
@@ -144,7 +144,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
MainApp.getDbHelper().delete(profileSwitch);
}
});
- builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
case R.id.profileswitch_date:
@@ -190,16 +190,16 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
switch (view.getId()) {
case R.id.profileswitch_refreshfromnightscout:
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
- builder.setTitle(this.getContext().getString(R.string.confirmation));
- builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?");
- builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + "?");
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MainApp.getDbHelper().resetProfileSwitch();
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
}
});
- builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java
index 5ce79636b5..df67349839 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTempTargetFragment.java
@@ -140,9 +140,9 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
switch (v.getId()) {
case R.id.temptargetrange_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.date));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.date));
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = tempTarget._id;
if (NSUpload.isIdValid(_id)) {
@@ -153,7 +153,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
MainApp.getDbHelper().delete(tempTarget);
}
});
- builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
@@ -192,16 +192,16 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
switch (view.getId()) {
case R.id.temptargetrange_refreshfromnightscout:
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
- builder.setTitle(this.getContext().getString(R.string.confirmation));
- builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + " ?");
- builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setTitle(MainApp.gs(R.string.confirmation));
+ builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + " ?");
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MainApp.getDbHelper().resetTempTargets();
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
}
});
- builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
+ builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java
index fdc14f32d4..5ec2723fa4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java
@@ -19,6 +19,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading;
+import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
@@ -31,6 +32,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
+import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@@ -40,6 +43,7 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
+import info.nightscout.androidaps.plugins.Treatments.CarbsGenerator;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.BolusWizard;
@@ -95,9 +99,9 @@ public class ActionStringHandler {
return;
}
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
- rMessage += MainApp.instance().getString(R.string.primefill) + ": " + insulinAfterConstraints + "U";
+ rMessage += MainApp.gs(R.string.primefill) + ": " + insulinAfterConstraints + "U";
if (insulinAfterConstraints - amount != 0)
- rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied);
+ rMessage += "\n" + MainApp.gs(R.string.constraintapllied);
rAction += "fill " + insulinAfterConstraints;
@@ -106,9 +110,9 @@ public class ActionStringHandler {
double amount = SafeParse.stringToDouble(act[1]);
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
- rMessage += MainApp.instance().getString(R.string.primefill) + ": " + insulinAfterConstraints + "U";
+ rMessage += MainApp.gs(R.string.primefill) + ": " + insulinAfterConstraints + "U";
if (insulinAfterConstraints - amount != 0)
- rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied);
+ rMessage += "\n" + MainApp.gs(R.string.constraintapllied);
rAction += "fill " + insulinAfterConstraints;
@@ -118,11 +122,11 @@ public class ActionStringHandler {
int carbs = SafeParse.stringToInt(act[2]);
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbs)).value();
- rMessage += MainApp.instance().getString(R.string.bolus) + ": " + insulinAfterConstraints + "U\n";
- rMessage += MainApp.instance().getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
+ rMessage += MainApp.gs(R.string.bolus) + ": " + insulinAfterConstraints + "U\n";
+ rMessage += MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g";
if ((insulinAfterConstraints - insulin != 0) || (carbsAfterConstraints - carbs != 0)) {
- rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied);
+ rMessage += "\n" + MainApp.gs(R.string.constraintapllied);
}
rAction += "bolus " + insulinAfterConstraints + " " + carbsAfterConstraints;
@@ -179,6 +183,9 @@ public class ActionStringHandler {
}
} else if ("wizard".equals(act[0])) {
+ sendError("Update APP on Watch!");
+ return;
+ } else if ("wizard2".equals(act[0])) {
////////////////////////////////////////////// WIZARD
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbsBeforeConstraints)).value();
@@ -188,10 +195,12 @@ public class ActionStringHandler {
return;
}
- boolean useBG = Boolean.parseBoolean(act[2]);
- boolean useBolusIOB = Boolean.parseBoolean(act[3]);
- boolean useBasalIOB = Boolean.parseBoolean(act[4]);
- int percentage = Integer.parseInt(act[5]);
+ boolean useBG = SP.getBoolean(R.string.key_wearwizard_bg, true);
+ boolean useBolusIOB = SP.getBoolean(R.string.key_wearwizard_bolusiob, true);
+ boolean useBasalIOB = SP.getBoolean(R.string.key_wearwizard_basaliob, true);
+ boolean useCOB = SP.getBoolean(R.string.key_wearwizard_cob, true);
+ boolean useTrend = SP.getBoolean(R.string.key_wearwizard_trend, false);
+ int percentage = Integer.parseInt(act[2]);
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
@@ -205,9 +214,16 @@ public class ActionStringHandler {
return;
}
+ CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "Wizard wear");
+ if (useCOB && (cobInfo == null || cobInfo.displayCob == null)) {
+ sendError("Unknown COB! BG reading missing or recent app restart?");
+ return;
+ }
+
DecimalFormat format = new DecimalFormat("0.00");
+ DecimalFormat formatInt = new DecimalFormat("0");
BolusWizard bolusWizard = new BolusWizard();
- bolusWizard.doCalc(profile, null, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, false);
+ bolusWizard.doCalc(profile, null, carbsAfterConstraints, useCOB?cobInfo.displayCob:0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, useTrend);
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(bolusWizard.calculatedTotalInsulin)).value();
if (insulinAfterConstraints - bolusWizard.calculatedTotalInsulin != 0) {
@@ -232,11 +248,15 @@ public class ActionStringHandler {
rMessage += "\n_____________";
rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): ";
rMessage += "\nFrom Carbs: " + format.format(bolusWizard.insulinFromCarbs) + "U";
+ if (useCOB)
+ rMessage += "\nFrom" + formatInt.format(cobInfo.displayCob) + "g COB : " + format.format(bolusWizard.insulinFromCOB) + "U";
if (useBG) rMessage += "\nFrom BG: " + format.format(bolusWizard.insulinFromBG) + "U";
if (useBolusIOB)
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
if (useBasalIOB)
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
+ if (useTrend)
+ rMessage += "\nFrom 15' trend: " + format.format(bolusWizard.insulinFromTrend) + "U";
if (percentage != 100) {
rMessage += "\nPercentage: " + format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
}
@@ -283,7 +303,7 @@ public class ActionStringHandler {
//if pump is not busy: try to fetch data
final PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
if (pump.isBusy()) {
- rMessage += MainApp.instance().getString(R.string.pumpbusy);
+ rMessage += MainApp.gs(R.string.pumpbusy);
} else {
rMessage += "trying to fetch data from pump.";
@@ -308,6 +328,27 @@ public class ActionStringHandler {
}
}
+ } else if ("ecarbs".equals(act[0])) {
+ ////////////////////////////////////////////// ECARBS
+ int carbs = SafeParse.stringToInt(act[1]);
+ int starttime = SafeParse.stringToInt(act[2]);
+ int duration = SafeParse.stringToInt(act[3]);
+ long starttimestamp = System.currentTimeMillis() + starttime*60*1000;
+ Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbs)).value();
+ rMessage += MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g";
+ rMessage += "\n" + MainApp.gs(R.string.time) + ": " + DateUtil.timeString(starttimestamp);
+ rMessage += "\n" + MainApp.gs(R.string.duration) + ": " + duration + "h";
+
+
+ if ( (carbsAfterConstraints - carbs != 0)) {
+ rMessage += "\n" + MainApp.gs(R.string.constraintapllied);
+ }
+ if(carbsAfterConstraints <= 0){
+ sendError("Carbs = 0! No action taken!");
+ return;
+ }
+ rAction += "ecarbs " + carbsAfterConstraints + " " + starttimestamp + " " + duration;
+
} else return;
@@ -513,15 +554,15 @@ public class ActionStringHandler {
}
if (!result.isChangeRequested()) {
- ret += MainApp.sResources.getString(R.string.nochangerequested) + "\n";
+ ret += MainApp.gs(R.string.nochangerequested) + "\n";
} else if (result.rate == 0 && result.duration == 0) {
- ret += MainApp.sResources.getString(R.string.canceltemp) + "\n";
+ ret += MainApp.gs(R.string.canceltemp) + "\n";
} else {
- ret += MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " +
+ ret += MainApp.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " +
"(" + DecimalFormatter.to2Decimal(result.rate / ConfigBuilderPlugin.getActivePump().getBaseBasalRate() * 100) + "%)\n" +
- MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration) + " min\n";
+ MainApp.gs(R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration) + " min\n";
}
- ret += "\n" + MainApp.sResources.getString(R.string.reason) + ": " + result.reason;
+ ret += "\n" + MainApp.gs(R.string.reason) + ": " + result.reason;
return ret;
}
@@ -560,7 +601,7 @@ public class ActionStringHandler {
high *= Constants.MMOLL_TO_MGDL;
}
generateTempTarget(duration, low, high);
- } else if ("wizard".equals(act[0])) {
+ } else if ("wizard2".equals(act[0])) {
//use last calculation as confirmed string matches
doBolus(lastBolusWizard.calculatedTotalInsulin, lastBolusWizard.carbs);
@@ -573,12 +614,28 @@ public class ActionStringHandler {
int timeshift = SafeParse.stringToInt(act[1]);
int percentage = SafeParse.stringToInt(act[2]);
setCPP(timeshift, percentage);
+ } else if ("ecarbs".equals(act[0])) {
+ int carbs = SafeParse.stringToInt(act[1]);
+ long starttime = SafeParse.stringToLong(act[2]);
+ int duration = SafeParse.stringToInt(act[3]);
+
+ doECarbs(carbs, starttime, duration);
} else if ("dismissoverviewnotification".equals(act[0])) {
MainApp.bus().post(new EventDismissNotification(SafeParse.stringToInt(act[1])));
}
lastBolusWizard = null;
}
+ private static void doECarbs(int carbs, long time, int duration) {
+ if (carbs > 0) {
+ if (duration == 0) {
+ CarbsGenerator.createCarb(carbs, time, CareportalEvent.CARBCORRECTION, "watch");
+ } else {
+ CarbsGenerator.generateCarbs(carbs, time, duration, "watch eCarbs");
+ }
+ }
+ }
+
private static void setCPP(int timeshift, int percentage) {
String msg = "";
@@ -586,18 +643,18 @@ public class ActionStringHandler {
//check for validity
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
- msg += String.format(MainApp.sResources.getString(R.string.valueoutofrange), "Profile-Percentage") + "\n";
+ msg += String.format(MainApp.gs(R.string.valueoutofrange), "Profile-Percentage") + "\n";
}
if (timeshift < 0 || timeshift > 23) {
- msg += String.format(MainApp.sResources.getString(R.string.valueoutofrange), "Profile-Timeshift") + "\n";
+ msg += String.format(MainApp.gs(R.string.valueoutofrange), "Profile-Timeshift") + "\n";
}
final Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
- msg += MainApp.sResources.getString(R.string.notloadedplugins) + "\n";
+ msg += MainApp.gs(R.string.notloadedplugins) + "\n";
}
if (!"".equals(msg)) {
- msg += MainApp.sResources.getString(R.string.valuesnotstored);
+ msg += MainApp.gs(R.string.valuesnotstored);
String rTitle = "STATUS";
String rAction = "statusmessage";
WearPlugin.getPlugin().requestActionConfirmation(rTitle, msg, rAction);
@@ -634,7 +691,7 @@ public class ActionStringHandler {
@Override
public void run() {
if (!result.success) {
- sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) +
+ sendError(MainApp.gs(R.string.treatmentdeliveryerror) +
"\n" +
result.comment);
}
@@ -652,7 +709,7 @@ public class ActionStringHandler {
@Override
public void run() {
if (!result.success) {
- sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) +
+ sendError(MainApp.gs(R.string.treatmentdeliveryerror) +
"\n" +
result.comment);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java
index dcda0bc0aa..7282ac0763 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java
@@ -158,7 +158,7 @@ public class WearPlugin extends PluginBase {
@Subscribe
public void onStatusEvent(final EventBolusRequested ev) {
- String status = String.format(MainApp.sResources.getString(R.string.bolusrequested), ev.getAmount());
+ String status = String.format(MainApp.gs(R.string.bolusrequested), ev.getAmount());
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
intent.putExtra("progresspercent", 0);
intent.putExtra("progressstatus", status);
@@ -172,9 +172,9 @@ public class WearPlugin extends PluginBase {
String status;
if (ev.result.success) {
- status = MainApp.sResources.getString(R.string.success);
+ status = MainApp.gs(R.string.success);
} else {
- status = MainApp.sResources.getString(R.string.nosuccess);
+ status = MainApp.gs(R.string.nosuccess);
}
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
intent.putExtra("progresspercent", 100);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java
index 0d809a7bab..696b8b0b57 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java
@@ -38,12 +38,11 @@ import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
+import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
-import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
@@ -214,7 +213,7 @@ public class WatchUpdaterService extends WearableListenerService implements
final DataMap dataMap = dataMapSingleBG(lastBG, glucoseStatus);
if (dataMap == null) {
- ToastUtils.showToastInUiThread(this, getString(R.string.noprofile));
+ ToastUtils.showToastInUiThread(this, MainApp.gs(R.string.noprofile));
return;
}
@@ -331,7 +330,7 @@ public class WatchUpdaterService extends WearableListenerService implements
if (!graph_bgs.isEmpty()) {
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
if (entries == null) {
- ToastUtils.showToastInUiThread(this, getString(R.string.noprofile));
+ ToastUtils.showToastInUiThread(this, MainApp.gs(R.string.noprofile));
return;
}
final ArrayList dataMaps = new ArrayList<>(graph_bgs.size());
@@ -478,7 +477,8 @@ public class WatchUpdaterService extends WearableListenerService implements
if (!predArray.isEmpty()) {
for (BgReading bg : predArray) {
- predictions.add(predictionMap(bg.date, bg.value));
+ if (bg.value < 40) continue;
+ predictions.add(predictionMap(bg.date, bg.value, bg.getPredectionColor()));
}
}
}
@@ -521,10 +521,11 @@ public class WatchUpdaterService extends WearableListenerService implements
return dm;
}
- private DataMap predictionMap(long timestamp, double sgv) {
+ private DataMap predictionMap(long timestamp, double sgv, int color) {
DataMap dm = new DataMap();
dm.putLong("timestamp", timestamp);
dm.putDouble("sgv", sgv);
+ dm.putInt("color", color);
return dm;
}
@@ -580,7 +581,7 @@ public class WatchUpdaterService extends WearableListenerService implements
if (googleApiClient.isConnected()) {
Profile profile = MainApp.getConfigBuilder().getProfile();
- String status = MainApp.instance().getString(R.string.noprofile);
+ String status = MainApp.gs(R.string.noprofile);
String iobSum, iobDetail, cobString, currentBasal, bgiString;
iobSum = iobDetail = cobString = currentBasal = bgiString = "";
if (profile != null) {
@@ -592,7 +593,7 @@ public class WatchUpdaterService extends WearableListenerService implements
iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
- cobString = generateCOBString();
+ cobString = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "WatcherUpdaterService").generateCOBString();
currentBasal = generateBasalString(treatmentsInterface);
//bgi
@@ -663,14 +664,14 @@ public class WatchUpdaterService extends WearableListenerService implements
String status = "";
if (profile == null) {
- status = MainApp.sResources.getString(R.string.noprofile);
+ status = MainApp.gs(R.string.noprofile);
return status;
}
LoopPlugin activeloop = LoopPlugin.getPlugin();
if (!activeloop.isEnabled(PluginType.LOOP)) {
- status += getString(R.string.disabledloop) + "\n";
+ status += MainApp.gs(R.string.disabledloop) + "\n";
lastLoopStatus = false;
} else {
lastLoopStatus = true;
@@ -715,21 +716,6 @@ public class WatchUpdaterService extends WearableListenerService implements
return basalStringResult;
}
- @NonNull
- private String generateCOBString() {
-
- String cobStringResult = "--";
- CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "WatcherUpdaterService");
- if (cobInfo.displayCob != null) {
- cobStringResult = DecimalFormatter.to0Decimal(cobInfo.displayCob);
- if (cobInfo.futureCarbs > 0) {
- cobStringResult += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")";
- }
- cobStringResult += "g";
- }
- return cobStringResult;
- }
-
@Override
public void onDestroy() {
if (googleApiClient != null && googleApiClient.isConnected()) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java
index 5ce277e399..03c6c48a1a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java
@@ -25,6 +25,8 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
+import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DecimalFormatter;
@@ -111,7 +113,7 @@ public class StatuslinePlugin extends PluginBase {
LoopPlugin loopPlugin = LoopPlugin.getPlugin();
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
- status += ctx.getString(R.string.disabledloop) + "\n";
+ status += MainApp.gs(R.string.disabledloop) + "\n";
lastLoopStatus = false;
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
lastLoopStatus = true;
@@ -130,7 +132,7 @@ public class StatuslinePlugin extends PluginBase {
IobTotal bolusIob = treatmentsInterface.getLastCalculationTreatments().round();
treatmentsInterface.updateTotalIOBTempBasals();
IobTotal basalIob = treatmentsInterface.getLastCalculationTempBasals().round();
- status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
+ status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob)+"U";
if (mPrefs.getBoolean("xdripstatus_detailediob", true)) {
@@ -146,6 +148,7 @@ public class StatuslinePlugin extends PluginBase {
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * profile.getIsf();
status += " " + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to2Decimal(bgi);
+ status += " " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "StatuslinePlugin").generateCOBString();
return status;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
index 93b6f99db0..b42cc47f13 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java
@@ -81,7 +81,7 @@ public class CommandQueue {
private QueueThread thread = null;
private PumpEnactResult executingNowError() {
- return new PumpEnactResult().success(false).enacted(false).comment(MainApp.sResources.getString(R.string.executingrightnow));
+ return new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.executingrightnow));
}
public boolean isRunning(Command.CommandType type) {
@@ -162,8 +162,18 @@ public class CommandQueue {
tempCommandQueue.readStatus(reason, callback);
}
+ public synchronized boolean bolusInQueue(){
+ if(isRunning(Command.CommandType.BOLUS)) return true;
+ for (int i = 0; i < queue.size(); i++) {
+ if (queue.get(i).commandType == Command.CommandType.BOLUS) {
+ return true;
+ }
+ }
+ return false;
+ }
+
// returns true if command is queued
- public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
+ public synchronized boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
Command.CommandType type = detailedBolusInfo.isSMB ? Command.CommandType.SMB_BOLUS : Command.CommandType.BOLUS;
if(type.equals(Command.CommandType.BOLUS) && detailedBolusInfo.carbs > 0 && detailedBolusInfo.insulin == 0){
@@ -314,10 +324,10 @@ public class CommandQueue {
}
if (!MainApp.isEngineeringModeOrRelease()) {
- Notification notification = new Notification(Notification.NOT_ENG_MODE_OR_RELEASE, MainApp.sResources.getString(R.string.not_eng_mode_or_release), Notification.URGENT);
+ Notification notification = new Notification(Notification.NOT_ENG_MODE_OR_RELEASE, MainApp.gs(R.string.not_eng_mode_or_release), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
if (callback != null)
- callback.result(new PumpEnactResult().success(false).comment(MainApp.sResources.getString(R.string.not_eng_mode_or_release))).run();
+ callback.result(new PumpEnactResult().success(false).comment(MainApp.gs(R.string.not_eng_mode_or_release))).run();
return false;
}
@@ -327,10 +337,10 @@ public class CommandQueue {
for (Profile.BasalValue basalValue : basalValues) {
if (basalValue.value < pump.getPumpDescription().basalMinimumRate) {
- Notification notification = new Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, MainApp.sResources.getString(R.string.basalvaluebelowminimum), Notification.URGENT);
+ Notification notification = new Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, MainApp.gs(R.string.basalvaluebelowminimum), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
if (callback != null)
- callback.result(new PumpEnactResult().success(false).comment(MainApp.sResources.getString(R.string.basalvaluebelowminimum))).run();
+ callback.result(new PumpEnactResult().success(false).comment(MainApp.gs(R.string.basalvaluebelowminimum))).run();
return false;
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java
index 8ec61932c8..a5ad59ca0b 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java
@@ -55,7 +55,7 @@ public class QueueThread extends Thread {
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (pump == null) {
log.debug("QUEUE: pump == null");
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.pumpNotInitialized)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.pumpNotInitialized)));
SystemClock.sleep(1000);
continue;
}
@@ -63,7 +63,7 @@ public class QueueThread extends Thread {
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
- MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.connectiontimedout)));
log.debug("QUEUE: timed out");
pump.stopConnecting();
diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java
index 8a8bc41dfa..03764dee0b 100644
--- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java
@@ -47,7 +47,7 @@ public class CommandSetProfile extends Command {
if (r.enacted && profileSwitch.source == Source.NIGHTSCOUT) {
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
- smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
+ smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.gs(R.string.profile_set_ok));
}
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/ChargingStateReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/ChargingStateReceiver.java
new file mode 100644
index 0000000000..3dbec90b4f
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/receivers/ChargingStateReceiver.java
@@ -0,0 +1,32 @@
+package info.nightscout.androidaps.receivers;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.BatteryManager;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.events.EventChargingState;
+
+public class ChargingStateReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ EventChargingState event = grabChargingState(context);
+
+ if (event != null)
+ MainApp.bus().post(event);
+ }
+
+ public EventChargingState grabChargingState(Context context) {
+ BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
+
+ int status = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_STATUS);
+ boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING
+ || status == BatteryManager.BATTERY_STATUS_FULL;
+
+ EventChargingState event = new EventChargingState(isCharging);
+ return event;
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java
index b3a99b66ff..4e01066bf9 100644
--- a/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java
@@ -8,7 +8,6 @@ import android.net.NetworkInfo;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
-import android.os.PowerManager;
import android.support.annotation.Nullable;
import org.slf4j.Logger;
@@ -18,27 +17,21 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.EventNetworkChange;
public class NetworkChangeReceiver extends BroadcastReceiver {
+
private static Logger log = LoggerFactory.getLogger(NetworkChangeReceiver.class);
@Override
public void onReceive(final Context context, final Intent intent) {
- PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
- if (pm == null) return;
- PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "NetworkChangeReceiver");
- wl.acquire(10000);
-
- EventNetworkChange event = grabNetworkStatus();
+ EventNetworkChange event = grabNetworkStatus(context);
if (event != null)
MainApp.bus().post(event);
-
- wl.release();
}
@Nullable
- public static EventNetworkChange grabNetworkStatus() {
+ public EventNetworkChange grabNetworkStatus(final Context context) {
EventNetworkChange event = new EventNetworkChange();
- ConnectivityManager cm = (ConnectivityManager) MainApp.instance().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) return null;
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
@@ -54,6 +47,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
log.debug("NETCHANGE: Wifi connected. SSID: " + event.ssid);
}
}
+
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
event.mobileConnected = true;
event.roaming = activeNetwork.isRoaming();
@@ -62,6 +56,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
} else {
log.debug("NETCHANGE: Disconnected.");
}
+
return event;
}
}
\ No newline at end of file
diff --git a/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java b/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java
index b8eb49e98e..c2fbbf581e 100644
--- a/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java
+++ b/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java
@@ -33,7 +33,7 @@ import info.nightscout.androidaps.events.EventAppExit;
public class ImportExportPrefs {
private static Logger log = LoggerFactory.getLogger(ImportExportPrefs.class);
static File path = new File(Environment.getExternalStorageDirectory().toString());
- static final File file = new File(path, MainApp.sResources.getString(R.string.app_name) + "Preferences");
+ static final File file = new File(path, MainApp.gs(R.string.app_name) + "Preferences");
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
@@ -59,7 +59,7 @@ public class ImportExportPrefs {
public static void exportSharedPreferences(final Activity c) {
new AlertDialog.Builder(c)
- .setMessage(MainApp.sResources.getString(R.string.export_to) + " " + file + " ?")
+ .setMessage(MainApp.gs(R.string.export_to) + " " + file + " ?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -73,9 +73,9 @@ public class ImportExportPrefs {
}
pw.close();
fw.close();
- ToastUtils.showToastInUiThread(c, MainApp.sResources.getString(R.string.exported));
+ ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.exported));
} catch (FileNotFoundException e) {
- ToastUtils.showToastInUiThread(c, MainApp.sResources.getString(R.string.filenotfound) + " " + file);
+ ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.filenotfound) + " " + file);
log.error("Unhandled exception", e);
} catch (IOException e) {
log.error("Unhandled exception", e);
@@ -88,7 +88,7 @@ public class ImportExportPrefs {
public static void importSharedPreferences(final Activity c) {
new AlertDialog.Builder(c)
- .setMessage(MainApp.sResources.getString(R.string.import_from) + " " + file + " ?")
+ .setMessage(MainApp.gs(R.string.import_from) + " " + file + " ?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -113,7 +113,7 @@ public class ImportExportPrefs {
}
reader.close();
editor.commit();
- OKDialog.show(c, MainApp.sResources.getString(R.string.setting_imported), MainApp.sResources.getString(R.string.restartingapp), new Runnable() {
+ OKDialog.show(c, MainApp.gs(R.string.setting_imported), MainApp.gs(R.string.restartingapp), new Runnable() {
@Override
public void run() {
log.debug("Exiting");
@@ -126,7 +126,7 @@ public class ImportExportPrefs {
}
});
} catch (FileNotFoundException e) {
- ToastUtils.showToastInUiThread(c, MainApp.sResources.getString(R.string.filenotfound) + " " + file);
+ ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.filenotfound) + " " + file);
log.error("Unhandled exception", e);
} catch (IOException e) {
log.error("Unhandled exception", e);
diff --git a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
index cc1a22355a..5556cae935 100644
--- a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
+++ b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
@@ -26,21 +26,21 @@ public class LocalAlertUtils {
private static Logger log = LoggerFactory.getLogger(LocalAlertUtils.class);
public static long missedReadingsThreshold() {
- return T.mins(SP.getInt(MainApp.sResources.getString(R.string.key_missed_bg_readings_threshold), 30)).msecs();
+ return T.mins(SP.getInt(MainApp.gs(R.string.key_missed_bg_readings_threshold), 30)).msecs();
}
private static long pumpUnreachableThreshold() {
- return T.mins(SP.getInt(MainApp.sResources.getString(R.string.key_pump_unreachable_threshold), 30)).msecs();
+ return T.mins(SP.getInt(MainApp.gs(R.string.key_pump_unreachable_threshold), 30)).msecs();
}
public static void checkPumpUnreachableAlarm(Date lastConnection, boolean isStatusOutdated) {
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis();
- if (Config.APS && SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
+ if (Config.APS && SP.getBoolean(MainApp.gs(R.string.key_enable_pump_unreachable_alert), true)
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !LoopPlugin.getPlugin().isDisconnected()) {
log.debug("Generating pump unreachable alarm. lastConnection: " + DateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated);
- Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
+ Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.gs(R.string.pump_unreachable), Notification.URGENT);
n.soundId = R.raw.alarm;
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
MainApp.bus().post(new EventNewNotification(n));
@@ -91,10 +91,10 @@ public class LocalAlertUtils {
public static void checkStaleBGAlert() {
BgReading bgReading = DatabaseHelper.lastBg();
- if (SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_missed_bg_readings_alert), false)
+ if (SP.getBoolean(MainApp.gs(R.string.key_enable_missed_bg_readings_alert), false)
&& bgReading != null && bgReading.date + missedReadingsThreshold() < System.currentTimeMillis()
&& SP.getLong("nextMissedReadingsAlarm", 0l) < System.currentTimeMillis()) {
- Notification n = new Notification(Notification.BG_READINGS_MISSED, MainApp.sResources.getString(R.string.missed_bg_readings), Notification.URGENT);
+ Notification n = new Notification(Notification.BG_READINGS_MISSED, MainApp.gs(R.string.missed_bg_readings), Notification.URGENT);
n.soundId = R.raw.alarm;
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
MainApp.bus().post(new EventNewNotification(n));
diff --git a/app/src/main/java/info/nightscout/utils/LogDialog.java b/app/src/main/java/info/nightscout/utils/LogDialog.java
index b98582c05f..7e2468774e 100644
--- a/app/src/main/java/info/nightscout/utils/LogDialog.java
+++ b/app/src/main/java/info/nightscout/utils/LogDialog.java
@@ -25,7 +25,7 @@ public class LogDialog {
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");
+ Process process = Runtime.getRuntime().exec("logcat -d " + MainApp.gs(R.string.app_name) + ":D");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder log = new StringBuilder();
String line;
@@ -46,11 +46,11 @@ public class LogDialog {
try {
AlertDialog alertDialog = new AlertDialog.Builder(context)
.setMessage(msg)
- .setPositiveButton(MainApp.sResources.getString(R.string.copy_to_clipboard), new DialogInterface.OnClickListener() {
+ .setPositiveButton(MainApp.gs(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));
+ ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.copied_to_clipboard));
}
})
.setNegativeButton(android.R.string.cancel, null)
diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java
index 3cd252f19a..2e5506f9c6 100644
--- a/app/src/main/java/info/nightscout/utils/NSUpload.java
+++ b/app/src/main/java/info/nightscout/utils/NSUpload.java
@@ -55,7 +55,7 @@ public class NSUpload {
if (temporaryBasal.pumpId != 0)
data.put("pumpId", temporaryBasal.pumpId);
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
- data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
if (originalExtendedAmount != null)
data.put("originalExtendedAmount", originalExtendedAmount); // for back synchronization
Bundle bundle = new Bundle();
@@ -93,7 +93,7 @@ public class NSUpload {
if (temporaryBasal.pumpId != 0)
data.put("pumpId", temporaryBasal.pumpId);
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
- data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
@@ -115,7 +115,7 @@ public class NSUpload {
JSONObject data = new JSONObject();
data.put("eventType", CareportalEvent.TEMPBASAL);
data.put("created_at", DateUtil.toISOString(time));
- data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
if (isFakedTempBasal)
data.put("isFakedTempBasal", isFakedTempBasal);
if (pumpId != 0)
@@ -147,7 +147,7 @@ public class NSUpload {
if (extendedBolus.pumpId != 0)
data.put("pumpId", extendedBolus.pumpId);
data.put("created_at", DateUtil.toISOString(extendedBolus.date));
- data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
@@ -173,7 +173,7 @@ public class NSUpload {
data.put("enteredinsulin", 0);
data.put("relative", 0);
data.put("created_at", DateUtil.toISOString(time));
- data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
if (pumpId != 0)
data.put("pumpId", pumpId);
Bundle bundle = new Bundle();
@@ -301,7 +301,7 @@ public class NSUpload {
data.put("percentage", profileSwitch.percentage);
}
data.put("created_at", DateUtil.toISOString(profileSwitch.date));
- data.put("enteredBy", MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", MainApp.gs(R.string.app_name));
uploadCareportalEntryToNS(data);
} catch (JSONException e) {
log.error("Unhandled exception", e);
@@ -325,7 +325,7 @@ public class NSUpload {
data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits()));
data.put("created_at", DateUtil.toISOString(tempTarget.date));
data.put("units", profile.getUnits());
- data.put("enteredBy", MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", MainApp.gs(R.string.app_name));
uploadCareportalEntryToNS(data);
} catch (JSONException e) {
log.error("Unhandled exception", e);
@@ -346,7 +346,7 @@ public class NSUpload {
data.put("percentage", profileSwitch.percentage);
}
data.put("created_at", DateUtil.toISOString(profileSwitch.date));
- data.put("enteredBy", MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", MainApp.gs(R.string.app_name));
if (profileSwitch._id != null) {
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
@@ -420,7 +420,7 @@ public class NSUpload {
data.put("eventType", "OpenAPS Offline");
data.put("duration", durationInMinutes);
data.put("created_at", DateUtil.toISOString(new Date()));
- data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
+ data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
@@ -496,7 +496,7 @@ public class NSUpload {
try {
data.put("eventType", "Note");
data.put("created_at", DateUtil.toISOString(new Date()));
- data.put("notes", MainApp.sResources.getString(R.string.androidaps_start)+" - "+ Build.MANUFACTURER + " "+ Build.MODEL);
+ data.put("notes", MainApp.gs(R.string.androidaps_start)+" - "+ Build.MANUFACTURER + " "+ Build.MODEL);
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
diff --git a/app/src/main/java/info/nightscout/utils/NumberPicker.java b/app/src/main/java/info/nightscout/utils/NumberPicker.java
index 64239cbaee..102abedc7d 100644
--- a/app/src/main/java/info/nightscout/utils/NumberPicker.java
+++ b/app/src/main/java/info/nightscout/utils/NumberPicker.java
@@ -199,7 +199,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
value += step * multiplier;
if (value > maxValue) {
value = maxValue;
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.youareonallowedlimit));
stopUpdating();
}
updateEditText();
@@ -209,7 +209,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
value -= step * multiplier;
if (value < minValue) {
value = minValue;
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.youareonallowedlimit));
stopUpdating();
}
updateEditText();
diff --git a/app/src/main/java/info/nightscout/utils/OKDialog.java b/app/src/main/java/info/nightscout/utils/OKDialog.java
index 3212e6b1fd..5185049678 100644
--- a/app/src/main/java/info/nightscout/utils/OKDialog.java
+++ b/app/src/main/java/info/nightscout/utils/OKDialog.java
@@ -25,7 +25,7 @@ public class OKDialog {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme));
builder.setTitle(title);
builder.setMessage(message);
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (runnable != null) {
@@ -46,7 +46,7 @@ public class OKDialog {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme));
builder.setTitle(title);
builder.setMessage(message);
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (runnable != null) {
diff --git a/app/src/main/java/info/nightscout/utils/PasswordProtection.java b/app/src/main/java/info/nightscout/utils/PasswordProtection.java
index 1af10eb2d2..2a15dc7311 100644
--- a/app/src/main/java/info/nightscout/utils/PasswordProtection.java
+++ b/app/src/main/java/info/nightscout/utils/PasswordProtection.java
@@ -37,7 +37,7 @@ public class PasswordProtection {
alertDialogBuilder.setView(promptsView);
final TextView label = (TextView) promptsView.findViewById(R.id.passwordprompt_text);
- label.setText(MainApp.sResources.getString(stringID));
+ label.setText(MainApp.gs(stringID));
final EditText userInput = (EditText) promptsView.findViewById(R.id.passwordprompt_pass);
// set dialog message
@@ -50,7 +50,7 @@ public class PasswordProtection {
if (password.equals(enteredPassword)) {
if (ok != null) ok.run();
} else {
- ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.wrongpassword));
+ ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.wrongpassword));
if (fail != null) fail.run();
}
}
diff --git a/app/src/main/java/info/nightscout/utils/SP.java b/app/src/main/java/info/nightscout/utils/SP.java
index 23a95840a8..eaf84946e6 100644
--- a/app/src/main/java/info/nightscout/utils/SP.java
+++ b/app/src/main/java/info/nightscout/utils/SP.java
@@ -17,7 +17,7 @@ public class SP {
}
static public String getString(int resourceID, String defaultValue) {
- return sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue);
+ return sharedPreferences.getString(MainApp.gs(resourceID), defaultValue);
}
static public String getString(String key, String defaultValue) {
@@ -26,7 +26,7 @@ public class SP {
static public boolean getBoolean(int resourceID, Boolean defaultValue) {
try {
- return sharedPreferences.getBoolean(MainApp.sResources.getString(resourceID), defaultValue);
+ return sharedPreferences.getBoolean(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) {
return defaultValue;
}
@@ -41,7 +41,7 @@ public class SP {
}
static public Double getDouble(int resourceID, Double defaultValue) {
- return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
+ return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
}
static public Double getDouble(String key, Double defaultValue) {
@@ -50,9 +50,9 @@ public class SP {
static public int getInt(int resourceID, Integer defaultValue) {
try {
- return sharedPreferences.getInt(MainApp.sResources.getString(resourceID), defaultValue);
+ return sharedPreferences.getInt(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) {
- return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
+ return SafeParse.stringToInt(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
}
}
@@ -66,9 +66,9 @@ public class SP {
static public long getLong(int resourceID, Long defaultValue) {
try {
- return sharedPreferences.getLong(MainApp.sResources.getString(resourceID), defaultValue);
+ return sharedPreferences.getLong(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) {
- return SafeParse.stringToLong(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
+ return SafeParse.stringToLong(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
}
}
@@ -88,7 +88,7 @@ public class SP {
static public void putBoolean(int resourceID, boolean value) {
SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putBoolean(MainApp.sResources.getString(resourceID), value);
+ editor.putBoolean(MainApp.gs(resourceID), value);
editor.apply();
}
@@ -100,7 +100,7 @@ public class SP {
static public void putLong(int resourceID, long value) {
SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putLong(MainApp.sResources.getString(resourceID), value);
+ editor.putLong(MainApp.gs(resourceID), value);
editor.apply();
}
@@ -112,13 +112,13 @@ public class SP {
static public void putInt(int resourceID, int value) {
SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putInt(MainApp.sResources.getString(resourceID), value);
+ editor.putInt(MainApp.gs(resourceID), value);
editor.apply();
}
static public void putString(int resourceID, String value) {
SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putString(MainApp.sResources.getString(resourceID), value);
+ editor.putString(MainApp.gs(resourceID), value);
editor.apply();
}
@@ -130,7 +130,7 @@ public class SP {
static public void remove(int resourceID) {
SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.remove(MainApp.sResources.getString(resourceID));
+ editor.remove(MainApp.gs(resourceID));
editor.apply();
}
diff --git a/app/src/main/java/info/nightscout/utils/Translator.java b/app/src/main/java/info/nightscout/utils/Translator.java
index 75ee881c21..98fdd32779 100644
--- a/app/src/main/java/info/nightscout/utils/Translator.java
+++ b/app/src/main/java/info/nightscout/utils/Translator.java
@@ -12,51 +12,51 @@ public class Translator {
switch (text) {
case "BG Check":
- return MainApp.sResources.getString(R.string.careportal_bgcheck);
+ return MainApp.gs(R.string.careportal_bgcheck);
case "Snack Bolus":
- return MainApp.sResources.getString(R.string.careportal_snackbolus);
+ return MainApp.gs(R.string.careportal_snackbolus);
case "Meal Bolus":
- return MainApp.sResources.getString(R.string.careportal_mealbolus);
+ return MainApp.gs(R.string.careportal_mealbolus);
case "Correction Bolus":
- return MainApp.sResources.getString(R.string.careportal_correctionbolus);
+ return MainApp.gs(R.string.careportal_correctionbolus);
case "Carb Correction":
- return MainApp.sResources.getString(R.string.careportal_carbscorrection);
+ return MainApp.gs(R.string.careportal_carbscorrection);
case "Combo Bolus":
- return MainApp.sResources.getString(R.string.careportal_combobolus);
+ return MainApp.gs(R.string.careportal_combobolus);
case "Announcement":
- return MainApp.sResources.getString(R.string.careportal_announcement);
+ return MainApp.gs(R.string.careportal_announcement);
case "Note":
- return MainApp.sResources.getString(R.string.careportal_note);
+ return MainApp.gs(R.string.careportal_note);
case "Question":
- return MainApp.sResources.getString(R.string.careportal_question);
+ return MainApp.gs(R.string.careportal_question);
case "Exercise":
- return MainApp.sResources.getString(R.string.careportal_exercise);
+ return MainApp.gs(R.string.careportal_exercise);
case "Site Change":
- return MainApp.sResources.getString(R.string.careportal_pumpsitechange);
+ return MainApp.gs(R.string.careportal_pumpsitechange);
case "Sensor Start":
- return MainApp.sResources.getString(R.string.careportal_cgmsensorstart);
+ return MainApp.gs(R.string.careportal_cgmsensorstart);
case "Sensor Change":
- return MainApp.sResources.getString(R.string.careportal_cgmsensorinsert);
+ return MainApp.gs(R.string.careportal_cgmsensorinsert);
case "Insulin Change":
- return MainApp.sResources.getString(R.string.careportal_insulincartridgechange);
+ return MainApp.gs(R.string.careportal_insulincartridgechange);
case "Temp Basal Start":
- return MainApp.sResources.getString(R.string.careportal_tempbasalstart);
+ return MainApp.gs(R.string.careportal_tempbasalstart);
case "Temp Basal End":
- return MainApp.sResources.getString(R.string.careportal_tempbasalend);
+ return MainApp.gs(R.string.careportal_tempbasalend);
case "Profile Switch":
- return MainApp.sResources.getString(R.string.careportal_profileswitch);
+ return MainApp.gs(R.string.careportal_profileswitch);
case "Temporary Target":
- return MainApp.sResources.getString(R.string.careportal_temporarytarget);
+ return MainApp.gs(R.string.careportal_temporarytarget);
case "Temporary Target Cancel":
- return MainApp.sResources.getString(R.string.careportal_temporarytargetcancel);
+ return MainApp.gs(R.string.careportal_temporarytargetcancel);
case "OpenAPS Offline":
- return MainApp.sResources.getString(R.string.careportal_openapsoffline);
+ return MainApp.gs(R.string.careportal_openapsoffline);
case "Finger":
- return MainApp.sResources.getString(R.string.glucosetype_finger);
+ return MainApp.gs(R.string.glucosetype_finger);
case "Sensor":
- return MainApp.sResources.getString(R.string.glucosetype_sensor);
+ return MainApp.gs(R.string.glucosetype_sensor);
case "Manual":
- return MainApp.sResources.getString(R.string.manual);
+ return MainApp.gs(R.string.manual);
}
return text;
}
diff --git a/app/src/main/java/info/nightscout/utils/XdripCalibrations.java b/app/src/main/java/info/nightscout/utils/XdripCalibrations.java
index 662b7a0c8f..66ec6bd3df 100644
--- a/app/src/main/java/info/nightscout/utils/XdripCalibrations.java
+++ b/app/src/main/java/info/nightscout/utils/XdripCalibrations.java
@@ -28,17 +28,17 @@ public class XdripCalibrations {
public static void confirmAndSendCalibration(final Double bg, Context parentContext) {
if (parentContext != null) {
- String confirmMessage = String.format(MainApp.sResources.getString(R.string.send_calibration), bg);
+ String confirmMessage = String.format(MainApp.gs(R.string.send_calibration), bg);
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
+ builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(confirmMessage);
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(MainApp.gs(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.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show();
}
}
@@ -55,12 +55,12 @@ public class XdripCalibrations {
context.sendBroadcast(intent);
List 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));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.xdripnotinstalled));
+ log.debug(MainApp.gs(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));
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.calibrationsent));
+ log.debug(MainApp.gs(R.string.calibrationsent));
return true;
}
}
diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml
index 9bda35856c..81a1589e47 100644
--- a/app/src/main/res/values-bg/strings.xml
+++ b/app/src/main/res/values-bg/strings.xml
@@ -578,7 +578,6 @@
Потвърждаване, че КЗ е достъпна в Найтскаут и данните за помпата се качват там
Раздели IOB от болус и от базал на часовника
Покажи подробен IOB
- AndroidAPS
Активирай профила
АКТИВНОСТ И ОБРАТНА ВРЪЗКА
ХРАНА И БОЛУС
@@ -683,4 +682,77 @@
Няма достатъчно инсулин в резервоара
Празен
Обнови
+ И
+ един
+ вддв
+ шжо
+ Добавяне на допълнителни функции за използване през деня, като SMB
+ Пълнене
+ Избран APS
+ Няма базални стойности за някои часове: %s
+ Предупреждение W31: Ниско ниво в резервоара
+ Предупреждение W32: Слаба батерия
+ Предупреждение W33: Невалидно време/дата
+ Предупреждение W34: Край на гаранцията
+ Предупреждение W36: Временният базал е прекъснат
+ Предупреждение W38: Болусът е прекъснат
+ Временният базал е зададен от помпата
+ Румънски
+ Френски
+ Китайски
+ Болусът е спрян
+ Спиране на болус
+ Хипоглекимия
+ Настройка на целевата КЗ чрез аутосенс
+ Възрастни с по-голяма инсулинова резистентност
+ OpenAPS SMB
+ SMB
+ Разреши UAM
+ Разреши SMB
+ Използвай супер микро болуси вместо временен базал за по бързо действие
+ Детекция на необявено хранене (UAM)
+ Продължителност на вр. цел при хипоглекимия
+ Временна цел при хипоглекимия
+ мин.
+ ч.
+ Максимални минути за ограничаване на базала от SMB
+ Програмиране на помпа за болус
+ Състояние
+ Активност
+ Няма връзка от %d мин.
+ %d%% (%d мин. остават)
+ Инициализация
+ Прекратен поради грешка
+ Прекратен от потребителя
+ Изпълнява
+ Отказва временен базал
+ Задава временен базал (%d%% / %d min)
+ Болус (%.1f U)
+ Обновява
+ Исканата операция не се поддържа от помпата
+ Опасно използване: удължени или многовълнови болуси са активни. Помпата е изключена за само 6 часа. Само нормални болуси се поддържат.
+ Опасно използване: помпата използва различни базални нива от първоначалния профил. Loop е спрян. Изберете първоначалния профил и обновете.
+ Болуси с едно и също количество бяха поискани в последните две минути. За да се предотврати дублиране вече доставен болус, операцията е забранена.
+ Сега
+ Ниско ниво на резервоар на помпа
+ Батерията на помпата е слаба
+ Помпата отчита грешка E%d: %s
+ Необходимо е сверяване на часа в помпата
+ Отказването на временният базал беше потвърдено
+ Помпата е недостъпна. Не беше доставен болус.
+ Болусът беше неуспешен. За да сте сигурни, моля, проверете помпата, за да избегнете повторение на вече доставен болус. За да се избегнат бъгове болусите не се повтарят автоматично.
+ Само %.2f U от искания болус от %.2f U е доставен поради грешка. Моля, проверете помпата, за да потвърдите това и да предприемете съответните действия.
+ Insight
+ Insight помпа
+ Статус
+ Променено
+ ПОМПАТА Е СПРЯНА
+ Статуса е актуализиран
+ преди
+ с
+ Активен временен базал
+ мин. остават
+ История
+ Последно извършено действие
+ мин.
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index acd0a5df3a..d4b1a0f9dc 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -193,7 +193,7 @@
Provedeno
Licenční ujednání
ROZUMÍM A POTVRZUJI
- hodin zpět
+ před %.1fh
Nenalezen bluetooth adaptér
Procent
Obnovit profil
@@ -484,7 +484,7 @@
Vzdálený příkaz není povolen
K pozastavení smyčky na %d minut odpověz SMS s kódem %s
Chybná doba trvání
- Logovat spuštění aplikace do NS
+ Zaznamenávat spuštění aplikace do NS
Ukončuji aplikaci, aby se nastavení projevilo.
Inzulín
Rychlý inzulín
@@ -814,7 +814,7 @@
Podkategorie
Kategorie
Bolus bude pouze zaznamenán
- Automaticky doplňovat chybějící glykémie z NS
+ Automaticky doplňovat chybějící glykémie z NS
Hypoglykémie
Citlivost
Odchylky
@@ -841,4 +841,99 @@
Přepnutí profilu chybí. Proveďte přepnutí profilu nebo ho aktivujte na záložce lokálního profilu
Počet bolusů
Počet dočasných bazálů
+ Varování W31: Nízký stav zásobníku
+ Varování W32: Nízký stav baterie
+ Varování W33: Chybný datum/čas
+ Varování W34: Konec záruky
+ Varování W36: Ukončení dočasného bazálu
+ Varování W38: Bolus přerušen
+ Údržba M20: Není vložený zásobník
+ Údržba M21: Zásobník prázdný
+ Údržba M22: Prázdná baterie
+ Údržba M23: Automatické vypnutí
+ Údržba M24: Okluze
+ Údržba M26: Výměna zásobníku nekompletní
+ Údržba M27: Stažení dat selhalo
+ Údržba M28: Vypršení pozastavení
+ Údržba M29: Nenastaven typ baterie
+ Údržba M30: Nenastaven typ zásobníku
+ Chyba E6: Mechanická chyba
+ Chyba E7: Chyba elektroniky
+ Chyba E10: Chyba převíjení
+ Chyba E13: Chyba jazyka
+ MM640g
+ %.2f U/h
+ Pumpa nedostupná. Bolus nebyl podán
+ Bolus zastaven
+ Zastavování bolusu
+ Pumpa zastavena
+ Pumpa spuštěna
+ Pumpa pozastavena
+ Maximální počet minut bazálu, ke kterým se limituje SMB
+ Úprava cílové glykémie pomocí Autosens
+ Trvání dočasného cíle při hypoglykémii
+ Cílová glykémie při hypoglykémii
+ m
+ h
+ Výukový cíl %d nespuštěn
+ Novorapid, Novolog, Humalog
+ Výukový cíl %d nedokončen
+ Pumpa nepodporuje dočasné bazály
+ Z pumpy nepřečten žádný platný bazál
+ Uzavřená smyčka zakázána v nastavení
+ Autosens zakázán v nastavení
+ SMB zakázáno v nastavení
+ Max bazál omezen na %.2f U/h: %s
+ limit pumpy
+ pořadována kladná hodnota
+ maximální násobek bazálu
+ mazimální násobek nejvyššího bazálu
+ Odeslán bolus během posledních 3 minut, SMB přeskočeno
+ Bazál nastaven správně
+ Bazál omezen na %d%%: %s
+ Bolus omezen na %.1f U: %s
+ Max IOB omezeno na %.1f U: %s
+ Sacharidy omezeny na %d g: %s
+ IOB omezeno na %.1f U: %s
+ maximální hodnota v nastavení
+ pevný limit
+ nebezpečné použití
+ Načtení stavu selhalo
+ Zaznamenat výmenu setu
+ Zaznamenat výmenu inzulínu
+ \"SMB vždy\" a \"po jídle\" zakázáno protože zdroj glykémie nepodporuje rozšířené filtrování
+ SBM není povoleno v otevřené smyčce
+ Jídlo
+ reset
+ Čekání na synchronizaci času (%d s)
+ Odpojeno (%d m)
+ Automatické vkládání péče
+ Automaticky vloží výměnu inzulínu, setu, baterie a alarmů pumpy do NS
+ Maximální celkové IOB, které OpenAPS nemůže překročit [U]
+ Tato hodnota je v kontextu OpenAPS nazývána Max IOB. OpenAPS nikdy nepřidá inzulín, pokud je současné IOB větší než tato hodnota
+ Maximální doba absorbce sacharidů [h]
+ Doba, po které jsou všechny sacharidy považovány za strávené. Zbylé budou oříznuty
+ Čas
+ Zobrazovat kolonku poznámky v dialozích ošetření
+ Požadováno: %.2fU Doručeno: %.2fU Chyba: %d
+ První přídavek izulínu
+ Druhý přídavek inzulínu
+ Třetí přídavek inzulínu
+ První přídavek sacharidů
+ Druhý přídavek sacharidů
+ Třetí přídavek sacharidů
+ CGM
+ Používat pouze WiFi
+ WiFi SSID
+ Pouze při nabíjení
+ Nastavení připojení
+ Povolené SSID (oddělené středníkem)
+ Povolit připojení pro roamingu
+ Max hodnota autosens
+ Min hodnota autosens
+ Dělitel \"bolus snooze\"
+ Max násobitel denního nejvyššiho bazálu
+ Max násobitel současného bazálu
+ ---
+ Doplňování glykémíí z NS
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 2f51b46c1f..b078523a63 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -174,8 +174,8 @@
Absolut
Bolus fehlgeschlagen
TBR abbrechen
- Temoräres Ziel
- Temoräres Ziel abbrechen
+ Temporäres Ziel
+ Temporäres Ziel abbrechen
Kommentar
Verbunden
Verbinden
@@ -331,7 +331,6 @@
Aktivität
Erwachsener
Erweiterte Einstellungen
- AndroidAPS
BAS
Basal-Schritt
Wert der Basalrate unter Minimum. Profil nicht gesetzt!
@@ -552,7 +551,7 @@
Anzahl der vergangenen Stunden, die verwendet werden, um die Sensitivität zu erkennen (Zeit, in der KH resorbiert werden, ist nicht berücksichtigt)
Entscheide anhand von dieser Erfahrung, wie hoch max Basal sein sollte, und übernehme den Wert in die Pumpen- und AAPS-Einstellungen
Erprobe den Closed Loop Modus mit max IOB = 0 für ein paar Tage, ohne zu viele Unterzuckerungen zu haben
- Starte den Closed Loop Modus mit Abschaltung bei niedrigen Werte
+ Starte den Closed Loop Modus mit Abschaltung bei niedrigen Werten
Verwende es ein paar Tage und zumindest eine Nacht ohne Niedrig-Alarme (UZ), bevor du den BZ-Zielbereich senkst
Fein-Einstellung des Closed-Loops, Erhöhen von max IOB über 0 und langsames Heruntersetzen des Zielbereichs
Eine Woche erfolgreiches Loopen am Tag mit regelmäßiger Kohlenhydrat-Eingabe
diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml
index 6cb7a1a252..7c23e3513d 100644
--- a/app/src/main/res/values-el/strings.xml
+++ b/app/src/main/res/values-el/strings.xml
@@ -1,6 +1,5 @@
- AndroidAPS
Ασφάλεια Θεραπειών
Μέγιστο Επιτρεπτό bolus[U]
Μέγιστο Επιτρεπτό υδατ.[g]
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 1fc2769177..c737dfa5aa 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -358,7 +358,6 @@
Número de teléfono inválido
Esperando bomba
Italian
- AndroidAPS
hollandes
Griego
Ruso
@@ -474,9 +473,9 @@
Adulto
Por favor elige edad del paciente para emplear limites de seguridad
Glimp
- Aparato parece no soportar optimisacion de bateria whitelisting!
+ Aparato parece no soportar optimizacion de bateria whitelisting!
Por favor permita Permission
- %s necesita optimisacion de bateria whitelisting para funcionar bien
+ %s necesita optimizacion de bateria whitelisting para funcionar bien
Loop desactivado
desactivado (%d m)
Superbolus (%d m)
@@ -518,8 +517,8 @@
xds
Mostrar BGI
agregar BGI a status line
- No upload to NS
- Todos los datos mandados a NS son borrados. AAPS esta conectado to NS pero no hay cambios en NS
+ datos no mandados a NS
+ Todos los datos mandados a NS son borrados. AAPS esta conectado a NS pero no hay cambios en NS
Nivel base
Nivel bolo
Bolo prolongado
@@ -564,7 +563,7 @@
UPLD
BAS
EXT
- Pantalle proteccion
+ Pantalla proteccion
Cierre
Al activar autosens recuerda editar todos carbohidratos comidos. Si no, sensividad será calculada incorrectamente !!!
Sensitivity WeightedAverage
@@ -577,7 +576,7 @@
ACTIVITY Y FEEDBACK
CARBS Y BOLUS
CGM Y OPENAPS
- PUMP
+ BOMBA
Valor base [U/h]
Duracion [min]
IOB Curve Peak Time
@@ -593,13 +592,13 @@
Coneccion OK
Coneccion fuera de tiempo
CONECTANDO
- aparato no enconrado
+ aparato no encontrado
Deposito vacio
Alerta de control de BG
Insulina restante en deposito
DanaRS
Dana
- Bomba sleccionada
+ Bomba seleccionada
Conectar bomba nueva
Velocidad bolo
Poner paso base a 0.01 U/h
@@ -615,7 +614,7 @@
recibiendo estado de bolo prolongado
recibiendo estado bolo
recibiendo estado bolo temporal
- recibiendo ah´justes bomba
+ recibiendo ajustes bomba
recibiendo hora bomba
usar otra vez
Control desde reloj
@@ -629,9 +628,9 @@
Pr
Grasa
]]>
- Esperande terminar bolo. Faltan %d seg.
+ Esperando terminar bolo. Faltan %d seg.
Processando
- "Iniciando emisioin bolo "
+ "Iniciando emision bolo "
Orden se esta efectuando en este momento
control de la bomba corigido
bomba no alcanzable
@@ -703,7 +702,7 @@
Se necesita actualizar reloj de la bomba
Alerta
TBR cancelada, advertencia acceptada
- Emision del bolo fallado. Ningún bolo se ha emitido. Para asegurarse, por favor controle la bomba para evitar bolo doble. Para evitar bugs no se reinician bolos automaticamente.
+ Emision del bolo fallada. Ningún bolo se ha emitido. Para asegurarse, por favor controle la bomba para evitar bolo doble. Para evitar bugs no se reinician bolos automaticamente.
"Solo %.2f U del bolo mandado de %.2f U ha sido emitido por causa de un error. Por favorn controla la bomba para confirmar y toma acciones apropiadas. "
"Fallo de emitir bolo y de controlar historical de la bomba.Por favor controla manualmente y crea un record en Careportal si el bolo ha sido emitido. "
Reestablecido coneccion fallada.
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index cedf15bd5e..1db4265171 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -1,6 +1,5 @@
- AndroidAPS
Traitements de sécurité
Bolus max. autorisé [U]
Glucides max. autorisés [g]
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 3c738259b3..5d572ed93a 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -457,6 +457,5 @@
Profilo NS
Profilo Basale aggiornato nel Micro
Impostazione Profilo Basale fallito
- AndroidAPS
diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml
index 55d0d9ba64..dd14859672 100644
--- a/app/src/main/res/values-nl/strings.xml
+++ b/app/src/main/res/values-nl/strings.xml
@@ -677,7 +677,6 @@
COB berekening
]]>
]]>
- AndroidAPS
BG beschikbaar op gekozen bron
Enkel positief
Enkel negatief
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index d04b486b95..9a57c5f366 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -521,7 +521,6 @@
состояние xdrip (часы)
xds
разрешенный предел достигнут
- AndroidAPS
Ожидаемое время усваивания всех углеводов пищи в часах
Максимальное время усваимости пищи
Настройки усваиваемости
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 47bd827e0a..9d9539ec20 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -2,58 +2,60 @@
Avbryt
Glimp
- MM640g
+ Minimed 640g
Absolut
- Åtgärd
- ACT
+ Åtgärder
+ Act
Aktivitet
Vuxen
Avancerade inställningar
- Starta om telefonen eller AndroidAPS from systeminställningar
- Använd alltid kort medel delta istället för enkel delta
+ Starta om telefonen eller AndroidAPS från systeminställningar, annars kommer Android APS inte kunna logga fel (viktigt att kunna spåra och verifiera att algoritmerna fungerar korrekt)!
+ Använd alltid kort medeldelta istället för enkel delta
Användbart när ofiltrerade källor som xDrip ger brusvärden
AndroidAPS startar
- Snart daglig max av insulin
- APS Mode
+ Maximal daglig dos snart nådd
+ APS-läge
+ Medeldelta
Basal
- Basal E/tim
- Basal steg
- Basal understiger min.nivå. Ingen profil satt
- Pump Batteri Urladdat
+ Basal:
+ Basalsteg
+ Basal saknas i profil. Använder standardvärde.
+ BR
+ Basal understiger miniminivå. Profilen sattes inte.
+ Basalprofil:
+ Pumpbatteri urladdat
Bolus
- Bolus Steg
- Bolus spärr aktiverad
- Bolus %.2fU korrekt tillförd
- Ger %.2fU
- Kommer att ge %.2fU
+ Bolussteg
+ Bolusspärr aktiverad
+ Bolus %.2f enheter korrekt tillförd
+ Ger %.2f enheter
+ Kommer att tillföra %.2f enheter
Knapp 1
Knapp 2
Knapp 3
Kalibrering skickad till xDrip
- Avbryt Temp Basal
+ Avbryt temp basal
Kolhydrater
- Kohydrat spärr aktiverad
+ Kolhydratsspärr aktiverad
Careportal
Meddelande
- BG Kontroll
- Kanyl ålder
- Kolhydrat korrektion
- CGM Sensor Insättning
- CGM Sensor Start
- Combo Bolus
- Korrektion Bolus
+ BG-kontroll
+ Kanylålder
+ Byte CGM-sensor
+ CGM-sensor start
+ Kombinationsbolus
+ Korrektionsbolus
Träning
- Insulin Ålder
- Insulin Reservoir Byte
- Måltids Bolus
+ Insulinålder
+ Byte insulinreservoar
+ Måltidsbolus
Absolut
- Kolhydrater
- KH tid
+ KH
+ KH-tid
Duration
Infört av
Tid för händelse
- Händelse typ
- Glukos sort
+ Händelsetyp
Insulin
Mätare
Notering
@@ -63,197 +65,209 @@
Sensor
Delad
Notering
- OpenAPS Offline
- Pump Batteri Ålder
- Profil Byte
- Pump Kanyl Byte
+ OpenAPS offline
+ Pumpbatteri ålder
+ Byt profil
+ Byte pumpkanyl
Fråga
CP
- Snack Bolus
- Temp Basal Slut
- Temp Basal Start
- Temp Mål BG
- Temp Mål BG Slut
+ Mellanmålsbolus
+ Temp basal slut
+ Temp basal start
+ Temp mål
+ Temp mål avbrutet
Ändra inmatning
Barn
- Ta bort kö
- Rensa inmatningar
+ Cirkadisk Profil Procent
+ CPP
+ Töm kö
+ Töm logg
Closed Loop
COB
Kommentar
Konfigurationsverktyg
APS
BG Källa
- Begränsningar
+ Begränsningar
Generell
Insulin
Loop
- Nightscout version:
+ Nightscoutversion:
Profil
Pump
- KONF
- Åtgärd
- Bekräftelse
- Sammankopplad
- Sammankopplar
- Sammankoppling till pump förlorad
- Begränsning aktiverad
- Begränsning Överträdelse
- Kopierad till Clipboard
- Kopiera till Clipboard
+ Konf
+ Tempbasaler
+ Behandlingar
+ Bekräfta
+ Ansluten
+ Ansluter
+ Anslutningsfel pump
+ Begränsning nådd
+ Begränsning nådd
+ Kopierat till Urklipp
+ Kopiera till Urklipp
Korr
- CZ
- Alarm
+ larm
basal tim
- Bluetooth Status
+ Bluetoothstatus
DanaR Bluetooth Pump
kolhydrat
- Enheter/Dag
- Avaktivera EasyUI mode in pump
- Aktivera förlängd bolus i pump
- Fel
- Glukos
- Historia
+ Enheter per dag
+ Avaktivera EasyUI mode in pumpen
+ Aktivera förlängd bolus i pumpen
+ fel
+ glukos
+ Historik
Larm
- Basal Timmar
+ Basaltimmar
Bolusar
Kolhydrater
- Sammankopplar för %d s
+ Ansluter (%d s)
Daglig insulinmängd
Fel
Glukos
- Påfyllnad
+ Påfyllning
Stoppa
- Ladda om
- Fel på inlagd data
+ Hämta
+ Fel på inmatad data
Pump IOB
- Sista bolus
- Lösenord Pump
- DanaR pump inställningar
- Påfyllnad
+ Senaste bolus
+ Lösenord pump
+ DanaR pumpinställningar
+ påfyllning
Kumulativ TDD
Datum
Exponentiellt viktad TDD
- Gammal Data Vg tryck \"Ladda om\"
+ Gammal data. Tryck på Hämta.
Kvot
- Använd förlängd bolus med >200%
- Värde ej korrekt angivet
- Se profil
- Se förlängd bolus som %
+ Använd förlängd bolus för att ange >200%
+ Misslyckades med inställning
+ Visa profil
+ Visa förlängd bolus som %
DanaR Korea
- DanaR profil inställningar
- DIA (h)
+ DanaR profilinställningar
+ DIA [tim]
Insulinets verkningstid (DIA)
DanaR
- DANA
+ Dana
dagar
- Deutsch
- Ge nu
+ Synkronisera nu
Delta
- Vald enhet ej funnen
- DIA
- Loop Frånkopplad
- Frånkoppla pump i 1 h
+ DEV
+ Vald enhet kan inte nås
+ DIA:
+ Loop frånkopplad
+ Koppla ifrån pump i 1 h
Stäng av loop
Frånkopplad
- Frånkopplar
- Frånkoppla pump i 2 h
- Frånkoppla pump i 15 min
- Frånkoppla pump i 30 min
- Frånkoppla pump i 3 h
+ Kopplar ifrån
+ Koppla ifrån pump i 10 h
+ Koppla ifrån pump i 2 h
+ Koppla ifrån pump i 30 min
+ Koppla ifrån pump i 3 h
TA BORT
+ Ignorera profilbyten
+ Alla profilbyten ignoreras och aktiv profil används alltid
+ Visa inte detta igen
Duration
Äta snart
- English
+ Ändra grundbasal:
+ Startad
Starta loop
Aktivera superbolus i kalkylatorn
- Aktivera superbolus funktionen i kalkylatorn. Aktivera inte innan du förstått hur den fungerar. DEN KAN ORSAKA ÖVERDOSERING AV INSULIN OM INSIKT SAKNAS OM FUNKTIONEN
+ Aktiverar superbolusfunktionen i kalkylatorn. Aktivera inte innan du förstått hur den fungerar. DEN KAN ORSAKA ÖVERDOSERING AV INSULIN OM INSIKT SAKNAS OM FUNKTIONEN!
Aktiverad
- Licensavtal för Slutanvändare
+ Licensavtal för slutanvändare
JAG FÖRSTÅR OCH GODKÄNNER
- Ange ny behandling
+ Ange ny behandling:
Denna kolumn får ej vara tom
- Endast siffror får användas
- Endast siffror är tillåtna inom %1$s - %2$s
- Ej giltigt telefonnummer
- Spanska
+ Endast siffror tillåtna.
+ Endast siffror mellan %1$s - %2$s är tillåtna.
+ Ogiltigt telefonnummer
Utför
Exportera inställningar till
Inställningar exporterade
- FörlängdBolus
- Lyckades ej uppdatera basalprofil
- Snabbverkande Insulin
+ Förlängd bolus
+ Lyckades inte uppdatera basalprofilen
+ Snabbverkande Insulin (gammal beräkningsmodell)
Novorapid, Novolog, Humalog, Apidra
- Data ej funnen
- Fyll/Förfyll standard insulin mängd
- Vg försäkra dig om att mängd motsvarar det som är specificerat för just ditt infusionsset
- Hämtar pump status
+ Hittade inte filen
+ Standardvärden för prime/fyll.
+ Försäkra dig om att mängden motsvarar det som är specificerat för just ditt infusionsset.
+ Hämtar pumpstatus
Glukos
Finger
Sensor
- HÖG markering
+ HÖG-markering
timmar
+ %.1f tim sedan
Importera inställningar från
- Startar…
- Ogiltig profil !!!
+ Startar...
+ Ogiltig profil!
IOB
- Italienska
- Koreanska
Språk
- Lokal Profil
+ Lokal profil
LP
Loop
APS
- Efter avklarade begränsningar
- LOOP
+ Efter begränsningar
+ Inställning i pump
+ Loop
LOOP STOPPAD PGA BEGRÄNSNINGAR
- Superbolus (%d m
- Loop avstängd
- LÅG markering
- Svagt Batteri
- Manual
+ Loop meny
+ Superbolus (%d min)
+ Loop pausad
+ LÅG-markering
+ Svagt batteri
+ Manuell
Avbryt
Måltid
- Fattas
+ Saknas
Om
- Exit
+ Backup
+ Avsluta
Exportera inställningar
Importera inställningar
Inställningar
Uppdatera behandlingar från NS
- Återställ Databaser
- Visa log
+ Återställ databaserna
+ Visa logg
+ Testa alarm
Nightscout
INGEN APS VALD
- Ingen Bluetooth adapter funnen
+ Ingen Bluetooth-adapter funnen
Ingen ändring behövs
- Ingen profil laddad ännu från NS
+ Ingen profil laddad från Nightscout ännu
Ingen profil vald
INGEN PROFIL VALD
misslyckat - vg kontrollera telefonen
Ej tillgängligt
- NSCLIENT har inga skrivrättigheter. Fel API secret?
+ NS Client har inga skrivrättigheter. Fel API secret?
Alarm inställningar
- Medge lokal sändning till andra appar (ex xDrip)
- Aktivera lokal Broadcasts
- Markera app start till NS
- Ingen uppladdning till NS
- Ingen data sänds till NS. AAPS kommunicerar med NS men inga ändringar görs i NS
+ Slå på sändning av data till alla appar i telefonen (ex xDrip).
+ Aktivera lokala broadcasts
+ Markera app start till Nightscout
+ Ingen uppladdning till Nightscout
+ Ingen data sänds till Nightscout. AAPS ansluter till Nightscout men inga ändringar görs i Nightscout.
Använd alltid absoluta värden i basal
- Endast uppladdning till NS (avaktiverad sync)
- Endast uppladdning till NS. Fungerar ej med SGV om inte lokal källa som xDrip används. Inte effektiv med Profiler om NS-Profiler används
+ Endast uppladdning till Nightscout
+ Endast uppladdning till Nightscout. Kommer inte få BG-data om inte lokal källa som xDrip används. Kommer heller inte att kunna hämta basalprofiler från Nightscout.
Hög
Låg
Gammal data
- Ange NS API sectet (min 12 tecken)
+ NSClient
+ Ange enhetens namn
+ Enhetens namn
+ Ange NS API secret (min 12 tecken)
NS API secret
NSClient är inte installerad. Data förlorad!
Nightscout URL
- Enter Nightscout URL
+ Ange Nightscout URL
URL:
NSClient
NSCI
NS API secret
+ Aktiv profil
Basal
DIA
IC
@@ -261,9 +275,9 @@
Målvärde
Enheter
OAPS
- Mål/Syfte
- Kontrollera att BG syns i NS, och att pump insulin data laddas upp
- Ställa in utseende och övervakning, för att sedan kunna analysera basaler och kvoter
+ Mål
+ Kontrollera att BG syns i Nightscout och att insulindata från pumpen laddas upp
+ Ställer in utseende och övervakning för att sedan kunna analysera basaler och kvoter
Du har nått din tillåtna gräns
xds
xDrip Status (klocka)
@@ -274,44 +288,49 @@
Fel lösenord
Visa BGI
Visa BGI i statusfält
- WEAR
- Wear inställningar
+ Wear
+ Inställningar för Wear
Visa detaljerad IOB
Visa IOB med bolus och basal på klocka
Wear
Väntar på resultat
+ Väntar på pump. Klicka för att uppdatera.
Väntar på pump
- Virtuell
- Ladda upp till NS
+ Virtuell pump
+ Synlig
+ Ladda upp status till Nightscout
Temp basal
- VPUMP
- Virtuell pump inställningar
+ SQL-fel
+ vPump
+ Inställningar för Virtuell pump
OK
- Reservoir
- Sista kontakt
- Programversion
+ Reservoar
+ Senast ansluten
+ Firmwareversion
Förlängd bolus
Batteri
- Grund basal hastighet
- Virtuell Pump
- Uppladdning
- Uppdaterar basal hastigheter
- Version av NS som inte stöds
+ Profilens basalhastighet
+ Virtuell pump
+ Laddar upp
+ Uppdaterar basalhastigheter
+ Upp
+ Version av Nightscout som inte stöds
Version av NSClient som inte stöds
Lås upp inställningar
Enheter:
Säkerhet vid behandling
- Max tillåtna KH (g)
+ Max tillåtna KH [g]
Max tillåten bolus [E]
- E
+ E
+ TOTAL
Korr
COB
KH
Bolus IOB
- 15min trend
+ 15 min trend
BG
Basal IOB
- TREAT
+ Beh
Insulin
KH
Total IOB:
@@ -321,226 +340,571 @@
KH:
Aktivitet:
Behandlingar
- Bolus ej tillförd
- TempMål
+ Fel vid bolusleverans
+ TT
+ Temp mål
+ TB
Dur:
Kvot:
Ins:
Total IOB:
IOB:
- Tempbasal ej tillförd
- Tempbasal
+ Fel vid justering av tempbasal
+ Temp basal
Tonåring
- Mål gränser:
- Stäng av loop i 3 h
- Stäng av loop i 2 h
- Stäng av loop i 1 h
- Stäng av loop i 10 h
+ Mål saknas i profil. Använder standardvärde.
+ Målområde:
+ Pausa loop i 3 h
+ Pausa loop i 2 h
+ Pausa loop i 1 h
+ Pausa loop i 10 h
Superbolus
Lyckad
- Stoppar temp basal
- Stoppar förlängd bolus
+ Avbryter temp basal
+ Avbryter förlängd bolus
Status:
Fel duration:
Okänt kommando eller fel svar
- Temp basal %.2fU/h for %d min startad
- Fel vid Temp basal start
- Gick ej att avbryta temp basal
+ Tempbasal %.2f enheter/tim i %d min startad
+ Fel vid start av temp basal
+ Misslyckades med att avbryta temp basal
Temp basal avbruten
- För att avbryta loop i %d minuter svara med kod %s
+ För att pausa loop i %d minuter, svara med kod %s
SMS
- Tillåt fjärrkommandon via SMS
- Fjärrkommandon tillåts ej
- Kalibrering från andra källor godkänns ej
+ Tillåt fjärrstyrning via SMS
+ Kalibrering från andra källor inte tillåtna
Fjärrbolus är inte tillåtet
Fjärrkommandon för att ändra basaler tillåts ej
- Ej godkänd för SMS
- Loop avstängd
- Loop åter startad
+ Saknar rättighet att skicka SMS
+ Loop pausad
+ Loop återupptagen
Loop är aktiverad
Loop är avstängd
Loop är aktiverat
Loop är avstängd
- Icke giltigt telefonnummer för SMS
- Kalibrering skickad. xDrip måste tillåta att ta emot kalibrering i inställningarna
- För att skicka kalibrering %.2f svar med kod %s
+ Ogiltigt telefonnummer för SMS
+ Kalibrering skickad. xDrip måste tillåta att ta emot kalibrering i inställningarna.
+ För att skicka kalibrering %.2f, svara med kod %s
xDrip tar inte emot kalibreringar
- För att ge bolus %.2fU svar med kod %s
- Bolus ej given
- Bolus %.2fU tillförd
- För att stoppa temp basal svara med kod %s
- För att starta basal %.2fU/h svara med kod %s
+ För att ge bolus %.2f enheter, svara med kod %s
+ Bolus avbruten
+ Bolus %.2f enheter tillförd
+ För att stoppa temp basal, svara med kod %s
+ För att starta basal %.2f enheter/tim, svara med kod %s
+XXXXXXXXXX;+YYYYYYYYYY
- Tillåtna telefonnummer
- SMS Tjänst
+ Godkända telefonnummer
+ SMS-tjänst
Senaste BG:
Enkel profil
Visa kö
Lösenord för inställningar
- Ställ in förlängd bolus
- inställningar importerade
+ Ställer in förlängd bolus
+ Inställningar importerade
Ställ in ny förlängd bolus:
- Acceptera ny temp basal:
+ Acceptera ny tempbasal:
Skicka kalibrering %.1f till xDrip?
+ SKICKA
Spara
Säkerhet
Återuppta
Resultat
- Gå ur applikationen för att starta inställning
+ Avslutar appen för att inställningarna ska läsas in.
Omstart
- Vill du verkligen återställa databasen?
- Återsänd all Data
+ Vill du verkligen återställa databaserna?
+ Uppdatera all data
Ta bort sparad data:
Ladda om profil
- Uppdatera händelser från NS
+ Uppdatera händelser från Nightscout
Orsak
+ RAT
Hastighet
- Kalkylator inställningar
+ Kalkylatorinställningar
Kalkylator
Kö:
- Pump stoppad
+ Pump pausad. Klicka för ladda om status.
+ Pump pausad
Pump avstängd
Pumpfel
Pump upptagen
- Pump inte igångsatt, ingen profil vald
- Pump inte startad
+ Pump inte initierad, ingen profil vald.
+ Pump inte initierad
Pump
- NSPROFIL
- NS Profil
- ProfilByte
- Basal profil i pump uppdaterad
- Ny basal profil misslyckades
+ NSProfil
+ NS profil
+ Profilbyte
+ Basalprofilen uppdaterad i pumpen
+ Lyckades inte sätta basalprofilen
Profil
Prime/Fyll
- Gränsvärden för Visualisering
- Högt och lågt värde för graf i översikten och i smartwatch
- Vg ge tillåtelse
+ Gränsvärden för visualisering
+ Högt och lågt värde för grafen i Översikt och i smartwatch
Procent
+ Procentfaktor med vilken basalprofilen kommer att bli multiplicerad.
Pausad
Vg ange personens ålder för inställningar av gränser
Personens ålder
- TempBasal
- Hemma
+ Temp basal
+ Hem
Ta bort
- Editera
- % (100% = current)
- Stoppa Förlängd Bolus
- Förlängd Bolus
+ Ändra
+ % (100% = profilens värde)
+ Stoppa förlängd bolus
+ Förlängd bolus
Lägg till
Giltig:
KH:
- Knapp text:
+ Knapptext:
Kalibrering
Kalibrering
Kalkylator
STOPP NEDTRYCKT
Stoppad
Stopp
- Kommer tillföra %.2fU
+ Kommer tillföra %.2f enheter
Tillförd
- Bolus
+ Bolus
Översikt
Andra
- Ny behandlingsrekommendation tillgänglig
+ Ny rekommendation tillgänglig
Open Loop
- Värde %s är utanför gränserna
- %.2f begränsad till %.2f
+ Värde %s är utanför gränserna
+ %.2f begränsad till %.2f
Kör nu
- Fråga
+ Beräknat behov
Profil
- Ingen glukos data tillänglig
- Måltids data
+ Ingen pump tillgänglig
+ Ingen profil tillänglig
+ Ingen glukosdata tillänglig
+ Måltidsdata
Maximal basal IOB som OpenAPS kan ge [E]
Detta värde kallas Max IOB i OpenAPS. Det är ställt till noll från start. Efter flera dagar till veckor, beroende på hur du känner, kan du välja att justera denna.
- Max E/h som Temp Basal kan ställas in på
+ Max enheter per timme som temp basal kan sättas till
Detta värde kallas max basal inom OpenAPS
- Senaste körning
+ Senast körd
Senast startad
IOB data
Ange värden
- Status Glukos
+ Glukosstatus
Plug in är avaktiverad
Nuvarande temp
- Autosens data
+ Autosensdata
OpenAPS MA
- Använd AMA autosens funktioner
- Inställt värde: 3.0 Detta är grundinställning för KH.absorption per 5 min. 3 mg/dl/5 min. Detta styr hur snabbt COB minskar, dvs hur snabbt programmet kalkylerar att KH tagits upp, och påverkar BG framöver när BG faller mer än väntat, eller inte stiger som väntat"
- Inställt värde: 3 Detta är en grundsten i OpenAPS säkerhetsaspekt. Detta begränsar din basal till att vara 3x din största basalhastighet. Du behöver ofta inte ändra detta värde, Läs på och förstå skilnaden på 3x nuvarande och 3x daglig max som säkerhetsinställningar.
+ Använd AMA autosens
+ Standardvärde: 3.0 mg/dl/5 min Detta är grundinställning för KH-absorption per 5 min. Detta styr hur snabbt COB minskar, dvs hur snabbt programmet kalkylerar att KH tagits upp, och påverkar BG framöver när BG faller mer än väntat, eller inte stiger som väntat.
+ Standardvärde: 3 Detta är en grundsten i OpenAPS säkerhet. Detta begränsar dina tempbasaler till maximalt 3x din största basalhastighet. Du behöver oftast inte ändra detta värde. Läs på och förstå skillnaden mellan 3x nuvarande och 3x daglig max som säkerhetsinställningar.
Viktigt! Normalt behöver du inte ändra dessa värden. Vg KLICKA HÄR och LÄS texten och försäkra dig om att du FÖRSTÅTT innan du ändrar dessa värden.
- Inställt värde: 4 Detta är andra delen i grunden för säkerhet i OpenAPS, dvs kring 3x och 4 x daglig och nuvarnde basaler. Detta värde innebär att din nuvarande basal, oberoende av din max basalhastighet, kan aldrig bli högre än 4x nuvarande basal. Detta för att undvika att man farliga inställningar. Om man når taket i denna inställning så kanske ändringar i andra inställningar behövs. De flesta behöver inte ändra denna inställning.
- Inställt värde: 2 Bolus snooze är aktivt efter att du givit en måltidsbolus, detta för att inte loop ska lågtempa när du just ätit. I detta exempel och grundvärde är 2; innebär att DIA på 3 tim kommer bolus snooze kommer att fasas ut under 1,5 tim (3DIA/2).
- Antal timmar för beräkning av känslighet (KH absorptionstid är exkluderad)
- Intervall för autosens (h)
- Inställt värde: 0.7 Detta är den andra delen av autosens säkerhetsaspekt, den sätter en gräns på hur lågt autosens kan justera basaler, och hur högt den kan justera ISF och BG mål
- Inställt värde: 1.2 Detta är inställt värde för hur mycket autosens kan multiplicera uppåt (snart även autotune) dvs max 20%, med 1.2 kan alltså autosens öka dina basaler med max 20%, denna gräns gäller alltså hur högt autosens kan justera dina basaler men även hur lågt den kan justera ISF och hur lågt den kan sätta BG mål.
- Inställt värde: sant Detta för att tillåta autosens justera BG målvärden, tillsammans med ISF och basaler
+ Standardvärde: 2 Bolus snooze är aktivt efter att du givit en måltidsbolus, detta för att inte loop ska lågtempa när du just ätit. I detta exempel och grundvärde är 2; innebär att DIA på 3 tim kommer bolus snooze kommer att fasas ut under 1,5 tim (3DIA/2).
+ Antal timmar för beräkning av känslighet (Absorptionstid för KH är exkluderad).
+ Intervall för autosens [tim]
+ Standardvärde: 1.2 Med standarvärdet 1.2 kan autosens justera upp dina basaler, kvoter etc med upp till 20% för att kompensera för t ex tillfällig insulinresistens.
+ Standardvärde: sant Detta för att tillåta autosens justera BG målvärden, ISF och basaler.
OpenAPS AMA
- OAPS
OpenAPS
Öppna inställningar på Wear
- Pågående rapportering
+ Konstant infonotis i telefonen
GAMMAL DATA
OK
Ocklusion
- M/S
- Pump status tillgänglig i NS
- Mål/syfte
+ Mål
+ Pumpstatus tillgängligt i Nightscout
+ Mål:
Minimal duration
Manuell aktivering
Spärr:
Godkänn
Starta
- BG är tillängligt i NS
- Aktiverar extra funktioner som kan användas dagitd, såsom avancerad måltids assist
- Justerar basaler och ration om det behövs, aktivera sedan auto-sens
- 1 veckas framgångsrik dagtids looping där alla måltider lagts in
+ BG är tillängligt i Nightscout
+ Aktiverar extra funktioner som kan användas dagtid, såsom avancerad måltidsassistans, AMA
+ Justerar basaler och kvoter om det behövs. Aktivera sedan autosens.
+ 1 veckas lyckad looping dagtid, där alla måltider lagts in.
Finjustering av closed loop, gradvis ökande IOB och minskande önskat BG målvärde
- Kör några dagar, och åtminstone en natt utan larm för lågt BG, innan du sänker BG målvärde
+ Kör några dagar och åtminstone en natt utan larm för lågt BG innan du sänker målvärdet för BG.
Börja använda closed loop med aktiverad funktion att stänga av vid lågt BG
Aktivera closed loop med max IOB=0 i några dagar till dess systemet inte stänger av pga lågt BG för många gånger
- Förstå din open loop, och hur den föreslår temp basaler
- Utifrån vad du nu lärt dig, besluta vilken max basal du vil ha, ställ in det både i inställningar i APS och i den pump.
+ Förstå din open loop och hur den föreslår temp basaler
+ Utifrån vad du nu lärt dig, besluta vilken max basal du vil ha. Ställ in det både i inställningarna i APS och i din pump.
Starta med open loop
- Starta Open loop och använd det några dagar, försök att ge många föreslagna temp basaler
+ Starta med open loop och använd det några dagar. Försök att ge många föreslagna temp basaler.
Tid i timmar när alla KH väntas vara absorberade
- Måltids max absorptions tid (h)
- Absorptions inställningar
- Bulgariska
+ Max absorptions tid för en måltid [tim]
+ Absorptionsinställningar
PUMP
- Batteribyte Pump
- Sensor ålder
- SAGE
- Värden sparas inte
- Möjligen felvärde om man använder bolus för att priming/fyllning!
- Grekiska
+ Byte pumpbatteri
+ Sensorålder
+ måste vara aktiverad för att kunna skicka värden till pumpen.
+ Värden sparades inte!
+ Kan visa fel om man använder bolus för priming/fyllning!
+ Ändra grund-IC:
+ Ändra grund-ISF:
MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+ ISF saknas i profilen. Använder standardvärde.
Lås skärm
Lås
mmol/l
- %dmin sedan
+ %d min sedan
mg/dl
OK
MDI
NSClient
Autoscroll
- Basal typ
+ http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html
+ Basaltyp
SENS
Genom att slå på Autosens funktionen, kom ihåg att skriva in alla KH. Annars kommer programmet göra fel i beräkningar av känslighet (ISF)!!
Sensitivity AAPS
Sensitivity Oref0
Sensitivity WeightedAverage
- Ställa in temp basal
+ Ställer in temp basal
SP
BG:
Basal:
Bolus:
Delta:
IOB:
- %dmin sedan
- Gammal data tröskelvärde
- Bråttom gammal data tröskelvärde
- Bråttom hög
- Bråttom låg
- Bråttom gammal data
+ %d min sedan
+ Tröskelvärde för \"Gammal data\" [min]
+ Tröskelvärde för \"Väldigt gammal data\" [min]
+ Akut hög
+ Akut låg
+ Väldigt gammal data
AndroidAPS
+ TT
+ Basal [%]
+ BG-källa
+ Svenska
+ Laddade upp totalt %d värden
+ Aktiverar ytterligare funktioner för användning dagtid, t ex SMB.
+ Otillåtet fjärrkommando
+ Tid (i timmar) som profilen kommer att förskjutas.
+ Ändra inställningen från E/d till E/tim i pumpen
+ Kort medeldelta
+ Långt medeldelta
+ Antal dagar
+ Vikt
+ Total grundbasal
+ Förkorta namnen på flikarna
+ Deltainställningar
+ Modell: %02X Protokoll: %02X Kod: %02X
+ "Standardvärde: 4 Detta är en grundsten i OpenAPS säkerhet. Detta begränsar dina tempbasaler till maximalt 4x din nuvarande basal, oberoende av din max basalhastighet. Detta för att undvika att man av misstag gör farliga inställningar. Om man når taket i denna inställning så kanske ändringar i andra inställningar behövs. De flesta behöver inte ändra denna inställning. "
+ Standardvärde: 0.7 Med standardvärdet 0.7 kan autosens justera ner dina basaler, kvoter etc med upp till 30% för att kompensera för t ex tillfällig hög insulinkänslighet.
+ "Det kommer att användas för att ange \"Inmatat av: \". "
+ Enheten verkar inte stöda vitlistning av appar för batteriförbrukning
+ Tillåt
+ %s behöver kunna kringgå batterisparfunktionerna för att fungera korrekt
+ Pausad (%d min)
+ Snabbverkande insulin (förlängd)
+ KH-kvot (IC) saknas i profilen. Använder standardvärde.
+ För närvarande satt till %f
+ Enhet
+ Uppladdare
+ Känslighetsmätning
+ Alla profiler laddades inte!
+ Notiser från Översikten
+ Sänd notiser från Översikten som bekräftelsemeddelanden på Wear.
+ Basal [E/tim]
+ Peaktid för IOB-kurvan
+ Peaktid [min]
+ Rapid-Acting Oref (ny beräkningsmodell)
+ Ultra-Rapid Oref (ny beräkningsmodell)
+ %s tim DIA är för kort. Använder %s istället!
+ Aktivera profil
+ Datum
+ OGILTIG
+ Väntar på parkoppling med pump
+ Parkoppling OK
+ Parkoppling tog för lång tid
+ PARKOPPLAR
+ Ingen enhet funnen ännu
+ Tom reservoar
+ Varning om blodsockermätning
+ "Återstående mängd insulin "
+ Vald pump
+ Parkoppla ny pump
+ Bolushastighet
+ Sätt basalsteg till 0.01 enheter per timme
+ Serienummer
+ Procent
+ Tidsförskjutning
+ Standardvärde för Temp-mål
+ Äta snart, duration
+ Äta snart, mål
+ Aktivitet, duration
+ Aktivitet, mål
+ Hämtar status för förlängd bolus
+ Hämtar status för bolus
+ Hämtar status för tempbasal
+ Hämtar pumpinställningar
+ Hämtar tid och datum i pumpen
+ återanvänd
+ Kontroller från klockan
+ Sätt tempmål och ange behandlingar från klockan.
+ Anslutningen tog för lång tid
+ Mat
+ g
+ kJ
+ En
+ Pr
+ Fett
+ Väntar på att bolus ska slutföras. %d sek återstår.
+ Behandlar
+ Påbörjar bolus
+ Kommandot kör just nu
+ Pumpdrivrutin justerad
+ Pumpen kan inte nås
+ BG-värden saknas
+ Använd systemnotiser för larm och information
+ Lokala larm
+ Varna om BG-data saknas
+ Varna om pumpen inte går att nå
+ Pumpen ses som ej nåbar efter [min]
+ Akut larm
+ Bluetooth-övervakare
+ Startar om bluetooth på telefonen om anslutning till pumpen misslyckas. Detta hjälper på en del telefoner där bluetooth ibland hänger sig.
+ Lada upp BG-data till Nightscout
+ Uppladdningsinställningar för G5
+ Visa detaljerad delta
+ Visa delta med en extra decimal
+ Osupportad firmware i pumpen
+ Skicka BG-data till xDrip+
+ Välj 640g/Eversense data som datakälla i xDrip+
+ Basalvärdet ersatt med det lägsta tillåtna
+ Använd BG
+ Använd bolus-IOB
+ Använd basal-IOB
+ Använd BG-trend
+ Använd superbolus
+ Ja
+ Nej
+ Endast positiva
+ Endast negativa
+ Använd COB
+ Använd tempmål
+ Loop påslagen
+ APS vald
+ NSClient har skrivrättigheter
+ Closed loop påslagen
+ Max IOB är korrekt angivet
+ BG tillgängligt från vald källa
+ Basalerna är inte satta på hel timme: %s
+ Ogiltig profil: %s
+ Programmerar bolus i pump
+ Uppdatera
+ Läge
+ Aktivitet
+ Ingen anslutning på %d min
+ %d%% (%d min återstår)
+ Initierar
+ Frånkopplad
+ Pausad pga fel
+ Pausad av användaren
+ Körs
+ Avbryter tempbasal
+ Sätter tempbasal (%d%% / %d min)
+ Ger bolus (%.1f enheter)
+ Uppdaterar
+ Aldrig
+ Önskad åtgärd stöds inte av pumpen
+ Osäker användning: Förlängd- eller kombibolus är aktiv. Loop mode är satt till att bromsa vid lågt BG i 6 timmar. Endast normala bolusar tillåtna i loopläge.
+ Osäker användning: Pumpen använder en annan basalprofil än den första. Loop avstängd. Välj den första profilen på pumpen och uppdatera.
+ En bolus med samma mängd efterfrågades inom den senaste minuten. För att förhindra att råka ge dubbla bolusar av misstag och ev programfel är detta inte tillåtet.
+ Nu
+ Läser historik från pumpen
+ Larm
+ Sätter basalprofil
+ Låg nivå i insulinreservoaren
+ Pumpbatteriet är svagt
+ Pumpen visar felet: E%d: %s
+ För att läsa pumpens historik, tryck och håll in ALERTS-knappen. VARNING: detta kan aktivera en bugg som orsakar att pumpen vägrar ansluta och kräver att en knapp trycks in på pumpen för att återgå. Det bör därför undvikas.
+ "För att läsa pumpens historik, tryck och håll in TDDS-knappen. VARNING: detta kan aktivera en bugg som orsakar att pumpen vägrar ansluta och kräver att en knapp trycks in på pumpen för att återgå. Det bör därför undvikas. "
+ Minimum: %3.1f enheter
+ Genomsnitt: %3.1f enheter
+ Maximum: %3.1f enheter
+ Låg
+ Tom
+ Normal
+ Pumpens klocka behöver ställas om
+ Historik
+ Varning
+ "Detta kommer att läsa pumpens fulla historik och status. Allt i Mitt Data och basalprogrammen. Bolusar och tempbasaler kommer att läggas till under Behandlingar om de inte redan finns där. Detta kan orsaka att vissa saker läggs in dubbelt eftersom pumpens klocka inte är så exakt. Detta bör inte göras medan loopen är ogång, utan bara när behov uppstår. Om du ändå vill göra detta, tryck och håll in den här knappen igen. VARNING: detta kan aktivera en bugg som orsakar att pumpen vägrar ansluta och kräver att en knapp trycks in på pumpen för att återgå. Det bör därför undvikas. "
+ Är du helt säker på att du vill läsa all pumphistorik och är medveten om konsekvenserna?
+ Varningen om avbruten tempbasal bekräftad
+ Bolus avbruten. Det verkar som om ingen bolus gavs. För att vara säker, vänligen kontrollera pumpen för att undvika dubbel bolus och prova sedan vid behov igen. För att förhindra fel orsakade av mjukvaran, försöker inte mjukvaran igen automatiskt.
+ Endast %.2f enheter %.2f gavs pga ett fel. Vänligen verifiera på pumpen och vidta nödvändiga åtgärder.
+ Leverans av bolus och verifiering av historiken misslyckades. Vänligen kontrollera på pumpen och lägg till bolusen manuellt under Careportal om den gått fram.
+ Återansluter efter att ha tappat kontakten
+ Inte tillräckligt med insulin i reservoaren för att ge bolus
+ Förlängd bolus misslyckad
+ KH-korrektion
+ E
+ Begränsningar
+ Temp basal satt i pump
+ Behandling
+ Bolus avbruten
+ Avbryter bolus
+ %.2f begränsat till %.2f
+ Värdet %s är utanför hård begränsning
+ Pumpen kunde inte nås. Bolus ej levererad.
+ Ändrad
+ PUMP STOPPAD
+ Status uppdaterad
+ sedan
+ med
+ Aktiv temp basal
+ min kvar
+ Loggbok
+ Senast utförda åtgärd
+ återstår över
+ total med
+ direkt med
+ Håll alltid ansluten
+ Stoppa temp basal på riktigt (skapar pumplarm) istället för att sätta till 90% i en minut
+ REDO
+ SYNKRONISERAR
+ UPPTAGEN
+ SYNKRONISERAD
+ STARTAR
+ behöver
+ Inte ansluten till hjälp-app!
+ Hjälp-app verkar inte vara installerad!
+ Inkompatibel hjälp-app. Vi behöver version
+ Okänd
+ Inväntar kodverifiering
+ Kod ej godkänd
+ Ej godkänd
+ Inkompatibel
+ sek
+ min
+ tim
+ dag
+ vecka
+ %ds går ut %s
+ Statistik
+ Anslut på förhand
+ Anslut automatiskt när AAPS är öppet, innan något pumpkommando är skickat, för att snabba upp kommunikationen
+ Rekommenderas inte, då det drar mycket batteri
+ Använd alltid SMB
+ Använd alltid SMB oberoende av bolus. Endast möjligt med en bra filtrerad BG-källa, t ex Dexcom G5.
+ Använd SMB efter kolhydrater
+ Använd SMB i 6 timmar efter kolhydrater, även med 0 COB. Endast möjligt med en bra filtrerad BG-källa, t ex Dexcom G5.
+ Använd SMB med kolhydrater (COB)
+ Använd SMB medan du har kolhydrater aktiva (COB)
+ Använd SMB när Temp mål är satt
+ Använd SMB när temp mål är satt, t ex Äta snart eller Träning
+ Använd SMB även när ett högt temp mål är satt
+ Använd SMB även när ett högt temp mål är satt (över 5,5 mmol)
+ Låt temp basalen gå
+ Tysta
+ Kolhydrater
+ Knappar
+ Insulin
+ Skicka kalibrering till xDrip+ eller öppna kalibreringsrutan i G5-appen
+ Öppnar xDrip+. Tillbaka-knappen återgår till AAPS
+ "Mängd kolhydrater att lägga till när man trycker på knappen "
+ Mängd insulin att lägga till när man trycker på knappen
+ Kunde inte starta CGM-appen. Kontrollera att den är installerad.
+ Historikläsare
+ Notis vid SMB
+ Visa SMB på klockan som en standardbolus.
+ Skapa notiser vid fel
+ Skapa notiser i Nightscout vid fel eller lokala meddelanden (även synliga i Careportal/Behandlingar)
+ Visa BG-prognos på klockan.
+ Prognos
+ Dataval
+ Uppladdning till Fabric
+ Tillåt automatisk rapportering av appkrascher och användningsinformation till utvecklarna via fabric.io-tjänsten.
+ Vänligen uppdatera din G5-app till en supportad version
+ Starta Tränings-TT
+ Starta Äta snart-TT
+ Ge ingen bolus, logga bara
+ Kategori
+ Underkategori
+ Bolusen sparas bara i loggboken
+ Hämta saknade BG från NS
+ SMB satt i pump
+ Känslighet
+ Avvikelser
+ Aktiva KH
+ Aktivt insulin
+ Basaler
+ Ingen åtgärd vald. Inget ändras.
+ Starta Hypo-TT
+ Du kör nu dev-versionen. Closed Loop inte tillåtet.
+ Engineering Mode aktiverat
+ Engineering Mode inte aktiverat och appen körs inte som release
+ %.2f E/h
+ Läser basalprofil
+ Pumphistoriken ändrad efter att boluskalkylen gjordes. Bolusen har inte levererats. Vänligen gör en ny kalkyl vid behov. Om samma mängd insulin krävs, vänligen vänta två minuter eftersom appen begränsar likadana bolusar av säkerhetsskäl.
+ Bolusen levererad, men det gick inte att lägga till den i loggen. Detta kan hända om två små bolusar ges inom två minuter. Vänligen kontrollera pumpens historik och Careportal och lägg till om det saknas. Se till att inte lägga till två bolusar med samma mängd och samma tid.
+ Avböjer hög tempbasal eftersom kalkylen inte innefattade nyligen ändrad historik
+ Uppdaterar pumpsstatus
+ Basalen på pumpen är ändrad och kommer att uppdateras inom kort
+ Basalen ändrad i pumpen, men det gick inte att läsa till vad
+ Letar efter förändringar i historiken
+ Flera bolusar med samma mängd insulin importerades just. Endast en kan läggas till i Careportal. Vänligen kontrollera pumpen och gör ändringar i Careportal manuellt vid behov. Observera att man bara kan ha en bolus per klockslag.
+ Den senaste bolusen är äldre än 24 timmar eller i framtiden. Vänligen konttrollera tid och datum i pumpen.
+ Tid/datum för bolusen verkar fel. IOB är troligen missvisande. Vänligen kontrollera tid och datum i pumpen.
+ Profilbyte saknas. Vänligen gör ett profilbyte eller tryck Aktivera profil under Lokal Profil.
+ Antal bolus
+ Antal temp basal
+ Mål %d inte startat
+ Mål %d inte nått
+ Pumpen är inte kapabel till temp basal
+ Ingen giltig data om temp basaler fanns i pumpen
+ Closed Loop inaktiverat i Inställningar
+ Autosens inaktiverat i Inställningar
+ SMB inaktiverat i Inställningar
+ Begränsar max basal till %.2f E/h pga %s
+ pumpbegränsning
+ det måste vara ett positivt värde
+ multiplikator för max basal
+ multiplikator för daglig max basal
+ En bolus gavs för mindre än 3 min sedan. Hoppar över SMB
+ Basal justerad korrekt
+ Begränsar max procent hastighet till %d%% pga %s
+ Begränsar bolus till %.1f enheter pga %s
+ Begränsar max IOB till %.1f pga %s
+ Begränsar kolhydrater till %d g pga %s
+ Begränsar IOB till %.1f pga %s
+ maxvärde i Inställningar
+ hård begränsning
+ osäker användning
+ Statuskontroll misslyckad
+ Logga byte av kanyl
+ Logga byte a insulinreservoar
+ SMB Alltid På och SMB Efter Kolhydrater är inaktiverat pga att den aktiva BG-källan inte stöder avancerad filtrering
+ SMB inte tillåtet i Open Loop
+ Mat
+ Återställ
+ Väntar på tidssynkronisering (%d sek)
+ Frånkopplad (%d min)
+ Automatisk loggning i Careportal
+ Ladda upp insulin-, kanyl- och batteribyten samt pumplarm till Nightscout
+ Max IOB som OpenAPS inte kan överstiga [E]
+ Det här värdet kallas Max IOB av OpenAPS. Om denna mängd insulin on board (IOB) nås, kan inte OpenAPS lägga till mer.
+ Pump stoppad
+ Pump startad
+ Pump pausad
+ Max absorptionstid för kolhydrater [tim]
+ Efter denna tid anses alla kolhydrater vara absorberade. Om det fortfarande finns COB, kommer dessa att tas bort ur beräkningen.
+ Tid
+ Visa noteringsrutan i behandlingsdialogerna
+ Angivet: %.2f enheter. Levererat: %.2f enheter. Felkod: %d
+ Första snabbknabben för insulin
+ Andra snabbknabben för insulin
+ Tredje snabbknabben för insulin
+ Första snabbknabben för kolhydrater
+ Andra snabbknabben för kolhydrater
+ Tredje snabbknabben för kolhydrater
+ Använd endast WiFi
+ Anslutningsinställningar
+ Tillåtna SSID (separerade med semikolon)
+ Tillåt anslutning vid Roaming
+ Multiplikator för max daglig basal (max_daily)
+ Multiplikator för nuvarande basal (max_current)
+ -
+ Free-Peak Oref (ny beräkningsmodell)
+ Hypo
+ Hypo längd [min]
+ Mål vid Hypo
+ Insulinresistent vuxen
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index e5b645dcc6..954184de6a 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -6,7 +6,7 @@
#FFFFCC03
#FFFB8C00
#ffea00
- #ff9500
+ #00ffff
#FFFFFF
#FFFFFF00
#FFFF00FF
@@ -52,7 +52,7 @@
#ca77dd
#de7550
- #1b5e20
+ #25912e
#47c8ff
#FFDD7792
@@ -64,4 +64,9 @@
#ff827c
#009705
+ #c8666666
+ #7200FF00
+ #72FF0000
+ #72000000
+
diff --git a/app/src/main/res/values/insight_alerts.xml b/app/src/main/res/values/insight_alerts.xml
index d78c448898..606868528e 100644
--- a/app/src/main/res/values/insight_alerts.xml
+++ b/app/src/main/res/values/insight_alerts.xml
@@ -4,8 +4,8 @@
Warning W32: Battery low
Warning W33: Invalid time/date
Warning W34: End of warranty
- Warning W36: TBR cancelled
- Warning W38: Bolus canelled
+ Warning W36: TBR canceled
+ Warning W38: Bolus canceled
Warning W39: Loantime warning
Maintenance M20: Cartridge not inserted
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 43d9346b50..8d9d9e8987 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -710,7 +710,7 @@
Getting extended bolus status
Getting bolus status
Getting temporary basal status
- Gettings pump settings
+ Getting pump settings
Getting pump time
reuse
Controls from Watch
@@ -926,7 +926,7 @@
Category
Subcategory
Bolus will be recorded only
- Autobackfill missig BGs from NS
+ Autobackfill missig BGs from NS
ns_autobackfill
SMB set by pump
Sensitivity
@@ -982,7 +982,7 @@
Limiting IOB to %.1f U because of %s
max value in preferences
hard limit
- treatmentssafety_maxcarbs
+ treatmentssafety_maxcarbs
unsafe usage
openapsama_useautosens
Read status failed
@@ -1006,7 +1006,7 @@
Meal max absorption time [h]
Time at which any meal is considered absorbed. Remaining carbs will be cut off.
Time
- show_notes_entry_dialogs
+ show_notes_entry_dialogs
Show notes field in treatment dialogs
openapsama_min_5m_carbimpact
Asked: %.2fU Delivered: %.2fU Error code: %d
@@ -1020,8 +1020,10 @@
ns_wifionly
ns_wifi_ssids
ns_allowroaming
+ ns_chargingonly
Use WiFi connection only
WiFi SSID
+ Only if charging
Connection settings
Allowed SSIDs (semicolon separated)
Allow connection in roaming
@@ -1034,6 +1036,16 @@
n/a
Virtual Pump Type
Pump Definition
- Bolus: Step=%s\nExtended Bolus: [Step=%s, Duration=%smin-%sh]\nBasal: Step=%s\nTBR: %s (by %s), Duration=%smin-%sh\nEXTENDED_NOTE
+ Bolus: Step=%s\nExtended Bolus: [Step=%s, Duration=%smin-%sh]\nBasal: Step=%s\nTBR: %s (by %s), Duration=%smin-%sh\nEXTENDED_NOTE
* Ranged basal/bolus values are not supported by Virtual Pump.
+ Autobackfill BG
+ Wizard Settings
+ wearwizard_bg
+ wearwizard_trend
+ wearwizard_cob
+ wearwizard_bolusiob
+ wearwizard_basaliob
+ Calculations included in the Wizard result:
+ Display Settings
+ General Settings
diff --git a/app/src/main/res/xml/pref_nsclientinternal.xml b/app/src/main/res/xml/pref_nsclientinternal.xml
index 3a7dc91d4b..2241463e1a 100644
--- a/app/src/main/res/xml/pref_nsclientinternal.xml
+++ b/app/src/main/res/xml/pref_nsclientinternal.xml
@@ -105,6 +105,11 @@
android:key="@string/key_ns_allowroaming"
android:title="@string/ns_allowroaming" />
+
+
@@ -112,7 +117,8 @@
+ android:title="@string/ns_autobackfill_title"
+ android:summary="@string/ns_autobackfill_summary" />
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/test/java/info/nightscout/MainAppTest.java b/app/src/test/java/info/nightscout/MainAppTest.java
index 7aa50158f2..7bb58797be 100644
--- a/app/src/test/java/info/nightscout/MainAppTest.java
+++ b/app/src/test/java/info/nightscout/MainAppTest.java
@@ -76,7 +76,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only
else
- expected = 6;
+ expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsList(PluginType.PUMP).size());
}
@@ -87,7 +87,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only
else
- expected = 6;
+ expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInList(PluginType.PUMP).size());
}
@@ -98,7 +98,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only
else
- expected = 6;
+ expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsListByInterface(PumpInterface.class).size());
}
@@ -109,7 +109,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only
else
- expected = 6;
+ expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInListByInterface(PumpInterface.class, PluginType.PUMP).size());
}
diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragmentTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragmentTest.java
index a4119e97e3..ca47477905 100644
--- a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragmentTest.java
+++ b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragmentTest.java
@@ -35,25 +35,10 @@ public class ObjectivesFragmentTest {
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
// started
- // time calculation is false, requirements met is false
+ // time calculation is true, requirements met is true
objectiveStartedTime = 10;
durationInDays = 0;
requirementsMet = true;
- assertEquals(2, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
- objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
-
- // started
- // time calculation is false, requirements met is true
- objectiveStartedTime = 10;
- durationInDays = 999999;
- requirementsMet = true;
- assertEquals(2, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
- objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
-
- // started, after duration, requirements met --> show verify
- objectiveStartedTime = Long.MAX_VALUE;
- durationInDays = 0;
- requirementsMet = true;
assertEquals(3, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/NSClientInternal/NsClientReceiverDelegateTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/NSClientInternal/NsClientReceiverDelegateTest.java
new file mode 100644
index 0000000000..70e8d2c9b7
--- /dev/null
+++ b/app/src/test/java/info/nightscout/androidaps/plugins/NSClientInternal/NsClientReceiverDelegateTest.java
@@ -0,0 +1,123 @@
+package info.nightscout.androidaps.plugins.NSClientInternal;
+
+import android.content.Context;
+import com.squareup.otto.Bus;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import info.AAPSMocker;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.events.EventChargingState;
+import info.nightscout.androidaps.events.EventNetworkChange;
+import info.nightscout.utils.SP;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({MainApp.class, SP.class, Context.class})
+public class NsClientReceiverDelegateTest {
+
+ private NsClientReceiverDelegate sut;
+
+ @Before
+ public void prepare() {
+ AAPSMocker.mockMainApp();
+ AAPSMocker.mockApplicationContext();
+
+ Bus bus = MainApp.bus();
+ Context context = MainApp.instance().getApplicationContext();
+
+ sut = new NsClientReceiverDelegate(context, bus);
+ }
+
+ @Test
+ public void testCalculateStatusChargingState() {
+ PowerMockito.mockStatic(SP.class);
+ when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false);
+ EventChargingState ev = new EventChargingState(true);
+ assertTrue(sut.calculateStatus(ev));
+ ev = new EventChargingState(false);
+ assertTrue(sut.calculateStatus(ev));
+
+ when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(true);
+ ev = new EventChargingState(true);
+ assertTrue(sut.calculateStatus(ev));
+ ev = new EventChargingState(false);
+ assertTrue(!sut.calculateStatus(ev));
+ }
+
+ @Test
+ public void testCalculateStatusNetworkState() {
+ PowerMockito.mockStatic(SP.class);
+ // wifiOnly = false
+ // allowRoaming = false as well
+ when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false);
+ when(SP.getString(anyInt(), anyString())).thenReturn("");
+ EventNetworkChange ev = new EventNetworkChange();
+ ev.ssid = "";
+
+ ev.mobileConnected = true;
+ ev.wifiConnected = true;
+ assertTrue(sut.calculateStatus(ev));
+ ev.wifiConnected = false;
+ assertTrue(sut.calculateStatus(ev));
+
+ // wifiOnly = true
+ // allowRoaming = true as well
+ when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(true);
+ ev.wifiConnected = true;
+ assertTrue(sut.calculateStatus(ev));
+ ev.wifiConnected = false;
+ assertTrue(!sut.calculateStatus(ev));
+
+ // wifiOnly = false
+ // allowRoaming = false as well
+ when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false);
+ ev.wifiConnected = false;
+ ev.roaming = true;
+ assertTrue(!sut.calculateStatus(ev));
+
+ // wifiOnly = false
+ // allowRoaming = true
+ when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(false);
+ when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(true);
+ ev.wifiConnected = false;
+ ev.roaming = true;
+ assertTrue(sut.calculateStatus(ev));
+
+ // wifiOnly = true
+ // allowRoaming = true
+ when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(true);
+ when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(true);
+ ev.wifiConnected = false;
+ ev.roaming = true;
+ assertTrue(!sut.calculateStatus(ev));
+
+ // wifiOnly = true
+ // allowRoaming = true
+ when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(true);
+ when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(true);
+ ev.wifiConnected = true;
+ ev.roaming = true;
+ assertTrue(sut.calculateStatus(ev));
+
+ // wifiOnly = false
+ // allowRoaming = false
+ when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(false);
+ when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(false);
+ ev.wifiConnected = true;
+ ev.roaming = true;
+ assertTrue(sut.calculateStatus(ev));
+ }
+}
diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml
index 32cf7a5d1d..01423985d0 100644
--- a/wear/src/main/AndroidManifest.xml
+++ b/wear/src/main/AndroidManifest.xml
@@ -208,6 +208,10 @@
android:name=".interaction.actions.FillActivity"
android:label="Fill">
+
+
diff --git a/wear/src/main/java/info/nightscout/androidaps/data/BgWatchData.java b/wear/src/main/java/info/nightscout/androidaps/data/BgWatchData.java
index 8f20d77282..4f258ee074 100644
--- a/wear/src/main/java/info/nightscout/androidaps/data/BgWatchData.java
+++ b/wear/src/main/java/info/nightscout/androidaps/data/BgWatchData.java
@@ -1,5 +1,7 @@
package info.nightscout.androidaps.data;
+import java.util.Objects;
+
/**
* Created by emmablack on 1/7/15.
*/
@@ -8,12 +10,14 @@ public class BgWatchData implements Comparable{
public double high;
public double low;
public long timestamp;
+ public int color;
- public BgWatchData(double aSgv, double aHigh, double aLow, long aTimestamp) {
+ public BgWatchData(double aSgv, double aHigh, double aLow, long aTimestamp, int aColor) {
this.sgv = aSgv;
this.high = aHigh;
this.low = aLow;
this.timestamp = aTimestamp;
+ this.color = aColor;
}
public BgWatchData(){
@@ -25,12 +29,14 @@ public class BgWatchData implements Comparable{
if(! (that instanceof BgWatchData)){
return false;
}
+ if (this.color != ((BgWatchData) that).color)
+ return false;
return this.timestamp == ((BgWatchData) that).timestamp;
}
@Override
- public int hashCode(){
- return (int) (timestamp%Integer.MAX_VALUE);
+ public int hashCode() {
+ return Objects.hash(timestamp, color);
}
@Override
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java
new file mode 100644
index 0000000000..a598a39c2c
--- /dev/null
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java
@@ -0,0 +1,134 @@
+package info.nightscout.androidaps.interaction.actions;
+
+
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.support.wearable.view.DotsPageIndicator;
+import android.support.wearable.view.GridPagerAdapter;
+import android.support.wearable.view.GridViewPager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import java.text.DecimalFormat;
+
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.data.ListenerService;
+import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
+import info.nightscout.androidaps.interaction.utils.SafeParse;
+
+/**
+ * Created by adrian on 04/08/18.
+ */
+
+
+public class ECarbActivity extends ViewSelectorActivity {
+
+ PlusMinusEditText editCarbs;
+ PlusMinusEditText editStartTime;
+ PlusMinusEditText editDuration;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.grid_layout);
+ final Resources res = getResources();
+ final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
+
+ pager.setAdapter(new MyGridViewPagerAdapter());
+ DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
+ dotsPageIndicator.setPager(pager);
+ }
+
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ finish();
+ }
+
+
+ private class MyGridViewPagerAdapter extends GridPagerAdapter {
+ @Override
+ public int getColumnCount(int arg0) {
+ return 4;
+ }
+
+ @Override
+ public int getRowCount() {
+ return 1;
+ }
+
+ @Override
+ public Object instantiateItem(ViewGroup container, int row, int col) {
+
+ if(col == 0){
+ final View view = getInflatedPlusMinusView(container);
+ double def = 0;
+ if (editCarbs != null){
+ def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
+ }
+ editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), true);
+ setLabelToPlusMinusView(view, "carbs");
+ container.addView(view);
+ return view;
+ } else if(col == 1){
+ final View view = getInflatedPlusMinusView(container);
+ double def = 0;
+ if (editStartTime != null){
+ def = SafeParse.stringToDouble(editStartTime.editText.getText().toString());
+ }
+ editStartTime = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 300d, 15d, new DecimalFormat("0"), false);
+ setLabelToPlusMinusView(view, "start [min]");
+ container.addView(view);
+ return view;
+ } else if(col == 2){
+ final View view = getInflatedPlusMinusView(container);
+ double def = 0;
+ if (editDuration != null){
+ def = SafeParse.stringToDouble(editDuration.editText.getText().toString());
+ }
+ editDuration = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 8d, 1d, new DecimalFormat("0"), false);
+ setLabelToPlusMinusView(view, "duration [h]");
+ container.addView(view);
+ return view;
+ } else {
+
+ final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
+ final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton);
+ confirmbutton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ //check if it can happen that the fagment is never created that hold data?
+ // (you have to swipe past them anyways - but still)
+
+ String actionstring = "ecarbs " +SafeParse.stringToInt(editCarbs.editText.getText().toString())
+ + " " + SafeParse.stringToInt(editStartTime.editText.getText().toString())
+ + " " + SafeParse.stringToInt(editDuration.editText.getText().toString());
+ ListenerService.initiateAction(ECarbActivity.this, actionstring);
+ finish();
+ }
+ });
+ container.addView(view);
+ return view;
+ }
+ }
+
+ @Override
+ public void destroyItem(ViewGroup container, int row, int col, Object view) {
+ // Handle this to get the data before the view is destroyed?
+ // Object should still be kept by this, just setup for reinit?
+ container.removeView((View)view);
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object object) {
+ return view==object;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
index 7701b17d25..5c16063bb2 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
@@ -32,9 +32,6 @@ public class WizardActivity extends ViewSelectorActivity {
PlusMinusEditText editCarbs;
PlusMinusEditText editPercentage;
- boolean useBG;
- boolean includeBolusIOB;
- boolean includeBasalIOB;
boolean hasPercentage;
@@ -63,7 +60,7 @@ public class WizardActivity extends ViewSelectorActivity {
private class MyGridViewPagerAdapter extends GridPagerAdapter {
@Override
public int getColumnCount(int arg0) {
- return hasPercentage?6:5;
+ return hasPercentage?3:2;
}
@Override
@@ -86,79 +83,7 @@ public class WizardActivity extends ViewSelectorActivity {
setLabelToPlusMinusView(view, "carbs");
container.addView(view);
return view;
- } else if(col == 1){
- final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
- final TextView textView = (TextView) view.findViewById(R.id.label);
- textView.setText("include BG?");
-
- final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
- if(useBG){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- togglebutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- useBG = !useBG;
- if(useBG){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- }
- });
- container.addView(view);
- return view;
- } else if(col == 2){
- final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
- final TextView textView = (TextView) view.findViewById(R.id.label);
- textView.setText("Bolus IOB?");
-
- final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
- if(includeBolusIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- togglebutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- includeBolusIOB = !includeBolusIOB;
- if(includeBolusIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- }
- });
- container.addView(view);
- return view;
- } else if(col == 3){
- final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
- final TextView textView = (TextView) view.findViewById(R.id.label);
- textView.setText("Basal IOB?");
-
- final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
- if(includeBasalIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- togglebutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- includeBasalIOB = !includeBasalIOB;
- if(includeBasalIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- }
- });
- container.addView(view);
- return view;
- } else if(col == 4 && hasPercentage){
+ } else if(col == 1 && hasPercentage){
final View view = getInflatedPlusMinusView(container);
if (editPercentage == null) {
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 50d, 150d, 1d, new DecimalFormat("0"), false);
@@ -184,10 +109,7 @@ public class WizardActivity extends ViewSelectorActivity {
if (editPercentage != null) percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
- String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
- + " " + useBG
- + " " + includeBolusIOB
- + " " + includeBasalIOB
+ String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
+ " " + percentage;
ListenerService.initiateAction(WizardActivity.this, actionstring);
finish();
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java
index 34dce7dd11..fb8bb61e20 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java
@@ -7,10 +7,10 @@ import android.preference.PreferenceManager;
import java.util.Vector;
-import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.AAPSPreferences;
import info.nightscout.androidaps.interaction.actions.BolusActivity;
+import info.nightscout.androidaps.interaction.actions.ECarbActivity;
import info.nightscout.androidaps.interaction.actions.TempTargetActivity;
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
import info.nightscout.androidaps.interaction.actions.WizardActivity;
@@ -46,8 +46,9 @@ public class MainMenuActivity extends MenuListActivity {
Vector menuitems = new Vector();
menuitems.add("TempT");
- menuitems.add("Bolus");
if(showWizard) menuitems.add("Wizard");
+ menuitems.add("eCarb");
+ menuitems.add("Bolus");
menuitems.add("Settings");
menuitems.add("Status");
if (showPrimeFill) menuitems.add("Prime/Fill");
@@ -86,6 +87,10 @@ public class MainMenuActivity extends MenuListActivity {
intent = new Intent(this, FillMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
- }
+ } else if ("eCarb".equals(action)) {
+ intent = new Intent(this, ECarbActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ this.startActivity(intent);
+ }
}
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java
index ce8c931078..b61bdc866b 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java
@@ -428,6 +428,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
BgWatchData bwd = new BgWatchData();
bwd.timestamp = prediction.getLong("timestamp");
bwd.sgv = prediction.getDouble("sgv");
+ bwd.color = prediction.getInt("color");
predictionList.add(bwd);
}
}
@@ -649,13 +650,15 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
double high = entry.getDouble("high");
double low = entry.getDouble("low");
long timestamp = entry.getLong("timestamp");
- bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
+ int color = entry.getInt("color", 0);
+ bgDataList.add(new BgWatchData(sgv, high, low, timestamp, color));
}
} else {
double sgv = dataMap.getDouble("sgvDouble");
double high = dataMap.getDouble("high");
double low = dataMap.getDouble("low");
long timestamp = dataMap.getLong("timestamp");
+ int color = dataMap.getInt("color", 0);
final int size = bgDataList.size();
if (size > 0) {
@@ -663,7 +666,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
return; // Ignore duplicates.
}
- bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
+ bgDataList.add(new BgWatchData(sgv, high, low, timestamp, color));
}
for (int i = 0; i < bgDataList.size(); i++) {
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java
index 3c980a713f..47ea3dbf08 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java
@@ -604,13 +604,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
double high = entry.getDouble("high");
double low = entry.getDouble("low");
long timestamp = entry.getLong("timestamp");
- bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
+ int color = entry.getInt("color", 0);
+ bgDataList.add(new BgWatchData(sgv, high, low, timestamp, color));
}
} else {
double sgv = dataMap.getDouble("sgvDouble");
double high = dataMap.getDouble("high");
double low = dataMap.getDouble("low");
long timestamp = dataMap.getLong("timestamp");
+ int color = dataMap.getInt("color", 0);
final int size = bgDataList.size();
if (size > 0) {
@@ -618,7 +620,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
return; // Ignore duplicates.
}
- bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
+ bgDataList.add(new BgWatchData(sgv, high, low, timestamp, color));
}
for (int i = 0; i < bgDataList.size(); i++) {
@@ -689,6 +691,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
BgWatchData bwd = new BgWatchData();
bwd.timestamp = prediction.getLong("timestamp");
bwd.sgv = prediction.getDouble("sgv");
+ bwd.color = prediction.getInt("color");
predictionList.add(bwd);
}
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java
index 7d50d7ff4c..4a401489d9 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java
@@ -10,7 +10,9 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.TimeZone;
import info.nightscout.androidaps.data.BasalWatchData;
@@ -173,13 +175,12 @@ public class BgGraphBuilder {
}
}
+ addPredictionLines(lines);
lines.add(basalLine((float) minChart, factor, highlight));
lines.add(bolusLine((float) minChart));
lines.add(bolusInvalidLine((float) minChart));
lines.add(carbsLine((float) minChart));
lines.add(smbLine((float) minChart));
- lines.add(predictionLine());
-
return lines;
}
@@ -275,29 +276,30 @@ public class BgGraphBuilder {
}
- private Line predictionLine() {
-
- List pointValues = new ArrayList();
-
+ private void addPredictionLines(List lines) {
+ Map> values = new HashMap<>();
long endTime = getPredictionEndTime();
- for (BgWatchData bwd: predictionsList) {
- if(bwd.timestamp <= endTime) {
- pointValues.add(new PointValue(fuzz(bwd.timestamp), (float) bwd.sgv));
+ for (BgWatchData bwd : predictionsList) {
+ if (bwd.timestamp <= endTime) {
+ double value = bwd.sgv < 300 ? bwd.sgv : 300;
+ if (!values.containsKey(bwd.color)) {
+ values.put(bwd.color, new ArrayList<>());
+ }
+ values.get(bwd.color).add(new PointValue(fuzz(bwd.timestamp), (float) value));
}
}
- Line line = new Line(pointValues);
- line.setColor(Color.MAGENTA);
- line.setHasLines(false);
- int size = pointSize/2;
- size = (size>0)?size:1;
- line.setPointRadius(size);
- line.setHasPoints(true);
- return line;
+ for (Map.Entry> entry : values.entrySet()) {
+ Line line = new Line(entry.getValue());
+ line.setColor(entry.getKey());
+ line.setHasLines(false);
+ int size = pointSize / 2;
+ size = (size > 0) ? size : 1;
+ line.setPointRadius(size);
+ line.setHasPoints(true);
+ lines.add(line);
+ }
}
-
-
-
public Line highValuesLine() {
Line highValuesLine = new Line(highValues);
highValuesLine.setColor(highColor);
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.java
index 3c479f3f86..4b6922fb90 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.java
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.java
@@ -573,7 +573,8 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
double high = dataMap.getDouble("high");
double low = dataMap.getDouble("low");
long timestamp = dataMap.getLong("timestamp");
- bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
+ int color = dataMap.getInt("color", 0);
+ bgDataList.add(new BgWatchData(sgv, high, low, timestamp, color));
} else if (!sharedPrefs.getBoolean("animation", false)) {
// don't load history at once if animations are set (less resource consumption)
Log.d("addToWatchSet", "entries.size(): " + entries.size());
@@ -583,7 +584,8 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
double high = entry.getDouble("high");
double low = entry.getDouble("low");
long timestamp = entry.getLong("timestamp");
- bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
+ int color = entry.getInt("color", 0);
+ bgDataList.add(new BgWatchData(sgv, high, low, timestamp, color));
}
} else