Skip to content

Conversation

@SilVdB
Copy link

@SilVdB SilVdB commented Oct 11, 2016

Motivation

Since Android 5.0 (Material UI), the DatePicker component (https://developer.android.com/reference/android/widget/DatePicker.html) supports two modes:

  • calendar
  • spinner

We wanted to be able to use the spinner mode, since some of our Android users were complaining about the calendar mode being confusing and causing too much cognitive strain.

Solution

I discovered that the easiest way to accomplish this is described here: http://stackoverflow.com/questions/27709668/hide-calenderview-from-datepicker-programatically-in-api-21/31610267#31610267

I added a property Boolean spinnerMode to the datepicker module (java) that decides wether or not the style suggested above is applied, resulting in a spinner in stead of a calendar view.

Test plan (required)
When opening a datepicker on Android, simply pass the property like this:

DatePickerAndroid.open({ date: Date.now(), spinnerMode: true })

The resulting datepicker looks like this:
unspecified-3

When setting spinnerMode to false (or not passing it at all), the datepicker looks like this:
unspecified-2

…datepicker is shown as a spinner, not the calenderview.
@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @AaaChiuuu to be a potential reviewer.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 12, 2016
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 12, 2016
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 13, 2016
final DatePickerDialog dialog =
new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day);
DatePickerDialog dialog;
if (args != null && args.containsKey(DatePickerDialogModule.ARG_SPINNERMODE) && args.getBoolean(DatePickerDialogModule.ARG_SPINNERMODE)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need args.containsKey(DatePickerDialogModule.ARG_SPINNERMODE)?
args.getBoolean(DatePickerDialogModule.ARG_SPINNERMODE) defaults to false

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we don't need that condition.

No need for check if args contains property DatePickerDialogModule.ARG_SPINNERMODE, getBoolean defaults to false when no prop is found.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 14, 2016
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Oct 14, 2016
@janicduplessis
Copy link
Contributor

Does using https://developer.android.com/reference/android/widget/DatePicker.html#setSpinnersShown(boolean) works instead of using an old holo theme? It would be better if there ends up being a material style spinner date picker.

@hramos
Copy link
Contributor

hramos commented Nov 7, 2016

@SilVdB do you still plan to ship this PR?

@mkonicek
Copy link
Contributor

Just merged #10932 which should provide the same functionality.

@mkonicek mkonicek closed this Nov 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants