Clean AndroidAPS started button
This commit is contained in:
parent
0d48cc8770
commit
a4b3b7b2e9
|
@ -107,16 +107,14 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
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)) {
|
||||
NSUpload.removeCareportalEntryFromNS(_id);
|
||||
} else {
|
||||
UploadQueue.removeID("dbAdd", _id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(careportalEvent);
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
||||
final String _id = careportalEvent._id;
|
||||
if (NSUpload.isIdValid(_id)) {
|
||||
NSUpload.removeCareportalEntryFromNS(_id);
|
||||
} else {
|
||||
UploadQueue.removeID("dbAdd", _id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(careportalEvent);
|
||||
});
|
||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||
builder.show();
|
||||
|
@ -142,6 +140,8 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
|
|||
refreshFromNS = (Button) view.findViewById(R.id.careportal_refreshfromnightscout);
|
||||
refreshFromNS.setOnClickListener(this);
|
||||
|
||||
view.findViewById(R.id.careportal_removeandroidapsstartedevents).setOnClickListener(this);
|
||||
|
||||
context = getContext();
|
||||
|
||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||
|
@ -169,6 +169,16 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
|
|||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||
builder.show();
|
||||
break;
|
||||
case R.id.careportal_removeandroidapsstartedevents:
|
||||
builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||
builder.setMessage(MainApp.gs(R.string.careportal_removestartedevents));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
||||
removeAndroidAPSStatedEvents();
|
||||
});
|
||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||
builder.show();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -189,4 +199,20 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void removeAndroidAPSStatedEvents() {
|
||||
List<CareportalEvent> events = MainApp.getDbHelper().getCareportalEvents(false);
|
||||
for (int i = 0; i < events.size(); i++) {
|
||||
CareportalEvent careportalEvent = events.get(i);
|
||||
if (careportalEvent.json.contains(MainApp.gs(R.string.androidaps_start))) {
|
||||
final String _id = careportalEvent._id;
|
||||
if (NSUpload.isIdValid(_id)) {
|
||||
NSUpload.removeCareportalEntryFromNS(_id);
|
||||
} else {
|
||||
UploadQueue.removeID("dbAdd", _id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(careportalEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,30 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/careportal_refreshfromnightscout"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/refresheventsfromnightscout" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/careportal_refreshfromnightscout"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/refresheventsfromnightscout" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/careportal_removeandroidapsstartedevents"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/careportal_removestartedevents" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/careportal_recyclerview"
|
||||
|
|
|
@ -1172,6 +1172,7 @@
|
|||
<string name="combo_invalid_setup">Invalid pump setup, check the docs and verify that the Quick Info menu is named "QUICK INFO" using the 360 configuration software.</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="key_lockscreen" translatable="false">lockscreen</string>
|
||||
<string name="careportal_removestartedevents">Clean AndroidAPS started</string>
|
||||
|
||||
<plurals name="objective_days">
|
||||
<item quantity="one">%d day</item>
|
||||
|
|
Loading…
Reference in a new issue