Fix date and time picker theme issues

pull/757/head
Alex Baker 6 years ago
parent 0538744004
commit 650d0e0ea7

@ -160,9 +160,7 @@ dependencies {
implementation('org.scala-saddle:google-rfc-2445:20110304') {
transitive = false
}
implementation('com.wdullaer:materialdatetimepicker:3.6.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
implementation('com.wdullaer:materialdatetimepicker:4.0.1')
implementation "me.leolin:ShortcutBadger:1.1.22@aar"
implementation 'com.google.apis:google-api-services-tasks:v1-rev52-1.23.0'
implementation 'com.google.api-client:google-api-client-android:1.23.0'

@ -47,12 +47,13 @@ public class DateAndTimePickerActivity extends InjectingAppCompatActivity
}
}
FragmentManager fragmentManager = getFragmentManager();
if (preferences.getBoolean(R.string.p_use_native_datetime_pickers, false)) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_DATE_PICKER) == null) {
newNativeDatePickerDialog(initial).show(fragmentManager, FRAG_TAG_DATE_PICKER);
}
} else {
androidx.fragment.app.FragmentManager fragmentManager = getSupportFragmentManager();
MyDatePickerDialog datePickerDialog =
(MyDatePickerDialog) fragmentManager.findFragmentByTag(FRAG_TAG_DATE_PICKER);
if (datePickerDialog == null) {

@ -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) {

@ -37,12 +37,13 @@ public class TimePickerActivity extends InjectingAppCompatActivity
initial = new DateTime(getIntent().getLongExtra(EXTRA_TIMESTAMP, currentTimeMillis()));
FragmentManager fragmentManager = getFragmentManager();
if (preferences.getBoolean(R.string.p_use_native_datetime_pickers, false)) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_TIME_PICKER) == null) {
newNativeTimePickerDialog(initial).show(fragmentManager, FRAG_TAG_TIME_PICKER);
}
} else {
androidx.fragment.app.FragmentManager fragmentManager = getSupportFragmentManager();
MyTimePickerDialog dialog =
(MyTimePickerDialog) fragmentManager.findFragmentByTag(FRAG_TAG_TIME_PICKER);
if (dialog == null) {

@ -6,6 +6,7 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.DatePicker;
@ -47,9 +48,11 @@ public class NativeDatePickerDialog extends InjectingNativeDialogFragment
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle args = getArguments();
Context context = getActivity();
theme.applyToContext(context);
DatePickerDialog datePickerDialog =
new DatePickerDialog(
theme.wrap(getActivity()),
context,
this,
args.getInt(EXTRA_YEAR),
args.getInt(EXTRA_MONTH),

@ -40,8 +40,9 @@ public class NativeTimePickerDialog extends InjectingNativeDialogFragment
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Context context = theme.wrap(getActivity());
Bundle args = getArguments();
Context context = getActivity();
theme.applyToContext(context);
TimePickerDialog timePickerDialog =
new TimePickerDialog(
context,

@ -5,5 +5,5 @@
<style name="DayNightAlert" parent="Theme.MaterialComponents.Dialog.Alert"/>
<style name="popup_overlay" parent="ThemeOverlay.AppCompat"/>
<style name="popup_overlay" parent="ThemeOverlay.MaterialComponents"/>
</resources>

@ -9,7 +9,8 @@
<item name="android:paddingRight">0dp</item>
</style>
<style name="TranslucentDialog" parent="Theme.MaterialComponents.Light.Dialog">
<style name="TranslucentDialog" parent="DayNightDialog">
<item name="viewInflaterClass">androidx.appcompat.app.AppCompatViewInflater</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>

Loading…
Cancel
Save