content: package com.google.android.material.datepicker;
  
  import android.app.Dialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.res.ColorStateList;
  import android.content.res.Resources;
  import android.content.res.TypedArray;
  import android.graphics.Rect;
  import android.graphics.drawable.Drawable;
  import android.graphics.drawable.InsetDrawable;
  import android.graphics.drawable.StateListDrawable;
  import android.os.Bundle;
  import android.util.AttributeSet;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.Window;
  import android.widget.Button;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import androidx.appcompat.content.res.AppCompatResources;
  import androidx.core.util.Pair;
  import androidx.core.view.AccessibilityDelegateCompat;
  import androidx.core.view.OnApplyWindowInsetsListener;
  import androidx.core.view.ViewCompat;
  import androidx.core.view.WindowInsetsCompat;
  import androidx.fragment.app.DialogFragment;
  import androidx.fragment.app.FragmentTransaction;
  import com.google.android.material.R;
  import com.google.android.material.datepicker.CalendarConstraints;
  import com.google.android.material.dialog.InsetDialogOnTouchListener;
  import com.google.android.material.internal.CheckableImageButton;
  import com.google.android.material.internal.EdgeToEdgeUtils;
  import com.google.android.material.internal.ViewUtils;
  import com.google.android.material.resources.MaterialAttributes;
  import com.google.android.material.shape.MaterialShapeDrawable;
  import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  import java.util.Iterator;
  import java.util.LinkedHashSet;
  import mt.Log1F380D;
  
  /* compiled from: 00F0 */
  public final class MaterialDatePicker<S> extends DialogFragment {
      private static final String CALENDAR_CONSTRAINTS_KEY = "CALENDAR_CONSTRAINTS_KEY";
      static final Object CANCEL_BUTTON_TAG = "CANCEL_BUTTON_TAG";
      static final Object CONFIRM_BUTTON_TAG = "CONFIRM_BUTTON_TAG";
      private static final String DATE_SELECTOR_KEY = "DATE_SELECTOR_KEY";
      public static final int INPUT_MODE_CALENDAR = 0;
      private static final String INPUT_MODE_KEY = "INPUT_MODE_KEY";
      public static final int INPUT_MODE_TEXT = 1;
      private static final String NEGATIVE_BUTTON_TEXT_KEY = "NEGATIVE_BUTTON_TEXT_KEY";
      private static final String NEGATIVE_BUTTON_TEXT_RES_ID_KEY = "NEGATIVE_BUTTON_TEXT_RES_ID_KEY";
      private static final String OVERRIDE_THEME_RES_ID = "OVERRIDE_THEME_RES_ID";
      private static final String POSITIVE_BUTTON_TEXT_KEY = "POSITIVE_BUTTON_TEXT_KEY";
      private static final String POSITIVE_BUTTON_TEXT_RES_ID_KEY = "POSITIVE_BUTTON_TEXT_RES_ID_KEY";
      private static final String TITLE_TEXT_KEY = "TITLE_TEXT_KEY";
      private static final String TITLE_TEXT_RES_ID_KEY = "TITLE_TEXT_RES_ID_KEY";
      static final Object TOGGLE_BUTTON_TAG = "TOGGLE_BUTTON_TAG";
      private MaterialShapeDrawable background;
      private MaterialCalendar<S> calendar;
      private CalendarConstraints calendarConstraints;
      /* access modifiers changed from: private */
      public Button confirmButton;
      private DateSelector<S> dateSelector;
      private boolean edgeToEdgeEnabled;
      private boolean fullscreen;
      private TextView headerSelectionText;
      /* access modifiers changed from: private */
      public CheckableImageButton headerToggleButton;
      private int inputMode;
      private CharSequence negativeButtonText;
      private int negativeButtonTextResId;
      private final LinkedHashSet<DialogInterface.OnCancelListener> onCancelListeners = new LinkedHashSet<>();
      private final LinkedHashSet<DialogInterface.OnDismissListener> onDismissListeners = new LinkedHashSet<>();
      /* access modifiers changed from: private */
      public final LinkedHashSet<View.OnClickListener> onNegativeButtonClickListeners = new LinkedHashSet<>();
      /* access modifiers changed from: private */
      public final LinkedHashSet<MaterialPickerOnPositiveButtonClickListener<? super S>> onPositiveButtonClickListeners = new LinkedHashSet<>();
      private int overrideThemeResId;
      private PickerFragment<S> pickerFragment;
      private CharSequence positiveButtonText;
      private int positiveButtonTextResId;
      private CharSequence titleText;
      private int titleTextResId;
  
      public static final class Builder<S> {
          CalendarConstraints calendarConstraints;
          final DateSelector<S> dateSelector;
          int inputMode = 0;
          CharSequence negativeButtonText = null;
          int negativeButtonTextResId = 0;
          int overrideThemeResId = 0;
          CharSequence positiveButtonText = null;
          int positiveButtonTextResId = 0;
          S selection = null;
          CharSequence titleText = null;
          int titleTextResId = 0;
  
          private Builder(DateSelector<S> dateSelector2) {
              this.dateSelector = dateSelector2;
          }
  
          private Month createDefaultOpenAt() {
              if (!this.dateSelector.getSelectedDays().isEmpty()) {
                  Month create = Month.create(this.dateSelector.getSelectedDays().iterator().next().longValue());
                  if (monthInValidRange(create, this.calendarConstraints)) {
                      return create;
                  }
              }
              Month current = Month.current();
              return monthInValidRange(current, this.calendarConstraints) ? current : this.calendarConstraints.getStart();
          }
  
          public static <S> Builder<S> customDatePicker(DateSelector<S> dateSelector2) {
              return new Builder<>(dateSelector2);
          }
  
          public static Builder<Long> datePicker() {
              return new Builder<>(new SingleDateSelector());
          }
  
          public static Builder<Pair<Long, Long>> dateRangePicker() {
              return new Builder<>(new RangeDateSelector());
          }
  
          private static boolean monthInValidRange(Month month, CalendarConstraints constraints) {
              return month.compareTo(constraints.getStart()) >= 0 && month.compareTo(constraints.getEnd()) <= 0;
          }
  
          public MaterialDatePicker<S> build() {
              if (this.calendarConstraints == null) {
                  this.calendarConstraints = new CalendarConstraints.Builder().build();
              }
              if (this.titleTextResId == 0) {
                  this.titleTextResId = this.dateSelector.getDefaultTitleResId();
              }
              S s = this.selection;
              if (s != null) {
                  this.dateSelector.setSelection(s);
              }
              if (this.calendarConstraints.getOpenAt() == null) {
                  this.calendarConstraints.setOpenAt(createDefaultOpenAt());
              }
              return MaterialDatePicker.newInstance(this);
          }
  
          public Builder<S> setCalendarConstraints(CalendarConstraints bounds) {
              this.calendarConstraints = bounds;
              return this;
          }
  
          public Builder<S> setInputMode(int inputMode2) {
              this.inputMode = inputMode2;
              return this;
          }
  
          public Builder<S> setNegativeButtonText(int textId) {
              this.negativeButtonTextResId = textId;
              this.negativeButtonText = null;
              return this;
          }
  
          public Builder<S> setNegativeButtonText(CharSequence text) {
              this.negativeButtonText = text;
              this.negativeButtonTextResId = 0;
              return this;
          }
  
          public Builder<S> setPositiveButtonText(int textId) {
              this.positiveButtonTextResId = textId;
              this.positiveButtonText = null;
              return this;
          }
  
          public Builder<S> setPositiveButtonText(CharSequence text) {
              this.positiveButtonText = text;
              this.positiveButtonTextResId = 0;
              return this;
          }
  
          public Builder<S> setSelection(S s) {
              this.selection = s;
              return this;
          }
  
          public Builder<S> setTheme(int themeResId) {
              this.overrideThemeResId = themeResId;
              return this;
          }
  
          public Builder<S> setTitleText(int titleTextResId2) {
              this.titleTextResId = titleTextResId2;
              this.titleText = null;
              return this;
          }
  
          public Builder<S> setTitleText(CharSequence charSequence) {
              this.titleText = charSequence;
              this.titleTextResId = 0;
              return this;
          }
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface InputMode {
      }
  
      private static Drawable createHeaderToggleDrawable(Context context) {
          StateListDrawable stateListDrawable = new StateListDrawable();
          stateListDrawable.addState(new int[]{16842912}, AppCompatResources.getDrawable(context, R.drawable.material_ic_calendar_black_24dp));
          stateListDrawable.addState(new int[0], AppCompatResources.getDrawable(context, R.drawable.material_ic_edit_black_24dp));
          return stateListDrawable;
      }
  
      private void enableEdgeToEdgeIfNeeded(Window window) {
          if (!this.edgeToEdgeEnabled) {
              final View findViewById = requireView().findViewById(R.id.fullscreen_header);
              EdgeToEdgeUtils.applyEdgeToEdge(window, true, ViewUtils.getBackgroundColor(findViewById), (Integer) null);
              final int paddingTop = findViewById.getPaddingTop();
              final int i = findViewById.getLayoutParams().height;
              ViewCompat.setOnApplyWindowInsetsListener(findViewById, new OnApplyWindowInsetsListener() {
                  public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                      int i = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top;
                      if (i >= 0) {
                          findViewById.getLayoutParams().height = i + i;
                          View view = findViewById;
                          view.setLayoutParams(view.getLayoutParams());
                      }
                      View view2 = findViewById;
                      view2.setPadding(view2.getPaddingLeft(), paddingTop + i, findViewById.getPaddingRight(), findViewById.getPaddingBottom());
                      return insets;
                  }
              });
              this.edgeToEdgeEnabled = true;
          }
      }
  
      /* access modifiers changed from: private */
      public DateSelector<S> getDateSelector() {
          if (this.dateSelector == null) {
              this.dateSelector = (DateSelector) getArguments().getParcelable(DATE_SELECTOR_KEY);
          }
          return this.dateSelector;
      }
  
      private static int getPaddedPickerWidth(Context context) {
          Resources resources = context.getResources();
          int dimensionPixelOffset = resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_content_padding);
          int i = Month.current().daysInWeek;
          return (dimensionPixelOffset * 2) + (i * resources.getDimensionPixelSize(R.dimen.mtrl_calendar_day_width)) + ((i - 1) * resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_month_horizontal_padding));
      }
  
      private int getThemeResId(Context context) {
          int i = this.overrideThemeResId;
          return i != 0 ? i : getDateSelector().getDefaultThemeResId(context);
      }
  
      private void initHeaderToggle(Context context) {
          this.headerToggleButton.setTag(TOGGLE_BUTTON_TAG);
          this.headerToggleButton.setImageDrawable(createHeaderToggleDrawable(context));
          this.headerToggleButton.setChecked(this.inputMode != 0);
          ViewCompat.setAccessibilityDelegate(this.headerToggleButton, (AccessibilityDelegateCompat) null);
          updateToggleContentDescription(this.headerToggleButton);
          this.headerToggleButton.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  MaterialDatePicker.this.confirmButton.setEnabled(MaterialDatePicker.this.getDateSelector().isSelectionComplete());
                  MaterialDatePicker.this.headerToggleButton.toggle();
                  MaterialDatePicker materialDatePicker = MaterialDatePicker.this;
                  materialDatePicker.updateToggleContentDescription(materialDatePicker.headerToggleButton);
                  MaterialDatePicker.this.startPickerFragment();
              }
          });
      }
  
      static boolean isFullscreen(Context context) {
          return readMaterialCalendarStyleBoolean(context, 16843277);
      }
  
      static boolean isNestedScrollable(Context context) {
          return readMaterialCalendarStyleBoolean(context, R.attr.nestedScrollable);
      }
  
      static <S> MaterialDatePicker<S> newInstance(Builder<S> builder) {
          MaterialDatePicker<S> materialDatePicker = new MaterialDatePicker<>();
          Bundle bundle = new Bundle();
          bundle.putInt(OVERRIDE_THEME_RES_ID, builder.overrideThemeResId);
          bundle.putParcelable(DATE_SELECTOR_KEY, builder.dateSelector);
          bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, builder.calendarConstraints);
          bundle.putInt(TITLE_TEXT_RES_ID_KEY, builder.titleTextResId);
          bundle.putCharSequence(TITLE_TEXT_KEY, builder.titleText);
          bundle.putInt(INPUT_MODE_KEY, builder.inputMode);
          bundle.putInt(POSITIVE_BUTTON_TEXT_RES_ID_KEY, builder.positiveButtonTextResId);
          bundle.putCharSequence(POSITIVE_BUTTON_TEXT_KEY, builder.positiveButtonText);
          bundle.putInt(NEGATIVE_BUTTON_TEXT_RES_ID_KEY, builder.negativeButtonTextResId);
          bundle.putCharSequence(NEGATIVE_BUTTON_TEXT_KEY, builder.negativeButtonText);
          materialDatePicker.setArguments(bundle);
          return materialDatePicker;
      }
  
      static boolean readMaterialCalendarStyleBoolean(Context context, int attributeResId) {
          TypedArray obtainStyledAttributes = context.obtainStyledAttributes(MaterialAttributes.resolveOrThrow(context, R.attr.materialCalendarStyle, MaterialCalendar.class.getCanonicalName()), new int[]{attributeResId});
          boolean z = obtainStyledAttributes.getBoolean(0, false);
          obtainStyledAttributes.recycle();
          return z;
      }
  
      /* access modifiers changed from: private */
      public void startPickerFragment() {
          int themeResId = getThemeResId(requireContext());
          this.calendar = MaterialCalendar.newInstance(getDateSelector(), themeResId, this.calendarConstraints);
          this.pickerFragment = this.headerToggleButton.isChecked() ? MaterialTextInputPicker.newInstance(getDateSelector(), themeResId, this.calendarConstraints) : this.calendar;
          updateHeader();
          FragmentTransaction beginTransaction = getChildFragmentManager().beginTransaction();
          beginTransaction.replace(R.id.mtrl_calendar_frame, this.pickerFragment);
          beginTransaction.commitNow();
          this.pickerFragment.addOnSelectionChangedListener(new OnSelectionChangedListener<S>() {
              public void onIncompleteSelectionChanged() {
                  MaterialDatePicker.this.confirmButton.setEnabled(false);
              }
  
              public void onSelectionChanged(S s) {
                  MaterialDatePicker.this.updateHeader();
                  MaterialDatePicker.this.confirmButton.setEnabled(MaterialDatePicker.this.getDateSelector().isSelectionComplete());
              }
          });
      }
  
      public static long thisMonthInUtcMilliseconds() {
          return Month.current().timeInMillis;
      }
  
      public static long todayInUtcMilliseconds() {
          return UtcDates.getTodayCalendar().getTimeInMillis();
      }
  
      /* access modifiers changed from: private */
      public void updateHeader() {
          String headerText = getHeaderText();
          TextView textView = this.headerSelectionText;
          String format = String.format(getString(R.string.mtrl_picker_announce_current_selection), new Object[]{headerText});
          Log1F380D.a((Object) format);
          textView.setContentDescription(format);
          this.headerSelectionText.setText(headerText);
      }
  
      /* access modifiers changed from: private */
      public void updateToggleContentDescription(CheckableImageButton toggle) {
          this.headerToggleButton.setContentDescription(this.headerToggleButton.isChecked() ? toggle.getContext().getString(R.string.mtrl_picker_toggle_to_calendar_input_mode) : toggle.getContext().getString(R.string.mtrl_picker_toggle_to_text_input_mode));
      }
  
      public boolean addOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
          return this.onCancelListeners.add(onCancelListener);
      }
  
      public boolean addOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
          return this.onDismissListeners.add(onDismissListener);
      }
  
      public boolean addOnNegativeButtonClickListener(View.OnClickListener onNegativeButtonClickListener) {
          return this.onNegativeButtonClickListeners.add(onNegativeButtonClickListener);
      }
  
      public boolean addOnPositiveButtonClickListener(MaterialPickerOnPositiveButtonClickListener<? super S> materialPickerOnPositiveButtonClickListener) {
          return this.onPositiveButtonClickListeners.add(materialPickerOnPositiveButtonClickListener);
      }
  
      public void clearOnCancelListeners() {
          this.onCancelListeners.clear();
      }
  
      public void clearOnDismissListeners() {
          this.onDismissListeners.clear();
      }
  
      public void clearOnNegativeButtonClickListeners() {
          this.onNegativeButtonClickListeners.clear();
      }
  
      public void clearOnPositiveButtonClickListeners() {
          this.onPositiveButtonClickListeners.clear();
      }
  
      public String getHeaderText() {
          return getDateSelector().getSelectionDisplayString(getContext());
      }
  
      public final S getSelection() {
          return getDateSelector().getSelection();
      }
  
      public final void onCancel(DialogInterface dialogInterface) {
          Iterator it = this.onCancelListeners.iterator();
          while (it.hasNext()) {
              ((DialogInterface.OnCancelListener) it.next()).onCancel(dialogInterface);
          }
          super.onCancel(dialogInterface);
      }
  
      public final void onCreate(Bundle bundle) {
          super.onCreate(bundle);
          Bundle arguments = bundle == null ? getArguments() : bundle;
          this.overrideThemeResId = arguments.getInt(OVERRIDE_THEME_RES_ID);
          this.dateSelector = (DateSelector) arguments.getParcelable(DATE_SELECTOR_KEY);
          this.calendarConstraints = (CalendarConstraints) arguments.getParcelable(CALENDAR_CONSTRAINTS_KEY);
          this.titleTextResId = arguments.getInt(TITLE_TEXT_RES_ID_KEY);
          this.titleText = arguments.getCharSequence(TITLE_TEXT_KEY);
          this.inputMode = arguments.getInt(INPUT_MODE_KEY);
          this.positiveButtonTextResId = arguments.getInt(POSITIVE_BUTTON_TEXT_RES_ID_KEY);
          this.positiveButtonText = arguments.getCharSequence(POSITIVE_BUTTON_TEXT_KEY);
          this.negativeButtonTextResId = arguments.getInt(NEGATIVE_BUTTON_TEXT_RES_ID_KEY);
          this.negativeButtonText = arguments.getCharSequence(NEGATIVE_BUTTON_TEXT_KEY);
      }
  
      public final Dialog onCreateDialog(Bundle bundle) {
          Dialog dialog = new Dialog(requireContext(), getThemeResId(requireContext()));
          Context context = dialog.getContext();
          this.fullscreen = isFullscreen(context);
          int resolveOrThrow = MaterialAttributes.resolveOrThrow(context, R.attr.colorSurface, MaterialDatePicker.class.getCanonicalName());
          MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(context, (AttributeSet) null, R.attr.materialCalendarStyle, R.style.Widget_MaterialComponents_MaterialCalendar);
          this.background = materialShapeDrawable;
          materialShapeDrawable.initializeElevationOverlay(context);
          this.background.setFillColor(ColorStateList.valueOf(resolveOrThrow));
          this.background.setElevation(ViewCompat.getElevation(dialog.getWindow().getDecorView()));
          return dialog;
      }
  
      public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
          View inflate = layoutInflater.inflate(this.fullscreen ? R.layout.mtrl_picker_fullscreen : R.layout.mtrl_picker_dialog, viewGroup);
          Context context = inflate.getContext();
          if (this.fullscreen) {
              inflate.findViewById(R.id.mtrl_calendar_frame).setLayoutParams(new LinearLayout.LayoutParams(getPaddedPickerWidth(context), -2));
          } else {
              inflate.findViewById(R.id.mtrl_calendar_main_pane).setLayoutParams(new LinearLayout.LayoutParams(getPaddedPickerWidth(context), -1));
          }
          TextView textView = (TextView) inflate.findViewById(R.id.mtrl_picker_header_selection_text);
          this.headerSelectionText = textView;
          ViewCompat.setAccessibilityLiveRegion(textView, 1);
          this.headerToggleButton = (CheckableImageButton) inflate.findViewById(R.id.mtrl_picker_header_toggle);
          TextView textView2 = (TextView) inflate.findViewById(R.id.mtrl_picker_title_text);
          CharSequence charSequence = this.titleText;
          if (charSequence != null) {
              textView2.setText(charSequence);
          } else {
              textView2.setText(this.titleTextResId);
          }
          initHeaderToggle(context);
          this.confirmButton = (Button) inflate.findViewById(R.id.confirm_button);
          if (getDateSelector().isSelectionComplete()) {
              this.confirmButton.setEnabled(true);
          } else {
              this.confirmButton.setEnabled(false);
          }
          this.confirmButton.setTag(CONFIRM_BUTTON_TAG);
          CharSequence charSequence2 = this.positiveButtonText;
          if (charSequence2 != null) {
              this.confirmButton.setText(charSequence2);
          } else {
              int i = this.positiveButtonTextResId;
              if (i != 0) {
                  this.confirmButton.setText(i);
              }
          }
          this.confirmButton.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  Iterator it = MaterialDatePicker.this.onPositiveButtonClickListeners.iterator();
                  while (it.hasNext()) {
                      ((MaterialPickerOnPositiveButtonClickListener) it.next()).onPositiveButtonClick(MaterialDatePicker.this.getSelection());
                  }
                  MaterialDatePicker.this.dismiss();
              }
          });
          Button button = (Button) inflate.findViewById(R.id.cancel_button);
          button.setTag(CANCEL_BUTTON_TAG);
          CharSequence charSequence3 = this.negativeButtonText;
          if (charSequence3 != null) {
              button.setText(charSequence3);
          } else {
              int i2 = this.negativeButtonTextResId;
              if (i2 != 0) {
                  button.setText(i2);
              }
          }
          button.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  Iterator it = MaterialDatePicker.this.onNegativeButtonClickListeners.iterator();
                  while (it.hasNext()) {
                      ((View.OnClickListener) it.next()).onClick(v);
                  }
                  MaterialDatePicker.this.dismiss();
              }
          });
          return inflate;
      }
  
      public final void onDismiss(DialogInterface dialogInterface) {
          Iterator it = this.onDismissListeners.iterator();
          while (it.hasNext()) {
              ((DialogInterface.OnDismissListener) it.next()).onDismiss(dialogInterface);
          }
          ViewGroup viewGroup = (ViewGroup) getView();
          if (viewGroup != null) {
              viewGroup.removeAllViews();
          }
          super.onDismiss(dialogInterface);
      }
  
      public final void onSaveInstanceState(Bundle bundle) {
          super.onSaveInstanceState(bundle);
          bundle.putInt(OVERRIDE_THEME_RES_ID, this.overrideThemeResId);
          bundle.putParcelable(DATE_SELECTOR_KEY, this.dateSelector);
          CalendarConstraints.Builder builder = new CalendarConstraints.Builder(this.calendarConstraints);
          if (this.calendar.getCurrentMonth() != null) {
              builder.setOpenAt(this.calendar.getCurrentMonth().timeInMillis);
          }
          bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, builder.build());
          bundle.putInt(TITLE_TEXT_RES_ID_KEY, this.titleTextResId);
          bundle.putCharSequence(TITLE_TEXT_KEY, this.titleText);
          bundle.putInt(POSITIVE_BUTTON_TEXT_RES_ID_KEY, this.positiveButtonTextResId);
          bundle.putCharSequence(POSITIVE_BUTTON_TEXT_KEY, this.positiveButtonText);
          bundle.putInt(NEGATIVE_BUTTON_TEXT_RES_ID_KEY, this.negativeButtonTextResId);
          bundle.putCharSequence(NEGATIVE_BUTTON_TEXT_KEY, this.negativeButtonText);
      }
  
      public void onStart() {
          super.onStart();
          Window window = requireDialog().getWindow();
          if (this.fullscreen) {
              window.setLayout(-1, -1);
              window.setBackgroundDrawable(this.background);
              enableEdgeToEdgeIfNeeded(window);
          } else {
              window.setLayout(-2, -2);
              int dimensionPixelOffset = getResources().getDimensionPixelOffset(R.dimen.mtrl_calendar_dialog_background_inset);
              Rect rect = new Rect(dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset);
              window.setBackgroundDrawable(new InsetDrawable(this.background, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset));
              window.getDecorView().setOnTouchListener(new InsetDialogOnTouchListener(requireDialog(), rect));
          }
          startPickerFragment();
      }
  
      public void onStop() {
          this.pickerFragment.clearOnSelectionChangedListeners();
          super.onStop();
      }
  
      public boolean removeOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
          return this.onCancelListeners.remove(onCancelListener);
      }
  
      public boolean removeOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
          return this.onDismissListeners.remove(onDismissListener);
      }
  
      public boolean removeOnNegativeButtonClickListener(View.OnClickListener onNegativeButtonClickListener) {
          return this.onNegativeButtonClickListeners.remove(onNegativeButtonClickListener);
      }
  
      public boolean removeOnPositiveButtonClickListener(MaterialPickerOnPositiveButtonClickListener<? super S> materialPickerOnPositiveButtonClickListener) {
          return this.onPositiveButtonClickListeners.remove(materialPickerOnPositiveButtonClickListener);
      }
  }
  