Add pref for native or 3rd party date pickers

pull/127/merge
Alex Baker 8 years ago
parent 561b069d8d
commit 29c8642792

@ -6,11 +6,11 @@ import android.os.Bundle;
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
import org.tasks.R;
import org.tasks.dialogs.MyDatePickerDialog;
import org.tasks.dialogs.NativeDatePickerDialog;
import org.tasks.injection.ActivityComponent;
import org.tasks.injection.InjectingAppCompatActivity;
import org.tasks.preferences.Device;
import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeAccent;
import org.tasks.themes.ThemeBase;
@ -18,8 +18,6 @@ import org.tasks.time.DateTime;
import javax.inject.Inject;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastMarshmallow;
import static org.tasks.dialogs.NativeDatePickerDialog.newNativeDatePickerDialog;
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
@ -31,7 +29,6 @@ public class DatePickerActivity extends InjectingAppCompatActivity implements Da
@Inject ThemeBase themeBase;
@Inject ThemeAccent themeAccent;
@Inject Device device;
@Inject Preferences preferences;
@Override
@ -42,7 +39,8 @@ public class DatePickerActivity extends InjectingAppCompatActivity implements Da
DateTime initial = (timestamp > 0 ? new DateTime(timestamp) : new DateTime()).startOfDay();
FragmentManager fragmentManager = getFragmentManager();
if (atLeastMarshmallow() || (atLeastLollipop() && !device.isBaneOfMyExistence())) {
if (preferences.getBoolean(R.string.p_use_native_datetime_pickers, false)) {
if (fragmentManager.findFragmentByTag(FRAG_TAG_DATE_PICKER) == null) {
newNativeDatePickerDialog(initial)
.show(fragmentManager, FRAG_TAG_DATE_PICKER);

@ -7,17 +7,18 @@ import android.text.format.DateFormat;
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
import org.tasks.R;
import org.tasks.dialogs.MyTimePickerDialog;
import org.tasks.dialogs.NativeTimePickerDialog;
import org.tasks.injection.ActivityComponent;
import org.tasks.injection.InjectingAppCompatActivity;
import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeAccent;
import org.tasks.themes.ThemeBase;
import org.tasks.time.DateTime;
import javax.inject.Inject;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
import static org.tasks.dialogs.NativeTimePickerDialog.newNativeTimePickerDialog;
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
@ -30,6 +31,7 @@ public class TimePickerActivity extends InjectingAppCompatActivity implements Ti
@Inject ThemeBase themeBase;
@Inject ThemeAccent themeAccent;
@Inject Preferences preferences;
private DateTime initial;
@ -40,7 +42,7 @@ public class TimePickerActivity extends InjectingAppCompatActivity implements Ti
initial = new DateTime(getIntent().getLongExtra(EXTRA_TIMESTAMP, currentTimeMillis()));
FragmentManager fragmentManager = getFragmentManager();
if (atLeastLollipop()) {
if (preferences.getBoolean(R.string.p_use_native_datetime_pickers, false)) {
if (fragmentManager.findFragmentByTag(FRAG_TAG_TIME_PICKER) == null) {
newNativeTimePickerDialog(initial)
.show(fragmentManager, FRAG_TAG_TIME_PICKER);

@ -29,10 +29,6 @@ public class Device {
this.locale = locale;
}
public boolean isBaneOfMyExistence() {
return Build.MANUFACTURER.equalsIgnoreCase("samsung");
}
public boolean hasCamera() {
return context.getPackageManager().queryIntentActivities(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), 0).size() > 0;
}

@ -319,5 +319,6 @@
<string name="debug">Debug</string>
<string name="p_rmd_show_description">rmd_show_description</string>
<string name="p_start_of_week">start_of_week</string>
<string name="p_use_native_datetime_pickers">use_native_datetime_pickers</string>
</resources>

@ -820,4 +820,5 @@ File %1$s contained %2$s.\n\n
<string name="date_and_time">Date and time</string>
<string name="start_of_week">Start of week</string>
<string name="use_locale_default">Use locale default</string>
<string name="use_native_datetime_pickers">Use native date and time pickers</string>
</resources>

@ -7,6 +7,11 @@
android:key="@string/p_start_of_week"
android:title="@string/start_of_week" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="false"
android:key="@string/p_use_native_datetime_pickers"
android:title="@string/use_native_datetime_pickers" />
<org.tasks.ui.TimePreference
android:defaultValue="@integer/default_morning"
android:key="@string/p_date_shortcut_morning"

Loading…
Cancel
Save