B4A Library MyDynamicCalendar

A partial shortcut wrap for this Github sample and this Github project.

This is Donation Ware and will expire on 29 April 2017 (donation = add additional features such as other colors, etc))

As "old school" as what I am you will need the following jars in your additional library folder (and I guess just about everyone has them there)
android-support-v4.jar
android-support-v7-appcompat.jar
android-support-v7-recyclerview.jar

It is quite a nice Calendar - you need to populate the events from within your B4A code.

I am using B4A version 6.50
I am using AppCompat V3.51 by @corwin42 (Thanks M)

Posting the following:
B4A sample project
B4A library files

You can find the remainder of the libs used (AppCompat V3.51) on the forum.

Extract folders DemoRes and LibRes and copy them to be on the same folder level as that of the B4A project's /Files and /Objects folders.

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aDynamicCalendar
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\LibRes

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Dim dc As DynamicCalendar

    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
   
    dc.Initialize("")
   
    Dim dates() As String = Array As String("10-04-2017","15-04-2017", "16-04-2017", "19-04-2017", "18-04-2017", "24-04-2017")
    Dim starttime() As String = Array As String("08:00", "08:00", "09:00", "10:00", "14:00", "15:00")
    Dim endtime() As String = Array As String("08:30", "08:15", "09:25", "10:45", "14:55", "15:15")
    Dim events() As String = Array As String("Safety Meeting", "Quality Meeting", "Supplier Meeting", "Customer Meeting", "IR Meeting", "Finance Meeting")
   
    dc.addEvents(dates, starttime, endtime, events)
   
    Dim holidays() As String = Array As String("14-04-2017", "17-04-2017", "25-12-2017", "26-12-2017", "01-01-2018")
    dc.addHolidays(holidays)
   
    dc.CalendarBackgroundColor = Colors.Green              'the color below the calendar when the Calendar Activity starts
    dc.HeaderBackgroundColor = Colors.Cyan                 'the background color of the 'banner' where the circles and arrows left/right appear
    dc.HeaderTextColor = Colors.Black                      'the color of the text in the 'banner' set in the above line of code
    dc.WeekDayLayoutBackgroundColor = Colors.Yellow        'the background color of the banner where the day names appear
    dc.NextPreviousIndicatorColor = Colors.Red             'the color of the circles and the arrows within them
    dc.ExtraDatesOfMonthBackgroundColor = Colors.ARGB(50, 175, 0, 100)
    dc.ExtraDatesOfMonthTextColor = Colors.Yellow
   
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
   
    dc.startCalendar
   
End Sub
 

Attachments

  • b4aDynamicCalendar.zip
    8.3 KB · Views: 643
  • DynamicCalendarLibFiles.zip
    53.8 KB · Views: 624
  • DemoRes.zip
    31.8 KB · Views: 636
  • LibRes.zip
    37.4 KB · Views: 611

Johan Schoeman

Expert
Licensed User
Longtime User
startCalendar.png


calendarStarted.png


dropdownmenudisplayed.png



dayview.png


weekview.png



agenda1.png


agenda2.png
 

Johan Schoeman

Expert
Licensed User
Longtime User
I just found the SAMPLE and was on the search for the second Github project as i wanted to do a wrap for it too...
And you already posted the lib :D
I have done a "shortcut" wrap for it. When I have time I will do a full wrapper.
 

asales

Expert
Licensed User
Longtime User
Very nice, Johan!
A few questions:
- Is possible to translate the names of the days (sun, mon, etc.)?
- Is possible to put the sunday in the first cell?
 

Johan Schoeman

Expert
Licensed User
Longtime User
Very nice, Johan!
A few questions:
- Is possible to translate the names of the days (sun, mon, etc.)?
- Is possible to put the sunday in the first cell?
In this project the order of the days can unfortunately not be changed. The names can be translated. The below pic has the day names for eg in Chinese.

1.png
 

Johan Schoeman

Expert
Licensed User
Longtime User
Did you initialized the internal calendar used with a locale?
No Manfred - have "hard" changed it in /LibRes/Layout/my_dynamic_calendar.xml
But I can add a setter whereby this can be done via code....I guess.

