materialdatetimepicker update
This commit is contained in:
parent
86a826e65a
commit
7cca9892dc
16 changed files with 54 additions and 68 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -567,7 +567,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
android:layout_marginRight="30dp" />
|
||||
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:entries="@array/quickWizardYesNo"/>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -82,6 +82,6 @@
|
|||
</LinearLayout>
|
||||
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
|
@ -179,7 +179,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@
|
|||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp" />
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="15dp" />
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue