MaterialDateTimePicker

DonManfred

Expert
Licensed User
Longtime User
this is a wrap for this github project.

I´m VERY PROUD to present you this Date- and TimePicker Dialog library! I have tried to wrap about 20 different Date and TimePickers in the past 1,5 years. ALL UNSuccessfully. :-(

But this one i got working :D


MaterialDateTimePicker
Author:
DonManfred (wrapper)
Version: 1.7
  • Calendar
    Fields:
    • CANADA As Locale
    • CANADA_FRENCH As Locale
    • CHINA As Locale
    • CHINESE As Locale
    • ENGLISH As Locale
    • FRANCE As Locale
    • FRENCH As Locale
    • GERMAN As Locale
    • GERMANY As Locale
    • ITALIAN As Locale
    • ITALY As Locale
    • JAPAN As Locale
    • JAPANESE As Locale
    • KOREA As Locale
    • KOREAN As Locale
    • PRC As Locale
    • ROOT As Locale
    • SIMPLIFIED_CHINESE As Locale
    • TAIWAN As Locale
    • TRADITIONAL_CHINESE As Locale
    • UK As Locale
    • US As Locale
    Methods:
    • Initialize (dateformat As String, locale As Locale, date As String)
    • IsInitialized As Boolean
  • DatePickerDialog
    Events:
    • onCancel ( As )
    • onDateSet (year As Int, monthOfYear As Int, dayOfMonth As Int)
    • onDismiss ( As )
    Methods:
    • Initialize (EventName As String, year As Int, monthOfYear As Int, dayOfMonth As Int)
    • IsInitialized As Boolean
    • autoDismiss (autoDismiss As Boolean)
      Set whether the picker should dismiss itself when a day is selected
      autoDismiss: true if the dialog should dismiss itself when a day is selected
    • dismissOnPause (dismissOnPause As Boolean)
      Set whether the picker should dismiss itself when being paused or whether it should try to survive an orientation change
      dismissOnPause: true if the dialog should dismiss itself when it's pausing
    • isThemeDark As Boolean
      Returns true when the dark theme should be used
      Return type: @return:true if the dark theme should be used, false if the default theme should be used
    • setYearRange (startYear As Int, endYear As Int)
    • show (tag As String)
    • showYearPickerFirst (yearPicker As Boolean)
      Set whether the year picker of the month and day picker is shown first
      yearPicker: boolean
    • vibrate (vibrate As Boolean)
      Set whether the device should vibrate when touching fields
      vibrate: true if the device should vibrate when touching a field
    Properties:
    • AccentColor As Int
      Get the accent color of this dialog
    • AccentColor2 As String [write only]
      Set the accent color of this dialog
    • CancelText As String [write only]
      Set the label for the Cancel button (max 12 characters)
    • FirstDayOfWeek As Int [write only]
    • HighlightedDays()() As Calendar
      Sets an array of dates which should be highlighted when the picker is drawn
    • MaxDate As Calendar
      Sets the minimal date supported by this DatePicker. Dates after (but not including) the
      specified date will be disallowed from being selected.
    • MinDate As Calendar
      Sets the minimal date supported by this DatePicker. Dates before (but not including) the
      specified date will be disallowed from being selected.
    • OkText As String [write only]
      Set the label for the Ok button (max 12 characters)
    • SelectableDays()() As Calendar
      Set's a list of days which are the only valid selections.
      Setting this value will take precedence over using setMinDate() and setMaxDate()
    • ThemeDark As Boolean [write only]
      Set whether the dark theme should be used
    • Title As String [write only]
      Set a title to be displayed instead of the weekday
    • Version As Int
  • TimePickerDialog
    Events:
    • onCancel ( As )
    • onDismiss ( As )
    • onTimeSet (hour As Int, minute As Int, second As Int)
    Methods:
    • Initialize (EventName As String, hourOfDay As Int, minute As Int, is24HourMode As Boolean)
    • IsInitialized As Boolean
    • dismissOnPause (dismissOnPause As Boolean)
      Set whether the picker should dismiss itself when it's pausing or whether it should try to survive an orientation change
      dismissOnPause: true if the picker should dismiss itself
    • enableSeconds (enableSeconds As Boolean)
      Set whether an additional picker for seconds should be shown
      enableSeconds: true if the seconds picker should be shown
    • is24HourMode As Boolean
    • isThemeDark As Boolean
    • setMaxTime (hour As Int, minute As Int, second As Int)
    • setMinTime (hour As Int, minute As Int, second As Int)
    • setStartTime (hourOfDay As Int, minute As Int)
    • setStartTime2 (hourOfDay As Int, minute As Int, second As Int)
    • setTimeInterval2 (hourInterval As Int, minuteInterval As Int)
      Set the interval for selectable times in the TimePickerDialog
      This is a convenience wrapper around setSelectableTimes
      The interval for all three time components can be set independently
      hourInterval: The interval between 2 selectable hours ([1,24])
      minuteInterval: The interval between 2 selectable minutes ([1,60])
    • setTimeInterval3 (hourInterval As Int, minuteInterval As Int, secondInterval As Int)
      Set the interval for selectable times in the TimePickerDialog
      This is a convenience wrapper around setSelectableTimes
      The interval for all three time components can be set independently
      hourInterval: The interval between 2 selectable hours ([1,24])
      minuteInterval: The interval between 2 selectable minutes ([1,60])
      secondInterval: The interval between 2 selectable seconds ([1,60])
    • show (tag As String)
    • vibrate (vibrate As Boolean)
      Set whether the device should vibrate when touching fields
      vibrate: true if the device should vibrate when touching a field
    Properties:
    • AccentColor As Int
      Get the accent color of this dialog
    • AccentColor2 As String [write only]
      Set the accent color of this dialog
    • CancelText As String [write only]
      Set the label for the Cancel button (max 12 characters)
    • MaxTime2 As Timepoint [write only]
    • MinTime2 As Timepoint [write only]
    • OkText As String [write only]
      Set the label for the Ok button (max 12 characters)
    • SelectableTimes() As Timepoint [write only]
    • ThemeDark As Boolean [write only]
      Set a dark or light theme. NOTE: this will only take effect for the next onCreateView.
    • TimeInterval As Int [write only]
      Set the interval for selectable times in the TimePickerDialog
      This is a convenience wrapper around setSelectableTimes
      The interval for all three time components can be set independently
    • Title As String
      Set a title. NOTE: this will only take effect with the next onCreateView
    • Version As Int
  • Timepoint
    Methods:
    • Initialize (hour As Int, minute As Int, second As Int)
    • IsInitialized As Boolean

Screenshot_20160625-184740.png


Screenshot_20160625-184747.png


Installation:
- Extract the contents (jar, xml and aar) of MaterialTimePickerV[x.yy].zip to your additional library folder


Neww in V1.7
- I have updated the lib to the newest release from github. It now has two layouts. Version 1 and Version 2
 

Attachments

  • MaterialDateTimePickerV1.5.zip
    269.8 KB · Views: 1,152
  • MaterialDateTimePickerEx.zip
    8.3 KB · Views: 1,748
  • MaterialDateTimePickerV1.51.zip
    270 KB · Views: 856
  • MaterialDateTimePickerV1.52.zip
    269.7 KB · Views: 1,207
  • MaterialDateTimePickerV1.7.zip
    301.7 KB · Views: 2,276
Last edited:

wimpie3

Well-Known Member
Licensed User
Longtime User
Wow, finally! Congrats! @Erel can you please make an acc file for the resources?

Just saw the lib needs Android 4.0, might be a dealbreaker for those who want to use this lib together with material dialogs?
 
Last edited:

jahswant

Well-Known Member
Licensed User
Longtime User
Congrats. I love your determination. When i saw the question about frangments by you.. I knew you will make it.
 

incendio

Well-Known Member
Licensed User
Longtime User
Great, btw, I think

  • AccentColor As Int
    Get the accent color of this dialog

should be

  • AccentColor As Int
    Set the accent color of this dialog
 
Last edited:

asales

Expert
Licensed User
Longtime User
Very nice. Thanks.

I get this messages in Logs, when I click in OK ou Cancel buttons.
Is possible to disable this messages?

B4X:
lib:Raising.. date_oncancel()
lib:Raising.. date_ondismiss()
lib:Raising.. date_ondateset()
lib:Raising.. date_ondismiss()
 

asales

Expert
Licensed User
Longtime User
When I try to set the color of TimePickerDialog:
B4X:
time.AccentColor = Colors.Blue

I get this error:
B4X:
java.lang.IllegalArgumentException: Unknown color
    at android.graphics.Color.parseColor(Color.java:225)
    at com.wdullaer.materialdatetimepicker.time.TimePickerDialog.setAccentColor(TimePickerDialog.java:227)
    at de.donmanfred.TimePickerDialogWrapper.setAccentColor(TimePickerDialogWrapper.java:156)
    at b4a.example.main._activity_create(main.java:352)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5214)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:814)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)
    at dalvik.system.NativeStart.main(Native Method)
 

georgelbs

Member
Licensed User
Longtime User
Hi DonManfred, in the sample you use date.Initialize("Date",2016,6,25) but when the app run show July 25, as see in your screenshot.
I use a Spanish locale device with android 4.4

Awesome work
 

luciano deri

Active Member
Licensed User
Longtime User
Hi @DonManfred, I've tried to run the example you provided, but it doesn't work in release mode.
In debug mode, everything works fine (also the accent color), but in release it return this error:

B4X:
java.lang.RuntimeException: Font asset not found fonts/Roboto-Medium.ttf

    at android.graphics.Typeface.createFromAsset(Typeface.java:272)
    at com.wdullaer.materialdatetimepicker.TypefaceHelper.get(TypefaceHelper.java:31)
    at com.wdullaer.materialdatetimepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:338)
    at android.app.Fragment.performCreateView(Fragment.java:2114)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
    at android.app.BackStackRecord.run(BackStackRecord.java:833)
    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

How can I handle it? :confused:
(I tested it on both 1.51 and 1.52)
 
Last edited:
Top