Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
35decd0e53
7 changed files with 306 additions and 328 deletions
|
@ -111,6 +111,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationRecyclerViewAdapter;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||||
|
@ -460,32 +461,32 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||||
if (activeloop == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
if (activeloop == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
||||||
return;
|
return;
|
||||||
menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
|
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
||||||
if (activeloop.isEnabled(PluginType.LOOP)) {
|
if (activeloop.isEnabled(PluginType.LOOP)) {
|
||||||
menu.add(MainApp.sResources.getString(R.string.disableloop));
|
menu.add(MainApp.gs(R.string.disableloop));
|
||||||
if (!activeloop.isSuspended()) {
|
if (!activeloop.isSuspended()) {
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor1h));
|
menu.add(MainApp.gs(R.string.suspendloopfor1h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
|
menu.add(MainApp.gs(R.string.suspendloopfor2h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
|
menu.add(MainApp.gs(R.string.suspendloopfor3h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
|
menu.add(MainApp.gs(R.string.suspendloopfor10h));
|
||||||
if (pumpDescription.tempDurationStep15mAllowed)
|
if (pumpDescription.tempDurationStep15mAllowed)
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor15m));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
|
||||||
if (pumpDescription.tempDurationStep30mAllowed)
|
if (pumpDescription.tempDurationStep30mAllowed)
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor30m));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor1h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor2h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor3h));
|
||||||
} else {
|
} else {
|
||||||
menu.add(MainApp.sResources.getString(R.string.resume));
|
menu.add(MainApp.gs(R.string.resume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!activeloop.isEnabled(PluginType.LOOP))
|
if (!activeloop.isEnabled(PluginType.LOOP))
|
||||||
menu.add(MainApp.sResources.getString(R.string.enableloop));
|
menu.add(MainApp.gs(R.string.enableloop));
|
||||||
} else if (v == activeProfileView) {
|
} else if (v == activeProfileView) {
|
||||||
menu.setHeaderTitle(MainApp.sResources.getString(R.string.profile));
|
menu.setHeaderTitle(MainApp.gs(R.string.profile));
|
||||||
menu.add(MainApp.sResources.getString(R.string.danar_viewprofile));
|
menu.add(MainApp.gs(R.string.danar_viewprofile));
|
||||||
if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) {
|
if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) {
|
||||||
menu.add(MainApp.sResources.getString(R.string.careportal_profileswitch));
|
menu.add(MainApp.gs(R.string.careportal_profileswitch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,7 +497,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return true;
|
return true;
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
if (item.getTitle().equals(MainApp.sResources.getString(R.string.disableloop))) {
|
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
||||||
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
||||||
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
||||||
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
||||||
|
@ -505,75 +506,75 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
||||||
activeloop.setPluginEnabled(PluginType.LOOP, true);
|
activeloop.setPluginEnabled(PluginType.LOOP, true);
|
||||||
activeloop.setFragmentVisible(PluginType.LOOP, true);
|
activeloop.setFragmentVisible(PluginType.LOOP, true);
|
||||||
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.resume))) {
|
||||||
activeloop.suspendTo(0L);
|
activeloop.suspendTo(0L);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor1h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(60);
|
MainApp.getConfigBuilder().suspendLoop(60);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor2h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(120);
|
MainApp.getConfigBuilder().suspendLoop(120);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor3h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(180);
|
MainApp.getConfigBuilder().suspendLoop(180);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor10h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(600);
|
MainApp.getConfigBuilder().suspendLoop(600);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor15m))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor15m))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(15, profile);
|
MainApp.getConfigBuilder().disconnectPump(15, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor30m))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(30, profile);
|
MainApp.getConfigBuilder().disconnectPump(30, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor1h))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(60, profile);
|
MainApp.getConfigBuilder().disconnectPump(60, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor2h))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(120, profile);
|
MainApp.getConfigBuilder().disconnectPump(120, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor3h))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(180, profile);
|
MainApp.getConfigBuilder().disconnectPump(180, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.careportal_profileswitch))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.careportal_profileswitch))) {
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
|
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
|
||||||
profileswitch.executeProfileSwitch = true;
|
profileswitch.executeProfileSwitch = true;
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.danar_viewprofile))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.danar_viewprofile))) {
|
||||||
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(System.currentTimeMillis());
|
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(System.currentTimeMillis());
|
||||||
FragmentManager manager = getFragmentManager();
|
FragmentManager manager = getFragmentManager();
|
||||||
pvd.show(manager, "ProfileViewDialog");
|
pvd.show(manager, "ProfileViewDialog");
|
||||||
|
@ -753,9 +754,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
|
||||||
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
builder.setPositiveButton(MainApp.gs(R.string.ok), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +766,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
accepted = false;
|
accepted = false;
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||||
builder.setMessage(confirmMessage);
|
builder.setMessage(confirmMessage);
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
@ -789,7 +790,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
i.putExtra("status", result.comment);
|
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);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
MainApp.instance().startActivity(i);
|
MainApp.instance().startActivity(i);
|
||||||
}
|
}
|
||||||
|
@ -810,7 +811,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
i.putExtra("status", result.comment);
|
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);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
MainApp.instance().startActivity(i);
|
MainApp.instance().startActivity(i);
|
||||||
}
|
}
|
||||||
|
@ -841,12 +842,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
sRefreshLoop = new Runnable() {
|
sRefreshLoop = () -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
scheduleUpdateGUI("refreshLoop");
|
scheduleUpdateGUI("refreshLoop");
|
||||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||||
registerForContextMenu(apsModeView);
|
registerForContextMenu(apsModeView);
|
||||||
|
@ -894,23 +892,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
scheduleUpdateGUI("EventExtendedBolusChange");
|
scheduleUpdateGUI("EventExtendedBolusChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handled by EventAutosensCalculationFinished
|
|
||||||
// @Subscribe
|
|
||||||
// public void onStatusEvent(final EventNewBG ev) {
|
|
||||||
// scheduleUpdateGUI("EventNewBG");
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
||||||
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handled by EventAutosensCalculationFinished
|
|
||||||
// @Subscribe
|
|
||||||
// public void onStatusEvent(final EventNewBasalProfile ev) {
|
|
||||||
// scheduleUpdateGUI("EventNewBasalProfile");
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
public void onStatusEvent(final EventTempTargetChange ev) {
|
||||||
scheduleUpdateGUI("EventTempTargetChange");
|
scheduleUpdateGUI("EventTempTargetChange");
|
||||||
|
@ -920,12 +906,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onStatusEvent(final EventPumpStatusChanged s) {
|
public void onStatusEvent(final EventPumpStatusChanged s) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> updatePumpStatus(s.textStatus()));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updatePumpStatus(s.textStatus());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideTempRecommendation() {
|
private void hideTempRecommendation() {
|
||||||
|
@ -962,12 +943,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void run() {
|
public void run() {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updateGUI(from);
|
updateGUI(from);
|
||||||
scheduledUpdate = null;
|
scheduledUpdate = null;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1010,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) +
|
avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) +
|
||||||
" øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units));
|
" øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units));
|
||||||
} else {
|
} else {
|
||||||
deltaView.setText("Δ " + MainApp.sResources.getString(R.string.notavailable));
|
deltaView.setText("Δ " + MainApp.gs(R.string.notavailable));
|
||||||
if (avgdeltaView != null)
|
if (avgdeltaView != null)
|
||||||
avgdeltaView.setText("");
|
avgdeltaView.setText("");
|
||||||
}
|
}
|
||||||
|
@ -1049,25 +1027,29 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
|
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
|
||||||
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
|
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isDisconnected()) {
|
||||||
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), activeloop.minutesToEndOfSuspend()));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
|
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (pump.isSuspended()) {
|
} else if (pump.isSuspended()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.pumpsuspended));
|
apsModeView.setText(MainApp.gs(R.string.pumpsuspended));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
||||||
if (closedLoopEnabled.value()) {
|
if (closedLoopEnabled.value()) {
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
|
apsModeView.setText(MainApp.gs(R.string.closedloop));
|
||||||
} else {
|
} else {
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
|
apsModeView.setText(MainApp.gs(R.string.openloop));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopdisabled));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopdisabled));
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.disabledloop));
|
apsModeView.setText(MainApp.gs(R.string.disabledloop));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1135,11 +1117,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
baseBasalView.setOnClickListener(new View.OnClickListener() {
|
baseBasalView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String fullText = MainApp.sResources.getString(R.string.pump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(profile.getBasal()) + "U/h\n";
|
String fullText = MainApp.gs(R.string.pump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(profile.getBasal()) + "U/h\n";
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
fullText += MainApp.sResources.getString(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
fullText += MainApp.gs(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
||||||
}
|
}
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.basal), fullText, null);
|
OKDialog.show(getActivity(), MainApp.gs(R.string.basal), fullText, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1173,7 +1155,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
extendedBolusView.setOnClickListener(new View.OnClickListener() {
|
extendedBolusView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.extendedbolus), extendedBolus.toString(), null);
|
OKDialog.show(getActivity(), MainApp.gs(R.string.extendedbolus), extendedBolus.toString(), null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1192,9 +1174,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
|
activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
|
||||||
activeProfileView.setBackgroundColor(Color.GRAY);
|
activeProfileView.setBackgroundColor(Color.GRAY);
|
||||||
|
|
||||||
tempTargetView.setOnLongClickListener(new View.OnLongClickListener() {
|
tempTargetView.setOnLongClickListener(view -> {
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View view) {
|
|
||||||
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||||
final OptionsToShow temptarget = CareportalFragment.TEMPTARGET;
|
final OptionsToShow temptarget = CareportalFragment.TEMPTARGET;
|
||||||
|
@ -1202,7 +1182,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||||
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
tempTargetView.setLongClickable(true);
|
tempTargetView.setLongClickable(true);
|
||||||
|
|
||||||
|
@ -1276,14 +1255,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (shorttextmode) {
|
if (shorttextmode) {
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
|
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
|
||||||
iobView.setText(iobtext);
|
iobView.setText(iobtext);
|
||||||
iobView.setOnClickListener(new View.OnClickListener() {
|
iobView.setOnClickListener(v -> {
|
||||||
@Override
|
String iobtext1 = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
|
||||||
public void onClick(View v) {
|
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
|
|
||||||
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
|
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
|
||||||
+ getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
|
+ getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.iob), iobtext, null);
|
OKDialog.show(getActivity(), MainApp.gs(R.string.iob), iobtext1, null);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
|
} else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||||
|
@ -1310,41 +1286,24 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
// pump status from ns
|
// pump status from ns
|
||||||
if (pumpDeviceStatusView != null) {
|
if (pumpDeviceStatusView != null) {
|
||||||
pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
|
pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
|
||||||
pumpDeviceStatusView.setOnClickListener(new View.OnClickListener() {
|
pumpDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus(), null));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus(), null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenAPS status from ns
|
// OpenAPS status from ns
|
||||||
if (openapsDeviceStatusView != null) {
|
if (openapsDeviceStatusView != null) {
|
||||||
openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
|
openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
|
||||||
openapsDeviceStatusView.setOnClickListener(new View.OnClickListener() {
|
openapsDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus(), null));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus(), null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uploader status from ns
|
// Uploader status from ns
|
||||||
if (uploaderDeviceStatusView != null) {
|
if (uploaderDeviceStatusView != null) {
|
||||||
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatus());
|
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatus());
|
||||||
uploaderDeviceStatusView.setOnClickListener(new View.OnClickListener() {
|
uploaderDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****** GRAPH *******
|
// ****** GRAPH *******
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// allign to hours
|
// allign to hours
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
@ -1448,9 +1407,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
// do GUI update
|
// do GUI update
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (SP.getBoolean("showiob", true) || SP.getBoolean("showcob", true) || SP.getBoolean("showdeviations", false) || SP.getBoolean("showratios", false) || Config.displayDeviationSlope) {
|
if (SP.getBoolean("showiob", true) || SP.getBoolean("showcob", true) || SP.getBoolean("showdeviations", false) || SP.getBoolean("showratios", false) || Config.displayDeviationSlope) {
|
||||||
iobGraph.setVisibility(View.VISIBLE);
|
iobGraph.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1460,118 +1417,26 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
graphData.performUpdate();
|
graphData.performUpdate();
|
||||||
secondGraphData.performUpdate();
|
secondGraphData.performUpdate();
|
||||||
Profiler.log(log, from + " - onDataChanged", updateGUIStart);
|
Profiler.log(log, from + " - onDataChanged", updateGUIStart);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
Profiler.log(log, from, updateGUIStart);
|
Profiler.log(log, from, updateGUIStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Notifications
|
//Notifications
|
||||||
static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.NotificationsViewHolder> {
|
|
||||||
|
|
||||||
List<Notification> notificationsList;
|
|
||||||
|
|
||||||
RecyclerViewAdapter(List<Notification> notificationsList) {
|
|
||||||
this.notificationsList = notificationsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
|
|
||||||
return new NotificationsViewHolder(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
|
|
||||||
Notification notification = notificationsList.get(position);
|
|
||||||
holder.dismiss.setTag(notification);
|
|
||||||
if (Objects.equals(notification.text, MainApp.sResources.getString(R.string.nsalarm_staledata)))
|
|
||||||
holder.dismiss.setText("snooze");
|
|
||||||
holder.text.setText(notification.text);
|
|
||||||
holder.time.setText(DateUtil.timeString(notification.date));
|
|
||||||
if (notification.level == Notification.URGENT)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationUrgent));
|
|
||||||
else if (notification.level == Notification.NORMAL)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationNormal));
|
|
||||||
else if (notification.level == Notification.LOW)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationLow));
|
|
||||||
else if (notification.level == Notification.INFO)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo));
|
|
||||||
else if (notification.level == Notification.ANNOUNCEMENT)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationAnnouncement));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return notificationsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
|
||||||
CardView cv;
|
|
||||||
TextView time;
|
|
||||||
TextView text;
|
|
||||||
Button dismiss;
|
|
||||||
|
|
||||||
NotificationsViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
cv = (CardView) itemView.findViewById(R.id.notification_cardview);
|
|
||||||
time = (TextView) itemView.findViewById(R.id.notification_time);
|
|
||||||
text = (TextView) itemView.findViewById(R.id.notification_text);
|
|
||||||
dismiss = (Button) itemView.findViewById(R.id.notification_dismiss);
|
|
||||||
dismiss.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Notification notification = (Notification) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.notification_dismiss:
|
|
||||||
MainApp.bus().post(new EventDismissNotification(notification.id));
|
|
||||||
if (notification.nsAlarm != null) {
|
|
||||||
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
|
|
||||||
}
|
|
||||||
// Adding current time to snooze if we got staleData
|
|
||||||
log.debug("Notification text is: " + notification.text);
|
|
||||||
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
|
||||||
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
|
||||||
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
|
||||||
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
|
||||||
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateNotifications() {
|
void updateNotifications() {
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null)
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
nstore.removeExpired();
|
nstore.removeExpired();
|
||||||
nstore.unSnooze();
|
nstore.unSnooze();
|
||||||
if (nstore.store.size() > 0) {
|
if (nstore.store.size() > 0) {
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(nstore.store);
|
NotificationRecyclerViewAdapter adapter = new NotificationRecyclerViewAdapter(nstore.store);
|
||||||
notificationsView.setAdapter(adapter);
|
notificationsView.setAdapter(adapter);
|
||||||
notificationsView.setVisibility(View.VISIBLE);
|
notificationsView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
notificationsView.setVisibility(View.GONE);
|
notificationsView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class OverviewPlugin extends PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewNotification n) {
|
public void onStatusEvent(final EventNewNotification n) {
|
||||||
notificationStore.add(n.notification);
|
if (notificationStore.add(n.notification))
|
||||||
MainApp.bus().post(new EventRefreshOverview("EventNewNotification"));
|
MainApp.bus().post(new EventRefreshOverview("EventNewNotification"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
package info.nightscout.androidaps.plugins.Overview.notifications;
|
||||||
|
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter<NotificationRecyclerViewAdapter.NotificationsViewHolder> {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(NotificationRecyclerViewAdapter.class);
|
||||||
|
|
||||||
|
private List<Notification> notificationsList;
|
||||||
|
|
||||||
|
public NotificationRecyclerViewAdapter(List<Notification> notificationsList) {
|
||||||
|
this.notificationsList = notificationsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
|
||||||
|
return new NotificationsViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
|
||||||
|
Notification notification = notificationsList.get(position);
|
||||||
|
holder.dismiss.setTag(notification);
|
||||||
|
if (Objects.equals(notification.text, MainApp.gs(R.string.nsalarm_staledata)))
|
||||||
|
holder.dismiss.setText("snooze");
|
||||||
|
holder.text.setText(notification.text);
|
||||||
|
holder.time.setText(DateUtil.timeString(notification.date));
|
||||||
|
if (notification.level == Notification.URGENT)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationUrgent));
|
||||||
|
else if (notification.level == Notification.NORMAL)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationNormal));
|
||||||
|
else if (notification.level == Notification.LOW)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationLow));
|
||||||
|
else if (notification.level == Notification.INFO)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo));
|
||||||
|
else if (notification.level == Notification.ANNOUNCEMENT)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationAnnouncement));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return notificationsList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||||
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
CardView cv;
|
||||||
|
TextView time;
|
||||||
|
TextView text;
|
||||||
|
Button dismiss;
|
||||||
|
|
||||||
|
NotificationsViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
cv = (CardView) itemView.findViewById(R.id.notification_cardview);
|
||||||
|
time = (TextView) itemView.findViewById(R.id.notification_time);
|
||||||
|
text = (TextView) itemView.findViewById(R.id.notification_text);
|
||||||
|
dismiss = (Button) itemView.findViewById(R.id.notification_dismiss);
|
||||||
|
dismiss.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Notification notification = (Notification) v.getTag();
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.notification_dismiss:
|
||||||
|
MainApp.bus().post(new EventDismissNotification(notification.id));
|
||||||
|
if (notification.nsAlarm != null) {
|
||||||
|
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
|
||||||
|
}
|
||||||
|
// Adding current time to snooze if we got staleData
|
||||||
|
log.debug("Notification text is: " + notification.text);
|
||||||
|
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
||||||
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
|
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
||||||
|
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
||||||
|
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,13 +49,13 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void add(Notification n) {
|
public synchronized boolean add(Notification n) {
|
||||||
log.info("Notification received: " + n.text);
|
log.info("Notification received: " + n.text);
|
||||||
for (Notification storeNotification : store) {
|
for (Notification storeNotification : store) {
|
||||||
if (storeNotification.id == n.id) {
|
if (storeNotification.id == n.id) {
|
||||||
storeNotification.date = n.date;
|
storeNotification.date = n.date;
|
||||||
storeNotification.validTo = n.validTo;
|
storeNotification.validTo = n.validTo;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
store.add(n);
|
store.add(n);
|
||||||
|
@ -71,6 +71,7 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(store, new NotificationComparator());
|
Collections.sort(store, new NotificationComparator());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean remove(int id) {
|
public synchronized boolean remove(int id) {
|
||||||
|
|
|
@ -306,12 +306,6 @@ public class CommandQueue {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRunning(Command.CommandType.BASALPROFILE)) {
|
|
||||||
if (callback != null)
|
|
||||||
callback.result(executingNowError()).run();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MainApp.isEngineeringModeOrRelease()) {
|
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.sResources.getString(R.string.not_eng_mode_or_release), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package info.nightscout.androidaps.queue.commands;
|
package info.nightscout.androidaps.queue.commands;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -17,6 +20,7 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommandSetProfile extends Command {
|
public class CommandSetProfile extends Command {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CommandSetProfile.class);
|
||||||
private Profile profile;
|
private Profile profile;
|
||||||
|
|
||||||
public CommandSetProfile(Profile profile, Callback callback) {
|
public CommandSetProfile(Profile profile, Callback callback) {
|
||||||
|
@ -27,6 +31,13 @@ public class CommandSetProfile extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
if (ConfigBuilderPlugin.getCommandQueue().isThisProfileSet(profile)) {
|
||||||
|
log.debug("QUEUE: Correct profile already set");
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(r).run();
|
callback.result(r).run();
|
||||||
|
|
|
@ -997,5 +997,5 @@
|
||||||
<string name="food_short">Food</string>
|
<string name="food_short">Food</string>
|
||||||
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
||||||
<string name="waitingfortimesynchronization">Waiting for time synchronization (%d sec)</string>
|
<string name="waitingfortimesynchronization">Waiting for time synchronization (%d sec)</string>
|
||||||
|
<string name="loopdisconnectedfor">Disconnected (%d m)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue