|
|
|
@ -3,14 +3,14 @@ package org.tasks.activities;
|
|
|
|
|
import static org.tasks.dialogs.NativeDatePickerDialog.newNativeDatePickerDialog;
|
|
|
|
|
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
|
|
|
|
|
|
|
|
|
|
import android.app.FragmentManager;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
|
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
import org.tasks.R;
|
|
|
|
|
import org.tasks.dialogs.MyDatePickerDialog;
|
|
|
|
|
import org.tasks.dialogs.NativeDatePickerDialog;
|
|
|
|
|
import org.tasks.dialogs.NativeDatePickerDialog.NativeDatePickerDialogCallback;
|
|
|
|
|
import org.tasks.injection.ActivityComponent;
|
|
|
|
|
import org.tasks.injection.InjectingAppCompatActivity;
|
|
|
|
|
import org.tasks.preferences.Preferences;
|
|
|
|
@ -19,8 +19,7 @@ import org.tasks.themes.ThemeBase;
|
|
|
|
|
import org.tasks.time.DateTime;
|
|
|
|
|
|
|
|
|
|
public class DatePickerActivity extends InjectingAppCompatActivity
|
|
|
|
|
implements DatePickerDialog.OnDateSetListener,
|
|
|
|
|
NativeDatePickerDialog.NativeDatePickerDialogCallback {
|
|
|
|
|
implements DatePickerDialog.OnDateSetListener, NativeDatePickerDialogCallback {
|
|
|
|
|
|
|
|
|
|
public static final String EXTRA_TIMESTAMP = "extra_timestamp";
|
|
|
|
|
private static final String FRAG_TAG_DATE_PICKER = "frag_tag_date_picker";
|
|
|
|
@ -31,17 +30,16 @@ public class DatePickerActivity extends InjectingAppCompatActivity
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
long timestamp = getIntent().getLongExtra(EXTRA_TIMESTAMP, currentTimeMillis());
|
|
|
|
|
DateTime initial = (timestamp > 0 ? new DateTime(timestamp) : new DateTime()).startOfDay();
|
|
|
|
|
|
|
|
|
|
FragmentManager fragmentManager = getFragmentManager();
|
|
|
|
|
|
|
|
|
|
if (preferences.getBoolean(R.string.p_use_native_datetime_pickers, false)) {
|
|
|
|
|
android.app.FragmentManager fragmentManager = getFragmentManager();
|
|
|
|
|
if (fragmentManager.findFragmentByTag(FRAG_TAG_DATE_PICKER) == null) {
|
|
|
|
|
newNativeDatePickerDialog(initial).show(fragmentManager, FRAG_TAG_DATE_PICKER);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
|
MyDatePickerDialog dialog =
|
|
|
|
|
(MyDatePickerDialog) fragmentManager.findFragmentByTag(FRAG_TAG_DATE_PICKER);
|
|
|
|
|
if (dialog == null) {
|
|
|
|
|