Edit:
This will do it from within B4A:
B4X:
    Dim weekdaynames() As String = Array As String("星期一", "星期二", "星期四", "星期三", "星期五", "星期六", "星期日")
    dc.WeekDayNames = weekdaynames
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
This is now 100% embedded in B4A via a CustomView. You can download the APK from here to test it. It will terminate on 29 April 2017

https://www.dropbox.com/s/i623uueg5olp80g/b4aDynamicCalendar.apk?dl=0


The B4A sample code looks like this:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aDynamicCalendar
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\LibRes

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
  


    Private mdc As myDynamicCalendar
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
  
    Activity.AddMenuItem("Month", "Month")
    Activity.AddMenuItem("Month with Events", "MonthWithEvents")
    Activity.AddMenuItem("Week", "Week")
    Activity.AddMenuItem("Day", "Day")
    Activity.AddMenuItem("Agenda", "Agenda")
    Activity.AddMenuItem("Today", "Today")
  
  
    Dim dates() As String = Array As String("10-04-2017","15-04-2017", "16-04-2017", "19-04-2017", "18-04-2017", "24-04-2017")
    Dim starttime() As String = Array As String("08:00", "08:00", "09:00", "10:00", "14:00", "15:00")
    Dim endtime() As String = Array As String("08:30", "08:15", "09:25", "10:45", "14:55", "15:15")
    Dim events() As String = Array As String("Safety Meeting", "Quality Meeting", "Supplier Meeting", "Customer Meeting", "IR Meeting", "Finance Meeting")
  
    'Dim weekdaynames() As String = Array As String("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
    Dim weekdaynames() As String = Array As String("星期一", "星期二", "星期四", "星期三", "星期五", "星期六", "星期日")

  
    Dim holidays() As String = Array As String("14-04-2017", "17-04-2017", "25-12-2017", "26-12-2017", "01-01-2018")

    mdc.showMonthView
    For i = 0 To 5
        mdc.addEvent(dates(i), starttime(i), endtime(i), events(i))
    Next
  
    For i = 0 To 4
        mdc.addHolidays(holidays(i))
    Next


    mdc.HolidayCellBackgroundColor = Colors.LightGray
    mdc.HolidayCellTextColor = Colors.Red
    mdc.CalendarBackgroundColor = Colors.White
    mdc.HeaderBackgroundColor = Colors.White
    mdc.HeaderTextColor = Colors.Magenta
    mdc.NextPreviousIndicatorColor = Colors.Blue
    mdc.WeekDayLayoutBackgroundColor = Colors.Blue
    mdc.WeekDayLayoutTextColor = Colors.White
    mdc.isSaturdayOff(True, Colors.LightGray, Colors.Red)
    mdc.isSundayOff(True, Colors.LightGray, Colors.Red)
    mdc.ExtraDatesOfMonthBackgroundColor = Colors.Black
    mdc.ExtraDatesOfMonthTextColor = Colors.White
    mdc.DatesOfMonthBackgroundColor = Colors.Cyan
    mdc.DatesOfMonthTextColor = Colors.ARGB(200, 255, 0, 100)
  
    mdc.WeekDayNames = weekdaynames
  
    mdc.CurrentDateBackgroundColor = Colors.Red
    mdc.CurrentDateTextColor = Colors.White
  
    mdc.EventCellBackgroundColor = Colors.White
    mdc.EventCellTextColor = Colors.Blue
    mdc.BelowMonthEventTextColor = Colors.Black
    mdc.BelowMonthEventDividerColor = Colors.Red
    mdc.HolidayCellClickable = True
  
    mdc.ListOfEvents                 'see the event being raised - Sub mdc_get_events(eventname As String, eventstartdate As String, eventstrattime As String, eventendtime As String)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Month_Click
  
    mdc.showMonthView
  
End Sub

Sub MonthWithEvents_Click
  
    mdc.showMonthViewWithBelowEvents
  
End Sub

Sub Week_Click
  
    mdc.showWeekView
  
End Sub

Sub Day_Click
  
    mdc.showDayView
  
End Sub

Sub Agenda_Click
  
    mdc.showAgendaView
  
End Sub

Sub Today_Click
  
    mdc.showToday  
  
End Sub


