Android Example Analog24hClock - Post #12

It wraps a tiny bit of this - just enough to show the clock. Thought it looked quite nifty...Have done nothing special to it other than painting the hands and the face a bit...:) Lib files are all in the /files folder - copy them to your additional libraries folder. Also posting the Java code - do with it as you like.

Edit - see post #2


pic1.png
 

Attachments

  • Analog24hClock.zip
    494.3 KB · Views: 845
  • src.zip
    262.6 KB · Views: 765
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Have wrapped some additional functionality of this Github project (although working it is not yet where it should be). Nevertheless, it would be interesting to know if it correctly shows the day/night time (sunrise/sunset) of where you are at present. Please post some pics of your display and if you don't mind state where you are and also if it represents your approximate sunrise/sunset times.

Library files (2 x Jar and 1 x Xml) are in the /files folder of the attached B4A project. Copy them to your additional libraries folder. You might have to enable the GPS of your device to get a current location in case you have been on the move. Else it will use your last known location.
The pic posted herewith is a very good representation of the sunrise/sunset times of where I am at present (i.e Durban, South Africa).


pic2.png


As it stands at present:

analog24hclock
Version:
1
  • Analog24HClock
    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)
    • setUsePassiveLocation
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • LargeFace As Boolean [write only]
      True = large face will be used
      False = small face will be used
    • Left As Int
    • Location As Location [write only]
    • OverlayNightColor As Int [write only]
    • OverlaySunColor As Int [write only]
    • Scale As Float [write only]
    • ShadeAlpha As Int [write only]
    • ShowSeconds As Boolean [write only]
      When set, the minute hand will move slightly based on the current number
      of seconds. If false, the minute hand will snap to the minute ticks.
      Note: there is no second hand, this only affects the minute hand.
    • Tag As Object
    • Time As Long [write only]
      Set the time (pass long milliseconds value of B4A's DateTime.Now)
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • Analog24hClockV2.zip
    506.6 KB · Views: 608
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
I would say yes

Edit: Yes, approx.
Actually a very interesting pic that you have posted. Does it tell us that where you are the sun is at its highest position above the horizon just before 14h00 (your local time)?
 
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
Have wrapped some additional functionality of this Github project (although working it is not yet where it should be). Nevertheless, it would be interesting to know if it correctly shows the day/night time (sunrise/sunset) of where you are at present. Please post some pics of your display and if you don't mind state where you are and also if it represents your approximate sunrise/sunset times.

Library files (2 x Jar and 1 x Xml) are in the /files folder of the attached B4A project. Copy them to your additional libraries folder. You might have to enable the GPS of your device to get a current location in case you have been on the move. Else it will use your last known location.
The pic posted herewith is a very good representation of the sunrise/sunset times of where I am at present (i.e Durban, South Africa).


View attachment 35780

As it stands at present:

analog24hclock
Version:
1
  • Analog24HClock
    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)
    • setUsePassiveLocation
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • LargeFace As Boolean [write only]
      True = large face will be used
      False = small face will be used
    • Left As Int
    • Location As Location [write only]
    • OverlayNightColor As Int [write only]
    • OverlaySunColor As Int [write only]
    • Scale As Float [write only]
    • ShadeAlpha As Int [write only]
    • ShowSeconds As Boolean [write only]
      When set, the minute hand will move slightly based on the current number
      of seconds. If false, the minute hand will snap to the minute ticks.
      Note: there is no second hand, this only affects the minute hand.
    • Tag As Object
    • Time As Long [write only]
      Set the time (pass long milliseconds value of B4A's DateTime.Now)
    • Top As Int
    • Visible As Boolean
    • Width As Int

Why you put this in Android Example and not in Library ??
Anyway great ;)
Good job
 

Johan Schoeman

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User
Getting there. The attached project adds the following:
1. Display the current date (month and day)
2. Add (reading from daytime towards night time on the clock or from lighter shade of grey to darker shade of grey) the civil, nautical, and astronomical twilights for the last known location of your device. You can read up about it here. The total black + shaded area covers sunset to sunrise.

New library files (2 x Jar and 1 x XML) are in the /files folder of the attached B4A project. Copy them to your additional library folder.

It seems that the jsuntimes-1.0.stripped library that this project also makes use of is indeed correct in drawing the different shaded/dark areas as far as their start/end times are concerned for last known locations of a device...;)



pic3.png
 

Attachments

  • Analog24HClockV3.zip
    506.5 KB · Views: 590
Last edited:

robertyoungs

Member
Licensed User
Longtime User
Hi Johan, from UK - doesn't appear to have rendered properly?

EDIT - works fine now and accurate - Apologies - helps if I turn on Location services!


This is the V3, and the libs from that zip, running on a Nexus 7

Love what you've done!
Screenshot_2016-04-28-09-30-41.png
 
Last edited:

Vahid_Maz

Member
Hi Johan Schoeman, you came up with a great idea. You are very optimistic. Thank you very much.
I have a problem on ASUS tablet. When GPS is activated, everything looks good and correct, when GPS is turned off again, the last my location is not calculated.
Of course, I tried "setUsePassiveLocation" and without "setUsePassiveLocation".
Where do you think my mistake is?
 
Top