ExpirationDatePickerDF: customize buttons on onStart instead of showing dialog on onCreate

That is how DialogFragment is supposed to work

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-04-29 10:52:24 +02:00 committed by Álvaro Brey (Rebase PR Action)
parent 3148d94262
commit 8c2fc3ee87

View file

@ -76,6 +76,19 @@ public class ExpirationDatePickerDialogFragment
this.onExpiryDateListener = onExpiryDateListener;
}
@Override
public void onStart() {
super.onStart();
final Dialog currentDialog = getDialog();
if (currentDialog != null) {
final DatePickerDialog dialog = (DatePickerDialog) currentDialog;
dialog.getButton(DatePickerDialog.BUTTON_NEUTRAL).setTextColor(themeColorUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(themeColorUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(themeColorUtils.primaryColor(getContext(), true));
}
}
/**
* {@inheritDoc}
*
@ -113,11 +126,6 @@ public class ExpirationDatePickerDialogFragment
});
}
dialog.show();
dialog.getButton(DatePickerDialog.BUTTON_NEUTRAL).setTextColor(themeColorUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(themeColorUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(themeColorUtils.primaryColor(getContext(), true));
// Prevent days in the past may be chosen
DatePicker picker = dialog.getDatePicker();
picker.setMinDate(tomorrowInMillis - 1000);