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