B4A Library CircleTimeView

A wrap for this Github project. Posting the following:
B4A sample project
Some Jars and XML files - copy them to your additional libs folder.

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aCircleTimeView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #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.
  
    Dim nativeMe As JavaObject
    Dim t As Timer

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 ctv1 As CircleTimeView
    Private btnStart As Button
    Private btnStop As Button
    Private btnReset 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")
    t.Initialize("t", 5000)
  
    nativeMe.InitializeContext
  
    set_defaults

End Sub

Sub Activity_Resume
  

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnStart_Click
    If ctv1.CurrentTimeInSeconds <> 0 Then
        t.Enabled = True

        ctv1.showLapsLabel               'use this or the next line.....
        ctv1.LabelText = ""
        ctv1.startTimer
    End If
  
End Sub

Sub btnStop_Click
    t.Enabled = False
    ctv1.stopTimer
    set_defaults
  
End Sub

Sub btnReset_Click
  
    t.Enabled = False
    ctv1.resetTime
    set_defaults
  
  
  
End Sub

Sub ctv1_time_updated(tm As Long)
  
    Log("timeupdated = " & tm)
  
End Sub

Sub ctv1_time_value_changed(tm As Long)
  
    Log("timevaluechanged = " & tm)
  
End Sub

Sub ctv1_timer_started()
  
    Log("timer started")
  
End Sub

Sub ctv1_timer_stopped()
    t.Enabled = False
    nativeMe.RunMethod("playTone",  Null)
    Log("calling set_defaults")
    ctv1.hideLapsLabel
    set_defaults
  
End Sub

Sub ctv1_time_manually_set(tm As Long)
  
    Log("time_manually_set = " & tm)
  
End Sub

Sub ctv1_time_manually_changed(tm As Long)
  
    Log("time_manually_changed = " & tm)
  
End Sub

Sub t_tick
  
    ctv1.CircleButtonRadius = Rnd(10, 21)
    ctv1.LapBackgroundColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.CircleButtonColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.QuarterNumberColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.TimeNumberColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.QuarterNumbersTextSize = Rnd(20, 40)
    ctv1.TimeNumbersTextSize = Rnd(30, 50)
    ctv1.MarkLineColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.MarkSize = Rnd(1,21)
    ctv1.HighlightMarkLineColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.CircleButtonPressedColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.CircleColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.LapLabelTextColor = Colors.ARGB(255, Rnd(100, 255), Rnd(100, 255), Rnd(100, 255))
    ctv1.QuarterMarkSize = Rnd(0, 26)
    ctv1.CircleStrokeWidth = Rnd(1, 11)
    ctv1.LapLabelMarginTop = Rnd(1,16)
    ctv1.MarkLineWidth = Rnd(1,6)
    ctv1.PaddingQuarterNumber = Rnd(5,21)
  
End Sub

Sub set_defaults
  
    ctv1.CurrentTimeMode = ctv1.MODE_MANUAL_SETUP
    ctv1.CircleButtonRadius = 20
    ctv1.LapBackgroundColor = Colors.LightGray
    ctv1.CircleButtonColor = Colors.Magenta
    ctv1.QuarterNumberColor = Colors.Green
    ctv1.TimeNumberColor = Colors.Cyan
    ctv1.QuarterNumbersTextSize = 30
    ctv1.TimeNumbersTextSize = 50
    ctv1.MarkLineColor = Colors.Yellow
    ctv1.MarkSize = 10
    ctv1.HighlightMarkLineColor = Colors.White
    ctv1.CircleButtonPressedColor = Colors.Red
    ctv1.CircleColor = Colors.Cyan
    ctv1.LapLabelTextColor = Colors.White
    ctv1.QuarterMarkSize = 25
    ctv1.CircleStrokeWidth = 1
    ctv1.LapLabelMarginTop = 10
    ctv1.MarkLineWidth = 1
    ctv1.PaddingQuarterNumber = 1
    ctv1.LabelText = "Set Time - Press Start"
    ctv1.LabelTextColor = Colors.White
    ctv1.LabelTextSize = 20
  
End Sub


#if Java

import android.media.ToneGenerator;
import android.media.AudioManager;

ToneGenerator tg;

  public void playTone() {
      tg = new ToneGenerator(AudioManager.RINGER_MODE_NORMAL, 100);
      tg.startTone(ToneGenerator.TONE_CDMA_CONFIRM);
  }    

#end If

Library as it is at present:
CircleTimeView
Author:
Github: Alexander Molochko, Wrapped by: Johan Schoeman
Version: 1
  • CircleTimeView
    Events:
    • time_manually_changed (tm As Long)
    • time_manually_set (tm As Long)
    • time_updated (tm As Long)
    • time_value_changed (tm As Long)
    • timer_started
    • timer_stopped
    Fields:
    • MODE_MANUAL_SETUP As Int
    • MODE_NORMAL As Int
    • MODE_TIMER As Int
    • 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
    • SetBackgroundImageNew (arg0 As Bitmap) As BitmapDrawable
    • 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)
    • hideLapsLabel
    • resetTime
    • showLapsLabel
      Display lap label
    • startTimer
    • stopTimer
    Properties:
    • Background As Drawable
    • CircleButtonColor As Int [write only]
    • CircleButtonPressedColor As Int [write only]
    • CircleButtonRadius As Float [write only]
    • CircleColor As Int [write only]
    • CircleStrokeWidth As Float [write only]
    • Color As Int [write only]
    • CurrentTime As Long [write only]
      Set current time with the default format (seconds)
    • CurrentTimeInSeconds As Long [read only]
    • CurrentTimeMode As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • HighlightMarkLineColor As Int [write only]
    • LabelText As String [write only]
    • LabelTextColor As Int [write only]
    • LabelTextSize As Float [write only]
    • LapBackgroundColor As Int [write only]
    • LapLabelMarginTop As Float [write only]
    • LapLabelTextColor As Int [write only]
    • Left As Int
    • MarkLineColor As Int [write only]
    • MarkLineWidth As Float [write only]
    • MarkSize As Float [write only]
    • Padding()() As Int
    • PaddingQuarterNumber As Float [write only]
    • Parent As Object [read only]
    • QuarterMarkSize As Float [write only]
    • QuarterNumberColor As Int [write only]
    • QuarterNumbersTextSize As Float [write only]
    • Tag As Object
    • TimeNumberColor As Int [write only]
    • TimeNumbersTextSize As Float [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int

1.png



2.png



1.gif


Drag the circle button clockwise to set the count down time.

You will also need the JavaObject library to be enabled.
 

Attachments

  • CircleTimeView.jar
    24.3 KB · Views: 303
  • b4aCircleTimeView.zip
    9.1 KB · Views: 316
  • CircleTimeView.xml
    15.9 KB · Views: 305
  • support-annotations-26.0.0-alpha1.jar
    23.2 KB · Views: 307
Last edited:
Top