diff --git a/catalog/java/io/material/catalog/picker/PickerMainDemoFragment.java b/catalog/java/io/material/catalog/picker/PickerMainDemoFragment.java
index 9bad496a3..585bd76f7 100644
--- a/catalog/java/io/material/catalog/picker/PickerMainDemoFragment.java
+++ b/catalog/java/io/material/catalog/picker/PickerMainDemoFragment.java
@@ -22,12 +22,8 @@ import android.app.Dialog;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
-import androidx.annotation.StyleRes;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.picker.MaterialDatePickerDialog;
-import com.google.android.material.picker.MaterialDateRangePickerDialog;
-import com.google.android.material.picker.MaterialPickerDialog;
-import com.google.android.material.picker.MaterialStyledDatePickerDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -50,25 +46,19 @@ public class PickerMainDemoFragment extends DemoFragment {
frameworkTodayDatePicker(0));
addDialogLauncher(
- dialogLaunchersLayout, R.string.cat_picker_date_material, materialStyledTodayDatePicker(0));
+ dialogLaunchersLayout,
+ R.string.cat_picker_date_material,
+ materialTodayDatePicker(0));
addDialogLauncher(
dialogLaunchersLayout,
- R.string.cat_picker_styled_date_spinner,
- materialStyledTodayDatePicker(getSpinnerTheme()));
+ R.string.cat_picker_date_spinner,
+ materialTodayDatePicker(getSpinnerTheme()));
addDialogLauncher(
dialogLaunchersLayout,
- R.string.cat_picker_styled_date_calendar,
- materialStyledTodayDatePicker(getCalendarTheme()));
-
- addDialogLauncher(
- dialogLaunchersLayout, R.string.cat_picker_date_calendar, materialTodayDatePicker());
-
- addDialogLauncher(
- dialogLaunchersLayout,
- R.string.cat_picker_date_range_calendar,
- materialTodayDateRangePicker());
+ R.string.cat_picker_date_calendar,
+ materialTodayDatePicker(getCalendarTheme()));
return view;
}
@@ -89,7 +79,7 @@ public class PickerMainDemoFragment extends DemoFragment {
viewGroup.addView(dialogLauncherButton);
}
- protected DatePickerDialog frameworkTodayDatePicker(@StyleRes int themeResId) {
+ protected DatePickerDialog frameworkTodayDatePicker(int themeResId) {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
@@ -97,26 +87,12 @@ public class PickerMainDemoFragment extends DemoFragment {
return new DatePickerDialog(getContext(), themeResId, null, year, month, day);
}
- // This demo is for a transient API. Once the API is set, the RestrictTo will be removed.
@SuppressWarnings("RestrictTo")
- protected DatePickerDialog materialStyledTodayDatePicker(@StyleRes int themeResId) {
+ protected DatePickerDialog materialTodayDatePicker(int themeResId) {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
- return new MaterialStyledDatePickerDialog(getContext(), themeResId, null, year, month, day);
+ return new MaterialDatePickerDialog(getContext(), themeResId, null, year, month, day);
}
-
- // This demo is for a transient API. Once the API is set, the RestrictTo will be removed.
- @SuppressWarnings("RestrictTo")
- protected MaterialPickerDialog> materialTodayDatePicker() {
- return new MaterialDatePickerDialog(getContext());
- }
-
- // This demo is for a transient API. Once the API is set, the RestrictTo will be removed.
- @SuppressWarnings("RestrictTo")
- protected MaterialPickerDialog> materialTodayDateRangePicker() {
- return new MaterialDateRangePickerDialog(getContext());
- }
-
}
diff --git a/catalog/java/io/material/catalog/picker/res/values/strings.xml b/catalog/java/io/material/catalog/picker/res/values/strings.xml
index f7df42194..328f71f6b 100644
--- a/catalog/java/io/material/catalog/picker/res/values/strings.xml
+++ b/catalog/java/io/material/catalog/picker/res/values/strings.xml
@@ -23,14 +23,9 @@
Default Date Picker
- Material Styled Date Picker with no themeResId
-
- Material Styled Date Picker Spinner
-
- Material Styled Date Picker Calendar
+ Material Date Picker with no themeResId
+
+ Material Date picker Spinner
- Material Date Picker Calendar
-
- Material Date Range Picker Calendar
-
+ Material Date picker Calendar
diff --git a/catalog/java/io/material/catalog/tableofcontents/TocModule.java b/catalog/java/io/material/catalog/tableofcontents/TocModule.java
index 1e9e55ae7..85ea734a9 100644
--- a/catalog/java/io/material/catalog/tableofcontents/TocModule.java
+++ b/catalog/java/io/material/catalog/tableofcontents/TocModule.java
@@ -30,7 +30,6 @@ import io.material.catalog.dialog.DialogDemoLandingFragment;
import io.material.catalog.fab.FabFragment;
import io.material.catalog.font.FontFragment;
import io.material.catalog.menu.MenuFragment;
-import io.material.catalog.picker.PickerDemoLandingFragment;
import io.material.catalog.radiobutton.RadioButtonFragment;
import io.material.catalog.shapetheming.ShapeThemingFragment;
import io.material.catalog.switchmaterial.SwitchFragment;
@@ -58,7 +57,6 @@ import io.material.catalog.transformation.TransformationFragment;
FabFragment.Module.class,
FontFragment.Module.class,
MenuFragment.Module.class,
- PickerDemoLandingFragment.Module.class,
RadioButtonFragment.Module.class,
ShapeThemingFragment.Module.class,
SwitchFragment.Module.class,
diff --git a/lib/java/com/google/android/material/picker/DaysHeaderAdapter.java b/lib/java/com/google/android/material/picker/DaysHeaderAdapter.java
deleted file mode 100644
index fd427abc0..000000000
--- a/lib/java/com/google/android/material/picker/DaysHeaderAdapter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-import java.util.Calendar;
-import java.util.Locale;
-
-/**
- * A single row adapter representing the days of the week for {@link Calendar}.
- *
- *
This {@link android.widget.Adapter} respects the {@link Calendar#getFirstDayOfWeek()}
- * determined by {@link Locale#getDefault()}.
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public class DaysHeaderAdapter extends BaseAdapter {
-
- private final Calendar calendar;
- private final int daysInWeek;
- private final int firstDayOfWeek;
- /** Style value from Calendar.NARROW_FORMAT unavailable before 1.8 */
- private static final int NARROW_FORMAT = 4;
- private static final int CALENDAR_DAY_STYLE =
- VERSION.SDK_INT >= VERSION_CODES.O ? NARROW_FORMAT : Calendar.SHORT;
-
- public DaysHeaderAdapter() {
- calendar = Calendar.getInstance();
- daysInWeek = calendar.getMaximum(Calendar.DAY_OF_WEEK);
- firstDayOfWeek = calendar.getFirstDayOfWeek();
- }
-
- @Override
- public Integer getItem(int position) {
- if (position >= daysInWeek) {
- return null;
- }
- return positionToDayOfWeek(position);
- }
-
- @Override
- public long getItemId(int position) {
- // There is only 1 row
- return 0;
- }
-
- @Override
- public int getCount() {
- return daysInWeek;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- TextView day = (TextView) convertView;
- if (convertView == null) {
- day = new TextView(parent.getContext());
- }
- calendar.set(Calendar.DAY_OF_WEEK, positionToDayOfWeek(position));
- day.setText(
- calendar.getDisplayName(Calendar.DAY_OF_WEEK, CALENDAR_DAY_STYLE, Locale.getDefault()));
- return day;
- }
-
- private int positionToDayOfWeek(int position) {
- // Day Constants start at 1
- int dayConstant = position + firstDayOfWeek;
- if (dayConstant > daysInWeek) {
- dayConstant = dayConstant - daysInWeek;
- }
- return dayConstant;
- }
-}
diff --git a/lib/java/com/google/android/material/picker/MaterialCalendarView.java b/lib/java/com/google/android/material/picker/MaterialCalendarView.java
deleted file mode 100644
index 6984ab66a..000000000
--- a/lib/java/com/google/android/material/picker/MaterialCalendarView.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import android.content.Context;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.appcompat.widget.LinearLayoutCompat;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.GridView;
-import android.widget.LinearLayout;
-import java.util.Calendar;
-
-/**
- * View for a days of week {@link Calendar} represented as a header row of days labels and {@link
- * GridView} of days backed by {@link MonthInYearAdapter}.
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public abstract class MaterialCalendarView extends LinearLayoutCompat {
-
- private final MonthInYearAdapter monthInYearAdapter;
-
- public MaterialCalendarView(Context context) {
- this(context, null);
- }
-
- public MaterialCalendarView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public MaterialCalendarView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- setOrientation(LinearLayout.VERTICAL);
-
- LayoutInflater layoutInflater = LayoutInflater.from(context);
- layoutInflater.inflate(R.layout.date_picker_calendar_days_header, this);
- layoutInflater.inflate(R.layout.date_picker_calendar_days, this);
- GridView daysHeader = findViewById(R.id.date_picker_calendar_days_header);
- GridView daysGrid = findViewById(R.id.date_picker_calendar_days);
-
- Calendar calendar = Calendar.getInstance();
- MonthInYear monthInYear =
- MonthInYear.create(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH));
- monthInYearAdapter = new MonthInYearAdapter(context, monthInYear);
-
- daysHeader.setAdapter(new DaysHeaderAdapter());
- daysHeader.setNumColumns(monthInYear.daysInWeek);
- daysGrid.setAdapter(monthInYearAdapter);
- daysGrid.setNumColumns(monthInYear.daysInWeek);
- daysGrid.setOnItemClickListener(
- new OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- getOnItemClickListener().onItemClick(parent, view, position, id);
- drawSelection(parent);
- // Allows users of MaterialCalendarView to set an OnClickListener
- if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
- callOnClick();
- } else {
- performClick();
- }
- }
- });
- }
-
- protected final MonthInYearAdapter getMonthInYearAdapter() {
- return monthInYearAdapter;
- }
-
- @Nullable
- protected abstract S getSelection();
-
- protected abstract void drawSelection(AdapterView> parent);
-
- protected abstract OnItemClickListener getOnItemClickListener();
-}
diff --git a/lib/java/com/google/android/material/picker/MaterialDatePickerDialog.java b/lib/java/com/google/android/material/picker/MaterialDatePickerDialog.java
index 080c82726..07c09f41b 100644
--- a/lib/java/com/google/android/material/picker/MaterialDatePickerDialog.java
+++ b/lib/java/com/google/android/material/picker/MaterialDatePickerDialog.java
@@ -18,45 +18,97 @@ package com.google.android.material.picker;
import com.google.android.material.R;
-import android.app.Dialog;
+import android.app.DatePickerDialog;
import android.content.Context;
+import android.content.res.ColorStateList;
+import android.graphics.Color;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Build.VERSION_CODES;
+import android.os.Bundle;
+import androidx.annotation.AttrRes;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
-import java.util.Calendar;
+import androidx.annotation.StyleRes;
+import com.google.android.material.dialog.InsetDialogOnTouchListener;
+import com.google.android.material.dialog.MaterialDialogs;
+import com.google.android.material.resources.MaterialAttributes;
+import com.google.android.material.shape.MaterialShapeDrawable;
+import android.util.TypedValue;
/**
- * A {@link Dialog} with a header, {@link MaterialDatePickerView}, and set of actions.
+ * A Material version of {@link android.app.DatePickerDialog}
*
* @hide
*/
@RestrictTo(Scope.LIBRARY_GROUP)
-public class MaterialDatePickerDialog extends MaterialPickerDialog {
+public class MaterialDatePickerDialog extends DatePickerDialog {
- private final MaterialDatePickerView materialDatePicker;
+ @AttrRes private static final int DEF_STYLE_ATTR = android.R.attr.datePickerStyle;
- public MaterialDatePickerDialog(Context context) {
+ @StyleRes
+ private static final int DEF_STYLE_RES =
+ R.style.MaterialAlertDialog_MaterialComponents_Picker_Date_Spinner;
+
+ private final Drawable background;
+ private final Rect backgroundInsets;
+
+ public MaterialDatePickerDialog(@NonNull Context context) {
this(context, 0);
}
- public MaterialDatePickerDialog(Context context, int themeResId) {
- super(context, getThemeResource(context, R.attr.materialDatePickerDialogTheme, themeResId));
- // Ensure we are using the correctly themed context rather than the context that was passed in.
+ public MaterialDatePickerDialog(@NonNull Context context, int themeResId) {
+ this(context, themeResId, null, -1, -1, -1);
+ }
+
+ public MaterialDatePickerDialog(
+ @NonNull Context context,
+ @Nullable OnDateSetListener listener,
+ int year,
+ int month,
+ int dayOfMonth) {
+ this(context, 0, listener, year, month, dayOfMonth);
+ }
+
+ public MaterialDatePickerDialog(
+ @NonNull Context context,
+ int themeResId,
+ @Nullable OnDateSetListener listener,
+ int year,
+ int monthOfYear,
+ int dayOfMonth) {
+
+ super(context, themeResId, listener, year, monthOfYear, dayOfMonth);
context = getContext();
- materialDatePicker = new MaterialDatePickerView(context);
- }
- @Override
- protected MaterialCalendarView getMaterialCalendarView() {
- return materialDatePicker;
- }
+ TypedValue colorSurfaceValue =
+ MaterialAttributes.resolveAttributeOrThrow(
+ getContext(), R.attr.colorSurface, getClass().getCanonicalName());
+ int surfaceColor = colorSurfaceValue.data;
- @Override
- protected String getHeaderText() {
- Calendar selectedDate = materialDatePicker.getSelection();
- if (selectedDate == null) {
- return getContext().getResources().getString(R.string.header_prompt);
+ MaterialShapeDrawable materialShapeDrawable =
+ new MaterialShapeDrawable(context, null, DEF_STYLE_ATTR, DEF_STYLE_RES);
+ // Pre-L, windowBackground is a second background behind the Picker Dialog.
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ materialShapeDrawable.setFillColor(ColorStateList.valueOf(surfaceColor));
+ } else {
+ materialShapeDrawable.setFillColor(ColorStateList.valueOf(Color.TRANSPARENT));
}
- String startString = getSimpleDateFormat().format(selectedDate.getTime());
- return getContext().getResources().getString(R.string.header_selected, startString);
+
+ backgroundInsets =
+ MaterialDialogs.getDialogBackgroundInsets(context, DEF_STYLE_ATTR, DEF_STYLE_RES);
+ background = MaterialDialogs.insetDrawable(materialShapeDrawable, backgroundInsets);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setBackgroundDrawable(background);
+ getWindow()
+ .getDecorView()
+ .setOnTouchListener(new InsetDialogOnTouchListener(this, backgroundInsets));
}
}
diff --git a/lib/java/com/google/android/material/picker/MaterialDatePickerView.java b/lib/java/com/google/android/material/picker/MaterialDatePickerView.java
deleted file mode 100644
index 2167e38e1..000000000
--- a/lib/java/com/google/android/material/picker/MaterialDatePickerView.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.core.view.ViewCompat;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import java.util.Calendar;
-
-/**
- * A {@link MaterialCalendarView} that supports single date selection
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public class MaterialDatePickerView extends MaterialCalendarView {
-
- private static final int DEF_STYLE_ATTR = R.attr.materialDatePickerStyle;
- private static final ColorDrawable emptyColor = new ColorDrawable(Color.TRANSPARENT);
- private static final ColorDrawable selectedColor = new ColorDrawable(Color.RED);
-
- private int selectedPosition = -1;
- private final OnItemClickListener onItemClickListener;
-
- public MaterialDatePickerView(Context context) {
- this(context, null);
- }
-
- public MaterialDatePickerView(Context context, AttributeSet attrs) {
- this(context, attrs, DEF_STYLE_ATTR);
- }
-
- public MaterialDatePickerView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- onItemClickListener =
- new OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- if (!getMonthInYearAdapter().withinMonth(position)) {
- return;
- }
- selectedPosition = position;
- }
- };
- }
-
- @Override
- protected OnItemClickListener getOnItemClickListener() {
- return onItemClickListener;
- }
-
- @Override
- protected void drawSelection(AdapterView> parent) {
- for (int i = 0; i < parent.getCount(); i++) {
- ViewCompat.setBackground(
- parent.getChildAt(i), i == selectedPosition ? selectedColor : emptyColor);
- }
- }
-
- @Override
- public Calendar getSelection() {
- return getMonthInYearAdapter().getItem(selectedPosition);
- }
-}
diff --git a/lib/java/com/google/android/material/picker/MaterialDateRangePickerDialog.java b/lib/java/com/google/android/material/picker/MaterialDateRangePickerDialog.java
deleted file mode 100644
index a1b863deb..000000000
--- a/lib/java/com/google/android/material/picker/MaterialDateRangePickerDialog.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import android.app.Dialog;
-import android.content.Context;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import android.util.Pair;
-import java.util.Calendar;
-
-/**
- * A {@link Dialog} with a header, {@link MaterialDateRangePickerView}, and set of actions.
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public class MaterialDateRangePickerDialog extends MaterialPickerDialog> {
-
- private final MaterialDateRangePickerView materialDateRangePicker;
-
- public MaterialDateRangePickerDialog(Context context) {
- this(context, 0);
- }
-
- public MaterialDateRangePickerDialog(Context context, int themeResId) {
- super(
- context, getThemeResource(context, R.attr.materialDateRangePickerDialogTheme, themeResId));
- // Ensure we are using the correctly themed context rather than the context that was passed in.
- context = getContext();
- materialDateRangePicker = new MaterialDateRangePickerView(context);
- }
-
- @Override
- protected MaterialCalendarView> getMaterialCalendarView() {
- return materialDateRangePicker;
- }
-
- @Override
- protected String getHeaderText() {
- Pair startAndEnd = materialDateRangePicker.getSelection();
- if (startAndEnd == null) {
- return getContext().getResources().getString(R.string.range_header_prompt);
- }
- String startString = getSimpleDateFormat().format(startAndEnd.first.getTime());
- String endString = getSimpleDateFormat().format(startAndEnd.second.getTime());
- return getContext()
- .getResources()
- .getString(R.string.range_header_selected, startString, endString);
- }
-}
diff --git a/lib/java/com/google/android/material/picker/MaterialDateRangePickerView.java b/lib/java/com/google/android/material/picker/MaterialDateRangePickerView.java
deleted file mode 100644
index c30f6510b..000000000
--- a/lib/java/com/google/android/material/picker/MaterialDateRangePickerView.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.core.view.ViewCompat;
-import android.util.AttributeSet;
-import android.util.Pair;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import java.util.Calendar;
-
-/**
- * A {@link MaterialCalendarView} that supports range selection
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public class MaterialDateRangePickerView extends MaterialCalendarView> {
-
- private static final int DEF_STYLE_ATTR = R.attr.materialDateRangePickerStyle;
-
- private static final ColorDrawable emptyColor = new ColorDrawable(Color.TRANSPARENT);
- private static final ColorDrawable startColor = new ColorDrawable(Color.RED);
- private static final ColorDrawable endColor = new ColorDrawable(Color.GREEN);
- private static final ColorDrawable rangeColor = new ColorDrawable(Color.YELLOW);
-
- private final OnItemClickListener onItemClickListener;
- private int selectedStartPosition = -1;
- private int selectedEndPosition = -1;
-
- public MaterialDateRangePickerView(Context context) {
- this(context, null);
- }
-
- public MaterialDateRangePickerView(Context context, AttributeSet attrs) {
- this(context, attrs, DEF_STYLE_ATTR);
- }
-
- public MaterialDateRangePickerView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- onItemClickListener =
- new OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- if (!getMonthInYearAdapter().withinMonth(position)) {
- return;
- }
- if (selectedStartPosition < 0) {
- selectedStartPosition = position;
- } else if (selectedEndPosition < 0 && position > selectedStartPosition) {
- selectedEndPosition = position;
- } else {
- selectedEndPosition = -1;
- selectedStartPosition = position;
- }
- }
- };
- }
-
- @Override
- protected OnItemClickListener getOnItemClickListener() {
- return onItemClickListener;
- }
-
- @Override
- protected void drawSelection(AdapterView> parent) {
- for (int i = 0; i < parent.getCount(); i++) {
- ColorDrawable setColor = emptyColor;
- if (i == selectedStartPosition) {
- setColor = startColor;
- } else if (i == selectedEndPosition) {
- setColor = endColor;
- } else if (i > selectedStartPosition && i < selectedEndPosition) {
- setColor = rangeColor;
- }
- ViewCompat.setBackground(parent.getChildAt(i), setColor);
- }
- }
-
- @Override
- @Nullable
- public Pair getSelection() {
- Calendar start = getStart();
- Calendar end = getEnd();
- if (start == null || end == null) {
- return null;
- }
- return new Pair<>(getStart(), getEnd());
- }
-
- @Nullable
- public Calendar getStart() {
- return getMonthInYearAdapter().getItem(selectedStartPosition);
- }
-
- @Nullable
- public Calendar getEnd() {
- return getMonthInYearAdapter().getItem(selectedEndPosition);
- }
-}
diff --git a/lib/java/com/google/android/material/picker/MaterialPickerDialog.java b/lib/java/com/google/android/material/picker/MaterialPickerDialog.java
deleted file mode 100644
index 6337528fc..000000000
--- a/lib/java/com/google/android/material/picker/MaterialPickerDialog.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.annotation.StyleRes;
-import android.util.TypedValue;
-import android.view.View;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-
-/**
- * A {@link Dialog} with a header, {@link MaterialCalendarView}, and set of actions.
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public abstract class MaterialPickerDialog extends Dialog {
-
- private SimpleDateFormat simpleDateFormat =
- new SimpleDateFormat("MMM dd, yyyy", Locale.getDefault());
-
- private TextView header;
- private S selection;
- private MaterialCalendarView extends S> materialCalendarView;
-
- @StyleRes
- protected static final int getThemeResource(
- Context context, int defaultThemeAttr, int themeResId) {
- if (themeResId != 0) {
- return themeResId;
- }
- TypedValue outValue = new TypedValue();
- context.getTheme().resolveAttribute(defaultThemeAttr, outValue, true);
- return outValue.resourceId;
- }
-
- public MaterialPickerDialog(Context context) {
- this(context, 0);
- }
-
- public MaterialPickerDialog(Context context, int themeResId) {
- super(context, themeResId);
- }
-
- /**
- * Returns a {@link S} instance representing the selection or null if the user has not confirmed a
- * selection.
- */
- @Nullable
- public final S getSelection() {
- return selection;
- }
-
- @Override
- protected final void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- materialCalendarView = getMaterialCalendarView();
-
- setContentView(R.layout.date_picker_dialog);
- header = findViewById(R.id.date_picker_header_title);
- FrameLayout calendarViewFrame = findViewById(R.id.date_picker_calendar_view_frame);
- calendarViewFrame.addView(materialCalendarView);
- materialCalendarView.setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- updateHeader();
- }
- });
-
- Button confirmButton = findViewById(R.id.confirm_button);
- Button cancelButton = findViewById(R.id.cancel_button);
-
- confirmButton.setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- selection = materialCalendarView.getSelection();
- dismiss();
- }
- });
- cancelButton.setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- selection = null;
- cancel();
- }
- });
- updateHeader();
- }
-
- private void updateHeader() {
- header.setText(getHeaderText());
- }
-
- public final void setSimpleDateFormat(SimpleDateFormat simpleDateFormat) {
- this.simpleDateFormat = simpleDateFormat;
- }
-
- public final SimpleDateFormat getSimpleDateFormat() {
- return simpleDateFormat;
- }
-
- protected abstract String getHeaderText();
-
- protected abstract MaterialCalendarView extends S> getMaterialCalendarView();
-}
diff --git a/lib/java/com/google/android/material/picker/MaterialStyledDatePickerDialog.java b/lib/java/com/google/android/material/picker/MaterialStyledDatePickerDialog.java
deleted file mode 100644
index 404d923ef..000000000
--- a/lib/java/com/google/android/material/picker/MaterialStyledDatePickerDialog.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import android.app.DatePickerDialog;
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.graphics.Color;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Build.VERSION_CODES;
-import android.os.Bundle;
-import androidx.annotation.AttrRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.annotation.StyleRes;
-import com.google.android.material.dialog.InsetDialogOnTouchListener;
-import com.google.android.material.dialog.MaterialDialogs;
-import com.google.android.material.resources.MaterialAttributes;
-import com.google.android.material.shape.MaterialShapeDrawable;
-import android.util.TypedValue;
-
-/**
- * A Material version of {@link android.app.DatePickerDialog}
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public class MaterialStyledDatePickerDialog extends DatePickerDialog {
-
- @AttrRes private static final int DEF_STYLE_ATTR = android.R.attr.datePickerStyle;
-
- @StyleRes
- private static final int DEF_STYLE_RES =
- R.style.MaterialAlertDialog_MaterialComponents_Picker_Date_Spinner;
-
- private final Drawable background;
- private final Rect backgroundInsets;
-
- public MaterialStyledDatePickerDialog(@NonNull Context context) {
- this(context, 0);
- }
-
- public MaterialStyledDatePickerDialog(@NonNull Context context, int themeResId) {
- this(context, themeResId, null, -1, -1, -1);
- }
-
- public MaterialStyledDatePickerDialog(
- @NonNull Context context,
- @Nullable OnDateSetListener listener,
- int year,
- int month,
- int dayOfMonth) {
- this(context, 0, listener, year, month, dayOfMonth);
- }
-
- public MaterialStyledDatePickerDialog(
- @NonNull Context context,
- int themeResId,
- @Nullable OnDateSetListener listener,
- int year,
- int monthOfYear,
- int dayOfMonth) {
-
- super(context, themeResId, listener, year, monthOfYear, dayOfMonth);
- context = getContext();
-
- TypedValue colorSurfaceValue =
- MaterialAttributes.resolveAttributeOrThrow(
- getContext(), R.attr.colorSurface, getClass().getCanonicalName());
- int surfaceColor = colorSurfaceValue.data;
-
- MaterialShapeDrawable materialShapeDrawable =
- new MaterialShapeDrawable(context, null, DEF_STYLE_ATTR, DEF_STYLE_RES);
- // Pre-L, windowBackground is a second background behind the Picker Dialog.
- if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
- materialShapeDrawable.setFillColor(ColorStateList.valueOf(surfaceColor));
- } else {
- materialShapeDrawable.setFillColor(ColorStateList.valueOf(Color.TRANSPARENT));
- }
-
- backgroundInsets =
- MaterialDialogs.getDialogBackgroundInsets(context, DEF_STYLE_ATTR, DEF_STYLE_RES);
- background = MaterialDialogs.insetDrawable(materialShapeDrawable, backgroundInsets);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setBackgroundDrawable(background);
- getWindow()
- .getDecorView()
- .setOnTouchListener(new InsetDialogOnTouchListener(this, backgroundInsets));
- }
-}
diff --git a/lib/java/com/google/android/material/picker/MonthInYear.java b/lib/java/com/google/android/material/picker/MonthInYear.java
deleted file mode 100644
index 780714878..000000000
--- a/lib/java/com/google/android/material/picker/MonthInYear.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import java.util.Arrays;
-import java.util.Calendar;
-
-/**
- * Contains convenience operations for a month within a specific year.
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public class MonthInYear {
-
- private final Calendar monthInYear;
- public final int month;
- public final int year;
- public final int daysInWeek;
- public final int daysInMonth;
-
- private MonthInYear(Calendar calendar) {
- this.monthInYear = calendar;
- monthInYear.set(Calendar.DAY_OF_MONTH, 1);
- month = calendar.get(Calendar.MONTH);
- year = calendar.get(Calendar.YEAR);
- daysInWeek = monthInYear.getMaximum(Calendar.DAY_OF_WEEK);
- daysInMonth = monthInYear.getActualMaximum(Calendar.DAY_OF_MONTH);
- }
-
- /**
- * Creates an instance of MonthInYear with the given parameters backed by a {@link Calendar}.
- *
- * @param year The year
- * @param month The 0-index based month. Use {@link Calendar} constants (e.g., {@link
- * Calendar#JANUARY}
- * @return A MonthInYear object backed by a new {@link Calendar} instance
- */
- public static MonthInYear create(int year, int month) {
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.YEAR, year);
- calendar.set(Calendar.MONTH, month);
- return new MonthInYear(calendar);
- }
-
- public int daysFromStartOfWeekToFirstOfMonth() {
- int difference = monthInYear.get(Calendar.DAY_OF_WEEK) - monthInYear.getFirstDayOfWeek();
- if (difference < 0) {
- difference = difference + daysInWeek;
- }
- return difference;
- }
-
- /**
- * Gets a {@link Calendar} for the specific day within the instance's month and year.
- *
- *
This method only guarantees validity with respect to {@link Calendar#isLenient()}.
- *
- * @param day The desired day within this month and year
- * @return A new {@link Calendar} instance for the given day within the specified month and year
- */
- public Calendar getDay(int day) {
- Calendar calendar = ((Calendar) monthInYear.clone());
- calendar.set(Calendar.DAY_OF_MONTH, day);
- return calendar;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof MonthInYear)) {
- return false;
- }
- MonthInYear that = (MonthInYear) o;
- return month == that.month && year == that.year;
- }
-
- @Override
- public int hashCode() {
- Object[] hashedFields = {month, year};
- return Arrays.hashCode(hashedFields);
- }
-}
diff --git a/lib/java/com/google/android/material/picker/MonthInYearAdapter.java b/lib/java/com/google/android/material/picker/MonthInYearAdapter.java
deleted file mode 100644
index c7abb36c6..000000000
--- a/lib/java/com/google/android/material/picker/MonthInYearAdapter.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import android.content.Context;
-import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import com.google.android.material.resources.MaterialAttributes;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-import java.util.Calendar;
-
-/**
- * Represents the days of a month with {@link TextView} instances for each day.
- *
- *
The number of rows is always equal to the maximum number of weeks that can exist across all
- * months (e.g., 6 for the GregorianCalendar).
- *
- * @hide
- */
-@RestrictTo(Scope.LIBRARY_GROUP)
-public class MonthInYearAdapter extends BaseAdapter {
-
- private static final int MAXIMUM_WEEKS =
- Calendar.getInstance().getMaximum(Calendar.WEEK_OF_MONTH);
-
- private final MonthInYear monthInYear;
- private final int textViewSize;
-
- MonthInYearAdapter(Context context, MonthInYear monthInYear) {
- this.monthInYear = monthInYear;
- TypedValue minTouchTargetSizeValue =
- MaterialAttributes.resolveAttribute(context, R.attr.minTouchTargetSize);
- if (minTouchTargetSizeValue == null) {
- textViewSize = (int) context.getResources().getDimension(R.dimen.mtrl_min_touch_target_size);
- } else {
- textViewSize =
- (int) minTouchTargetSizeValue.getDimension(context.getResources().getDisplayMetrics());
- }
- }
-
- /**
- * Returns a {@link Calendar} object for the given grid position
- *
- * @param position Index for the item. 0 matches the {@link Calendar#getFirstDayOfWeek()} for the
- * first week of the month represented by {@link MonthInYear}.
- * @return An {@link Calendar} representing the Day at the position or null if the position does
- * not represent a valid day in the month.
- */
- @Nullable
- @Override
- public Calendar getItem(int position) {
- if (position < monthInYear.daysFromStartOfWeekToFirstOfMonth()
- || position > lastPositionInMonth()) {
- return null;
- }
- return monthInYear.getDay(positionToDay(position));
- }
-
- @Override
- public long getItemId(int position) {
- return position / monthInYear.daysInWeek;
- }
-
- /**
- * Returns the number of days in a week times the maximum number of weeks in any possible month.
- * This number is at least the number of days in the month.
- *
- * @return The maximum valid position index
- */
- @Override
- public int getCount() {
- return monthInYear.daysInWeek * MAXIMUM_WEEKS;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- TextView day = (TextView) convertView;
- if (convertView == null) {
- day = new TextView(parent.getContext());
- day.setHeight(textViewSize);
- }
- int offsetPosition = position - firstPositionInMonth();
- if (offsetPosition < 0 || offsetPosition >= monthInYear.daysInMonth) {
- day.setVisibility(View.INVISIBLE);
- } else {
- day.setText(String.valueOf(offsetPosition + 1));
- day.setVisibility(View.VISIBLE);
- }
- return day;
- }
-
- /**
- * Returns the index of the first position which is part of the month.
- *
- *
For example, this returns the position index representing February 1st. Since position 0
- * represents a day which must be the first day of the week, the first position in the month may
- * be greater than 0.
- */
- public int firstPositionInMonth() {
- return monthInYear.daysFromStartOfWeekToFirstOfMonth();
- }
-
- /**
- * Returns the index of the last position which is part of the month.
- *
- *
For example, this returns the position index representing November 30th. Since position 0
- * represents a day which must be the first day of the week, the last position in the month may
- * not match the number of days in the month.
- */
- public int lastPositionInMonth() {
- return monthInYear.daysFromStartOfWeekToFirstOfMonth() + monthInYear.daysInMonth - 1;
- }
-
- /**
- * Returns the day representing the provided adapter index
- *
- * @param position The adapter index
- * @return The day corresponding to the adapter index. May be non-positive for position inputs
- * less than {@link MonthInYearAdapter#firstPositionInMonth()}.
- */
- public int positionToDay(int position) {
- return position - monthInYear.daysFromStartOfWeekToFirstOfMonth() + 1;
- }
-
- /** True when a provided adapter position is within the calendar month */
- public boolean withinMonth(int position) {
- return position >= firstPositionInMonth() && position <= lastPositionInMonth();
- }
-}
diff --git a/lib/java/com/google/android/material/picker/res/layout/date_picker_actions.xml b/lib/java/com/google/android/material/picker/res/layout/date_picker_actions.xml
deleted file mode 100644
index 5f831a781..000000000
--- a/lib/java/com/google/android/material/picker/res/layout/date_picker_actions.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/java/com/google/android/material/picker/res/layout/date_picker_calendar_days.xml b/lib/java/com/google/android/material/picker/res/layout/date_picker_calendar_days.xml
deleted file mode 100644
index a197e4df6..000000000
--- a/lib/java/com/google/android/material/picker/res/layout/date_picker_calendar_days.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
diff --git a/lib/java/com/google/android/material/picker/res/layout/date_picker_calendar_days_header.xml b/lib/java/com/google/android/material/picker/res/layout/date_picker_calendar_days_header.xml
deleted file mode 100644
index e692ab5cf..000000000
--- a/lib/java/com/google/android/material/picker/res/layout/date_picker_calendar_days_header.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
diff --git a/lib/java/com/google/android/material/picker/res/layout/date_picker_dialog.xml b/lib/java/com/google/android/material/picker/res/layout/date_picker_dialog.xml
deleted file mode 100644
index 79362ffd2..000000000
--- a/lib/java/com/google/android/material/picker/res/layout/date_picker_dialog.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/java/com/google/android/material/picker/res/layout/date_picker_header.xml b/lib/java/com/google/android/material/picker/res/layout/date_picker_header.xml
deleted file mode 100644
index 8f6128e0d..000000000
--- a/lib/java/com/google/android/material/picker/res/layout/date_picker_header.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/lib/java/com/google/android/material/picker/res/values-v21/styles.xml b/lib/java/com/google/android/material/picker/res/values-v21/styles.xml
index e6e5a5c77..dea21e27f 100644
--- a/lib/java/com/google/android/material/picker/res/values-v21/styles.xml
+++ b/lib/java/com/google/android/material/picker/res/values-v21/styles.xml
@@ -34,6 +34,7 @@
@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog.Picker.Date.Header.Text@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog.Picker.Date.Header.Text.Day@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog.Picker.Date.Header.Text
+
-
-
-
-
diff --git a/lib/java/com/google/android/material/picker/res/values/themes.xml b/lib/java/com/google/android/material/picker/res/values/themes.xml
index 8b2cea3d5..e1698759e 100644
--- a/lib/java/com/google/android/material/picker/res/values/themes.xml
+++ b/lib/java/com/google/android/material/picker/res/values/themes.xml
@@ -20,8 +20,4 @@
-
-
-
-
diff --git a/lib/java/com/google/android/material/theme/res/values/attrs.xml b/lib/java/com/google/android/material/theme/res/values/attrs.xml
index bd4768e80..a7113dc6c 100644
--- a/lib/java/com/google/android/material/theme/res/values/attrs.xml
+++ b/lib/java/com/google/android/material/theme/res/values/attrs.xml
@@ -88,11 +88,6 @@
-
-
-
-
-
diff --git a/lib/java/com/google/android/material/theme/res/values/themes_base.xml b/lib/java/com/google/android/material/theme/res/values/themes_base.xml
index b447d778b..47619207e 100644
--- a/lib/java/com/google/android/material/theme/res/values/themes_base.xml
+++ b/lib/java/com/google/android/material/theme/res/values/themes_base.xml
@@ -70,12 +70,6 @@
?attr/textAppearanceSubtitle1?attr/textAppearanceSubtitle1
-
-
- @style/Widget.MaterialComponents.DatePicker
- @style/Widget.MaterialComponents.DateRangePicker
- @style/ThemeOverlay.MaterialComponents.DatePicker
- @style/ThemeOverlay.MaterialComponents.DateRangePicker
-
-
-
-
-
-
-
diff --git a/lib/javatests/com/google/android/material/picker/MonthInYearAdapterTest.java b/lib/javatests/com/google/android/material/picker/MonthInYearAdapterTest.java
deleted file mode 100644
index fd055f063..000000000
--- a/lib/javatests/com/google/android/material/picker/MonthInYearAdapterTest.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import com.google.android.material.R;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import android.content.Context;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.test.core.app.ApplicationProvider;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.internal.DoNotInstrument;
-
-@RunWith(RobolectricTestRunner.class)
-@DoNotInstrument
-public class MonthInYearAdapterTest {
-
- private static final Locale ISRAEL = new Locale("iw", "IL");
-
- private Context context;
- private MonthInYearAdapter monthInYearFeb2019;
- private MonthInYearAdapter monthInYearFeb2016;
- private MonthInYearAdapter monthInYearJul2018;
- private MonthInYearAdapter monthInYearMarch2019;
-
- @Before
- public void setupMonthInYearAdapters() {
- ApplicationProvider.getApplicationContext().setTheme(R.style.Theme_MaterialComponents_Light);
- AppCompatActivity activity = Robolectric.buildActivity(AppCompatActivity.class).setup().get();
- context = activity.getApplicationContext();
- }
-
- private void setupLocalizedCalendars(Locale locale) {
- Locale.setDefault(locale);
- monthInYearFeb2016 =
- new MonthInYearAdapter(context, MonthInYear.create(2016, Calendar.FEBRUARY));
- monthInYearJul2018 = new MonthInYearAdapter(context, MonthInYear.create(2018, Calendar.JULY));
- monthInYearFeb2019 =
- new MonthInYearAdapter(context, MonthInYear.create(2019, Calendar.FEBRUARY));
- monthInYearMarch2019 =
- new MonthInYearAdapter(context, MonthInYear.create(2019, Calendar.MARCH));
- }
-
- @Test
- public void testUsLastPositionMatchesMonthLength() {
- setupLocalizedCalendars(Locale.US);
- assertLastPositionMatchesMonthLength();
- }
-
- @Test
- public void testFrLastPositionMatchesMonthLength() {
- setupLocalizedCalendars(Locale.FRANCE);
- assertLastPositionMatchesMonthLength();
- }
-
- @Test
- public void testIlLastPositionMatchesMonthLength() {
- setupLocalizedCalendars(ISRAEL);
- assertLastPositionMatchesMonthLength();
- }
-
- private void assertLastPositionMatchesMonthLength() {
- assertEquals(29, monthInYearFeb2016.positionToDay(monthInYearFeb2016.lastPositionInMonth()));
- assertEquals(31, monthInYearJul2018.positionToDay(monthInYearJul2018.lastPositionInMonth()));
- assertEquals(28, monthInYearFeb2019.positionToDay(monthInYearFeb2019.lastPositionInMonth()));
- }
-
- @Test
- public void testUsMaxPosition() {
- setupLocalizedCalendars(Locale.US);
- Map localizedMaxPositionInMonth = new HashMap<>();
- localizedMaxPositionInMonth.put(monthInYearFeb2016, 29);
- localizedMaxPositionInMonth.put(monthInYearJul2018, 30);
- localizedMaxPositionInMonth.put(monthInYearFeb2019, 32);
- assertMaxPosition(localizedMaxPositionInMonth);
- }
-
- @Test
- public void testFrMaxPosition() {
- setupLocalizedCalendars(Locale.FRANCE);
- Map localizedMaxPositionInMonth = new HashMap<>();
- localizedMaxPositionInMonth.put(monthInYearFeb2016, 28);
- localizedMaxPositionInMonth.put(monthInYearJul2018, 36);
- localizedMaxPositionInMonth.put(monthInYearFeb2019, 31);
- assertMaxPosition(localizedMaxPositionInMonth);
- }
-
- @Test
- public void testIlMaxPosition() {
- setupLocalizedCalendars(ISRAEL);
- Map localizedMaxPositionInMonth = new HashMap<>();
- localizedMaxPositionInMonth.put(monthInYearFeb2016, 29);
- localizedMaxPositionInMonth.put(monthInYearJul2018, 30);
- localizedMaxPositionInMonth.put(monthInYearFeb2019, 32);
- assertMaxPosition(localizedMaxPositionInMonth);
- }
-
- private void assertMaxPosition(Map localizedMaxPositionInMonth) {
- assertEquals(
- (int) localizedMaxPositionInMonth.get(monthInYearFeb2016),
- monthInYearFeb2016.lastPositionInMonth());
- assertEquals(
- (int) localizedMaxPositionInMonth.get(monthInYearJul2018),
- monthInYearJul2018.lastPositionInMonth());
- assertEquals(
- (int) localizedMaxPositionInMonth.get(monthInYearFeb2019),
- monthInYearFeb2019.lastPositionInMonth());
- }
-
- @Test
- public void testUsPositions() {
- setupLocalizedCalendars(Locale.US);
- Map localizedPositionToDay =
- localizedPositionToDay = new HashMap<>();
- localizedPositionToDay.put(monthInYearFeb2016, 1);
- localizedPositionToDay.put(monthInYearJul2018, 7);
- localizedPositionToDay.put(monthInYearFeb2019, 11);
- assertPositionsForDays(localizedPositionToDay);
- }
-
- @Test
- public void testFrPositions() {
- setupLocalizedCalendars(Locale.FRANCE);
- Map localizedPositionToDay =
- localizedPositionToDay = new HashMap<>();
- localizedPositionToDay.put(monthInYearFeb2016, 2);
- localizedPositionToDay.put(monthInYearJul2018, 1);
- localizedPositionToDay.put(monthInYearFeb2019, 12);
- assertPositionsForDays(localizedPositionToDay);
- }
-
- @Test
- public void testIlPositions() {
- setupLocalizedCalendars(ISRAEL);
- Map localizedPositionToDay =
- localizedPositionToDay = new HashMap<>();
- localizedPositionToDay.put(monthInYearFeb2016, 1);
- localizedPositionToDay.put(monthInYearJul2018, 7);
- localizedPositionToDay.put(monthInYearFeb2019, 11);
- assertPositionsForDays(localizedPositionToDay);
- }
-
- private void assertPositionsForDays(Map localizedPositionToDay) {
- assertEquals(
- (int) localizedPositionToDay.get(monthInYearFeb2016), monthInYearFeb2016.positionToDay(1));
- assertEquals(
- (int) localizedPositionToDay.get(monthInYearJul2018), monthInYearJul2018.positionToDay(6));
- assertEquals(
- (int) localizedPositionToDay.get(monthInYearFeb2019), monthInYearFeb2019.positionToDay(15));
- }
-
- @Test
- public void testUsStableCount() {
- setupLocalizedCalendars(Locale.US);
- assertStableCount();
- }
-
- @Test
- public void testFrStableCount() {
- setupLocalizedCalendars(Locale.FRANCE);
- assertStableCount();
- }
-
- @Test
- public void testIlStableCount() {
- setupLocalizedCalendars(ISRAEL);
- assertStableCount();
- }
-
- private void assertStableCount() {
- assertEquals(6 * 7, monthInYearFeb2016.getCount());
- assertEquals(6 * 7, monthInYearJul2018.getCount());
- assertEquals(6 * 7, monthInYearFeb2019.getCount());
- }
-
- @Test
- public void testUsPositionsWithinMonthReturnAValidItem() {
- setupLocalizedCalendars(Locale.US);
- Collection localizedNullPositionsInFebruary2019 = Arrays.asList(-5, 0, 4, 33, 100);
- Collection localizedNonNullPositionsInFebruary2019 = Arrays.asList(5, 32);
- assertPositionsWithinMonthReturnAValidItem(
- localizedNullPositionsInFebruary2019, localizedNonNullPositionsInFebruary2019);
- }
-
- @Test
- public void testFrPositionsWithinMonthReturnAValidItem() {
- setupLocalizedCalendars(Locale.FRANCE);
- Collection localizedNullPositionsInFebruary2019 = Arrays.asList(-5, 0, 3, 32, 100);
- Collection localizedNonNullPositionsInFebruary2019 = Arrays.asList(4, 31);
- assertPositionsWithinMonthReturnAValidItem(
- localizedNullPositionsInFebruary2019, localizedNonNullPositionsInFebruary2019);
- }
-
- @Test
- public void testIlPositionsWithinMonthReturnAValidItem() {
- setupLocalizedCalendars(ISRAEL);
- Collection localizedNullPositionsInFebruary2019 = Arrays.asList(-5, 0, 4, 33, 100);
- Collection localizedNonNullPositionsInFebruary2019 = Arrays.asList(5, 32);
- assertPositionsWithinMonthReturnAValidItem(
- localizedNullPositionsInFebruary2019, localizedNonNullPositionsInFebruary2019);
- }
-
- private void assertPositionsWithinMonthReturnAValidItem(
- Collection localizedNullPositionsInFebruary2019,
- Collection localizedNonNullPositionsInFebruary2019) {
- for (int position : localizedNullPositionsInFebruary2019) {
- assertNull(monthInYearFeb2019.getItem(position));
- }
- for (int position : localizedNonNullPositionsInFebruary2019) {
- assertNotNull(monthInYearFeb2019.getItem(position));
- }
- }
-
- @Test
- public void testUsDaysOfPositions() {
- setupLocalizedCalendars(Locale.US);
- Map localizedDaysOfPositionsInFebruary2019 = new HashMap<>();
- localizedDaysOfPositionsInFebruary2019.put(6, 2);
- localizedDaysOfPositionsInFebruary2019.put(32, 28);
- assertDaysOfPositions(localizedDaysOfPositionsInFebruary2019);
- }
-
- @Test
- public void testFrDaysOfPositions() {
- setupLocalizedCalendars(Locale.FRANCE);
- Map localizedDaysOfPositionsInFebruary2019 = new HashMap<>();
- localizedDaysOfPositionsInFebruary2019.put(6, 3);
- localizedDaysOfPositionsInFebruary2019.put(31, 28);
- assertDaysOfPositions(localizedDaysOfPositionsInFebruary2019);
- }
-
- @Test
- public void testIlDaysOfPositions() {
- setupLocalizedCalendars(ISRAEL);
- Map localizedDaysOfPositionsInFebruary2019 = new HashMap<>();
- localizedDaysOfPositionsInFebruary2019.put(6, 2);
- localizedDaysOfPositionsInFebruary2019.put(32, 28);
- assertDaysOfPositions(localizedDaysOfPositionsInFebruary2019);
- }
-
- private void assertDaysOfPositions(Map localizedDaysOfPositionsInFebruary2019) {
- for (int day : localizedDaysOfPositionsInFebruary2019.keySet()) {
- assertEquals(
- (int) localizedDaysOfPositionsInFebruary2019.get(day),
- monthInYearFeb2019.getItem(day).get(Calendar.DAY_OF_MONTH));
- }
- }
-
- @Test
- public void testRows() {
- setupLocalizedCalendars(Locale.FRANCE);
- assertEquals(0, monthInYearFeb2019.getItemId(0));
- assertEquals(1, monthInYearFeb2019.getItemId(7));
- assertEquals(3, monthInYearFeb2019.getItemId(26));
- assertEquals(5, monthInYearMarch2019.getItemId(35));
- }
-}
diff --git a/lib/javatests/com/google/android/material/picker/MonthInYearTest.java b/lib/javatests/com/google/android/material/picker/MonthInYearTest.java
deleted file mode 100644
index c5952b2b8..000000000
--- a/lib/javatests/com/google/android/material/picker/MonthInYearTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.material.picker;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.internal.DoNotInstrument;
-
-@RunWith(RobolectricTestRunner.class)
-@DoNotInstrument
-public class MonthInYearTest {
-
- private static final Locale ISRAEL = new Locale("iw", "IL");
-
- private MonthInYear monthInYearFeb2016;
- private MonthInYear monthInYearJul2018;
- private MonthInYear monthInYearFeb2019;
-
- private void setupLocalizedCalendars(Locale locale) {
- Locale.setDefault(locale);
- monthInYearFeb2016 = MonthInYear.create(2016, Calendar.FEBRUARY);
- monthInYearJul2018 = MonthInYear.create(2018, Calendar.JULY);
- monthInYearFeb2019 = MonthInYear.create(2019, Calendar.FEBRUARY);
- }
-
- @Test
- public void testUsDaysInWeek() {
- setupLocalizedCalendars(Locale.US);
- assertDaysInWeek();
- }
-
- @Test
- public void testFrDaysInWeek() {
- ;
- setupLocalizedCalendars(Locale.FRANCE);
- assertDaysInWeek();
- }
-
- @Test
- public void testIlDaysInWeek() {
- setupLocalizedCalendars(ISRAEL);
- assertDaysInWeek();
- }
-
- private void assertDaysInWeek() {
- assertEquals(7, monthInYearFeb2016.daysInWeek);
- assertEquals(7, monthInYearJul2018.daysInWeek);
- assertEquals(7, monthInYearFeb2019.daysInWeek);
- }
-
- @Test
- public void testUsDaysInMonth() {
- setupLocalizedCalendars(Locale.US);
- assertDaysInMonth();
- }
-
- @Test
- public void testFrDaysInMonth() {
- setupLocalizedCalendars(Locale.FRANCE);
- assertDaysInMonth();
- }
-
- @Test
- public void testIlDaysInMonth() {
- setupLocalizedCalendars(ISRAEL);
- assertDaysInMonth();
- }
-
- private void assertDaysInMonth() {
- assertEquals(29, monthInYearFeb2016.daysInMonth);
- assertEquals(31, monthInYearJul2018.daysInMonth);
- assertEquals(28, monthInYearFeb2019.daysInMonth);
- }
-
- @Test
- public void testUsDaysFromStart() {
- setupLocalizedCalendars(Locale.US);
- Map localizedStartOfWeekToStartOfMonth = new HashMap<>();
- localizedStartOfWeekToStartOfMonth.put(monthInYearFeb2016, 1);
- localizedStartOfWeekToStartOfMonth.put(monthInYearJul2018, 0);
- localizedStartOfWeekToStartOfMonth.put(monthInYearFeb2019, 5);
- assertDaysFromStart(localizedStartOfWeekToStartOfMonth);
- }
-
- @Test
- public void testFrDaysFromStart() {
- setupLocalizedCalendars(Locale.FRANCE);
- Map localizedStartOfWeekToStartOfMonth = new HashMap<>();
- localizedStartOfWeekToStartOfMonth.put(monthInYearFeb2016, 0);
- localizedStartOfWeekToStartOfMonth.put(monthInYearJul2018, 6);
- localizedStartOfWeekToStartOfMonth.put(monthInYearFeb2019, 4);
- assertDaysFromStart(localizedStartOfWeekToStartOfMonth);
- }
-
- @Test
- public void testIlDaysFromStart() {
- setupLocalizedCalendars(ISRAEL);
- Map localizedStartOfWeekToStartOfMonth = new HashMap<>();
- localizedStartOfWeekToStartOfMonth.put(monthInYearFeb2016, 1);
- localizedStartOfWeekToStartOfMonth.put(monthInYearJul2018, 0);
- localizedStartOfWeekToStartOfMonth.put(monthInYearFeb2019, 5);
- assertDaysFromStart(localizedStartOfWeekToStartOfMonth);
- }
-
- private void assertDaysFromStart(Map localizedStartOfWeekToStartOfMonth) {
- assertEquals(
- (int) localizedStartOfWeekToStartOfMonth.get(monthInYearFeb2016),
- monthInYearFeb2016.daysFromStartOfWeekToFirstOfMonth());
- assertEquals(
- (int) localizedStartOfWeekToStartOfMonth.get(monthInYearJul2018),
- monthInYearJul2018.daysFromStartOfWeekToFirstOfMonth());
- assertEquals(
- (int) localizedStartOfWeekToStartOfMonth.get(monthInYearFeb2019),
- monthInYearFeb2019.daysFromStartOfWeekToFirstOfMonth());
- }
-}