Merge branch 'master' of https://github.com/MilosKozak/AndroidAPS
This commit is contained in:
commit
ced974e96d
20 changed files with 171 additions and 78 deletions
|
@ -89,7 +89,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
if (Config.DANAR) {
|
||||
addPreferencesFromResource(R.xml.pref_danar);
|
||||
DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
if (danaRPlugin.isEnabled(PluginBase.PROFILE)) {
|
||||
if (danaRPlugin.isEnabled(PluginBase.PUMP)) {
|
||||
addPreferencesFromResource(R.xml.pref_danarprofile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -70,8 +71,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
|
||||
static Date lastDeviceStatusUpload = new Date(0);
|
||||
|
||||
PowerManager.WakeLock mWakeLock;
|
||||
|
||||
public ConfigBuilderPlugin() {
|
||||
MainApp.bus().register(this);
|
||||
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "ConfigBuilderPlugin");;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -334,13 +339,27 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
|
||||
public PumpEnactResult deliverTreatmentFromBolusWizard(Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
|
||||
mWakeLock.acquire();
|
||||
insulin = applyBolusConstraints(insulin);
|
||||
carbs = applyCarbsConstraints(carbs);
|
||||
|
||||
PumpEnactResult result = deliverTreatment(insulin, carbs, context);
|
||||
BolusProgressDialog bolusProgressDialog = null;
|
||||
if (context != null) {
|
||||
bolusProgressDialog = new BolusProgressDialog(insulin);
|
||||
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
|
||||
}
|
||||
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("deliverTreatmentFromBolusWizard insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
|
||||
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context);
|
||||
|
||||
bolusProgressDialog.bolusEnded = true;
|
||||
|
||||
if (bolusProgressDialog != null && bolusProgressDialog.running) {
|
||||
try {
|
||||
bolusProgressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); // TODO: handle this better
|
||||
}
|
||||
}
|
||||
|
||||
if (result.success) {
|
||||
Treatment t = new Treatment();
|
||||
|
@ -356,11 +375,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
|
||||
MainApp.bus().post(new EventTreatmentChange());
|
||||
}
|
||||
mWakeLock.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context) {
|
||||
mWakeLock.acquire();
|
||||
insulin = applyBolusConstraints(insulin);
|
||||
carbs = applyCarbsConstraints(carbs);
|
||||
|
||||
|
@ -372,8 +393,14 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
|
||||
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context);
|
||||
|
||||
if (bolusProgressDialog != null) {
|
||||
bolusProgressDialog.bolusEnded = true;
|
||||
|
||||
if (bolusProgressDialog != null && bolusProgressDialog.running) {
|
||||
try {
|
||||
bolusProgressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); // TODO: handle this better
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.logCongigBuilderActions)
|
||||
|
@ -393,6 +420,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
t.sendToNSClient();
|
||||
MainApp.bus().post(new EventTreatmentChange());
|
||||
}
|
||||
mWakeLock.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
if (type == PluginBase.PROFILE) return fragmentProfileEnabled;
|
||||
if (type == PluginBase.PROFILE) return fragmentProfileEnabled && fragmentPumpEnabled;
|
||||
else if (type == PluginBase.PUMP) return fragmentPumpEnabled;
|
||||
else if (type == PluginBase.CONSTRAINTS) return fragmentPumpEnabled;
|
||||
return false;
|
||||
|
@ -240,7 +240,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
if (insulin > 0 || carbs > 0) {
|
||||
Treatment t = new Treatment();
|
||||
boolean connectionOK = false;
|
||||
if (insulin > 0) connectionOK = sExecutionService.bolus(insulin, carbs, t);
|
||||
if (insulin > 0 || carbs > 0) connectionOK = sExecutionService.bolus(insulin, carbs, t);
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = connectionOK;
|
||||
result.bolusDelivered = t.insulin;
|
||||
|
@ -576,6 +576,9 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
@Override
|
||||
public JSONObject getJSONStatus() {
|
||||
if (getDanaRPump().lastConnection.getTime() + 5 * 60 * 1000L < new Date().getTime()) {
|
||||
return null;
|
||||
}
|
||||
JSONObject pump = new JSONObject();
|
||||
JSONObject battery = new JSONObject();
|
||||
JSONObject status = new JSONObject();
|
||||
|
@ -583,7 +586,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
try {
|
||||
battery.put("percent", getDanaRPump().batteryRemaining);
|
||||
status.put("status", "normal");
|
||||
status.put("timestamp", DateUtil.toISOString(new Date()));
|
||||
status.put("timestamp", DateUtil.toISOString(getDanaRPump().lastConnection));
|
||||
if (isTempBasalInProgress()) {
|
||||
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalStart", DateUtil.toISOString(getTempBasal().timeStart));
|
||||
|
|
|
@ -149,6 +149,8 @@ public class DanaRPump {
|
|||
store.put("" + (activeProfile + 1), profile);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return new NSProfile(json, "" + (activeProfile + 1));
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class ExecutionService extends Service {
|
|||
}
|
||||
|
||||
public void connect(String from) {
|
||||
if (danaRPump.isNewPump && danaRPump.password != SafeParse.stringToInt(SP.getString("danar_password", "-1"))) {
|
||||
if (danaRPump.password != -1 && danaRPump.password != SafeParse.stringToInt(SP.getString("danar_password", "-1"))) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
|
||||
return;
|
||||
}
|
||||
|
@ -382,6 +382,7 @@ public class ExecutionService extends Service {
|
|||
while (!stop.stopped && !start.failed) {
|
||||
waitMsec(100);
|
||||
}
|
||||
waitMsec(300);
|
||||
bolusingTreatment = null;
|
||||
getPumpStatus();
|
||||
return true;
|
||||
|
|
|
@ -29,7 +29,6 @@ public class MsgInitConnStatusOption extends MessageBase {
|
|||
int i = intFromBuff(bytes, 8, 1);
|
||||
if (bytes.length >= 21) {
|
||||
DanaRPlugin.getDanaRPump().password = intFromBuff(bytes, 9, 2) ^ 0x3463;
|
||||
DanaRPlugin.getDanaRPump().isNewPump = true;
|
||||
if (Config.logDanaMessageDetail)
|
||||
log.debug("Pump password: " + DanaRPlugin.getDanaRPump().password);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.DanaR.comm;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||
|
||||
|
@ -20,6 +22,9 @@ public class MsgSettingShippingInfo extends MessageBase {
|
|||
DanaRPlugin.getDanaRPump().serialNumber = stringFromBuff(bytes, 0, 10);
|
||||
DanaRPlugin.getDanaRPump().shippingDate = dateFromBuff(bytes, 10);
|
||||
DanaRPlugin.getDanaRPump().shippingCountry = asciiStringFromBuff(bytes, 13, 3);
|
||||
if (DanaRPlugin.getDanaRPump().shippingDate.getTime() > new Date(116, 4, 1).getTime()) {
|
||||
DanaRPlugin.getDanaRPump().isNewPump = true;
|
||||
}
|
||||
if (Config.logDanaMessageDetail) {
|
||||
log.debug("Serial number: " + DanaRPlugin.getDanaRPump().serialNumber);
|
||||
log.debug("Shipping date: " + DanaRPlugin.getDanaRPump().shippingDate);
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.squareup.otto.Subscribe;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||
import info.nightscout.androidaps.plugins.NSProfileViewer.events.EventNSProfileViewerUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.NSProfileViewer.events.EventNSProfileViewerUpdateGUI;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
public class NSProfileViewerFragment extends Fragment implements FragmentBase {
|
||||
|
@ -63,7 +63,7 @@ public class NSProfileViewerFragment extends Fragment implements FragmentBase {
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNSProfileViewerUpdateGui ev) {
|
||||
public void onStatusEvent(final EventNSProfileViewerUpdateGUI ev) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.Services.Intents;
|
|||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.plugins.NSProfileViewer.events.EventNSProfileViewerUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.NSProfileViewer.events.EventNSProfileViewerUpdateGUI;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ public class NSProfileViewerPlugin implements PluginBase, ProfileInterface {
|
|||
public void onStatusEvent(final EventNewBasalProfile ev) {
|
||||
profile = new NSProfile(ev.newNSProfile.getData(), ev.newNSProfile.getActiveProfile());
|
||||
storeNSProfile();
|
||||
MainApp.bus().post(new EventNSProfileViewerUpdateGui());
|
||||
MainApp.bus().post(new EventNSProfileViewerUpdateGUI());
|
||||
}
|
||||
|
||||
private void storeNSProfile() {
|
||||
|
|
|
@ -3,5 +3,5 @@ package info.nightscout.androidaps.plugins.NSProfileViewer.events;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventNSProfileViewerUpdateGui {
|
||||
public class EventNSProfileViewerUpdateGUI {
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Layout;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -37,6 +38,8 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
|
|||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
CheckBox enableFake;
|
||||
LinearLayout fake_layout;
|
||||
TextView reset;
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -82,7 +85,7 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
|
|||
ObjectivesPlugin.Objective o = (ObjectivesPlugin.Objective) v.getTag();
|
||||
o.started = new Date();
|
||||
updateGUI();
|
||||
objectivesPlugin.saveProgress();
|
||||
ObjectivesPlugin.saveProgress();
|
||||
}
|
||||
});
|
||||
holder.verifyButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -91,7 +94,7 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
|
|||
if (objectivesPlugin.requirementsMet(o.num).done || enableFake.isChecked()) {
|
||||
o.accomplished = new Date();
|
||||
updateGUI();
|
||||
objectivesPlugin.saveProgress();
|
||||
ObjectivesPlugin.saveProgress();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -185,11 +188,20 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
|
|||
llm = new LinearLayoutManager(view.getContext());
|
||||
recyclerView.setLayoutManager(llm);
|
||||
enableFake = (CheckBox) view.findViewById(R.id.objectives_fake);
|
||||
fake_layout = (LinearLayout) view.findViewById(R.id.objectives_fake_layout);
|
||||
reset = (TextView) view.findViewById(R.id.objectives_reset);
|
||||
enableFake.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
reset.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
objectivesPlugin.initializeData();
|
||||
objectivesPlugin.saveProgress();
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
|
||||
// Add correct translations to array after app is initialized
|
||||
objectivesPlugin.objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective);
|
||||
|
@ -216,7 +228,7 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(objectivesPlugin.objectives);
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(ObjectivesPlugin.objectives);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
@ -130,78 +131,88 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
}
|
||||
|
||||
|
||||
private void initializeData() {
|
||||
public void initializeData() {
|
||||
objectives = new ArrayList<>();
|
||||
objectives.add(new Objective(0,
|
||||
MainApp.sResources.getString(R.string.objectives_0_objective),
|
||||
MainApp.sResources.getString(R.string.objectives_0_gate),
|
||||
new Date(0, 0, 0),
|
||||
new Date(0),
|
||||
1, // 1 day
|
||||
new Date(0, 0, 0)));
|
||||
new Date(0)));
|
||||
objectives.add(new Objective(1,
|
||||
MainApp.sResources.getString(R.string.objectives_1_objective),
|
||||
MainApp.sResources.getString(R.string.objectives_1_gate),
|
||||
new Date(0, 0, 0),
|
||||
new Date(0),
|
||||
7, // 7 days
|
||||
new Date(0, 0, 0)));
|
||||
new Date(0)));
|
||||
objectives.add(new Objective(2,
|
||||
MainApp.sResources.getString(R.string.objectives_2_objective),
|
||||
MainApp.sResources.getString(R.string.objectives_2_gate),
|
||||
new Date(0, 0, 0),
|
||||
new Date(0),
|
||||
0, // 0 days
|
||||
new Date(0, 0, 0)));
|
||||
new Date(0)));
|
||||
objectives.add(new Objective(3,
|
||||
MainApp.sResources.getString(R.string.objectives_3_objective),
|
||||
MainApp.sResources.getString(R.string.objectives_3_gate),
|
||||
new Date(0, 0, 0),
|
||||
new Date(0),
|
||||
5, // 5 days
|
||||
new Date(0, 0, 0)));
|
||||
new Date(0)));
|
||||
objectives.add(new Objective(4,
|
||||
MainApp.sResources.getString(R.string.objectives_4_objective),
|
||||
MainApp.sResources.getString(R.string.objectives_4_gate),
|
||||
new Date(0, 0, 0),
|
||||
new Date(0),
|
||||
1,
|
||||
new Date(0, 0, 0)));
|
||||
new Date(0)));
|
||||
objectives.add(new Objective(5,
|
||||
MainApp.sResources.getString(R.string.objectives_5_objective),
|
||||
MainApp.sResources.getString(R.string.objectives_5_gate),
|
||||
new Date(0, 0, 0),
|
||||
new Date(0),
|
||||
7,
|
||||
new Date(0, 0, 0)));
|
||||
new Date(0)));
|
||||
objectives.add(new Objective(6,
|
||||
MainApp.sResources.getString(R.string.objectives_6_objective),
|
||||
"",
|
||||
new Date(0, 0, 0),
|
||||
new Date(0),
|
||||
1,
|
||||
new Date(0, 0, 0)));
|
||||
new Date(0)));
|
||||
}
|
||||
|
||||
public static void saveProgress() {
|
||||
if (objectives != null) {
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
for (int num = 0; num < objectives.size(); num++) {
|
||||
Objective o = objectives.get(num);
|
||||
editor.putLong("Objectives" + num + "started", o.started.getTime());
|
||||
editor.putLong("Objectives" + num + "accomplished", o.accomplished.getTime());
|
||||
editor.putString("Objectives" + num + "started", Long.toString(o.started.getTime()));
|
||||
editor.putString("Objectives" + num + "accomplished", Long.toString(o.accomplished.getTime()));
|
||||
}
|
||||
editor.putBoolean("Objectives" + "bgIsAvailableInNS", bgIsAvailableInNS);
|
||||
editor.putBoolean("Objectives" + "pumpStatusIsAvailableInNS", pumpStatusIsAvailableInNS);
|
||||
editor.putInt("Objectives" + "manualEnacts", manualEnacts);
|
||||
editor.putString("Objectives" + "manualEnacts", Integer.toString(manualEnacts));
|
||||
editor.apply();
|
||||
if (Config.logPrefsChange)
|
||||
log.debug("Objectives stored");
|
||||
}
|
||||
}
|
||||
|
||||
void loadProgress() {
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
for (int num = 0; num < objectives.size(); num++) {
|
||||
Objective o = objectives.get(num);
|
||||
o.started = new Date(settings.getLong("Objectives" + num + "started", 0));
|
||||
o.accomplished = new Date(settings.getLong("Objectives" + num + "accomplished", 0));
|
||||
try {
|
||||
o.started = new Date(SafeParse.stringToLong(settings.getString("Objectives" + num + "started", "0")));
|
||||
o.accomplished = new Date(SafeParse.stringToLong(settings.getString("Objectives" + num + "accomplished", "0")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
bgIsAvailableInNS = settings.getBoolean("Objectives" + "bgIsAvailableInNS", false);
|
||||
pumpStatusIsAvailableInNS = settings.getBoolean("Objectives" + "pumpStatusIsAvailableInNS", false);
|
||||
manualEnacts = settings.getInt("Objectives" + "manualEnacts", 0);
|
||||
try {
|
||||
manualEnacts = SafeParse.stringToInt(settings.getString("Objectives" + "manualEnacts", "0"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Config.logPrefsChange)
|
||||
log.debug("Objectives loaded");
|
||||
}
|
||||
|
|
|
@ -30,12 +30,19 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
TextView stopPressedView;
|
||||
ProgressBar progressBar;
|
||||
|
||||
double amount;
|
||||
static double amount;
|
||||
public static boolean bolusEnded = false;
|
||||
public static boolean running = true;
|
||||
|
||||
boolean started = false;
|
||||
|
||||
public BolusProgressDialog() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BolusProgressDialog(double amount) {
|
||||
this.amount = amount;
|
||||
bolusEnded = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,12 +66,15 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
running = true;
|
||||
if (bolusEnded) dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
running = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,13 +38,10 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
Handler mHandler;
|
||||
public static HandlerThread mHandlerThread;
|
||||
|
||||
Context parentContext;
|
||||
|
||||
public NewTreatmentDialog(Context context) {
|
||||
public NewTreatmentDialog() {
|
||||
mHandlerThread = new HandlerThread(NewTreatmentDialog.class.getSimpleName());
|
||||
mHandlerThread.start();
|
||||
this.mHandler = new Handler(mHandlerThread.getLooper());
|
||||
parentContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,7 +88,9 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
||||
final Context context = getContext();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
||||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
|
@ -101,9 +100,9 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints, parentContext);
|
||||
PumpEnactResult result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints, context);
|
||||
if (!result.success) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
builder.setMessage(result.comment);
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||
|
|
|
@ -82,10 +82,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
Context parentContext;
|
||||
|
||||
public WizardDialog(Context context) {
|
||||
mHandlerThread = new HandlerThread(NewExtendedBolusDialog.class.getSimpleName());
|
||||
public WizardDialog() {
|
||||
mHandlerThread = new HandlerThread(WizardDialog.class.getSimpleName());
|
||||
mHandlerThread.start();
|
||||
mHandler = new Handler(mHandlerThread.getLooper());
|
||||
}
|
||||
|
||||
|
||||
public WizardDialog(Context context) {
|
||||
this();
|
||||
parentContext = context;
|
||||
}
|
||||
|
||||
|
@ -120,7 +125,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
ToastUtils.showToastInUiThread(getContext(), MainApp.sResources.getString(R.string.noprofileselected));
|
||||
ToastUtils.showToastInUiThread(parentContext, MainApp.sResources.getString(R.string.noprofileselected));
|
||||
wizardDialogDeliverButton.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
|
@ -192,10 +197,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||
|
||||
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || carbsAfterConstraints != calculatedCarbs) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
||||
builder.setPositiveButton(getContext().getString(R.string.ok), null);
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||
builder.show();
|
||||
return;
|
||||
}
|
||||
|
@ -203,8 +208,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(getContext().getString(R.string.confirmation));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
@ -223,10 +228,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
boluscalcJSON
|
||||
);
|
||||
if (!result.success) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
builder.setMessage(result.comment);
|
||||
builder.setPositiveButton(getContext().getString(R.string.ok), null);
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public class OverviewFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
FragmentManager manager = getFragmentManager();
|
||||
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog(getContext());
|
||||
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
|
||||
treatmentDialogFragment.show(manager, "TreatmentDialog");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,12 +9,30 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/objectives_fake_layout"
|
||||
android:visibility="gone">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Enable fake time and progress"
|
||||
android:id="@+id/objectives_fake" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Reset"
|
||||
android:id="@+id/objectives_reset"
|
||||
android:textColor="#fef900"
|
||||
android:gravity="right"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_marginRight="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/objectives_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -277,7 +277,7 @@
|
|||
<string name="danar_history_syspend">Прекъсване</string>
|
||||
<string name="danar_historyreload">Презареждане</string>
|
||||
<string name="danar_iob_label">IOB на помпата</string>
|
||||
<string name="danar_password">Парола за помпа след 2016г</string>
|
||||
<string name="danar_password">Парола за помпа</string>
|
||||
<string name="danar_refill">пълнене</string>
|
||||
<string name="danar_totaluploaded" formatted="false">Общо %d записа са изпратени</string>
|
||||
<string name="enacted">Приложено</string>
|
||||
|
|
|
@ -278,7 +278,7 @@
|
|||
<string name="pumpbusy">Pumpa je zaneprázdněna</string>
|
||||
<string name="wrongpumppassword">Špatné heslo k pumpě</string>
|
||||
<string name="mm640g">MM 640g</string>
|
||||
<string name="danar_password">Heslo k pumpě (pouze verze 2016)</string>
|
||||
<string name="danar_password">Heslo k pumpě</string>
|
||||
<string name="overview_bolusiprogress_occlusion">Okluze</string>
|
||||
<string name="overview_bolusprogress_delivered">Podáno</string>
|
||||
<string name="overview_bolusprogress_stop">Stop</string>
|
||||
|
|
|
@ -279,7 +279,7 @@
|
|||
<string name="danar_history_refill">Refill</string>
|
||||
<string name="danar_history_syspend">Suspend</string>
|
||||
<string name="danar_history_connectingfor" formatted="false">Connecting for %d s</string>
|
||||
<string name="danar_password">Pump password (2016 pump only)</string>
|
||||
<string name="danar_password">Pump password</string>
|
||||
<string name="wrongpumppassword">Wrong pump password!</string>
|
||||
<string name="pumpbusy">Pump is busy</string>
|
||||
<string name="overview_bolusprogress_delivered">Delivered</string>
|
||||
|
@ -304,6 +304,6 @@
|
|||
<string name="objectives_6_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
|
||||
<string name="youareonallowedlimit">You reached allowed limit</string>
|
||||
<string name="openapsma_target_bg">Target value for calculations</string>
|
||||
<string name="noprofileselected">No profile seselcted</string>
|
||||
<string name="noprofileselected">No profile selected</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue