From 8c2fc3ee87885ea0942fb8deafd2fd8d2b02437f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Fri, 29 Apr 2022 10:52:24 +0200 Subject: [PATCH] ExpirationDatePickerDF: customize buttons on onStart instead of showing dialog on onCreate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That is how DialogFragment is supposed to work Signed-off-by: Álvaro Brey Vilas --- .../ExpirationDatePickerDialogFragment.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java b/app/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java index 2325056fcf..800acdc041 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/dialog/ExpirationDatePickerDialogFragment.java @@ -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);