diff --git a/app/build.gradle b/app/build.gradle
index 0f99593636..5e4622da15 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -238,7 +238,7 @@ dependencies {
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
- implementation "com.wdullaer:materialdatetimepicker:2.3.0"
+ implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
diff --git a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java
index 2397dda9ed..c0f654bbbb 100644
--- a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java
@@ -45,7 +45,7 @@ import info.nightscout.androidaps.utils.T;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
-public class HistoryBrowseActivity extends NoSplashActivity {
+public class HistoryBrowseActivity extends NoSplashAppCompatActivity {
private static Logger log = LoggerFactory.getLogger(HistoryBrowseActivity.class);
private CompositeDisposable disposable = new CompositeDisposable();
@@ -150,7 +150,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
);
dpd.setThemeDark(true);
dpd.dismissOnPause(true);
- dpd.show(getFragmentManager(), "Datepickerdialog");
+ dpd.show(getSupportFragmentManager(), "Datepickerdialog");
});
bgGraph.getGridLabelRenderer().setGridColor(MainApp.gc(R.color.graphgrid));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java
index 69ac67bf07..c1bca15028 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java
@@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.general.automation.triggers;
-import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import com.google.common.base.Optional;
@@ -84,11 +84,11 @@ public abstract class Trigger {
}
@Nullable
- Activity scanForActivity(Context cont) {
+ AppCompatActivity scanForActivity(Context cont) {
if (cont == null)
return null;
- else if (cont instanceof Activity)
- return (Activity) cont;
+ else if (cont instanceof AppCompatActivity)
+ return (AppCompatActivity) cont;
else if (cont instanceof ContextWrapper)
return scanForActivity(((ContextWrapper) cont).getBaseContext());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.java
index 89c8d17085..f7f1035558 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.java
@@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.general.automation.triggers;
-import android.app.Activity;
import android.graphics.Typeface;
import android.text.format.DateFormat;
import android.view.ViewGroup;
@@ -9,6 +8,7 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import com.dpro.widgets.WeekdaysPicker;
@@ -294,9 +294,9 @@ public class TriggerRecurringTime extends Trigger {
);
tpd.setThemeDark(true);
tpd.dismissOnPause(true);
- Activity a = scanForActivity(root.getContext());
+ AppCompatActivity a = scanForActivity(root.getContext());
if (a != null)
- tpd.show(a.getFragmentManager(), "TimePickerDialog");
+ tpd.show(a.getSupportFragmentManager(), "TimePickerDialog");
});
int px = MainApp.dpToPx(10);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java
index 08f9a65aa7..91e739ca45 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java
@@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.general.automation.triggers;
-import android.app.Activity;
import android.graphics.Typeface;
import android.text.format.DateFormat;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import com.google.common.base.Optional;
@@ -142,9 +142,9 @@ public class TriggerTime extends Trigger {
);
dpd.setThemeDark(true);
dpd.dismissOnPause(true);
- Activity a = scanForActivity(root.getContext());
+ AppCompatActivity a = scanForActivity(root.getContext());
if (a != null)
- dpd.show(a.getFragmentManager(), "DatePickerDialog");
+ dpd.show(a.getSupportFragmentManager(), "DatePickerDialog");
});
timeButton.setOnClickListener(view -> {
GregorianCalendar calendar = new GregorianCalendar();
@@ -162,9 +162,9 @@ public class TriggerTime extends Trigger {
);
tpd.setThemeDark(true);
tpd.dismissOnPause(true);
- Activity a = scanForActivity(root.getContext());
+ AppCompatActivity a = scanForActivity(root.getContext());
if (a != null)
- tpd.show(a.getFragmentManager(), "TimePickerDialog");
+ tpd.show(a.getSupportFragmentManager(), "TimePickerDialog");
});
int px = MainApp.dpToPx(10);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.java
index 1d03871620..082c5af75c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.java
@@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.general.automation.triggers;
-import android.app.Activity;
import android.graphics.Typeface;
import android.text.format.DateFormat;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import com.google.common.base.Optional;
@@ -18,7 +18,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Calendar;
-import java.util.Date;
import java.util.GregorianCalendar;
import info.nightscout.androidaps.MainApp;
@@ -33,14 +32,14 @@ import info.nightscout.androidaps.utils.T;
public class TriggerTimeRange extends Trigger {
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
-
+
// in minutes since midnight 60 means 1AM
private int start;
private int end;
long timeZoneOffset = DateUtil.getTimeZoneOffsetMs();
public TriggerTimeRange() {
-
+
start = getMinSinceMidnight(DateUtil.now());
end = getMinSinceMidnight(DateUtil.now());
}
@@ -60,11 +59,11 @@ public class TriggerTimeRange extends Trigger {
return false;
boolean doRun = false;
- if ( start < end && start < currentMinSinceMidnight && currentMinSinceMidnight < end)
+ if (start < end && start < currentMinSinceMidnight && currentMinSinceMidnight < end)
doRun = true;
- // handle cases like 10PM to 6AM
- else if ( start > end && (start < currentMinSinceMidnight || currentMinSinceMidnight < end))
+ // handle cases like 10PM to 6AM
+ else if (start > end && (start < currentMinSinceMidnight || currentMinSinceMidnight < end))
doRun = true;
if (doRun) {
@@ -129,8 +128,8 @@ public class TriggerTimeRange extends Trigger {
}
TriggerTimeRange period(int start, int end) {
- this.start = getMinSinceMidnight(start*60000);
- this.end = getMinSinceMidnight(end*60000);
+ this.start = getMinSinceMidnight(start * 60000);
+ this.end = getMinSinceMidnight(end * 60000);
return this;
}
@@ -145,7 +144,7 @@ public class TriggerTimeRange extends Trigger {
}
long toMilis(long minutesSinceMidnight) {
- return minutesSinceMidnight*60*1000;
+ return minutesSinceMidnight * 60 * 1000;
}
public int getMinSinceMidnight(long time) {
@@ -157,11 +156,11 @@ public class TriggerTimeRange extends Trigger {
return (calendar.get(Calendar.HOUR_OF_DAY) * 60) + calendar.get(Calendar.MINUTE);
}
- int getStart(){
+ int getStart() {
return start;
}
- int getEnd(){
+ int getEnd() {
return end;
}
@@ -170,8 +169,8 @@ public class TriggerTimeRange extends Trigger {
TextView label = new TextView(root.getContext());
TextView startButton = new TextView(root.getContext());
TextView endButton = new TextView(root.getContext());
- log.debug("Start is: " + start );
- log.debug("End is: " + end );
+ log.debug("Start is: " + start);
+ log.debug("End is: " + end);
startButton.setText(DateUtil.timeString(toMilis(start) - timeZoneOffset));
endButton.setText(MainApp.gs(R.string.and) + " " + DateUtil.timeString(toMilis(end) - timeZoneOffset));
@@ -193,9 +192,9 @@ public class TriggerTimeRange extends Trigger {
);
tpd.setThemeDark(true);
tpd.dismissOnPause(true);
- Activity a = scanForActivity(root.getContext());
+ AppCompatActivity a = scanForActivity(root.getContext());
if (a != null)
- tpd.show(a.getFragmentManager(), "TimePickerDialog");
+ tpd.show(a.getSupportFragmentManager(), "TimePickerDialog");
});
endButton.setOnClickListener(view -> {
GregorianCalendar calendar = new GregorianCalendar();
@@ -213,9 +212,9 @@ public class TriggerTimeRange extends Trigger {
);
tpd.setThemeDark(true);
tpd.dismissOnPause(true);
- Activity a = scanForActivity(root.getContext());
+ AppCompatActivity a = scanForActivity(root.getContext());
if (a != null)
- tpd.show(a.getFragmentManager(), "TimePickerDialog");
+ tpd.show(a.getSupportFragmentManager(), "TimePickerDialog");
});
int px = MainApp.dpToPx(10);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java
index e2be9075e3..64b7b05987 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java
@@ -1,10 +1,8 @@
package info.nightscout.androidaps.plugins.general.careportal.Dialogs;
-import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
-import androidx.fragment.app.DialogFragment;
-import androidx.appcompat.app.AlertDialog;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.format.DateFormat;
@@ -20,9 +18,12 @@ import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatDialogFragment;
+import androidx.fragment.app.DialogFragment;
+
import com.google.common.collect.Lists;
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
-import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
import org.json.JSONException;
@@ -39,7 +40,6 @@ import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.db.BgReading;
@@ -51,6 +51,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
+import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DefaultValueHelper;
@@ -61,11 +62,9 @@ import info.nightscout.androidaps.utils.SP;
import info.nightscout.androidaps.utils.SafeParse;
import info.nightscout.androidaps.utils.Translator;
-public class NewNSTreatmentDialog extends DialogFragment implements View.OnClickListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {
+public class NewNSTreatmentDialog extends AppCompatDialogFragment implements View.OnClickListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {
private static Logger log = LoggerFactory.getLogger(NewNSTreatmentDialog.class);
- private Activity context;
-
private static OptionsToShow options;
private static String event;
@@ -119,18 +118,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
}
}
- @Override
- public void onAttach(Activity activity) {
- context = activity;
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- super.onDetach();
- this.context = null;
- }
-
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -421,18 +408,18 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
);
dpd.setThemeDark(true);
dpd.dismissOnPause(true);
- dpd.show(context.getFragmentManager(), "Datepickerdialog");
+ dpd.show(getActivity().getSupportFragmentManager(), "Datepickerdialog");
break;
case R.id.careportal_newnstreatment_eventtime:
TimePickerDialog tpd = TimePickerDialog.newInstance(
this,
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE),
- DateFormat.is24HourFormat(context)
+ DateFormat.is24HourFormat(getContext())
);
tpd.setThemeDark(true);
tpd.dismissOnPause(true);
- tpd.show(context.getFragmentManager(), "Timepickerdialog");
+ tpd.show(getActivity().getSupportFragmentManager(), "Timepickerdialog");
break;
case R.id.ok:
confirmNSTreatmentCreation();
@@ -469,7 +456,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
}
@Override
- public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute, int second) {
+ public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
eventTime.setHours(hourOfDay);
eventTime.setMinutes(minute);
eventTime.setSeconds(this.seconds++); // randomize seconds to prevent creating record of the same time, if user choose time manually
@@ -477,7 +464,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
updateBGforDateTime();
}
-
JSONObject gatherData() {
String enteredBy = SP.getString("careportal_enteredby", "");
JSONObject data = new JSONObject();
@@ -702,6 +688,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
}
void confirmNSTreatmentCreation() {
+ Context context = getContext();
if (context != null) {
final JSONObject data = gatherData();
final String confirmText = buildConfirmText(data);
@@ -715,7 +702,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
}
- public void createNSTreatment(JSONObject data) {
+ void createNSTreatment(JSONObject data) {
if (options.executeProfileSwitch) {
if (data.has("profile")) {
ProfileFunctions.doProfileSwitch(profileStore, JsonHelper.safeGetString(data, "profile"), JsonHelper.safeGetInt(data, "duration"), JsonHelper.safeGetInt(data, "percentage"), JsonHelper.safeGetInt(data, "timeshift"));
diff --git a/app/src/main/res/layout/actions_fill_dialog.xml b/app/src/main/res/layout/actions_fill_dialog.xml
index 27fdb02ee7..ce52f25abb 100644
--- a/app/src/main/res/layout/actions_fill_dialog.xml
+++ b/app/src/main/res/layout/actions_fill_dialog.xml
@@ -142,7 +142,7 @@
-
+
diff --git a/app/src/main/res/layout/careportal_newnstreatment_dialog.xml b/app/src/main/res/layout/careportal_newnstreatment_dialog.xml
index d27a5883b5..fc0fa1ea49 100644
--- a/app/src/main/res/layout/careportal_newnstreatment_dialog.xml
+++ b/app/src/main/res/layout/careportal_newnstreatment_dialog.xml
@@ -567,7 +567,7 @@
-
+
diff --git a/app/src/main/res/layout/overview_calibration_dialog.xml b/app/src/main/res/layout/overview_calibration_dialog.xml
index 2b50ad88fb..7caca56269 100644
--- a/app/src/main/res/layout/overview_calibration_dialog.xml
+++ b/app/src/main/res/layout/overview_calibration_dialog.xml
@@ -47,7 +47,7 @@
android:layout_marginRight="30dp" />
-
+
diff --git a/app/src/main/res/layout/overview_editquickwizard_dialog.xml b/app/src/main/res/layout/overview_editquickwizard_dialog.xml
index fd0c5fd5ce..fe7862d93f 100644
--- a/app/src/main/res/layout/overview_editquickwizard_dialog.xml
+++ b/app/src/main/res/layout/overview_editquickwizard_dialog.xml
@@ -150,7 +150,7 @@
android:layout_height="wrap_content"
android:entries="@array/quickWizardYesNo"/>
-
+
diff --git a/app/src/main/res/layout/overview_newcarbs_dialog.xml b/app/src/main/res/layout/overview_newcarbs_dialog.xml
index 9c5f3840ec..457e11c15d 100644
--- a/app/src/main/res/layout/overview_newcarbs_dialog.xml
+++ b/app/src/main/res/layout/overview_newcarbs_dialog.xml
@@ -214,7 +214,7 @@
-
+
diff --git a/app/src/main/res/layout/overview_newextendedbolus_dialog.xml b/app/src/main/res/layout/overview_newextendedbolus_dialog.xml
index e0c6aefd37..b3a17229d3 100644
--- a/app/src/main/res/layout/overview_newextendedbolus_dialog.xml
+++ b/app/src/main/res/layout/overview_newextendedbolus_dialog.xml
@@ -82,6 +82,6 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/overview_newinsulin_dialog.xml b/app/src/main/res/layout/overview_newinsulin_dialog.xml
index e4ce5bbfe7..a3f3b6d56f 100644
--- a/app/src/main/res/layout/overview_newinsulin_dialog.xml
+++ b/app/src/main/res/layout/overview_newinsulin_dialog.xml
@@ -179,7 +179,7 @@
-
+
diff --git a/app/src/main/res/layout/overview_newtempbasal_dialog.xml b/app/src/main/res/layout/overview_newtempbasal_dialog.xml
index f4254dbe8a..1bd77a26e0 100644
--- a/app/src/main/res/layout/overview_newtempbasal_dialog.xml
+++ b/app/src/main/res/layout/overview_newtempbasal_dialog.xml
@@ -139,7 +139,7 @@
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
-
+
diff --git a/app/src/main/res/layout/overview_newtreatment_dialog.xml b/app/src/main/res/layout/overview_newtreatment_dialog.xml
index 4a899fbd9b..9aec3699e9 100644
--- a/app/src/main/res/layout/overview_newtreatment_dialog.xml
+++ b/app/src/main/res/layout/overview_newtreatment_dialog.xml
@@ -65,7 +65,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp" />
-
+