Sub mdc_get_events(eventname As String, eventstartdate As String, eventstrattime As String, eventendtime As String)
  
    Log("eventname = " & eventname)
    Log("eventstartdate = " & eventstartdate)
    Log("eventstrattime = " & eventstrattime)
    Log("eventendtime = " & eventendtime)
    Log("***************************")
  
End Sub

The library is as follows:
myDynamicCalendar
Author:
Github: Vatsal Desai, Wrapped by: Johan Schoeman
Version: 1
  • myDynamicCalendar
    Events:
    • get_events (eventname As String, eventstartdate As String, eventstrattime As String, eventendtime As String)
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • ListOfEvents
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • addEvent (date As String, startTime As String, endTime As String, name As String)
    • addHolidays (date As String)
    • isSaturdayOff (saturdayoff As Boolean, saturdaybackgroundcolor As Int, saturdaytextcolor As Int)
    • isSundayOff (sundayoff As Boolean, sundaybackgroundcolor As Int, sundaytextcolor As Int)
    • showAgendaView
    • showDayView
    • showMonthView
    • showMonthViewWithBelowEvents
    • showToday
    • showWeekView
    Properties:
    • Background As Drawable
    • BelowMonthEventDividerColor As Int [write only]
    • BelowMonthEventTextColor As Int [write only]
    • CalendarBackgroundColor As Int [write only]
    • Color As Int [write only]
    • CurrentDateBackgroundColor As Int [write only]
    • CurrentDateTextColor As Int [write only]
    • DatesOfMonthBackgroundColor As Int [write only]
    • DatesOfMonthTextColor As Int [write only]
    • Enabled As Boolean
    • EventCellBackgroundColor As Int [write only]
    • EventCellTextColor As Int [write only]
    • ExtraDatesOfMonthBackgroundColor As Int [write only]
    • ExtraDatesOfMonthTextColor As Int [write only]
    • HeaderBackgroundColor As Int [write only]
    • HeaderTextColor As Int [write only]
    • Height As Int
    • HolidayCellBackgroundColor As Int [write only]
    • HolidayCellClickable As Boolean [write only]
    • HolidayCellTextColor As Int [write only]
    • Left As Int
    • NextPreviousIndicatorColor As Int [write only]
    • Padding()() As Int
    • Parent As Object [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • WeekDayLayoutBackgroundColor As Int [write only]
    • WeekDayLayoutTextColor As Int [write only]
    • WeekDayNames() As String [write only]
    • Width As Int

1.png

2.png


3.png



4.png
 
Last edited:

rkmoray

Active Member
Licensed User
Longtime User
I notice in your first post, you are using the
DynamicCalendar Libarary, and you included the Library. Near the end, you move over to

MyDynamicCalendar with no library add. Please attach the
MyDynamicCalendar library. Thank you.
 

Johan Schoeman

Expert
Licensed User
Longtime User

rkmoray

Active Member
Licensed User
Longtime User
Thank you for the quick reply. I don't mean to sound stupid (and I don't think I am) but I don't know what you mean by "CustomView"
I find no CustomView library.
I downloaded your sampler and it looks great which is why I want to integrate it into my project.
And for the record, if I can, I will donte to the cost of the control.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Thank you for the quick reply. I don't mean to sound stupid (and I don't think I am) but I don't know what you mean by "CustomView"
I find no CustomView library.
I downloaded your sampler and it looks great which is why I want to integrate it into my project.
And for the record, if I can, I will donte to the cost of the control.
What I mean is that is no longer an external activity that gets started from B4A. It is now fully integrated into B4A via a customview which can be added in the B4A designer of via B4A code. I have not made it available - just the APK.
 

fishwolf

Well-Known Member
Licensed User
Longtime User
Sorry
Can you explain better where copy the library folder?

i must copy also the appcompact resource, but b4a say that the appcompact library is not used.....

Where is possible do a donation?
 

DonManfred

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User
Sorry
Can you explain better where copy the library folder?

i must copy also the appcompact resource, but b4a say that the appcompact library is not used.....

Where is possible do a donation?

I will revisit the project and add an extension to the expiry date of the project for evaluation purposes and then post a new link to the new APK. Will do it sometime this weekend as I am at present busy with another project for a B4A member.
 
Top