B4A Library Another Dial Time Picker

It wraps this Github project. Posting the following:
1. B4A sample project
2. B4A library files (copy them to your additional library folder)

1.png


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

#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 dtp1 As DialTimePicker
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")
  
  
    dtp1.HourFormat24 = False
    dtp1.CanvasColor = Colors.Transparent
    dtp1.TextColor = Colors.Yellow
    dtp1.DialColor = Colors.Blue
    dtp1.ClockColor = Colors.Red

End Sub

Sub Activity_Resume
  
    dtp1.setFirstTime


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub dtp1_time_changed(hr As Int, minute As Int, AmPm As String)
  
    Log("hour = " & hr)
    Log("minute = " & minute)
    Log("AM PM = " & AmPm)
  
End Sub

The library:
DialTimePicker
Author:
Github: Ugur Tekbas, Wrapped by: Johan Schoeman
Version: 1
  • DialTimePicker
    Events:
    • time_changed (hr As Int, minute As Int, AmPm 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
    • 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)
    • disableTouch (disableTouch As Boolean)
    • setFirstTime
    Properties:
    • AmPM As String [read only]
    • Background As Drawable
    • CanvasColor As Int [write only]
    • ClockColor As Int [write only]
    • Color As Int [write only]
    • CurrentHour As Int [read only]
    • CurrentMin As Int [read only]
    • DialColor As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • HourFormat24 As Boolean [write only]
    • Left As Int
    • Tag As Object
    • TextColor As Int [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • DialTimePickerLibFiles.zip
    9.6 KB · Views: 475
  • b4aDialTimePicker.zip
    7.8 KB · Views: 451
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Hi, is it possible to set the time in this view? for example Im saving and retrieving time from a db and want to show saved time..
I will revisit the project and if possible add the functionality to set the time
 

Johan Schoeman

Expert
Licensed User
Longtime User
I will revisit the project and if possible add the functionality to set the time
Try with the attached library files.

Sample code:

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

#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 dtp1 As DialTimePicker
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")
   
   
    dtp1.HourFormat24 = False
    dtp1.CanvasColor = Colors.Transparent
    dtp1.TextColor = Colors.Yellow
    dtp1.DialColor = Colors.Blue
    dtp1.ClockColor = Colors.Red
    dtp1.setTime(17, 28)                'or dtp1.initTime(17, 28) ----> dtp1.initTime(hour, minutes)
   
End Sub

Sub Activity_Resume
   


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub dtp1_time_changed(hr As Int, minute As Int, AmPm As String)
   
    Log("hour = " & hr)
    Log("minute = " & minute)
    Log("AM PM = " & AmPm)
   
End Sub


Added
dtp1.setTime(17, 28) 'or dtp1.initTime(17, 28) ----> dtp1.initTime(hour, minutes)
 

Attachments

  • DialTimePickerLibFilesV1_01.zip
    10.1 KB · Views: 344
  • b4aDialTimePicker.zip
    7.9 KB · Views: 340

Mashiane

Expert
Licensed User
Longtime User
Try with the attached library files.

Sample code:

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

#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 dtp1 As DialTimePicker
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")
  
  
    dtp1.HourFormat24 = False
    dtp1.CanvasColor = Colors.Transparent
    dtp1.TextColor = Colors.Yellow
    dtp1.DialColor = Colors.Blue
    dtp1.ClockColor = Colors.Red
    dtp1.setTime(17, 28)                'or dtp1.initTime(17, 28) ----> dtp1.initTime(hour, minutes)
  
End Sub

Sub Activity_Resume
  


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub dtp1_time_changed(hr As Int, minute As Int, AmPm As String)
  
    Log("hour = " & hr)
    Log("minute = " & minute)
    Log("AM PM = " & AmPm)
  
End Sub


Added
dtp1.setTime(17, 28) 'or dtp1.initTime(17, 28) ----> dtp1.initTime(hour, minutes)
Thanks, will check this out soon...
 

jaraiza

Active Member
Licensed User
Longtime User
Hi! Is there any way to make the little circle bigger? In some phones is very difficult to change the hour when the dial circle needs to be medium or small size.

Thanks!
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi! Is there any way to make the little circle bigger? In some phones is very difficult to change the hour when the dial circle needs to be medium or small size.

Thanks!
Attached updated library files (V1.02).

Added the following two methods:
B4X:
dtp1.DialRadiusDP = 25       'set the size of the small circle
dtp1.TrackSize = 5           'set the width of the big circle
 

Attachments

  • DialTimePickerLibFiles_V1_02.zip
    10.3 KB · Views: 356

JohnC

Expert
Licensed User
Longtime User
I think I found a bug with this library...

If I set to AM/PM mode using "dtFrom.HourFormat24 = False" and then try either of these methods:

B4X:
    dtp1.initTime(22,0)
    dtp1.setTime(22,0)

It should set the clock to 10:00 PM, but it sets it to 10:00 "AM".

Or am I doing something wrong?
 
Top